#!/usr/bin/env python3 import sys, os, re, markdown, datetime try: mark_down_file = sys.argv[1] except: sys.exit( sys.argv[0] + ": Bitte eine Text oder Markdowndatei angeben.\ Dieses Tool wandelt eine entsprechende Datei in eine einfache Webseite" ) # 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) html_out_file = open(new_file_name, "w") title_of_text = re.sub(".md$", "", mark_down_file) else: html_out_file = sys.stdout head1 = ( '\n\ \n\ \n\ \n\ ' + title_of_text + '\n\ \n\ \n\ \n\ \n\ \n\ \n" body1 = 'Go Back' foot = " " html_out_file.write(head1 + styles + head2 + body1) with open(mark_down_file) as infile: for line in infile: a = markdown.markdown(line) html_out_file.write(a) html_out_file.write(foot)