Created
January 6, 2016 19:31
-
-
Save bpj/20ff7452590ad1692028 to your computer and use it in GitHub Desktop.
Pandoc filter to restore pre 1.16 behavior of wrapping Span contents in braces in LaTeX output
This file contains hidden or 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
#!/usr/bin/env python | |
""" | |
Pandoc filter to restore pre 1.16 behavior of wrapping Span contents in braces in LaTeX output, | |
since I and maybe others have documents and/or filters relying on the old behavior | |
""" | |
import pandocfilters as pf | |
want_braces = None | |
open_brace = [pf.RawInline('tex', '{')] | |
close_brace = [pf.RawInline('tex', '}')] | |
def brace_spans(key, val, fmt, meta): | |
global want_braces | |
if not 'Span' == key: | |
return | |
if want_braces is None: | |
want_braces = 'latex' == fmt | |
if not want_braces: | |
return | |
attrs = val[0] | |
text = open_brace + val[1] + close_brace | |
return pf.Span(attrs, text) | |
if __name__ == "__main__": | |
pf.toJSONFilter(brace_spans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment