From 4fc7dd18c0037b43ab26992b52dd7876dcda56ee Mon Sep 17 00:00:00 2001 From: Govindas Date: Mon, 24 Jan 2022 12:09:04 +0200 Subject: [PATCH] Basic markdown and raw HTML support --- Home.page | 4 +++- generate.py | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Home.page b/Home.page index a38dc49..9d98ab8 100644 --- a/Home.page +++ b/Home.page @@ -1,2 +1,4 @@ -Welcome! +# Welcome! This is the homepage of our website. +> + Hello diff --git a/generate.py b/generate.py index 6b83613..fe62b27 100644 --- a/generate.py +++ b/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)