diff options
Diffstat (limited to 'process.py')
-rw-r--r-- | process.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -5,15 +5,17 @@ from markdown import markdown import subprocess PROCESSORS = { + "lit": lambda c: c, "ex": lambda c: popen(c).read(), "exmd": lambda c: markdown(popen(c).read()) } def run_pi(input: str) -> str: - RE_PI = r"(?sm)\<\?(?P<name>\w+)\W(?P<body>.*)\?\>" + RE_PI = r"(?sm)\<\?(?P<n>\w+)\W(?P<b>.*?)\?\>" def run_pi_match(m: re.Match): - name = m.group("name") - body = m.group("body") + name = m.group("n") + body = m.group("b") + print(f"({name})$ {body}") output = PROCESSORS[name](body) return output return re.sub(RE_PI, run_pi_match, input) |