diff --git a/notes.py b/notes.py new file mode 100644 index 0000000..a3eef53 --- /dev/null +++ b/notes.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# file notes.py +# author Florent Guiotte +# 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) +