kgames

KGames — free keyboard games for kids
git clone https://www.keyboard.games/code/kgames.git
Log | Files | Refs | README | LICENSE

commit 3d4e4857e933b510a936057cbd4b5ce75a2eca14
parent 59e2f40d4ac6b2aa81ebb64d4bee442aae20fd37
Author: Kyle Barlow <kb@kylebarlow.com>
Date:   Mon, 17 Aug 2026 20:57:37 -0700

Render README as the code browser landing page

/code/ opened on the raw commit log, and stagit's README nav link went to
the syntax-less blob page. Generate index.html from README.md with
cmark-gfm instead, reusing stagit's own header markup so the nav and clone
URL stay identical, and repoint every README link at it. The log moves one
click away behind "Browse the commit log".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C3gaidQGTXzcyXKfEaw45a

Diffstat:
Atools/make-code-index.sh | 36++++++++++++++++++++++++++++++++++++
Mtools/stagit-style.css | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/tools/make-code-index.sh b/tools/make-code-index.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Build /code/index.html: the rendered README as the landing page for the code +# browser, wearing stagit's own header so the nav is identical. +# +# usage: tools/make-code-index.sh <stagit-output-dir> <path/to/README.md> +# +# Reuses the header stagit already emitted into log.html (title, clone URL, nav) +# rather than hand-rolling a second copy that would drift. +set -eu + +OUT=$1 +README=$2 +IDX="$OUT/index.html" + +command -v cmark-gfm >/dev/null 2>&1 || { + echo "make-code-index.sh: cmark-gfm not found" >&2 + exit 1 +} + +# Everything up to and including <div id="content">, retitled. +sed -n '1,/<div id="content">/p' "$OUT/log.html" \ + | sed 's|<title>Log - |<title>|' > "$IDX" + +printf '<div id="readme">\n' >> "$IDX" +cmark-gfm --extension table \ + --extension strikethrough \ + --extension autolink \ + --extension tagfilter \ + "$README" >> "$IDX" +printf '</div>\n<hr/>\n<p id="browse"><a href="log.html">Browse the commit log &rarr;</a></p>\n' >> "$IDX" +printf '</div>\n</body>\n</html>\n' >> "$IDX" + +# Point every README nav link at the rendered page instead of the raw blob. +# stagit uses a consistent relative prefix per page depth, so keep group 1. +find "$OUT" -name '*.html' -type f -exec sed -i -E \ + 's|href="((\.\./)*)file/README\.md\.html"|href="\1index.html"|g' {} + diff --git a/tools/stagit-style.css b/tools/stagit-style.css @@ -173,3 +173,65 @@ pre a.d:hover { background-color: #22222a; } } + +/* --- rendered README landing page (index.html) ------------------------- */ + +#readme { + max-width: 44em; + line-height: 1.6; +} + +/* stagit's #content rules assume monospace tables; undo them for prose. */ +#readme table td, +#readme table th { + white-space: normal; + vertical-align: top; + border-bottom: 1px solid rgba(46, 196, 182, 0.35); +} + +#readme h1 { font-size: 1.8em; font-weight: 600; margin: 0.8em 0 0.3em; } +#readme h2 { font-size: 1.3em; font-weight: 600; margin: 1.4em 0 0.3em; color: #1D7CF2; } +#readme h3 { font-size: 1.1em; font-weight: 600; margin: 1.1em 0 0.2em; } + +#readme p, #readme li { margin: 0.4em 0; } +#readme ul, #readme ol { padding-left: 1.4em; } + +#readme code { + background: rgba(46, 196, 182, 0.14); + border-radius: 4px; + padding: 0.1em 0.35em; + font-size: 0.92em; +} + +#readme pre { + background: rgba(46, 196, 182, 0.10); + border-left: 3px solid #2EC4B6; + border-radius: 6px; + padding: 0.7em 0.9em; + overflow-x: auto; +} + +#readme pre code { + background: none; + padding: 0; +} + +#readme blockquote { + margin: 0.6em 0; + padding-left: 0.9em; + border-left: 3px solid #FFD23F; + color: #6b6b6b; +} + +#readme img { max-width: 100%; } + +#browse { + font-weight: 600; + margin: 0.8em 0; +} + +@media (prefers-color-scheme: dark) { + #readme h2 { color: #5FA8FF; } + #readme blockquote { color: #a0a0a0; } + #readme code, #readme pre { background: rgba(46, 196, 182, 0.13); } +}