summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-10-03 23:14:58 +0200
committermetamuffin <metamuffin@disroot.org>2025-10-03 23:14:58 +0200
commit5c92840108a05f0f311d5bef2d6512579b593438 (patch)
tree2f564a598380f00f53fa02f6dc3433cbddb0909b
parent8444803182573e59414ebcbc4bec9da36aeac451 (diff)
downloadmetamuffin-website-5c92840108a05f0f311d5bef2d6512579b593438.tar
metamuffin-website-5c92840108a05f0f311d5bef2d6512579b593438.tar.bz2
metamuffin-website-5c92840108a05f0f311d5bef2d6512579b593438.tar.zst
read title from h1
-rw-r--r--process.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/process.py b/process.py
index 6cef2a8..c9db002 100644
--- a/process.py
+++ b/process.py
@@ -11,18 +11,21 @@ PROCESSORS = {
}
def run_pi(input: str) -> str:
- RE_PI = r"(?sm)\<\?(?P<n>\w+)\W(?P<b>.*?)\?\>"
+ RE_PI = r"(?sm)<\?(?P<name>\w+)\W(?P<body>.*?)\?>"
def run_pi_match(m: re.Match):
- name = m.group("n")
- body = m.group("b")
+ name = m.group("name")
+ body = m.group("body")
print(f"({name})$ {body}")
output = PROCESSORS[name](body)
return output
return re.sub(RE_PI, run_pi_match, input)
def template(input: str) -> str:
+ RE_TITLE = r"<h1>(?P<title>.*?)</h1>"
+ title_match = re.match(RE_TITLE, input)
+ title = title_match.group(1) if title_match != None else "no title :("
tpl = open("template.html", "r").read()
- return tpl.replace("CONTENT", input).replace("TITLE", "TODO TITLE")
+ return tpl.replace("CONTENT", input).replace("TITLE", title)
doc = open(argv[1], "r").read()
doc = markdown(doc)