Skip to content

Commit c36800b

Browse files
committed
Fix LaTeX math output to avoid nested equation environments
1 parent a3f3db8 commit c36800b

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

scripts/lib/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def _rst_to_html(rst_text: str) -> str:
413413
"report_level": 5,
414414
"halt_level": 5,
415415
"initial_header_level": 4,
416-
"math_output": "MathJax",
416+
"math_output": "LaTeX",
417417
"syntax_highlight": "short",
418418
}
419419
)

src/lib/components/api/DocstringRenderer.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
cleaned = `\\begin{aligned}${cleaned}\\end{aligned}`;
6565
}
6666
67-
const isDisplay = el.tagName === 'DIV' || latex.includes('\\[');
67+
const isDisplay = el.tagName === 'DIV' || el.tagName === 'PRE' || latex.includes('\\[');
6868
6969
const rendered = k.default.renderToString(cleaned, {
7070
displayMode: isDisplay,
@@ -238,8 +238,9 @@
238238
const preElements = container.querySelectorAll('pre');
239239
240240
for (const preEl of preElements) {
241-
// Skip if already processed
241+
// Skip if already processed or is math content
242242
if (preEl.classList.contains('cm-processed')) continue;
243+
if (preEl.classList.contains('math')) continue;
243244
244245
// Get code content - either from nested code element or directly from pre
245246
const codeEl = preEl.querySelector('code');

0 commit comments

Comments
 (0)