Created
January 17, 2020 12:10
-
-
Save jojonki/af190dfa57d6fccfc1ddd6a62b9d85c4 to your computer and use it in GitHub Desktop.
Convert latex to text with pandocfilters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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