|
|
@@ -5,6 +5,7 @@ import subprocess |
|
|
|
import sys |
|
|
|
import shutil |
|
|
|
import pathlib |
|
|
|
import json |
|
|
|
|
|
|
|
output = sys.argv[1] |
|
|
|
|
|
|
@@ -24,19 +25,44 @@ for dp, dns, fns in os.walk('static'): |
|
|
|
continue |
|
|
|
shutil.copy2(os.path.join(dp, fn), os.path.join(output, fn)) |
|
|
|
|
|
|
|
TITLE_PREFIX = 'title: ' |
|
|
|
|
|
|
|
# Convert and export the markdown files. |
|
|
|
def export_markdown(f): |
|
|
|
outfile = os.path.splitext(os.path.join(output, f))[0] + '.html' |
|
|
|
def export_markdown(path): |
|
|
|
title = None |
|
|
|
|
|
|
|
with open('markdown/' + path, 'r') as f: |
|
|
|
for l in f.readlines(): |
|
|
|
# Shittily parse out the thing. |
|
|
|
if l.startswith(TITLE_PREFIX): |
|
|
|
tstr = l[len(TITLE_PREFIX):] |
|
|
|
if tstr.startswith('\''): |
|
|
|
tstr = tstr[1:] |
|
|
|
if tstr.endswith('\''): |
|
|
|
tstr = tstr[:-1] |
|
|
|
title = tstr.strip() |
|
|
|
|
|
|
|
title = str(title) |
|
|
|
|
|
|
|
outfile = os.path.splitext(os.path.join(output, path))[0] + '.page' |
|
|
|
try: |
|
|
|
os.makedirs(os.path.dirname(outfile)) |
|
|
|
except: |
|
|
|
pass |
|
|
|
cmd = 'pandoc --from markdown+yaml_metadata_block --to html --standalone --template=pandoc.template --include-in-header=mdheader.htm -o ' + outfile + ' markdown/' + f |
|
|
|
cmd = 'pandoc --from markdown+yaml_metadata_block --to html --standalone --template=squarespace.template --include-in-header=mdheader.htm -o ' + outfile + ' markdown/' + path |
|
|
|
subprocess.run(cmd.split(), shell=False) |
|
|
|
|
|
|
|
# Generate info file |
|
|
|
with open(outfile + '.conf', 'w') as f: |
|
|
|
conf = { |
|
|
|
'title': '%s :: ProvDSA PoliEd' % title, |
|
|
|
'description': '%s - ProvDSA PoliEd Foundational Series' % title |
|
|
|
} |
|
|
|
|
|
|
|
json.dump(conf, f, indent=' ') |
|
|
|
|
|
|
|
for dp, dns, fns in os.walk('markdown'): |
|
|
|
for fn in fns: |
|
|
|
if fn.endswith('~'): |
|
|
|
continue |
|
|
|
export_markdown(os.path.relpath(os.path.join(dp, fn), 'markdown')) |
|
|
|
|