Skip to content

Commit 0d7f2e8

Browse files
committed
toc: <ol> with list-marker numbering, drop "Part N:" prefix from link text
Index TOC previously read: • Part 1: Anatomy of a PURL (41 sections) • Part 2: Building & Stringifying PURLs (46 sections) … Which was redundant — the "Part N:" prefix repeats what a numbered list already conveys via its marker. Swap the <ul> for an <ol> so the browser supplies the "1." "2." numbering, and strip "Part N:" from each link's visible text. Now reads: 1. Anatomy of a PURL (41 sections) 2. Building & Stringifying PURLs (46 sections) … Accessibility preserved — the aria-label and title on each <a> still carry the full "Part N: <title>" so screen readers + tooltips get the part number context unchanged. The rewrite lives in the post-processor on index.html only (gated on the <h3>Parts</h3> + /part/<n> href shape so part pages and any future documents page aren't touched). Bullet/marker color updated to muted-lavender so the numbers recede and the titles carry the visual weight.
1 parent 1031bbf commit 0d7f2e8

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

scripts/walkthrough.mts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,29 @@ async function generate(
637637
})
638638
}
639639

640+
// Index-page TOC cleanup. Meander emits `<ul><li><a>Part N: Title</a>
641+
// <span class="ok">(M sections)</span></li>…`. Two tweaks:
642+
// - Swap <ul> → <ol> so numbers come from the list marker, not
643+
// the link text. Users read "1. Anatomy of a PURL" instead of
644+
// "• Part 1: Anatomy of a PURL".
645+
// - Strip the "Part N: " prefix from each link so the title
646+
// alone carries the line, no duplication with the list marker.
647+
// Only applies to the index page (has <h3>Parts</h3> + ul with
648+
// /part/<n> hrefs) — part pages don't have this shape.
649+
if (entry === 'index.html' && html.includes('<h3>Parts</h3>')) {
650+
html = html.replace(
651+
/(<h3>Parts<\/h3>\s*)<ul>([\s\S]*?)<\/ul>/,
652+
(_m, head, body) => `${head}<ol class="wt-parts-ol">${body}</ol>`,
653+
)
654+
// Strip the "Part N: " prefix from the visible link text — the
655+
// list marker already supplies the number. aria-label + title
656+
// keep the full "Part N: <title>" for screen readers / tooltips.
657+
html = html.replace(
658+
/(<a\s[^>]*\bhref="\/[^"]+\/part\/\d+"[^>]*>)Part \d+:\s*/g,
659+
'$1',
660+
)
661+
}
662+
640663
// Base-path rewrite — last step so every injected tag above gets
641664
// prefixed in one pass. No-op when --base-path is empty (local dev,
642665
// Val Town hosting, etc.).

walkthrough-overrides.css

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,32 +301,34 @@ html[data-theme='dark'] .file-grid > .code-section:hover {
301301
margin: 0 0 16px 0;
302302
}
303303

304-
/* Index-page TOC list. Meander's default was a tight bullet list that
305-
* read as cramped against the generous topbar above it. Bump the item
306-
* font + line-height, space the bullets, and add a hover tint on the
307-
* link. Bullets get the muted-lavender tint so they don't compete
308-
* with the part titles. */
309-
.annotation-card > ul {
304+
/* Index-page TOC list. Meander emits <ul> but our post-processor
305+
* rewrites it to <ol class="wt-parts-ol"> + strips the "Part N: "
306+
* prefix from each link — so the list marker carries the number
307+
* and the title stands alone. Muted-lavender markers + section
308+
* counts keep the meta visually behind the titles. Hover tint on
309+
* each row for affordance. */
310+
.annotation-card .wt-parts-ol {
310311
margin: 0;
311-
padding-left: 1.5em;
312-
list-style: disc;
312+
padding-left: 2em;
313+
list-style: decimal;
313314
}
314-
.annotation-card > ul > li {
315+
.annotation-card .wt-parts-ol > li {
315316
padding: 8px 0;
316317
font-size: 16px;
317318
line-height: 1.5;
318319
color: var(--muted-lavender);
319320
}
320-
.annotation-card > ul > li::marker {
321+
.annotation-card .wt-parts-ol > li::marker {
321322
color: var(--muted-lavender);
323+
font-weight: 600;
322324
}
323-
.annotation-card > ul > li > a {
325+
.annotation-card .wt-parts-ol > li > a {
324326
border-radius: 4px;
325327
padding: 2px 4px;
326328
margin: -2px -4px;
327329
transition: background var(--transition-fast);
328330
}
329-
.annotation-card > ul > li > a:hover {
331+
.annotation-card .wt-parts-ol > li > a:hover {
330332
background: color-mix(in srgb, var(--accent) 10%, transparent);
331333
}
332334

0 commit comments

Comments
 (0)