Upgrade convert_textdivs_p to allow some children.

This commit is contained in:
Ethan Dalool 2019-12-29 13:07:35 -08:00
parent 6e2c36bdbb
commit 68a555cfd8

View file

@ -164,7 +164,16 @@ def convert_textdivs_p(soup):
divs = soup.find_all('div')
for div in divs:
children = list(div.children)
if len(children) == 1 and isinstance(children[0], (str, bs4.element.NavigableString)):
convertme = True
for child in children:
if isinstance(child, bs4.element.NavigableString):
pass
elif child.name in ['i', 'b', 'em', 'strong', 'a', 'span', 'small']:
pass
else:
convertme = False
break
if convertme:
div.name = 'p'
@soup_cleaner