mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Merge pull request #504 from evandroforks/fix_beautiful_soup
Fixed BeautifulSoup breaking string paths
This commit is contained in:
commit
e65873c0e4
2 changed files with 16 additions and 5 deletions
|
@ -150,6 +150,11 @@ class SupermemoXmlImporter(NoteImporter):
|
||||||
|
|
||||||
# my sm2004 also ecaped & char in escaped sequences.
|
# my sm2004 also ecaped & char in escaped sequences.
|
||||||
html = re.sub("&", "&", html)
|
html = re.sub("&", "&", html)
|
||||||
|
|
||||||
|
# https://anki.tenderapp.com/discussions/ankidesktop/39543-anki-is-replacing-the-character-by-when-i-exit-the-html-edit-mode-ctrlshiftx
|
||||||
|
if html.find(">") < 0:
|
||||||
|
return html
|
||||||
|
|
||||||
# unescaped solitary chars < or > that were ok for minidom confuse btfl soup
|
# unescaped solitary chars < or > that were ok for minidom confuse btfl soup
|
||||||
# html = re.sub(u'>',u'>',html)
|
# html = re.sub(u'>',u'>',html)
|
||||||
# html = re.sub(u'<',u'<',html)
|
# html = re.sub(u'<',u'<',html)
|
||||||
|
|
|
@ -495,6 +495,8 @@ 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:
|
||||||
# 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>
|
||||||
with warnings.catch_warnings() as w:
|
with warnings.catch_warnings() as w:
|
||||||
|
@ -806,6 +808,10 @@ to a cloze type first, via Edit>Change Note Type."""
|
||||||
removeTags = ["script", "iframe", "object", "style"]
|
removeTags = ["script", "iframe", "object", "style"]
|
||||||
|
|
||||||
def _pastePreFilter(self, html, internal):
|
def _pastePreFilter(self, html, internal):
|
||||||
|
# https://anki.tenderapp.com/discussions/ankidesktop/39543-anki-is-replacing-the-character-by-when-i-exit-the-html-edit-mode-ctrlshiftx
|
||||||
|
if html.find(">") < 0:
|
||||||
|
return html
|
||||||
|
|
||||||
with warnings.catch_warnings() as w:
|
with warnings.catch_warnings() as w:
|
||||||
warnings.simplefilter("ignore", UserWarning)
|
warnings.simplefilter("ignore", UserWarning)
|
||||||
doc = BeautifulSoup(html, "html.parser")
|
doc = BeautifulSoup(html, "html.parser")
|
||||||
|
|
Loading…
Reference in a new issue