Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Forked from wcaleb/inlinenotes.py
Created August 18, 2014 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hepplerj/6c73462327be220fa3be to your computer and use it in GitHub Desktop.
Save hepplerj/6c73462327be220fa3be to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from pandocfilters import toJSONFilter, RawInline, Str, Space
"""
Pandoc filter for Markdown that converts all notes to inline notes.
If input notes had multiple paragraphs, the paragraphs are joined
by a single space.
"""
def inlinenotes(k, v, f, meta):
if k == 'Note' and f == 'markdown':
vlist = v[0]['c']
for d in v[1:]:
vlist.append(Space())
vlist.extend(d['c'])
return [RawInline('html', '^[')] + vlist + [Str(']')]
if __name__ == "__main__":
toJSONFilter(inlinenotes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment