#!/usr/bin/env python3 import sys, os, uuid, shutil, subprocess, markdown, re, datetime targetdir = os.path.expanduser("~/www/i21k.de/posts/") 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" # there are 2 parameters. if --html is given, the fileending will be .html. # Else there will be no fileending, but it will still contain html # there is no parameter: if len(sys.argv) == 1: headline = input("Bitte gib eine Headline ein: ") # there is 1 parameter 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]) # there are 2 parameters. if --html is given, the fileending will be .html. E 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"\n') headlinemd = headline + ".md" headlinehtml = headline + fileending creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") creationtimeheader = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") new_file_name = targetdir + creationtime + " " + headline + fileending print("You will edit now: ", headlinemd, "\n", "Outputfile= ", new_file_name) a = input("Press to continue or to stop: ") edit(headlinemd) html_out_file = open(new_file_name, "w") head1 = ( '\n\ \n' + headline + '\n\ \n\ \n\ \n\ ' ) # Some fancy css for minimalistic terminal style styles = "