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.
This commit is contained in:
Damien Elmes 2015-11-17 18:06:45 +10:00
parent 52f8a4a75e
commit 47940680d2

View file

@ -21,11 +21,13 @@ class Exporter(object):
def escapeText(self, text): def escapeText(self, text):
"Escape newlines, tabs, CSS and quotechar." "Escape newlines, tabs, CSS and quotechar."
text = text.replace("\n", "<br>") # fixme: we should probably quote fields with newlines
# instead of converting them to spaces
text = text.replace("\n", " ")
text = text.replace("\t", " " * 8) text = text.replace("\t", " " * 8)
text = re.sub("(?i)<style>.*?</style>", "", text) text = re.sub("(?i)<style>.*?</style>", "", text)
if "\"" in text: if "\"" in text:
text = "\"" + text.replace("\"", "\"\"") + "\"" text = "\"" + text.replace("\"", "\"\"") + "\""
return text return text
def cardIds(self): def cardIds(self):