work on blog generation

This commit is contained in:
ktyl 2022-05-17 01:39:33 +01:00
parent 65e4c8130c
commit ae899e2855
7 changed files with 106 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
html/ html/
site/ site/
.blogtmp/

View File

@ -29,7 +29,12 @@ run: $(HTML_TARGETS) $(CSS_TARGETS) blog | $(OUT_DIR)
blog: $(BLOG_TARGETS) | $(BLOG_TMP_DIR) blog: $(BLOG_TARGETS) | $(BLOG_TMP_DIR)
$(BLOG_OUT_DIR)/%.html: $(BLOG_SRC_DIR)/%.md | $(BLOG_OUT_DIR) $(BLOG_OUT_DIR)/%.html: $(BLOG_OUT_DIR)/%.html.tmp $(HTML_INCLUDES) $(CSS_TARGETS)
python ppp/ppp.py $< $(HTML_INCLUDES) > $@
cp $(CSS_TARGETS) `dirname $@`
rm $<
$(BLOG_OUT_DIR)/%.html.tmp: $(BLOG_SRC_DIR)/%.md | $(BLOG_TMP_DIR)
python scripts/mkblog.py $< $@ python scripts/mkblog.py $< $@
$(BLOG_OUT_DIR): | $(OUT_DIR) $(BLOG_OUT_DIR): | $(OUT_DIR)

View File

@ -3,6 +3,7 @@
import os import os
import sys import sys
import markdown import markdown
import re
# SRC # SRC
# +-2022/ # +-2022/
@ -41,6 +42,35 @@ print(dest_dir)
if not os.path.isdir(dest_dir): if not os.path.isdir(dest_dir):
os.makedirs(dest_dir) os.makedirs(dest_dir)
print(f"{src_file} -> {dest_file}") # write markdown into a dummy file first so that we can add lines before it in the final output
markdown.markdownFromFile(input=src_file, output=dest_file, extensions=["fenced_code"]) dummy_file = f"{dest_file}.bak"
open(dummy_file, 'w').close()
print(f"{dummy_file} -> {dummy_file}")
markdown.markdownFromFile(input=src_file, output=dummy_file, extensions=["fenced_code"])
print(f"{dummy_file} -> {dest_file}")
with open(dummy_file, 'r') as read_file, open(dest_file, 'w') as write_file:
write_file.write("#include blogstart.html\n")
# modify the basic html to make it nicer for styling later
html = read_file.read()
# insert para-block start between non-p and p elements
html = re.sub('((?<!</p>)\n)(<p>)', r'\1<div class="para-block">\n\2', html)
# insert para-block end between p and non-p elements
html = re.sub('(</p>\n)((?!<p>))', r'\1</div>\n\2', html)
lines = html.split("\n")
# tack on a closing div because we will have opened one without closing it on the final <p>
lines.append("</div>")
for line in lines:
write_file.write(line + "\n")
write_file.write("\n#include blogend.html\n")
os.remove(dummy_file)

View File

@ -1,4 +1,42 @@
.blog.page h1 { .blog.page {
padding-top: 10%;
font-size: 3em;
} }
.blog.page h1 {
font-size: 2.5em;
}
.blog.page .para-block {
color: var(--foreground-inactive);
font-size: 1.1em;
line-height: 1.25em;
background-color: var(--background);
border-color: var(--background-alt);
border-width: 3px;
border-radius: 2em;
border-style: solid;
padding: 1.0em 1.5em;
}
.blog.page .para-block p {
}
.blog.page pre {
color: var(--background);
background-color: var(--foreground);
font-size 1.5em;
line-height: 1.3em;
border-color: var(--accent);
border-width: 2px;
border-radius: 2em;
border-style: solid;
padding: 1.5em 2.0em;
margin: 2.5em -3.0em;
}

View File

@ -56,7 +56,7 @@
} }
.page h1 { .page h1, h2 {
color: var(--foreground-inactive); color: var(--foreground-inactive);
font-size: 1.7em; font-size: 1.7em;

View File

@ -0,0 +1,6 @@
</div>
#include planets.html
</body>
</html>

View File

@ -0,0 +1,19 @@
<!doctype html>
<html>
#include header.html
<body>
<title>ktyl ~ blog</title>
<div class="nav">
#include titlestart.html
/blog
#include titleend.html
#include nav.html
#include socials.html
</div>
<div class="page blog">