neue Datei: md2html.py markdown to html converter 1.0
This commit is contained in:
parent
8f7004ad08
commit
94cb455f9e
1 changed files with 21 additions and 0 deletions
21
md2html.py
Executable file
21
md2html.py
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Liest markdownfile ein und spuckt html aus: md2html meinmarkdownfile.md
|
||||
|
||||
"""
|
||||
import sys, markdown2 as markdown
|
||||
|
||||
markdown.Markdown.extras=["break-on-newline","footnotes"]
|
||||
mdfile = sys.argv[1]
|
||||
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)
|
Loading…
Reference in a new issue