You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
from glob import glob
|
|
import os
|
|
import subprocess
|
|
import jinja2
|
|
|
|
# https://devdocs.io/python~3.9/library/glob#glob.glob
|
|
# files = glob("content/**", recursive=True)
|
|
# print(files)
|
|
print("---------")
|
|
stoplist = ["print", "colophon"]
|
|
folders = glob("*")
|
|
|
|
for folder in folders:
|
|
if folder in stoplist:
|
|
continue
|
|
files = glob(folder + "/*")
|
|
|
|
for file in files:
|
|
#print(file)
|
|
if file.endswith(".md"):
|
|
print("===========")
|
|
file = file.replace(" ", "\ ")
|
|
print(file)
|
|
|
|
pandoc2 = "pandoc -f markdown -t html " + file
|
|
html_data = subprocess.check_output(pandoc2, shell=True, text=True, encoding="utf-8")
|
|
# print(type(html_data))
|
|
# print("html_data: ", html_data)
|
|
|
|
env = jinja2.Environment(loader=jinja2.FileSystemLoader("."))
|
|
template = env.get_template("webpage.template.html")
|
|
html_data = template.render(content=html_data)
|
|
# print("this is the html for ",file,": ", html_data)
|
|
output = open(file[:-3] + ".html", "w", encoding="utf-8")
|
|
output.write(html_data)
|
|
output.close()
|
|
print("standalone index.html file saved!")
|
|
|
|
#take all the css files and write to main css
|
|
|
|
|
|
# Now open this page in the browser, remember: paged.js needs to be accessed through a webserver.
|
|
|
|
# To run a webserver locally, you can use:
|
|
# cd SI20/booklet/
|
|
# python3 -m http.server
|
|
# localhost:8000/index.html
|