#!/usr/bin/env python3 import sys, os, uuid, shutil, subprocess, markdown, re, datetime sourcedir = os.path.expanduser("~/") sourcefile = sourcedir + "up.php" targetdir = os.path.expanduser("~/www/i21k.de/") fileending = "" def edit(headline): editor = os.getenv("EDITOR") if not editor: editor = "vim" subprocess.call([editor, headline]) return headline # Parse arguments "--html" and "Some Headline" if len(sys.argv) == 1: headline = input("Bitte gib eine Headline ein: ") elif len(sys.argv) == 2: if sys.argv[1] == "--html": fileending = ".html" headline = input("Bitte gib eine Headline ein: ") else: headline = str(sys.argv[1]) elif len(sys.argv) == 3: if sys.argv[1] == "--html": fileending = ".html" headline = str(sys.argv[2]) elif sys.argv[2] == "--html": fileending = ".html" headline = str(sys.argv[1]) else: sys.exit(str(sys.argv[0]) + ' [--html] "some Headline"\nIf --html is choosen, output will be written to STDOUT.') headlinemd = headline + ".md" headlinehtml = headline + fileending print("Headlinefile= ", headlinemd, "\n", "Outputfile= ", headlinehtml) a = input("Press to continue: ") edit(headlinemd) mark_down_file = headlinemd creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") creationtimeheader = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") if re.match(".*\.md$", mark_down_file): new_file_name = creationtime + " " + re.sub(".md$", fileending, mark_down_file) html_out_file = open(new_file_name, "w") title_of_tfileending = re.sub(".md$", "", mark_down_file) else: html_out_file = sys.stdout title_of_tfileending = mark_down_file head1 = ( '\n\ \n' + title_of_tfileending + '\n\ \n\ \n\ \n\ ' ) styles = "