hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 1 | #!/usr/bin/python2.7 |
| 2 | |
onqtam | b6c6967 | 2016-09-21 15:41:52 +0300 | [diff] [blame] | 3 | # STUFF THAT DOESN'T WORK: |
| 4 | # - before doing a list with '-' make sure to put an empty line before it |
| 5 | # - external links with '.md' in them get broken - gets replaced with '.html' |
| 6 | # - anchors that work in github don't work in the generated html so all interlinking with anchors doesn't work |
| 7 | |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 8 | import os |
| 9 | |
| 10 | html_dir = "../doc/html_generated/" |
| 11 | md_dir = "../doc/markdown/" |
| 12 | |
| 13 | filelist = [f for f in os.listdir(html_dir) if f.endswith(".html")] |
| 14 | for f in filelist: |
| 15 | os.remove(html_dir + f) |
| 16 | |
| 17 | for filename in os.listdir(md_dir): |
| 18 | if filename[-2:] == "md": |
| 19 | md = open(md_dir + filename, "r") |
| 20 | md_contents = md.read() |
| 21 | md.close() |
| 22 | html = open(html_dir + filename[:-3] + ".html", "w") |
| 23 | html.write('<!DOCTYPE html>\n') |
| 24 | html.write('<html>\n') |
| 25 | html.write('<title>' + filename[:-3] + '</title>\n') |
| 26 | html.write('<xmp theme="united" style="display:none;">\n\n') |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 27 | md_contents = md_contents.replace(".md", ".html") |
| 28 | md_contents = md_contents.replace("```c++", "```") |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 29 | html.write(md_contents) |
| 30 | html.write('\n\n</xmp>\n') |
| 31 | html.write('<script src="strapdown.js/strapdown.js"></script>\n') |
| 32 | html.write('</html>\n') |
| 33 | html.close() |