more formatting

This commit is contained in:
truePhilipp committed 2024-05-05 20:48:28 +02:00
1 parent 42715de295
commit b042a297b5
5 files changed
+55 -5

No files matched your search

@@ -0,0 +1,12 @@
from bs4 import BeautifulSoup
from .style_formatter import parse_style, style_to_string
def format(soup: BeautifulSoup) -> None:
for element in soup.find_all(attrs={"dj-style-raw": True}):
style = parse_style(element["style"])
dj_style = element.get("dj-style-raw")
for name, value in [declaration.split(";") for declaration in dj_style.split("~") if declaration]:
style[name] = value
element["style"] = style_to_string(style)
del element.attrs["dj-style-raw"]