Add footnote extension support
This commit is contained in:
parent
6dff989116
commit
2ee7b67ab5
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ build:
|
||||||
./build.py
|
./build.py
|
||||||
|
|
||||||
watch:
|
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:
|
serve:
|
||||||
python -m http.server --directory out/
|
python -m http.server --directory out/
|
||||||
|
|
7
build.py
7
build.py
|
@ -19,7 +19,7 @@ def main():
|
||||||
src = pathlib.Path(args.src).absolute()
|
src = pathlib.Path(args.src).absolute()
|
||||||
out = pathlib.Path(args.out).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
|
# Clean the output directory
|
||||||
if out.exists():
|
if out.exists():
|
||||||
|
@ -33,10 +33,12 @@ def main():
|
||||||
|
|
||||||
# cd to src so os.walk(.) returns paths relative to src
|
# cd to src so os.walk(.) returns paths relative to src
|
||||||
os.chdir(src)
|
os.chdir(src)
|
||||||
|
count = 0
|
||||||
for dirpath, dirnames, filenames in os.walk("."):
|
for dirpath, dirnames, filenames in os.walk("."):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if filename[0] == ".":
|
if filename[0] == ".":
|
||||||
continue # Skip dotfiles
|
continue # Skip dotfiles
|
||||||
|
count += 1
|
||||||
|
|
||||||
# Future-proofing
|
# Future-proofing
|
||||||
if not filename.endswith(".html") and not filename.endswith(".md"):
|
if not filename.endswith(".html") and not filename.endswith(".md"):
|
||||||
|
@ -52,6 +54,7 @@ def main():
|
||||||
# Preprocess markdown into html
|
# Preprocess markdown into html
|
||||||
if dest.name.endswith(".md"):
|
if dest.name.endswith(".md"):
|
||||||
print("Converting", path)
|
print("Converting", path)
|
||||||
|
md.reset()
|
||||||
dest = dest.with_suffix(".html")
|
dest = dest.with_suffix(".html")
|
||||||
content = md.convert(content)
|
content = md.convert(content)
|
||||||
meta = md.Meta
|
meta = md.Meta
|
||||||
|
@ -73,6 +76,8 @@ def main():
|
||||||
print("Writing ", dest)
|
print("Writing ", dest)
|
||||||
dest.write_text(str(page))
|
dest.write_text(str(page))
|
||||||
|
|
||||||
|
print("Processed", count, "files")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
<title>Untitled Page</title>
|
<title>Untitled Page</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
max-width: 100ch;
|
max-width: 100ch;
|
||||||
|
|
Loading…
Reference in New Issue