Last active
August 29, 2015 14:05
Revisions
-
dwcramer renamed this gist
Aug 23, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,10 @@ # h1 below an h2, this happily sticks it in the file # for it's parent h2. # Name output files based on heading names, replacing # spaces with - and adding ".html.md". No other bad characters # are stripped from the heading. import re with open('concepts.html.markdown') as file: -
dwcramer revised this gist
Aug 23, 2014 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,11 @@ #!/usr/bin/python # Chunk a big markdown file into smaller files # at the h2 level. Throw away anything above that. # This assumes a 'well-formed' file. I.e. if you put an # h1 below an h2, this happily sticks it in the file # for it's parent h2. import re with open('concepts.html.markdown') as file: -
dwcramer created this gist
Aug 23, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/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]