Last active
August 29, 2015 14:05
-
-
Save dwcramer/3c997a6a6360a6369bf2 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/python | |
import re | |
with open('concepts.html.markdown') as file: | |
data = file.readlines() | |
data.reverse() | |
headings = [] | |
for line in data: | |
m = re.match("^## ", line) | |
if m: | |
headings.append(line) | |
section = [] | |
for line in data: | |
section.append(line) | |
if len(headings) > 0 and line == headings[0]: | |
section.reverse() | |
filename = line.split("## ",1)[1].replace(" ","-").rstrip().lower() + ".html.md" | |
sectionFile = open(filename,'w') | |
for lline in section: | |
sectionFile.write('%s'% lline) | |
sectionFile.close() | |
section = [] | |
del headings[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment