fix: Detect and render inline math using single dollar delimiters

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-04 20:56:14 +00:00
parent 5e7240e2d0
commit d511453418

View File

@@ -106,7 +106,7 @@ function Article({ cache }) {
if (v.nodeName === '#text') {
const text = v.data;
if (text.includes('\\[') || text.includes('\\(') || text.includes('$$')) {
if (text.includes('\\[') || text.includes('\\(') || text.includes('$$') || text.includes('$')) {
return <Latex key={key} delimiters={latexDelimiters}>{text}</Latex>;
}
@@ -138,7 +138,8 @@ function Article({ cache }) {
const textContent = v.textContent.trim();
const isMath = (textContent.startsWith('\\(') && textContent.endsWith('\\)')) ||
(textContent.startsWith('\\[') && textContent.endsWith('\\]')) ||
(textContent.startsWith('$$') && textContent.endsWith('$$'));
(textContent.startsWith('$$') && textContent.endsWith('$$')) ||
(textContent.startsWith('$') && textContent.endsWith('$') && textContent.indexOf('$') !== textContent.lastIndexOf('$'));
const props = { key: key };
if (v.hasAttributes()) {