from html5tagger import Document, E, HTML import shutil import markdown import html from pathlib import Path def parseLink(link, pagetitle, homepage): if link.strip() == pagetitle + ".page": return "#" elif link.strip() == homepage + ".page": return "/" else: destination = link.replace(" ", "-").replace(".page", "").lower() #Start local links with / symbol if link.strip().endswith(".page"): return "/" + destination return destination def generateNavigationBar(lines, pagetitle): global navbar navbar = E rawhtml = False htmlstring = "" dropdown = False for id, line in enumerate(lines): #parse raw HTML rawhtml, navbar, htmlstring = parseRawHTML(navbar, line, htmlstring, rawhtml, id, len(lines)) #parse navigation bar (custom format) if not rawhtml: if "::" in line: title, link = line.split("::", 1) if line.strip().endswith("|"): dropdown = True link = link.strip()[:len(link.strip())-1] dphtml = E #some duplicate logic as normal navbar entries get, to make dropdown button in itself act like a normal clickable navbar entry link = parseLink(link, pagetitle, homepage) if link.strip() == "#": dphtml = dphtml(HTML("