Skip to content

Instantly share code, notes, and snippets.

@jojonki
Created January 17, 2020 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jojonki/af190dfa57d6fccfc1ddd6a62b9d85c4 to your computer and use it in GitHub Desktop.
Save jojonki/af190dfa57d6fccfc1ddd6a62b9d85c4 to your computer and use it in GitHub Desktop.
Convert latex to text with pandocfilters
"""Remove latex blocks and replace math functiosn with (MATH)
- How to debug:
pandoc -t json aaa.tex | python ./this-file.py | pandoc -f json -t plain
- How to use:
pandoc -s aaa.tex --filter=./this-file.py -o out.text
"""
from pandocfilters import toJSONFilter, Str
def abc(key, value, format, _):
if key == 'RawBlock':
if value[0] == 'latex':
return []
elif key == 'Math':
return Str('(MATH)')
if __name__ == "__main__":
toJSONFilter(abc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment