File: deflists.py

package info (click to toggle)
python-pandocfilters 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 140 kB
  • ctags: 65
  • sloc: python: 336; makefile: 3
file content (20 lines) | stat: -rwxr-xr-x 515 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

"""
Pandoc filter to convert definition lists to bullet
lists with the defined terms in strong emphasis (for
compatibility with standard markdown).
"""

from pandocfilters import toJSONFilter, BulletList, Para, Strong

def deflists(key, value, format, meta):
  if key == 'DefinitionList':
    return BulletList([tobullet(t,d) for [t,d] in value])

def tobullet(term, defs):
  return([Para([Strong(term)])] + [b for d in defs for b in d])


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