import re, string, os, glob import markdown as mmdd import xml.etree.ElementTree as ET def mkdown(mdfile): htfile = mdfile[:-2]+'html' f = open(mdfile, 'r') mkstr = f.read() f.close() f = open('web/sidebar.md', 'r') sidebar = f.read() f.close() f = open('web/docnav.md', 'r') docnav = '' f.close() f = open('web/template.html', 'r') templatestr = f.read() f.close() titlere = re.compile(r"^\s*#\s*([^\n]*)(.*)", re.DOTALL) title = titlere.findall(mkstr) if len(title) == 0: title = "Fac" else: mkstr = title[0][1] title = mmdd.markdown(title[0][0]) title = title[3:len(title)-4] if title[:4] == "Fac ": pagetitle = title[4:] else: pagetitle = title if '$docnav' in mkstr: templatestr = templatestr.replace('$docnav', docnav) mkstr = mkstr.replace('$docnav', '') else: templatestr = templatestr.replace('$docnav', '') template = string.Template(templatestr) f = open(htfile, 'w') myhtml = template.safe_substitute( title = title, pagetitle = pagetitle, #content = mmdd.markdown(mkstr, extensions=['mathjax']), #sidebar = mmdd.markdown(sidebar, extensions=['mathjax']))) content = mmdd.markdown(mkstr, extensions=['def_list']), sidebar = mmdd.markdown(sidebar, extensions=['def_list'])) myhtml = myhtml.replace('