Created
August 26, 2016 12:15
-
-
Save pingiun/b616fa816e3a94aa4078df5604c99d7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import markdown2 | |
with open('head.html') as f: | |
head = f.read() | |
with open('foot.html') as f: | |
foot = f.read() | |
for root, __, files in os.walk('.'): | |
for name in files: | |
filename = os.path.splitext(name) | |
if not len(filename) == 2: | |
continue | |
if not filename[1] == '.md': | |
continue | |
html = markdown2.markdown_path(os.path.join(root, name)) | |
with open(os.path.join(root, os.path.splitext(name)[0] + '.html'), 'w') as f: | |
f.write(head) | |
f.write(html) | |
f.write(foot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This needs the python module markdown2 (
pip install markdown2
)