Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
# Pandoc filter to convert inline HTML comments to LaTeX todos
# Requires panflute (if you don't have it, do "pip install panflute")
# Also requires the todonotes LaTeX package, see
# When prerequisites are installed, use pandoc option "--filter ./"
# (adjusting the filter directory if necessary)
import panflute as pf
import re
def action(e, doc):
if (isinstance(e, pf.RawBlock) or isinstance(e, pf.RawInline)) and (doc.format == 'latex'):
match ="<!-- ([^-]+) -->", e.text)
if match:
if len( > 20:
e.format = 'latex'
e.text = '\\todo[inline]{' + + '}'
e.format = 'latex'
e.text = '\\todo{' + + '}'
def main():
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.