blog

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit cabea9bbc6752932ded6e0eda1f4542ace0d7c2a
parent acb364df89862758d592ab23a20d018795fff5e9
Author: Andrew Laack <andrew@laack.co>
Date:   Sat, 27 Sep 2025 22:36:06 -0500

Progress on setting up converion

Diffstat:
Aposts/entries/link_citation.py | 29+++++++++++++++++++++++++++++
Rposts/site/sustainability-of-youtube.md.html -> posts/site/sustainability-of-youtube.html | 0
Rposts/site/wikipedia-and-truth-on-the-internet.md.html -> posts/site/wikipedia-and-truth-on-the-internet.html | 0
Mscripts/convert.sh | 4+++-
4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/posts/entries/link_citation.py b/posts/entries/link_citation.py @@ -0,0 +1,29 @@ +import re +import sys +from pathlib import Path + +def fix_citations(md_text: str) -> str: + """ + Rewrites citations so they look like: + [[1] https://example.com](https://example.com) + """ + # Match lines like: [1] https://example.com OR [1] - https://example.com + pattern = re.compile(r'^\[+(\d+)\]+[ \-]*\[*([^\]\s]+)\]*', re.MULTILINE) + + def repl(match): + num = match.group(1) + url = match.group(2) + return f'[[{num}] {url}]({url})' + + return pattern.sub(repl, md_text) + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python fix_citations.py input.md output.md") + sys.exit(1) + + infile, outfile = Path(sys.argv[1]), Path(sys.argv[2]) + text = infile.read_text(encoding="utf-8") + fixed_text = fix_citations(text) + outfile.write_text(fixed_text, encoding="utf-8") + print(f"Citations rewritten in {outfile}") diff --git a/posts/site/sustainability-of-youtube.md.html b/posts/site/sustainability-of-youtube.html diff --git a/posts/site/wikipedia-and-truth-on-the-internet.md.html b/posts/site/wikipedia-and-truth-on-the-internet.html diff --git a/scripts/convert.sh b/scripts/convert.sh @@ -7,6 +7,8 @@ for FILE in $FILES do if [[ $FILE =~ \.md ]] ; then echo $FILE - pandoc posts/entries/$FILE -o posts/site/$FILE.html -s --css=style.css + BASENAME="${FILE%.md}" + echo $BASENAME + pandoc posts/entries/$FILE -o posts/site/$BASENAME.html -s --css=style.css fi done