Basic markdown and raw HTML support
This commit is contained in:
parent
1e02f03a0f
commit
4fc7dd18c0
@ -1,2 +1,4 @@
|
||||
Welcome!
|
||||
# Welcome!
|
||||
This is the homepage of our website.
|
||||
>
|
||||
<b>Hello</b>
|
||||
|
27
generate.py
27
generate.py
@ -1,6 +1,7 @@
|
||||
import os
|
||||
from html5tagger import Document, E, HTML
|
||||
from shutil import rmtree
|
||||
import markdown
|
||||
|
||||
#if homepage is at Home.page, set homepage to "Home"
|
||||
homepage = "Home"
|
||||
@ -27,9 +28,31 @@ def generateNavigationBar(lines):
|
||||
def generateLines(title, lines):
|
||||
title = title.replace(".page", "")
|
||||
document = Document(title, lang="en")
|
||||
|
||||
rawhtml = False
|
||||
for line in lines:
|
||||
document.p(line.strip())
|
||||
|
||||
#raw html start
|
||||
if line.strip() == ">":
|
||||
rawhtml = True
|
||||
html = ""
|
||||
|
||||
#parse indented raw html
|
||||
elif rawhtml == True:
|
||||
if line.startswith(" "):
|
||||
html = html + line.strip()
|
||||
else:
|
||||
rawhtml = False
|
||||
document.join(HTML(html))
|
||||
|
||||
#parse markdown
|
||||
else:
|
||||
md = markdown.markdown(line.strip())
|
||||
document.join(HTML(md))
|
||||
|
||||
#if indented html was the last line, this is needed for it to not be ignored
|
||||
if rawhtml == True:
|
||||
rawhtml = False
|
||||
document.join(HTML(html))
|
||||
|
||||
generatePage(title, document)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user