File: myemph.py

package info (click to toggle)
python-pandocfilters 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 376 kB
  • sloc: python: 802; makefile: 26
file content (20 lines) | stat: -rwxr-xr-x 466 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3
from pandocfilters import toJSONFilter, RawInline

"""
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, meta):
    if k == 'Emph' and f == 'latex':
        return [latex('\\myemph{')] + v + [latex('}')]

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