MimIR
0.4-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
fences.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
"""Doxygen input filter: wraps every Mim and EBNF listing in a `<lang>-code` div.
4
5
Doxygen discards the language of a fenced code block, so `docs/mim.js` and `docs/ebnf.js` need the wrapper to tell such a listing from any other verbatim block.
6
"""
7
8
import
re
9
import
sys
10
11
WRAP = re.compile(
r'^([ \t]*)(?:```(mim|ebnf)\n.*?^[ \t]*```|\\include "[^"]*\.(mim)")$'
, re.M | re.S)
12
13
14
def
wrap
(match):
15
indent, lang = match.group(1), match.group(2)
or
match.group(3)
16
return
f
'{indent}<div class="{lang}-code">\n\n{match.group(0)}\n\n{indent}</div>'
17
18
19
def
main
():
20
with
open(sys.argv[1], encoding=
'utf-8'
)
as
file:
21
sys.stdout.write(WRAP.sub(wrap, file.read()))
22
23
24
if
__name__ ==
'__main__'
:
25
main
()
fences.wrap
wrap(match)
Definition
fences.py:14
fences.main
main()
Definition
fences.py:19
docs
fences.py
Generated by
1.18.0