added assets_formatter and remove_formatter
This commit is contained in:
1 parent
8697f3ecb5
commit
ddc9add551
6 files changed
+108
-7
No files matched your search
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
This module contains a function `format` that modifies a BeautifulSoup object in place. The function searches for
|
||||
all elements with the attribute "dj-remove". For each found element, it calls the `decompose` method, which removes
|
||||
the element from the parse tree. This effectively removes all elements marked with "dj-remove" from the HTML document.
|
||||
|
||||
Example:
|
||||
If an element is <div dj-remove></div>,
|
||||
after processing, it will be removed from the BeautifulSoup object.
|
||||
"""
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def format(soup: BeautifulSoup) -> None:
|
||||
for element in soup.find_all(attrs={"dj-remove": True}):
|
||||
element.decompose()
|
||||
Reference in new issue
Block a user