Upgrade convert_textdivs_p to allow some children.

master
Ethan Dalool 2019-12-29 13:07:35 -08:00
parent 6e2c36bdbb
commit 68a555cfd8
1 changed files with 10 additions and 1 deletions

View File

@ -164,7 +164,16 @@ def convert_textdivs_p(soup):
divs = soup.find_all('div') divs = soup.find_all('div')
for div in divs: for div in divs:
children = list(div.children) 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' div.name = 'p'
@soup_cleaner @soup_cleaner