Drop empty notes

Reviewed-by: Goncharov, Artem <artem.goncharov@t-systems.com>
Co-authored-by: gtema <artem.goncharov@gmail.com>
Co-committed-by: gtema <artem.goncharov@gmail.com>
This commit is contained in:
gtema 2022-10-27 14:06:33 +00:00 committed by zuul
parent 02ea98d597
commit d55a9f77ef

View File

@ -91,13 +91,22 @@ class OTCDocConvertor:
# Process divs
for i in soup.body.find_all("div"):
if i.decomposed:
# if we decompose a later in the code it may still be returned
# here in the list. Skip those
continue
if "note" in i.get("class", []):
# Notes
del i["id"]
if i.img:
i.img.decompose()
notetitle = i.find("span", class_="notetitle")
if notetitle:
notebody = i.find(class_="notebody")
if not (notebody and notebody.get_text()):
# Some smart people make empty notes. Since this is
# breaking layout we need to drop those
i.decompose()
elif notetitle:
title = soup.new_tag("div")
title["class"] = "title"
title.string = "Note:"