|
929
|
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() |