Created
April 26, 2019 03:32
-
-
Save GammaGames/201a07cfde833ae2985b2c6bb4e46438 to your computer and use it in GitHub Desktop.
Parse markdown files into html files
This file contains 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
from markdown2 import Markdown | |
import os | |
markdown = Markdown() | |
for root, dirs, files in os.walk("/var/www/html", topdown=False): | |
for name in files: | |
if name.endswith(".md"): | |
filename = os.path.join(root, name) | |
with open(filename, 'r') as md_file: | |
html_filename = os.path.join(root, "{}.html".format(os.path.splitext(filename)[0])) | |
with open(html_filename, 'w') as html_file: | |
html_file.write(markdown.convert(md_file.read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment