diff --git a/build_colophon.py b/build_colophon.py index df76e31..f7d474e 100755 --- a/build_colophon.py +++ b/build_colophon.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import json -import re from datetime import datetime import html from pathlib import Path @@ -14,11 +13,22 @@ def format_commit_message(message): - """Format commit message with line breaks and linkified URLs.""" + """Render commit message as HTML with Markdown support.""" + escaped = html.escape(message) - url_pattern = r"(https?://[^\s]+)" - linkified = re.sub(url_pattern, r'\1', escaped) - return linkified.replace("\n", "
") + extensions = ["extra", "sane_lists", "nl2br"] + + try: + md = markdown.Markdown( + extensions=extensions + ["linkify"], + output_format="html5", + ) + except ModuleNotFoundError: + md = markdown.Markdown(extensions=extensions, output_format="html5") + + formatted = md.convert(escaped) + md.reset() + return formatted def build_colophon(): @@ -56,12 +66,12 @@ def get_most_recent_date(page_data): +
+

tools.mathspp.com colophon

+

The tools on tools.mathspp.com were mostly built using AI-assisted programming. This page lists {tool_count} tools and their development history.

+

This page lists the commit messages for each tool.

+
-
-

tools.mathspp.com colophon

-

The tools on tools.mathspp.com were mostly built using AI-assisted programming. This page lists {tool_count} tools and their development history.

-

This page lists the commit messages for each tool.

-
"""