From 3ad862a9d082529a21824d38e19cbf270e668ef0 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 29 Dec 2019 13:08:12 -0800 Subject: [PATCH] Remove empty classes from elements. --- cleanerupper/plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cleanerupper/plugin.py b/cleanerupper/plugin.py index 3dee417..e821289 100644 --- a/cleanerupper/plugin.py +++ b/cleanerupper/plugin.py @@ -235,6 +235,11 @@ def remove_unwanted_classes_ids(soup): else: tag['class'] = list(tag['class']) + try: + tag['class'].remove('') + except ValueError: + pass + # Intentional list() duplicate so we can remove from original. for cls in list(tag['class']): if any(re.match(pattern, cls) for pattern in PATTERNS):