askiiart-net/md2html.py

14 lines
516 B
Python
Raw Normal View History

2023-03-22 15:37:47 -05:00
import os
from pathlib import Path
2023-03-22 15:37:47 -05:00
dir = os.path.dirname(__file__)
2023-05-09 12:33:37 -05:00
print(dir)
os.chdir(dir)
files = [str(item)[:-3] for item in Path(dir).rglob('*.md')]
2023-03-22 15:37:47 -05:00
for item in files:
2023-05-09 12:33:37 -05:00
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)\"')
2023-08-27 18:05:38 -05:00
# Replace 'language-' with 'language-' recursively
2023-08-27 18:22:56 -05:00
os.system("find . \( ! -regex './md2html.py' \) -type f | xargs sed -i 's/sourceCode /language-/g'")