Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > acd44bec1713fb11c3f3b2fd943dbaae > files > 18

python3-pandocfilters-1.4.2-3.mga7.noarch.rpm

#!/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)