from glob import glob import os # https://devdocs.io/python~3.9/library/glob#glob.glob files = glob("content/**", recursive=True) print(files) print("---------") for file in files: #print(file) if file.endswith(".md"): print("===========") print(file) html_file = file.replace(".md", ".html") pandoc_cmd = "pandoc -f markdown -t html " + file + " -o " + html_file print(pandoc_cmd) # pandoc_cmd = f"pandoc -f markdown -t html { file } -o { html_file }" #os.system(pandoc_cmd) print("html file saved!") # --------------- # We find all the HTML files, # read the content, # and then collect all that content into a variable called "all_html" html_files = glob("content/**", recursive=True) print("---------") all_html = "" for html_file in html_files: if html_file.endswith(".html"): print(html_file) # open the html file and read the content html = open(html_file).read() # add this content to all_html all_html = all_html + html print("----------") print(all_html) template = f""" { all_html } """ output = open("booklet.html", "w") output.write(template) # Now open this page in the browser, remember: paged.js needs to be accessed through a webserver. # To run a webserver locally, you can use: # cd SI20/booklet/ # python3 -m http.server # localhost:8000/booklet.html