generate html from .md and stdout from other files. New renaming of files. v0.03

This commit is contained in:
Wolfgang Nowak 2021-04-17 16:21:17 +02:00
parent 23e7340925
commit ef5f39473d

View file

@ -14,7 +14,7 @@ except:
if parameters == "--html": if parameters == "--html":
fileending = ".html" fileending = ".html"
try: try:
mark_down_file = sys.argv[2] parameters = sys.argv[2]
except: except:
sys.exit( sys.exit(
sys.argv[0] sys.argv[0]
@ -23,9 +23,10 @@ if parameters== "--html":
else: else:
fileending = "" fileending = ""
mark_down_file = parameters
# creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H ") creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ")
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$", fileending, mark_down_file) new_file_name = creationtime + " " + re.sub(".md$", fileending, mark_down_file)
@ -33,10 +34,11 @@ if re.match(".*\.md$", mark_down_file):
title_of_text = re.sub(".md$", "", mark_down_file) title_of_text = re.sub(".md$", "", mark_down_file)
else: else:
html_out_file = sys.stdout html_out_file = sys.stdout
title_of_text = mark_down_file
head1 = ( head1 = (
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n\ '<!DOCTYPE HTML>\n\
<html>\n\ <html>\n\
<head>\n\ <head>\n\
<meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\ <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
@ -55,7 +57,7 @@ head1 = (
styles = " <!--\n\ styles = " <!--\n\
* { font-family: monospace; color: #00f020; background-color: #1c1414; font-size: 1.1em;}\n\ * { font-family: monospace; color: #00f020; background-color: #1c1414; font-size: 1.15em;}\n\
body { font-family: monospace; }\n\ body { font-family: monospace; }\n\
pre { white-space: pre-wrap; font-family: monospace; color: #00f020; background-color: #1c1414; }\n\ pre { white-space: pre-wrap; font-family: monospace; color: #00f020; background-color: #1c1414; }\n\
.Statement { color: #00f020; font-weight: bold; }\n\ .Statement { color: #00f020; font-weight: bold; }\n\
@ -72,3 +74,5 @@ with open(mark_down_file) as infile:
a = markdown.markdown(line) a = markdown.markdown(line)
html_out_file.write(a) html_out_file.write(a)
html_out_file.write(foot) html_out_file.write(foot)
print(new_file_name)