only .decompose() when it's an empty and unknown tag

This commit is contained in:
jesopo 2019-11-04 12:51:24 +00:00
parent 62781badc4
commit 516884acb8

View file

@ -77,9 +77,10 @@ def _normalise_note(content):
lines = []
for element in soup.find_all():
if not element.name in KNOWN_TAGS:
element.unwrap()
elif element.text.strip() == "":
element.decompose()
if element.text.strip() == "":
element.decompose()
else:
element.unwrap()
out = ""
for element in soup.children: