From fd0a6e7d6d1d6754475aa06bc1e55ff0079e8381 Mon Sep 17 00:00:00 2001 From: stanley2058 Date: Tue, 18 Nov 2025 14:35:12 +0800 Subject: [PATCH 1/2] fix: allow inline block mathjax syntax --- mode/markdown/markdown_math.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/mode/markdown/markdown_math.js b/mode/markdown/markdown_math.js index f24d832892..7c7741112e 100644 --- a/mode/markdown/markdown_math.js +++ b/mode/markdown/markdown_math.js @@ -248,7 +248,32 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { state.code = -1 return getType(state); } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedMathRE, true))) { - state.fencedEndRE = new RegExp(match[1].replace(/\$/g, '\\$') + "+ *$"); + // match[0] is the whole line + // match[1] is the opening fence "$$" + // match[2] is the optional language / mode name + var wholeLine = match[0]; + var openingFence = match[1]; + + // Everything after the opening "$$" + var rest = wholeLine.slice(openingFence.length); + + // If there's another "$$" in the rest of the line, treat this as + // a single-line math block: $$ ... $$. + var closingIndex = rest.indexOf("$$"); + + if (closingIndex !== -1) { + // Single-line $$ ... $$: highlight as math, but do NOT enter + // multi-line fenced math mode. + + state.formatting = "math"; + state.math = 0; // not in a multi-line math block + // We've already consumed the whole line via stream.match(..., true) + // so just return the math token type for this line. + return tokenTypes.math; + } + + // Otherwise fall back to the original behavior: multi-line fenced math + state.fencedEndRE = new RegExp(openingFence.replace(/\$/g, '\\$') + "+ *$"); // try switching mode state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode ); if (state.localMode) state.localState = CodeMirror.startState(state.localMode); From 036375e406f12880325b8a5061ec332c979cc7e0 Mon Sep 17 00:00:00 2001 From: stanley2058 Date: Tue, 18 Nov 2025 14:44:49 +0800 Subject: [PATCH 2/2] fix: incorrect delimiter capture in shell mode --- mode/shell/shell.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mode/shell/shell.js b/mode/shell/shell.js index 8271485f5f..2b59d1b9b9 100644 --- a/mode/shell/shell.js +++ b/mode/shell/shell.js @@ -72,7 +72,7 @@ CodeMirror.defineMode('shell', function() { } if (ch == "<") { if (stream.match("<<")) return "operator" - var heredoc = stream.match(/^<-?\s*['"]?([^'"]*)['"]?/) + var heredoc = stream.match(/^<-?\s*['"]?([^\s'"]*)['"]?/) if (heredoc) { state.tokens.unshift(tokenHeredoc(heredoc[1])) return 'string-2'