askiiart-net/md2html.py
2023-05-09 12:33:37 -05:00

10 lines
363 B
Python
Executable file

import os
from pathlib import Path
dir = os.path.dirname(__file__)
print(dir)
os.chdir(dir)
files = [str(item)[:-3] for item in Path(dir).rglob('*.md')]
for item in files:
os.system(f'pandoc -f markdown-smart --data-dir . --template {dir}/template.html -t html -o {item}.html {item}.md --metadata title=\"$(grep -m 1 -oP \'(?<=^# ).*\' {item}.md | cat)\"')