html.xonsh/main.py

82 lines
1.9 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/python
import readFile
import datetime
import header
#outFile = outFile + ".html"
timeCreate = ""
timeMod = ""
m2h = "" # markdown 2 html
headerStr = ""
footStr = "\n</body>\n</html>"
def printHtml(head, body, foot, outFile):
print("placeholder")
file = open(outFile, 'w')
file.write(str(head + body + foot))
file.close()
def parseMd(inFile):
global m2h
m2h = str(readFile.readMarkdown(inFile))
return(m2h)
#def metadata(inFile):
# # Read metadata from possible file
# ## Pretend there's code here
#
# # Generate metadata
# getTime = datetime.datetime.now()
# timeMod = str(getTime.strftime("%A, %B %d, %Y at %X UTC06:00")) #TODO: I don't want to hard-code this but the %z utc offset isn't printing
# timeCreate = timeMod
#
# 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 = """\
#<!DOCTYPE HTML>
#<html>
#<head>
# <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
# <title>"""
# headerStr1 = """</title>
# <meta name="generator" content="HTML.xonsh https://git.nixnet.services/amber/html.xonsh"/>
# <meta name="created" content=" """
# headerStr2 = """"/>
# <meta name="changed" content=" """
# headerStr3 = """"/>
#</head>
#<body>
#"""
#
# headerStr = headerStr + str(title) + headerStr1 + timeMod + headerStr2 + timeCreate + headerStr3
#
# return(str(headerStr))
def css():
print("placeholder")
def main():
# metadata("sample.md")
parseMd("sample.md")
printHtml(headerStr, m2h, footStr, "outdir/index.html")
def test():
#print(readFile.readMarkdown("/home/amber/website.sh/sample.md"))
#print(parseMd("sample.md"))
#metadata("sample.md")
print(str(header.readHead("htmlTemplate/header.html", "string")))
#main()
test()