Skip to content

Commit c422522

Browse files
committed
Fix markdown_math for markdown mode recent updates
1 parent 07d769d commit c422522

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mode/markdown/markdown_math.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
9494
, linkDefRE = /^\s*\[[^\]]+?\]:\s*\S+(\s*\S*\s*)?$/ // naive link-definition
9595
, punctuation = /[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~]/
9696
, expandedTab = " " // CommonMark specifies tab as 4 spaces
97-
, fencedMathRE = new RegExp("^(\$\$)[ \\t]*([\\w+#\-]*)");
97+
, fencedMathRE = /^(\$\$)[ \t]*([\w+#-]*)[^\n`]*$/
9898

9999
function switchInline(stream, state, f) {
100100
state.f = state.inline = f;
@@ -228,10 +228,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
228228
if (modeCfg.highlightFormatting) state.formatting = "code-block";
229229
state.code = -1
230230
return getType(state);
231-
} else if (match = stream.match(fencedMathRE, true)) {
232-
state.fencedChars = match[1]
231+
} else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedMathRE, true))) {
232+
state.fencedEndRE = new RegExp(match[1].replace(/\$/g, '\\$') + "+ *$");
233233
// try switching mode
234-
state.localMode = getMode(match[2]);
234+
state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]);
235235
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
236236
state.f = state.block = local;
237237
state.formatting = "math";

0 commit comments

Comments
 (0)