Mercurial > evolve
view docs/tutorial/mypandocfilters/raw-file.py @ 5595:e190a81a3ee8
evolvecmd: inline _evolvemerge() into _relocatecommit()
I'm about to add a version of `_relocatecommit()` that uses in-memory
merge. It will be simpler to have `_evolvemerge()` inlined then than
to need a separate version of that function too. Also, the name
`_evolvemerge()` has often made me think that it's about evolving
merge commits, so it's nice to get rid of it for that reason too.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 25 Sep 2020 13:31:41 -0700 |
parents | aad37ffd7d58 |
children |
line wrap: on
line source
#!/usr/bin/env python """ Insert a raw-file as HTML code block """ import panflute as pf def action(elem, doc): if isinstance(elem, pf.CodeBlock) and 'raw-file' in elem.classes: filepath = elem.text with open(filepath, 'r') as fd: content = fd.read() return pf.RawBlock('<pre>%s</pre>' % content, "html") # elem.text = content def main(doc=None): return pf.run_filter(action, doc=doc) if __name__ == '__main__': main()