aboutsummaryrefslogtreecommitdiffstats
path: root/src/md.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/md.py')
-rwxr-xr-xsrc/md.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/md.py b/src/md.py
new file mode 100755
index 0000000..d07df0f
--- /dev/null
+++ b/src/md.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python2
+import os
+import os.path
+import sys
+
+from jinja2 import Environment, PackageLoader, Template, FileSystemLoader
+
+import mistune
+
+#check if there is input file
+if len(sys.argv) < 2:
+ print "Need more arguments"
+ sys.exit(0)
+
+md_fn = sys.argv[1]
+
+#template loader
+loader = FileSystemLoader( "/home/fam/prog/python/mdsite/templ/" )
+templ_env = Environment( loader = loader )
+
+t = templ_env.get_template("main.thtml")
+
+#get md file
+f = open( md_fn, "r" )
+data = f.read()
+md = mistune.Markdown(rule=True)
+md_rend = md.render( data )
+
+print t.render( block = md_rend ) \ No newline at end of file