Skip to content

Instantly share code, notes, and snippets.

@oskimura
Created February 24, 2017 15:06
Show Gist options
  • Save oskimura/a00ac0343947093cca466972fe3edb12 to your computer and use it in GitHub Desktop.
Save oskimura/a00ac0343947093cca466972fe3edb12 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from pandocfilters import toJSONFilter, RawInline
def conv(key,value,format,meta):
if format == 'latex':
if key == 'Code':
[[ident, classes, kvs], contents] = value
dst = contents.translate({
ord(u'_'): u'\\_',
ord(u'%'): u'\\%',
ord(u'$'): u'\\$',
ord(u'#'): u'\\#',
ord(u'&'): u'\\&',
})
return RawInline('latex','\\tt{' + dst + '}')
else:
return None
if __name__ == "__main__":
toJSONFilter(conv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment