2022-09-13 04:53:00 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2023-08-31 19:48:18 +02:00
|
|
|
"""
|
|
|
|
Liest markdownfile ein und spuckt html aus: md2html meinmarkdownfile.md
|
2022-09-13 04:53:00 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
import sys, markdown2 as markdown
|
|
|
|
|
2022-09-29 23:18:49 +02:00
|
|
|
markdown.Markdown.extras = ["break-on-newline", "footnotes"]
|
|
|
|
|
|
|
|
try:
|
|
|
|
mdfile = sys.argv[1]
|
|
|
|
except:
|
2023-08-31 19:48:18 +02:00
|
|
|
sys.exit("No file, honey.\n"+sys.argv[0]+ ": Liest markdownfile ein und spuckt html aus: md2html meinmarkdownfile.md")
|
2022-09-29 23:18:49 +02:00
|
|
|
|
2022-09-13 04:53:00 +02:00
|
|
|
headline = mdfile.split(".md")[0]
|
|
|
|
htmlfilename = headline + ".html"
|
|
|
|
myhead = "<!DOCTYPE HTML><html><head><title>" + headline + "</title></head><body>"
|
|
|
|
myfooter = "</body></html>"
|
|
|
|
|
|
|
|
with open(mdfile, "r", encoding="utf-8") as datafile:
|
|
|
|
md = datafile.read()
|
|
|
|
htmlcontent = markdown.markdown(md, extras=markdown.Markdown.extras)
|
|
|
|
|
|
|
|
with open(htmlfilename, "w", encoding="utf-8") as outfile:
|
|
|
|
outfile.write(myhead + htmlcontent + myfooter)
|