Skip to content

Instantly share code, notes, and snippets.

@jojonki
Created January 17, 2020 12:10
Show Gist options
  • Save jojonki/af190dfa57d6fccfc1ddd6a62b9d85c4 to your computer and use it in GitHub Desktop.
Save jojonki/af190dfa57d6fccfc1ddd6a62b9d85c4 to your computer and use it in GitHub Desktop.

Revisions

  1. jojonki created this gist Jan 17, 2020.
    21 changes: 21 additions & 0 deletions convert.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    """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)