Skip to content

Instantly share code, notes, and snippets.

@mikeyakymenko
Created April 7, 2013 19:40
Show Gist options
  • Save mikeyakymenko/5332156 to your computer and use it in GitHub Desktop.
Save mikeyakymenko/5332156 to your computer and use it in GitHub Desktop.
Конвертация markdown файлов в html.
#!/usr/bin/env python
import os
import urllib
import markdown
def rel(*x):
return os.path.join(os.path.abspath(os.path.dirname(__file__)), *x)
directory = rel('md/')
md = filter(lambda x: x.endswith('.md'), os.listdir(directory))
for a in md:
b = directory + a
f = open(b, 'r')
html = markdown.markdown( f.read() )
new_name = directory + a.split('.')[0] + '.html'
new = open(new_name, 'a')
new.write(html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment