|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | import json |
3 | | -import re |
4 | 3 | from datetime import datetime |
5 | 4 | import html |
6 | 5 | from pathlib import Path |
|
14 | 13 |
|
15 | 14 |
|
16 | 15 | def format_commit_message(message): |
17 | | - """Format commit message with line breaks and linkified URLs.""" |
| 16 | + """Render commit message as HTML with Markdown support.""" |
| 17 | + |
18 | 18 | escaped = html.escape(message) |
19 | | - url_pattern = r"(https?://[^\s]+)" |
20 | | - linkified = re.sub(url_pattern, r'<a href="\1">\1</a>', escaped) |
21 | | - return linkified.replace("\n", "<br>") |
| 19 | + extensions = ["extra", "sane_lists", "nl2br"] |
| 20 | + |
| 21 | + try: |
| 22 | + md = markdown.Markdown( |
| 23 | + extensions=extensions + ["linkify"], |
| 24 | + output_format="html5", |
| 25 | + ) |
| 26 | + except ModuleNotFoundError: |
| 27 | + md = markdown.Markdown(extensions=extensions, output_format="html5") |
| 28 | + |
| 29 | + formatted = md.convert(escaped) |
| 30 | + md.reset() |
| 31 | + return formatted |
22 | 32 |
|
23 | 33 |
|
24 | 34 | def build_colophon(): |
@@ -56,12 +66,12 @@ def get_most_recent_date(page_data): |
56 | 66 | <link rel=\"stylesheet\" href=\"styles.css\"> |
57 | 67 | </head> |
58 | 68 | <body> |
| 69 | + <header class=\"page-shell content-flow\"> |
| 70 | + <h1>tools.mathspp.com colophon</h1> |
| 71 | + <p>The tools on <a href=\"https://tools.mathspp.com/\">tools.mathspp.com</a> were mostly built using AI-assisted programming. This page lists {tool_count} tools and their development history.</p> |
| 72 | + <p>This page lists the commit messages for each tool.</p> |
| 73 | + </header> |
59 | 74 | <main class=\"page-shell content-flow\"> |
60 | | - <header class=\"content-flow\"> |
61 | | - <h1>tools.mathspp.com colophon</h1> |
62 | | - <p>The tools on <a href=\"https://tools.mathspp.com/\">tools.mathspp.com</a> were mostly built using AI-assisted programming. This page lists {tool_count} tools and their development history.</p> |
63 | | - <p>This page lists the commit messages for each tool.</p> |
64 | | - </header> |
65 | 75 | <section class=\"tool-list\"> |
66 | 76 | """ |
67 | 77 |
|
|
0 commit comments