generate html from .md and stdout from other files. v0.02

This commit is contained in:
Wolfgang Nowak 2021-04-14 12:59:22 +02:00
parent 5258cec6b3
commit 23e7340925

View file

@ -3,7 +3,7 @@
import sys, os, re, markdown, datetime import sys, os, re, markdown, datetime
try: try:
mark_down_file = sys.argv[1] parameters = sys.argv[1]
except: except:
sys.exit( sys.exit(
sys.argv[0] 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 ")
creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
if re.match(".*\.md$", mark_down_file): 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") html_out_file = open(new_file_name, "w")
title_of_text = re.sub(".md$", "", mark_down_file) title_of_text = re.sub(".md$", "", mark_down_file)
else: else: