diff --git a/webclient/src/Article.js b/webclient/src/Article.js
index 08261bb..0761dca 100644
--- a/webclient/src/Article.js
+++ b/webclient/src/Article.js
@@ -149,8 +149,25 @@ function Article({ cache }) {
}
if (isMath) {
- console.log(v, isMath);
- return {v.textContent};
+ let mathContent = v.textContent;
+ // 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 {mathContent};
}
if (VOID_ELEMENTS.includes(Tag)) {