diff --git a/otc_doc_convertor/convertor.py b/otc_doc_convertor/convertor.py index c58ac075..52d2bd57 100644 --- a/otc_doc_convertor/convertor.py +++ b/otc_doc_convertor/convertor.py @@ -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:"