2021-04-14 01:26:24 +02:00
|
|
|
#!/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"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-04-14 12:49:11 +02:00
|
|
|
# creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H ")
|
2021-04-14 01:26:24 +02:00
|
|
|
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 = (
|
|
|
|
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n\
|
|
|
|
<html>\n\
|
|
|
|
<head>\n\
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
|
|
|
|
<title>'
|
|
|
|
+ title_of_text
|
|
|
|
+ '</title>\n\
|
|
|
|
<meta name="Generator" content="Vim/8.1">\n\
|
|
|
|
<meta name="plugin-version" content="vim8.1_v1">\n\
|
|
|
|
<meta name="syntax" content="markdown">\n\
|
|
|
|
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">\n\
|
|
|
|
<meta name="ctime" content="'
|
|
|
|
+ creationtime
|
|
|
|
+ '">\n\
|
|
|
|
<style type="text/css"> '
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
styles = " <!--\n\
|
2021-04-14 12:49:11 +02:00
|
|
|
* { font-family: monospace; color: #00f020; background-color: #1c1414; font-size: 1.1em;}\n\
|
2021-04-14 01:26:24 +02:00
|
|
|
body { font-family: monospace; }\n\
|
|
|
|
pre { white-space: pre-wrap; font-family: monospace; color: #00f020; background-color: #1c1414; }\n\
|
|
|
|
.Statement { color: #00f020; font-weight: bold; }\n\
|
|
|
|
-->\n"
|
|
|
|
head2 = "</style> </head><body>\n"
|
2021-04-14 12:49:11 +02:00
|
|
|
body1 = '<a href="#" onclick="history.go(-1)">Go Back</a>'
|
2021-04-14 01:26:24 +02:00
|
|
|
foot = "</body> </html>"
|
|
|
|
|
|
|
|
|
|
|
|
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)
|