From 04e9d83cdcc08932510ef54dad18b4d10b156971 Mon Sep 17 00:00:00 2001 From: Amber Date: Thu, 3 Mar 2022 20:40:32 -0600 Subject: [PATCH] added basic page generation --- TODO | 1 + main.py | 40 ++++++++++++++++++++++++++++++++++------ readFile.py | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 4fbe774..882a1cf 100644 --- a/TODO +++ b/TODO @@ -3,3 +3,4 @@ Nice HTML tabs Don't hard-code timezone Build system Take input file as a command-line arguement +Figure out licencing \ No newline at end of file diff --git a/main.py b/main.py index 336da33..e849360 100755 --- a/main.py +++ b/main.py @@ -3,22 +3,24 @@ import readFile import datetime -outFile = "" #outFile = outFile + ".html" timeCreate = "" timeMod = "" m2h = "" # markdown 2 html +headerStr = "" +footStr = "\n" -def printHtml(body): +def printHtml(head, body, foot, outFile): print("placeholder") file = open(outFile, 'w') - file.write(str(body)) + file.write(str(head + body + foot)) file.close() def parseMd(inFile): - m2h = readFile.readMarkdown(inFile) + global m2h + m2h = str(readFile.readMarkdown(inFile)) return(m2h) def metadata(inFile): @@ -32,13 +34,39 @@ def metadata(inFile): title = inFile.split(".") title = str(title[0]) #TODO: figure out a way to make longer titles without putting spaces in the filename + # Take title as optional command-line arguement + + # Generate html + global headerStr + headerStr = """\ + + + + + """ + headerStr1 = """ + + + + +""" + + headerStr = headerStr + str(title) + headerStr1 + timeMod + headerStr2 + timeCreate + headerStr3 + + return(str(headerStr)) def css(): print("placeholder") def main(): - print("placeholder") + metadata("sample.md") + parseMd("sample.md") + printHtml(headerStr, m2h, footStr, "outdir/index.html") + + def test(): #print(readFile.readMarkdown("/home/amber/website.sh/sample.md")) @@ -46,4 +74,4 @@ def test(): metadata("sample.md") -test() \ No newline at end of file +main() \ No newline at end of file diff --git a/readFile.py b/readFile.py index 15c2640..9b3ee8a 100755 --- a/readFile.py +++ b/readFile.py @@ -15,7 +15,7 @@ class readMarkdown(): def markdown(self, mdFile): print("placeholder") - file = open(mdFile, 'r') + file = open(self.mdFile, 'r') #middleVar = file.read() self.outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations file.close()