From a712ca12da4cc9ddbf02a8eb6ceed145ed505fa8 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 7 Dec 2025 22:59:09 +0000 Subject: [PATCH] Bring single dollar sign math back, check for whitespace --- webclient/src/Article.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webclient/src/Article.js b/webclient/src/Article.js index 88a79f9..629e7d6 100644 --- a/webclient/src/Article.js +++ b/webclient/src/Article.js @@ -12,6 +12,7 @@ const DANGEROUS_TAGS = ['svg', 'math']; const latexDelimiters = [ { left: '$$', right: '$$', display: true }, { left: '\\[', right: '\\]', display: true }, + { left: '$', right: '$', display: false }, { left: '\\(', right: '\\)', display: false } ]; @@ -105,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 {text}; } @@ -158,6 +159,13 @@ function Article({ cache }) { 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};