pandoc-slides/notes.py
2019-08-20 14:11:07 +02:00

39 lines
762 B
Python

#!/usr/bin/env python
# file notes.py
# author Florent Guiotte <florent.guiotte@uhb.fr>
# version 0.0
# date 27 mai 2019
"""Abstract
doc.
"""
import panflute as pf
import re
f = None
def prepare(doc):
global f
doc.ignore = False
f = open('test.pdfpc', 'w')
def comment(el, doc):
global f
is_relevant = (type(el) == pf.RawBlock)# and (el.format == 'html')
if is_relevant and re.search("::notes", el.text):
doc.ignore = True
if doc.ignore:
if is_relevant and re.search("::", el.text):
doc.ignore = False
f.write('{}\n'.format(el.text))
return []
def finalize(doc):
global f
f.close()
if __name__ == "__main__":
pf.toJSONFilter(comment, prepare=prepare, finalize=finalize)