sbin/doc/markdown2html.py
changeset 1072 ac1eacb3aa33
parent 1071 02c04d2c8fd8
child 1073 687133dc13cf
equal deleted inserted replaced
1071:02c04d2c8fd8 1072:ac1eacb3aa33
     1 import re, sys, markdown, codecs
       
     2 
       
     3 inputname = sys.argv[1]
       
     4 outputname = re.sub("\.\w+$",".html",inputname)
       
     5 shortname = re.sub("(^.+\/|\.\w+$)","",inputname)
       
     6 
       
     7 print "Converting %s"%shortname
       
     8 
       
     9 f = codecs.open(inputname, mode="r", encoding="utf8")
       
    10 mdtext = f.read()
       
    11 f.close()
       
    12 html = markdown.markdown(mdtext)
       
    13 
       
    14 f = codecs.open(outputname, "w", encoding="utf8")
       
    15 
       
    16 header = """<!doctype html>
       
    17 <html>
       
    18 <head>
       
    19 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
       
    20 <title>Metadataplayer docs: %s</title>
       
    21 </head>
       
    22 <body>
       
    23 """%shortname
       
    24 footer = """
       
    25 </body>
       
    26 </html>"""
       
    27 
       
    28 f.write(header)
       
    29 f.write(html)
       
    30 f.write(footer)
       
    31 
       
    32 f.close()