".format(index['title'], index['description'])
gmihome = "# {}\n{}".format(index['title'], index['description'])
os.makedirs("out/html", exist_ok=True)
os.makedirs("out/gmi", exist_ok=True)
for folderinfo in index['folders']:
htmlhome += "\n
{}
\n
".format(folderinfo['title'])
gmihome += "\n\n## {}".format(folderinfo['title'])
if 'texts' in folderinfo:
for textinfo in folderinfo['texts']:
with open(os.path.join(folderinfo['folder'], textinfo['file']), "r", encoding="utf-8") as mdfile:
mdcontent = mdfile.read()
# clean header
mdcontent = re.sub(r'---\n[\s\S]*?\n---\n*', '', mdcontent)
htmlcontent = md2html(mdcontent)
gmicontent = md2gmi(mdcontent)
with open("out/html/{}".format(textinfo['file']).replace('.md', '.html'), "w", encoding="utf-8") as htmlfile:
htmlfile.write(apply_html_template(htmlcontent, "{} | {}".format(textinfo['title'], index['title'])))
with open("out/gmi/{}".format(textinfo['file']).replace('.md', '.gmi'), "w", encoding="utf-8") as gmifile:
gmifile.write(gmicontent)
if 'restricted' not in textinfo:
htmlhome += "
"
with open("out/html/index.html", "w", encoding="utf-8") as htmlindex:
htmlindex.write(apply_html_template(htmlhome, index['title']))
with open("out/gmi/index.gmi", "w", encoding="utf-8") as gmiindex:
gmiindex.write(gmihome)