don't insert <br> into text of cards on import

When "allow HTML" was turned off, Anki was replacing newlines with <br>s
in the text of the new notes before it escaped HTML characters, so the
line breaks were becoming &lt;br&gt;.
This commit is contained in:
Soren I. Bjornstad 2014-06-21 11:02:34 -05:00
parent 5b61db7d0a
commit ba084cb46a
2 changed files with 4 additions and 3 deletions

View file

@ -132,6 +132,6 @@ class TextImporter(NoteImporter):
def noteFromFields(self, fields):
note = ForeignNote()
note.fields.extend([x.strip().replace("\n", "<br>") for x in fields])
note.fields.extend([x for x in fields])
note.tags.extend(self.tagsToAdd)
return note

View file

@ -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", "<br>")
fld0 = n.fields[fld0idx]
csum = fieldChecksum(fld0)
# first field must exist