Remove empty classes from elements.

This commit is contained in:
Ethan Dalool 2019-12-29 13:08:12 -08:00
parent 68a555cfd8
commit 3ad862a9d0

View file

@ -235,6 +235,11 @@ def remove_unwanted_classes_ids(soup):
else: else:
tag['class'] = list(tag['class']) tag['class'] = list(tag['class'])
try:
tag['class'].remove('')
except ValueError:
pass
# Intentional list() duplicate so we can remove from original. # Intentional list() duplicate so we can remove from original.
for cls in list(tag['class']): for cls in list(tag['class']):
if any(re.match(pattern, cls) for pattern in PATTERNS): if any(re.match(pattern, cls) for pattern in PATTERNS):