diff --git a/Home.page b/Home.page index 294ec26..81fa69c 100644 --- a/Home.page +++ b/Home.page @@ -6,4 +6,4 @@ Another markdown line **Another markdown line 2** >
**HTML Italics test 1** -
HTML Italics test 2 +
[Test link](/about) diff --git a/generate.py b/generate.py index 189d526..82073db 100644 --- a/generate.py +++ b/generate.py @@ -4,20 +4,7 @@ from shutil import rmtree import markdown import html -#if homepage is at Home.page, set homepage to "Home" -homepage = "Home" -try: - os.mkdir("./website-output") -except FileExistsError: - print("Output directory already exists, let's clean it!") - - #deleting contents of folder without deleting the folder, to increase compatibility with various systems - for root, dirs, files in os.walk('./website-output'): - for f in files: - os.unlink(os.path.join(root, f)) - for d in dirs: - rmtree(os.path.join(root, d)) def generateNavigationBar(lines): global navbar @@ -84,16 +71,37 @@ def generatePage(title, doc): else: newpage.write(str(doc)) -if os.path.exists("./navbar"): - with open("./navbar", 'r') as navbarfile: - generateNavigationBar(navbarfile.readlines()) -else: - print("No 'navbar' file found, there will be no navigation bar.") -pagescount = 0 -for file in os.listdir("./"): - if file.endswith(".page"): - with open(file, 'r') as page: - generateLines(os.path.basename(file), page.readlines()) - pagescount += 1 -print("Generated " + str(pagescount) + " pages") +def main(): + #if homepage is at Home.page, set homepage to "Home" + global homepage + homepage = "Home" + + try: + os.mkdir("./website-output") + except FileExistsError: + print("Output directory already exists, let's clean it!") + + #deleting contents of folder without deleting the folder, to increase compatibility with various systems + for root, dirs, files in os.walk('./website-output'): + for f in files: + os.unlink(os.path.join(root, f)) + for d in dirs: + rmtree(os.path.join(root, d)) + + if os.path.exists("./navbar"): + with open("./navbar", 'r') as navbarfile: + generateNavigationBar(navbarfile.readlines()) + else: + print("No 'navbar' file found, there will be no navigation bar.") + + pagescount = 0 + for file in os.listdir("./"): + if file.endswith(".page"): + with open(file, 'r') as page: + generateLines(os.path.basename(file), page.readlines()) + pagescount += 1 + print("Generated " + str(pagescount) + " pages") + +if __name__ == "__main__": + main()