work on blog generation
This commit is contained in:
parent
65e4c8130c
commit
ae899e2855
|
@ -1,2 +1,3 @@
|
|||
html/
|
||||
site/
|
||||
.blogtmp/
|
||||
|
|
7
makefile
7
makefile
|
@ -29,7 +29,12 @@ run: $(HTML_TARGETS) $(CSS_TARGETS) blog | $(OUT_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 $< $@
|
||||
|
||||
$(BLOG_OUT_DIR): | $(OUT_DIR)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
import sys
|
||||
import markdown
|
||||
import re
|
||||
|
||||
# SRC
|
||||
# +-2022/
|
||||
|
@ -41,6 +42,35 @@ print(dest_dir)
|
|||
if not os.path.isdir(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
|
||||
print(f"{src_file} -> {dest_file}")
|
||||
markdown.markdownFromFile(input=src_file, output=dest_file, extensions=["fenced_code"])
|
||||
# write markdown into a dummy file first so that we can add lines before it in the final output
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,42 @@
|
|||
.blog.page h1 {
|
||||
padding-top: 10%;
|
||||
font-size: 3em;
|
||||
.blog.page {
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
}
|
||||
|
||||
|
||||
.page h1 {
|
||||
.page h1, h2 {
|
||||
color: var(--foreground-inactive);
|
||||
|
||||
font-size: 1.7em;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
</div>
|
||||
|
||||
#include planets.html
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -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">
|
Loading…
Reference in New Issue