Mercurial > evolve
comparison docs/tutorial/mypandocfilters/raw-file.py @ 3376:aad37ffd7d58
doc: import the training support
Import the training support which was stored in a private-repository before.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 08 Jan 2018 11:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3375:1cb549cd6236 | 3376:aad37ffd7d58 |
---|---|
1 #!/usr/bin/env python | |
2 """ | |
3 Insert a raw-file as HTML code block | |
4 """ | |
5 | |
6 import panflute as pf | |
7 | |
8 | |
9 def action(elem, doc): | |
10 if isinstance(elem, pf.CodeBlock) and 'raw-file' in elem.classes: | |
11 filepath = elem.text | |
12 | |
13 with open(filepath, 'r') as fd: | |
14 content = fd.read() | |
15 | |
16 return pf.RawBlock('<pre>%s</pre>' % content, "html") | |
17 # elem.text = content | |
18 | |
19 def main(doc=None): | |
20 return pf.run_filter(action, doc=doc) | |
21 | |
22 | |
23 if __name__ == '__main__': | |
24 main() |