blob: a5f5acd88d938f590eebe1c138f92f0670a00dab [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
onqtamb6c69672016-09-21 15:41:52 +03003# 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
hardlyb1e7e142014-08-06 00:43:51 +03008import os
9
10html_dir = "../doc/html_generated/"
11md_dir = "../doc/markdown/"
12
13filelist = [f for f in os.listdir(html_dir) if f.endswith(".html")]
14for f in filelist:
15 os.remove(html_dir + f)
16
17for 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')
onqtam8126b562016-05-27 17:01:15 +030027 md_contents = md_contents.replace(".md", ".html")
28 md_contents = md_contents.replace("```c++", "```")
hardlyb1e7e142014-08-06 00:43:51 +030029 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()