aboutsummaryrefslogtreecommitdiff
path: root/blog_experiment/blog/html.py
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2023-09-17 17:39:54 +0200
committeralex <alex@pdp7.net>2023-09-17 17:39:54 +0200
commite7d04e802ea9fcf4a56210be16aaa0b131e5e797 (patch)
tree071fc39e31a08dd9c91fe5c5ab4d8c05fde3feab /blog_experiment/blog/html.py
parente5a7e9667c709c20988158b30b29e5ac019c0fe2 (diff)
Refactor in modules, add gemtext parser
Diffstat (limited to 'blog_experiment/blog/html.py')
-rw-r--r--blog_experiment/blog/html.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/blog_experiment/blog/html.py b/blog_experiment/blog/html.py
new file mode 100644
index 00000000..7293d395
--- /dev/null
+++ b/blog_experiment/blog/html.py
@@ -0,0 +1,29 @@
+import subprocess
+
+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,
+ ),
+ ),
+ {},
+ )
+ )