fix: Convert inline align environments to display math
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -149,8 +149,25 @@ function Article({ cache }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isMath) {
|
if (isMath) {
|
||||||
console.log(v, isMath);
|
let mathContent = v.textContent;
|
||||||
return <Tag {...props}><Latex delimiters={latexDelimiters}>{v.textContent}</Latex></Tag>;
|
// align environment requires display math mode
|
||||||
|
if (mathContent.includes('\\begin{align')) {
|
||||||
|
const trimmed = mathContent.trim();
|
||||||
|
if (trimmed.startsWith('\\(')) {
|
||||||
|
// Replace \( and \) with \[ and \] to switch to display mode
|
||||||
|
const firstParen = mathContent.indexOf('\\(');
|
||||||
|
const lastParen = mathContent.lastIndexOf('\\)');
|
||||||
|
mathContent = mathContent.substring(0, firstParen) + '\\[' + mathContent.substring(firstParen + 2, lastParen) + '\\]' + mathContent.substring(lastParen + 2);
|
||||||
|
} else if (trimmed.startsWith('$') && !trimmed.startsWith('$$')) {
|
||||||
|
// Replace $ with $$
|
||||||
|
const firstDollar = mathContent.indexOf('$');
|
||||||
|
const lastDollar = mathContent.lastIndexOf('$');
|
||||||
|
if (firstDollar !== lastDollar) {
|
||||||
|
mathContent = mathContent.substring(0, firstDollar) + '$$' + mathContent.substring(firstDollar + 1, lastDollar) + '$$' + mathContent.substring(lastDollar + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <Tag {...props}><Latex delimiters={latexDelimiters}>{mathContent}</Latex></Tag>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VOID_ELEMENTS.includes(Tag)) {
|
if (VOID_ELEMENTS.includes(Tag)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user