From a4d7a6d6b23180660d53df499a72e8af3548a8c1 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 7 Oct 2023 21:53:02 +0200 Subject: Make blog work as container * Use BeautifulSoup instead of HTML Tidy, so everything is done in Python * Pull content as submodule for testing purposes * Comment how to use bicephalus from working copy --- blog_experiment/blog/html.py | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'blog_experiment/blog/html.py') diff --git a/blog_experiment/blog/html.py b/blog_experiment/blog/html.py index a114318a..6c3b0099 100644 --- a/blog_experiment/blog/html.py +++ b/blog_experiment/blog/html.py @@ -1,30 +1,17 @@ -import subprocess - +import bs4 import htmlgenerator as h -def tidy(s): - p = subprocess.run( - ["tidy", "--indent", "yes", "-q", "-wrap", "160"], - input=s, - stdout=subprocess.PIPE, - encoding="UTF8", - ) - return p.stdout - - def html_template(*content): - return tidy( - h.render( - h.HTML( - h.HEAD(h.TITLE("El blog es mío")), - h.BODY( - h.H1("El blog es mío"), - h.H2("Hay otros como él, pero este es el mío"), - *content, - ), - doctype="html", + return bs4.BeautifulSoup(h.render( + h.HTML( + h.HEAD(h.TITLE("El blog es mío")), + h.BODY( + h.H1("El blog es mío"), + h.H2("Hay otros como él, pero este es el mío"), + *content, ), - {}, - ) - ) + doctype="html", + ), + {}, + ), features="html.parser").prettify() -- cgit v1.2.3