forked from gratipay/inside.gratipay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgfm.py
29 lines (21 loc) · 755 Bytes
/
gfm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import absolute_import, division, print_function, unicode_literals
import misaka
from aspen_jinja2_renderer import Renderer as Jinja2Renderer, Factory as Jinja2Factory
def gfm(md):
html = misaka.html( md
, misaka.EXT_STRIKETHROUGH | misaka.EXT_AUTOLINK | misaka.EXT_FENCED_CODE
, misaka.HTML_SMARTYPANTS | misaka.HTML_TOC
)
return html
wrapper = """
{{% extends "templates/page.html" %}}
{{% block content %}}
{}
{{% endblock %}}
"""
class Renderer(Jinja2Renderer):
def compile(self, filepath, raw):
raw = wrapper.format(gfm(raw))
return Jinja2Renderer.compile(self, filepath, raw)
class Factory(Jinja2Factory):
Renderer = Renderer