mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
(un)escape image references in HTML editor to fix ampersand handling
https://anki.tenderapp.com/discussions/ankidesktop/41479-image-names-with-are-breaking
This commit is contained in:
parent
5f2987d0f8
commit
43da12a445
1 changed files with 3 additions and 2 deletions
|
@ -532,13 +532,14 @@ class Editor:
|
||||||
form.textEdit.moveCursor(QTextCursor.End)
|
form.textEdit.moveCursor(QTextCursor.End)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
html = form.textEdit.toPlainText()
|
html = form.textEdit.toPlainText()
|
||||||
# https://anki.tenderapp.com/discussions/ankidesktop/39543-anki-is-replacing-the-character-by-when-i-exit-the-html-edit-mode-ctrlshiftx
|
|
||||||
if html.find(">") > -1:
|
if html.find(">") > -1:
|
||||||
# filter html through beautifulsoup so we can strip out things like a
|
# filter html through beautifulsoup so we can strip out things like a
|
||||||
# leading </div>
|
# leading </div>
|
||||||
|
html_escaped = self.mw.col.media.escapeImages(html)
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("ignore", UserWarning)
|
warnings.simplefilter("ignore", UserWarning)
|
||||||
html = str(BeautifulSoup(html, "html.parser"))
|
html_escaped = str(BeautifulSoup(html_escaped, "html.parser"))
|
||||||
|
html = self.mw.col.media.escapeImages(html_escaped, unescape=True)
|
||||||
self.note.fields[field] = html
|
self.note.fields[field] = html
|
||||||
if not self.addMode:
|
if not self.addMode:
|
||||||
self.note.flush()
|
self.note.flush()
|
||||||
|
|
Loading…
Reference in a new issue