forked from docs/doc-exports
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:
parent
02ea98d597
commit
d55a9f77ef
@ -91,13 +91,22 @@ class OTCDocConvertor:
|
|||||||
|
|
||||||
# Process divs
|
# Process divs
|
||||||
for i in soup.body.find_all("div"):
|
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", []):
|
if "note" in i.get("class", []):
|
||||||
# Notes
|
# Notes
|
||||||
del i["id"]
|
del i["id"]
|
||||||
if i.img:
|
if i.img:
|
||||||
i.img.decompose()
|
i.img.decompose()
|
||||||
notetitle = i.find("span", class_="notetitle")
|
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 = soup.new_tag("div")
|
||||||
title["class"] = "title"
|
title["class"] = "title"
|
||||||
title.string = "Note:"
|
title.string = "Note:"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user