[FEATURE] page templating system and parser

This commit is contained in:
mDuo13
2015-02-03 00:24:44 -08:00
parent df6cfa9fb5
commit 539d23bfce
31 changed files with 2507 additions and 2133 deletions

25
tool/buttonize.py Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python
"""
Pandoc filter to make output more like Flatdoc's parser:
* convert links ending in > to button-class links without the >
* convert underscores to dashes in header IDs
"""
from pandocfilters import toJSONFilter, Link, Str, RawInline, Header, stringify
def buttonize(key, value, format, meta):
if key == 'Link':
inlines, (href, title) = value
linktext = stringify(inlines).strip()
if (format == "html" or format == "html5") and linktext[-1] == ">":
html = "<a class='button' title='%s' href='%s'>%s</a>" % (title, href, linktext[:-1])
newlink = RawInline("html", html)
return newlink
elif key == 'Header':
level, (identifier, classes, kv), inlines = value
identifier = identifier.replace("_","-")
return Header(level, (identifier, classes, kv), inlines)
if __name__ == "__main__":
toJSONFilter(buttonize)