|
|
@@ -0,0 +1,42 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
import os |
|
|
|
import subprocess |
|
|
|
import sys |
|
|
|
import shutil |
|
|
|
import pathlib |
|
|
|
|
|
|
|
output = sys.argv[1] |
|
|
|
|
|
|
|
print('exporting to \'' + output + '\'') |
|
|
|
|
|
|
|
# Make sure the directory doesn't already exist. |
|
|
|
if not os.path.exists(output): |
|
|
|
os.mkdir(output) |
|
|
|
else: |
|
|
|
print('directory already exists!') |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
# Copy the static files |
|
|
|
for dp, dns, fns in os.walk('static'): |
|
|
|
for fn in fns: |
|
|
|
if fn.endswith('~'): |
|
|
|
continue |
|
|
|
shutil.copy2(os.path.join(dp, fn), os.path.join(output, fn)) |
|
|
|
|
|
|
|
# Convert and export the markdown files. |
|
|
|
def export_markdown(f): |
|
|
|
outfile = os.path.splitext(os.path.join(output, f))[0] + '.html' |
|
|
|
try: |
|
|
|
os.makedirs(os.path.dirname(outfile)) |
|
|
|
except: |
|
|
|
pass |
|
|
|
cmd = 'pandoc --from gfm --to html --standalone --include-in-header=mdheader.htm -o ' + outfile + ' markdown/' + f |
|
|
|
subprocess.run(cmd.split(), shell=False) |
|
|
|
|
|
|
|
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')) |
|
|
|
|