added new formatters
This commit is contained in:
1 parent
043b1e918f
commit
42715de295
8 files changed
+60
-4
No files matched your search
@@ -0,0 +1,19 @@
|
||||
from bs4 import BeautifulSoup, Doctype, Tag
|
||||
|
||||
|
||||
def format(soup: BeautifulSoup) -> None:
|
||||
if html := soup.find("html"):
|
||||
if isinstance(html, Tag):
|
||||
if html.has_attr("dj-remove-default"):
|
||||
if isinstance(soup.contents[0], Doctype):
|
||||
soup.contents[0].extract()
|
||||
if head := html.find("head"):
|
||||
if isinstance(head, Tag):
|
||||
head.decompose()
|
||||
if body := html.find("body"):
|
||||
if isinstance(body, Tag):
|
||||
if script := body.find("script"):
|
||||
if isinstance(script, Tag):
|
||||
script.decompose()
|
||||
body.unwrap()
|
||||
html.unwrap()
|
||||
Reference in new issue
Block a user