nit
This commit is contained in:
parent
e8d2f67a40
commit
50365401d3
14
build.py
14
build.py
|
|
@ -23,12 +23,10 @@ def glob_all_to(src, dst):
|
|||
else:
|
||||
yield page, Path(f'{dst}/{page.relative_to(src)}')
|
||||
|
||||
def path_write(path, text):
|
||||
path.parent.mkdir(exist_ok=True, parents=True)
|
||||
if minimal and path.suffix == '.html':
|
||||
def minify(html):
|
||||
from bs4 import BeautifulSoup
|
||||
import minify_html
|
||||
soup = BeautifulSoup(text, 'html.parser')
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
for div in soup.find_all('div'):
|
||||
div.unwrap()
|
||||
tab = False
|
||||
|
|
@ -45,8 +43,12 @@ def path_write(path, text):
|
|||
soup.insert(1, tab)
|
||||
for tag in soup.find_all(True):
|
||||
tag.attrs = {k: v for k, v in tag.attrs.items() if k != 'class'}
|
||||
t = minify_html.minify(str(soup))
|
||||
path.write_text(t)
|
||||
return minify_html.minify(str(soup))
|
||||
|
||||
def path_write(path, text):
|
||||
path.parent.mkdir(exist_ok=True, parents=True)
|
||||
if minimal and path.suffix == '.html':
|
||||
path.write_text(minify(text))
|
||||
else:
|
||||
path.write_text(text)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue