From ba084cb46adde67e3639712386cab4ac9772c8f0 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Sat, 21 Jun 2014 11:02:34 -0500 Subject: [PATCH] don't insert
into text of cards on import When "allow HTML" was turned off, Anki was replacing newlines with
s in the text of the new notes before it escaped HTML characters, so the line breaks were becoming <br>. --- anki/importing/csvfile.py | 2 +- anki/importing/noteimp.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/anki/importing/csvfile.py b/anki/importing/csvfile.py index bd0b1ff4b..612cdd27a 100644 --- a/anki/importing/csvfile.py +++ b/anki/importing/csvfile.py @@ -132,6 +132,6 @@ class TextImporter(NoteImporter): def noteFromFields(self, fields): note = ForeignNote() - note.fields.extend([x.strip().replace("\n", "
") for x in fields]) + note.fields.extend([x for x in fields]) note.tags.extend(self.tagsToAdd) return note diff --git a/anki/importing/noteimp.py b/anki/importing/noteimp.py index fd3a7877a..e9e435d67 100644 --- a/anki/importing/noteimp.py +++ b/anki/importing/noteimp.py @@ -120,9 +120,10 @@ class NoteImporter(Importer): dupeCount = 0 dupes = [] for n in notes: - if not self.allowHTML: - for c in range(len(n.fields)): + for c in range(len(n.fields)): + if not self.allowHTML: n.fields[c] = cgi.escape(n.fields[c]) + n.fields[c] = n.fields[c].strip().replace("\n", "
") fld0 = n.fields[fld0idx] csum = fieldChecksum(fld0) # first field must exist