fix: Render LaTeX expressions that are entire element contents

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-04 20:35:51 +00:00
parent 1729e5b2be
commit 7ce94e80dd

View File

@@ -135,6 +135,11 @@ function Article({ cache }) {
);
}
const textContent = v.textContent.trim();
const isMath = (textContent.startsWith('\\(') && textContent.endsWith('\\)')) ||
(textContent.startsWith('\\[') && textContent.endsWith('\\]')) ||
(textContent.startsWith('$$') && textContent.endsWith('$$'));
const props = { key: key };
if (v.hasAttributes()) {
for (const attr of v.attributes) {
@@ -143,6 +148,10 @@ function Article({ cache }) {
}
}
if (isMath) {
return <Tag {...props}><Latex delimiters={latexDelimiters}>{v.textContent}</Latex></Tag>;
}
if (VOID_ELEMENTS.includes(Tag)) {
return <Tag {...props} />;
}