-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
30 lines (24 loc) · 828 Bytes
/
build.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
30
import sys
import CommonMark
import jinja2
from codecs import open
from jinja2 import Environment, FileSystemLoader
if __name__ == '__main__':
output_file = 'index.html'
template_name = 'base.html'
if len(sys.argv) >= 2:
output_file = sys.argv[1]
if len(sys.argv) >= 3:
template_name = sys.argv[2]
print output_file, template_name
parser = CommonMark.DocParser()
renderer = CommonMark.HTMLRenderer()
with open('stagiaires.md', encoding='utf8') as fd:
content = fd.read()
ast = parser.parse(content)
html = renderer.render(ast)
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template(template_name)
output = template.render(content=html)
with open(output_file, 'w', encoding='utf8') as fd:
fd.write(output)