refactoring

This commit is contained in:
2026-09-02 08:38:03 +02:00
parent 649ff0d7c5
commit 38f255c1a4
48 changed files with 6998 additions and 5577 deletions
+30
View File
@@ -0,0 +1,30 @@
import test from "node:test";
import assert from "node:assert/strict";
import { headingId, markdownHeadings } from "../static/js/wiki/page-outline.js";
test("heading identifiers are readable and unique", () => {
const usedIds = new Set();
assert.equal(headingId("Résumé & planning", usedIds), "resume-planning");
assert.equal(headingId("Résumé & planning", usedIds), "resume-planning-2");
assert.equal(headingId("***", usedIds), "section");
});
test("Markdown headings retain their source line and level", () => {
const markdown = "intro\n# First\ntext\n ### Third ###\n";
assert.deepEqual(markdownHeadings(markdown), [
{ level: 1, text: "First", line: 1 },
{ level: 3, text: "Third", line: 3 }
]);
});
test("headings inside fenced code are ignored", () => {
const markdown = "# Visible\n```racket\n## Code\n```\n## Also visible";
assert.deepEqual(markdownHeadings(markdown), [
{ level: 1, text: "Visible", line: 0 },
{ level: 2, text: "Also visible", line: 4 }
]);
});