From 8d9b80f5dc65672dcf8d7d3613e07471b8d86bb4 Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Sun, 29 Oct 2023 13:49:49 +0100 Subject: [PATCH] =?UTF-8?q?Belanglose=20Test=C3=A4nderung=20an=20=20=20=20?= =?UTF-8?q?=20=20=20webgen.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webgen.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/webgen.py b/webgen.py index 4552233..0ab1952 100755 --- a/webgen.py +++ b/webgen.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +<<<<<<< HEAD import sys, os, uuid, shutil, signal, subprocess, markdown2 as markdown, re, datetime, locale, glob from dialog import Dialog @@ -23,7 +24,7 @@ dospellcheck = os.getenv("SPELLCHECK") spellcheck = "aspell" spellcheckparam = "-c" -# Configure Markdown, activate "break-on-newline" for letting a line end without havin to put doublespaces there. +# Configure Markdown, activate "break-on-newline" for letting a line end without havin to put doublespaces there. # # More options: # break-on-newline, code-friendly, cuddled-lists, fenced-code-blocks, @@ -283,3 +284,63 @@ linecounter = mkdirindex(filesdir, indexfilename, filesdirheadline) print("Dirindex in ", filesdir, " has ", linecounter, "lines") # Have a nice time. +======= +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:%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 to upper folder' +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) +>>>>>>> 6dd9be7 (Generate a blog htmlpage from a markdownfile. v0.01)