From 2ee7b67ab5e475e6ca2e526334cea984818d33d1 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 11 Sep 2023 16:17:14 -0700 Subject: [PATCH] Add footnote extension support --- Makefile | 2 +- build.py | 7 ++++++- src/.template.html | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dac7adb..a02ee46 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ build: ./build.py watch: - while sleep 1 0; do find src/ build Makefile | entr -d make build; done + while sleep 1; do find src/ build.py Makefile | entr -d make build; done serve: python -m http.server --directory out/ diff --git a/build.py b/build.py index 227ad65..c160a5c 100755 --- a/build.py +++ b/build.py @@ -19,7 +19,7 @@ def main(): src = pathlib.Path(args.src).absolute() out = pathlib.Path(args.out).absolute() - md = markdown.Markdown(extensions=["attr_list", "meta"]) + md = markdown.Markdown(extensions=["attr_list", "footnotes", "meta"]) # Clean the output directory if out.exists(): @@ -33,10 +33,12 @@ def main(): # cd to src so os.walk(.) returns paths relative to src os.chdir(src) + count = 0 for dirpath, dirnames, filenames in os.walk("."): for filename in filenames: if filename[0] == ".": continue # Skip dotfiles + count += 1 # Future-proofing if not filename.endswith(".html") and not filename.endswith(".md"): @@ -52,6 +54,7 @@ def main(): # Preprocess markdown into html if dest.name.endswith(".md"): print("Converting", path) + md.reset() dest = dest.with_suffix(".html") content = md.convert(content) meta = md.Meta @@ -73,6 +76,8 @@ def main(): print("Writing ", dest) dest.write_text(str(page)) + print("Processed", count, "files") + if __name__ == "__main__": main() diff --git a/src/.template.html b/src/.template.html index 5395da0..4a0922c 100644 --- a/src/.template.html +++ b/src/.template.html @@ -1,6 +1,8 @@ + Untitled Page +