aboutsummaryrefslogtreecommitdiff
path: root/scripts/myemph.py
blob: 2a322b3859815a222a133561e405d6444dec1ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
from pandoc import toJSONFilter

"""
Pandoc filter that causes emphasis to be rendered using
the custom macro '\myemph{...}' rather than '\emph{...}'
in latex.  Other output formats are unaffected.
"""

def latex(s):
  return {'RawInline': ['latex', s]}

def myemph(k, v, f):
  if k == 'Emph' and f == 'latex':
    return [latex('\\myemph{')] + v + [latex('}')]

if __name__ == "__main__":
  toJSONFilter(myemph)