forked from tanner/qotnews
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:
@@ -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} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user