From 47940680d27dca0c2f4bca2acd83630414c56db3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 17 Nov 2015 18:06:45 +1000 Subject: [PATCH] don't convert newlines into br tags in export fixes https://anki.tenderapp.com/discussions/ankidesktop/15795-export -error-doubling-br-tags This code dates back a few years, and was probably a naive solution for files breaking when exported with newlines. Ideally we should be preserving the newlines and wrapping the field in quotes, but since some people may be relying on exported files not to be quoted, we'll wait to change this until the next major release. For now, we'll use a space instead, which should not alter the appearance of the rendered HTML. --- anki/exporting.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/anki/exporting.py b/anki/exporting.py index 93a7018b8..d959f0fb7 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -21,11 +21,13 @@ class Exporter(object): def escapeText(self, text): "Escape newlines, tabs, CSS and quotechar." - text = text.replace("\n", "
") + # fixme: we should probably quote fields with newlines + # instead of converting them to spaces + text = text.replace("\n", " ") text = text.replace("\t", " " * 8) text = re.sub("(?i)", "", text) if "\"" in text: - text = "\"" + text.replace("\"", "\"\"") + "\"" + text = "\"" + text.replace("\"", "\"\"") + "\"" return text def cardIds(self):