Start notes filter

This commit is contained in:
Florent Guiotte 2019-08-20 14:11:07 +02:00
parent 4a7bfff7e4
commit 73cbe8e371

38
notes.py Normal file
View File

@ -0,0 +1,38 @@
#!/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)