From 94cb455f9e76b1c82c4983ca3d942542ee06068d Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Tue, 13 Sep 2022 04:53:00 +0200 Subject: [PATCH] neue Datei: md2html.py markdown to html converter 1.0 --- md2html.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 md2html.py diff --git a/md2html.py b/md2html.py new file mode 100755 index 0000000..7cd2ec9 --- /dev/null +++ b/md2html.py @@ -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 = "" + headline + "" +myfooter = "" + +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)