This repository has been archived on 2024-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
Auberge_Vagabonde/utils.py
Michel Roux 9aa5b46a72
All checks were successful
continuous-integration/drone/push Build is passing
Add utils and multiple modifications on pypub
2021-04-11 18:02:29 +02:00

13 lines
368 B
Python

from bs4.element import NavigableString
def strip_content(tag):
# strip content from all children
children = [strip_content(child) for child in tag.children if not isinstance(child, NavigableString)]
# remove everything from the tag
tag.clear()
for child in children:
# Add back stripped children
tag.append(child)
return tag