From 68a555cfd8d518faf57c901309726c72147cdfe4 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 29 Dec 2019 13:07:35 -0800 Subject: [PATCH] Upgrade convert_textdivs_p to allow some children. --- cleanerupper/plugin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cleanerupper/plugin.py b/cleanerupper/plugin.py index e10c1ee..3dee417 100644 --- a/cleanerupper/plugin.py +++ b/cleanerupper/plugin.py @@ -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