wip: toc clause numbers

This commit is contained in:
2026-01-11 01:46:22 +00:00
parent e86b0de9fa
commit 88a8ba2f28
11 changed files with 45 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ export interface TocItem {
id: string;
title: string;
level: number;
clause?: string;
}
export interface FAQItem {
@@ -25,6 +26,7 @@ export interface SpecSection {
id: string;
title: string;
content: string;
clause: string;
}
export interface ParsedSpec {
@@ -182,11 +184,13 @@ function findSpecSections(nodes: RootContent[]): SpecSection[] {
for (const node of nodes) {
if (node.type === "list" && (node as List).ordered) {
const titles = extractListItemTitles(node as List);
for (const title of titles) {
for (let i = 0; i < titles.length; i++) {
const title = titles[i];
sections.push({
id: `spec-${slugify(title)}`,
title,
content: "",
clause: `${i + 1}.`,
});
}
break; // Only process first ordered list
@@ -286,7 +290,12 @@ function buildTocItems(parsed: Partial<ParsedSpec>): TocItem[] {
if (parsed.specSections) {
for (const section of parsed.specSections) {
items.push({ id: section.id, title: section.title, level: 3 });
items.push({
id: section.id,
title: section.title,
level: 3,
clause: section.clause,
});
}
}
}