note_filter.py 454 B

123456789101112131415161718192021
  1. #! /usr/bin/env python3
  2. import panflute as pf
  3. def handle_note(elem, doc):
  4. if isinstance(elem, pf.RawInline) and elem.text == '<mark>':
  5. elem.text = r'\colorbox{yellow}{'
  6. elem.format = 'tex'
  7. if isinstance(elem, pf.RawInline) and elem.text == '</mark>':
  8. elem.text = '}'
  9. elem.format = 'tex'
  10. return elem
  11. def main(doc=None):
  12. return pf.run_filter(handle_note, doc=doc)
  13. if __name__ == "__main__":
  14. main()