From 23e7340925ae2ace08af6e698869a9ff55e0a2d1 Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Wed, 14 Apr 2021 12:59:22 +0200 Subject: [PATCH] generate html from .md and stdout from other files. v0.02 --- webgen.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/webgen.py b/webgen.py index 7688d31..a6bfc97 100755 --- a/webgen.py +++ b/webgen.py @@ -3,7 +3,7 @@ import sys, os, re, markdown, datetime try: - mark_down_file = sys.argv[1] + parameters = sys.argv[1] except: sys.exit( sys.argv[0] @@ -11,11 +11,24 @@ except: ) +if parameters== "--html": + fileending=".html" + try: + mark_down_file = sys.argv[2] + except: + sys.exit( + sys.argv[0] + + ": Bitte eine Text oder Markdowndatei angeben.\ Dieses Tool wandelt eine entsprechende Datei in eine einfache Webseite" + ) +else: + fileending="" + + # creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H ") creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") if re.match(".*\.md$", mark_down_file): - new_file_name = creationtime + " " + re.sub(".md$", ".html", mark_down_file) + new_file_name = creationtime + " " + re.sub(".md$", fileending, mark_down_file) html_out_file = open(new_file_name, "w") title_of_text = re.sub(".md$", "", mark_down_file) else: