forked from samrocketman/chewbotkah
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown2html.py
More file actions
executable file
·33 lines (28 loc) · 892 Bytes
/
markdown2html.py
File metadata and controls
executable file
·33 lines (28 loc) · 892 Bytes
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
31
32
33
#!/usr/bin/env python
#Created by Sam Gleske
#Fri Feb 28 10:44:32 PST 2014
#Ubuntu 13.10
#Linux 3.11.0-12-generic x86_64
#Python 2.7.5+
#Convert markdown to html outputting html to stdout
import os
import re
from sys import argv
from sys import exit
from sys import stderr
from markdown2 import Markdown
from quik import FileLoader
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
TEMPLATE_ROOT=PROJECT_PATH+"/assets"
if not len(argv) > 1:
print >> stderr, "Must provide a markdown file as an argument."
exit(1)
if not os.path.isfile(argv[1]):
print >> stderr, "File %s does not exist." % argv[1]
exit(1)
markdown=Markdown(extras=["fenced-code-blocks"])
with open(argv[1],'r') as f:
htmlmarkdown=markdown.convert(f.read())
loader = FileLoader(TEMPLATE_ROOT)
template = loader.load_template('report.html')
print template.render(locals(),loader=loader).encode('utf-8')