Merge pull request #501 from evandroforks/fix_beautiful_soup

Renamed BeautifulSoup import name for consistency with other usages of it
This commit is contained in:
Damien Elmes 2020-03-11 15:55:15 +10:00 committed by GitHub
commit 1f26bac890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,18 +143,18 @@ class SupermemoXmlImporter(NoteImporter):
]
)
def _decode_htmlescapes(self, s: str) -> str:
def _decode_htmlescapes(self, html: str) -> str:
"""Unescape HTML code."""
# In case of bad formated html you can import MinimalSoup etc.. see btflsoup source code
from bs4 import BeautifulSoup as btflsoup
# In case of bad formated html you can import MinimalSoup etc.. see BeautifulSoup source code
from bs4 import BeautifulSoup
# my sm2004 also ecaped & char in escaped sequences.
s = re.sub("&", "&", s)
html = re.sub("&", "&", html)
# unescaped solitary chars < or > that were ok for minidom confuse btfl soup
# s = re.sub(u'>',u'&gt;',s)
# s = re.sub(u'<',u'&lt;',s)
# html = re.sub(u'>',u'&gt;',html)
# html = re.sub(u'<',u'&lt;',html)
return str(btflsoup(s, "html.parser"))
return str(BeautifulSoup(html, "html.parser"))
def _afactor2efactor(self, af: float) -> float:
# Adapted from <http://www.supermemo.com/beta/xml/xml-core.htm>