Skip to content

Instantly share code, notes, and snippets.

@GammaGames
Created April 26, 2019 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GammaGames/201a07cfde833ae2985b2c6bb4e46438 to your computer and use it in GitHub Desktop.
Save GammaGames/201a07cfde833ae2985b2c6bb4e46438 to your computer and use it in GitHub Desktop.
Parse markdown files into html files
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