Skip to content

Commit a86ebe6

Browse files
andrewboldiclaude
andcommitted
fix: strip Table of Contents blocks from problem/solution HTML
Remove .toc, #toc elements and "Contents" headings injected by AoPS wiki on problems with multiple solution sections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d8d96df commit a86ebe6

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/lib/utils/katex.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ export function renderLatexInContainer(container: HTMLElement): void {
6666
}
6767
}
6868

69+
// Remove Table of Contents blocks injected by the AoPS wiki
70+
const tocElements = container.querySelectorAll('.toc, #toc, [id*="toctitle"]');
71+
for (const toc of tocElements) {
72+
toc.remove();
73+
}
74+
// Also remove any "Contents" text/heading that precedes a TOC list
75+
const allElements = container.querySelectorAll('*');
76+
for (const el of allElements) {
77+
if (el.textContent?.trim() === 'Contents' && el.tagName.match(/^H[1-6]$/)) {
78+
el.remove();
79+
}
80+
}
81+
6982
// Hide [asy] Asymptote source code blocks (can't render client-side)
7083
// These appear as raw text in <p> elements
7184
const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);

0 commit comments

Comments
 (0)