Use main()

This commit is contained in:
Govindas 2022-01-24 18:49:02 +02:00
parent 3f7e90fd46
commit 95afcd1e1b
2 changed files with 34 additions and 26 deletions

View File

@ -6,4 +6,4 @@ Another markdown line
<a href=/test>**Another markdown line 2**</a>
>
<p><i>**HTML Italics test 1**
<p><i>HTML Italics test 2
<p><i>[Test link](/about)

View File

@ -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,6 +71,24 @@ def generatePage(title, doc):
else:
newpage.write(str(doc))
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())
@ -97,3 +102,6 @@ for file in os.listdir("./"):
generateLines(os.path.basename(file), page.readlines())
pagescount += 1
print("Generated " + str(pagescount) + " pages")
if __name__ == "__main__":
main()