diff options
Diffstat (limited to 'process.py')
-rw-r--r-- | process.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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) |