Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
pandoc filter to convert gitlab flavor markdown math to pandoc compatible markdown
from pandocfilters import toJSONFilter, Math, Para
Pandoc filter to convert gitlab flavored markdown to pandoc flavored markdown
def gitlab_markdown(key, value, format, meta):
if key == "CodeBlock":
[[identification, classes, keyvals], code] = value
if classes[0] == "math":
fmt = {'t': 'DisplayMath',
'c': []}
return Para([Math(fmt, code)])
elif key == "Math":
[fmt, code] = value
if isinstance(fmt, dict) and 't' in fmt.keys():
if fmt['t'] == "InlineMath":
return Math(fmt, code.strip('`'))
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment