Skip to content

Commit 2f87090

Browse files
andrewboldiclaude
andcommitted
fix: broaden TOC removal to catch plain "Contents" text in any element
61 problems have TOC blocks. Now removes any leaf element whose only text is "Contents" regardless of tag type, not just headings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a86ebe6 commit 2f87090

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/lib/utils/katex.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ export function renderLatexInContainer(container: HTMLElement): void {
7171
for (const toc of tocElements) {
7272
toc.remove();
7373
}
74-
// Also remove any "Contents" text/heading that precedes a TOC list
74+
// Remove any element whose only text content is "Contents"
75+
// (may be a heading, div, span, or other wrapper)
7576
const allElements = container.querySelectorAll('*');
7677
for (const el of allElements) {
77-
if (el.textContent?.trim() === 'Contents' && el.tagName.match(/^H[1-6]$/)) {
78+
const text = el.textContent?.trim();
79+
if (text === 'Contents' && el.children.length === 0) {
7880
el.remove();
7981
}
8082
}

0 commit comments

Comments
 (0)