Skip to content

Commit

Permalink
[markdown mode] Fix irresponsible use of global/static variable
Browse files Browse the repository at this point in the history
Closes #3787
  • Loading branch information
marijnh committed Jan 24, 2016
1 parent fbf1486 commit 933aedc
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions mode/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (modeCfg.tokenTypeOverrides === undefined)
modeCfg.tokenTypeOverrides = {};

var codeDepth = 0;

var tokenTypes = {
header: "header",
code: "comment",
Expand Down Expand Up @@ -215,7 +213,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (state.localMode) state.localState = state.localMode.startState();
state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = true;
state.code = -1
return getType(state);
}

Expand Down Expand Up @@ -253,9 +251,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.f = inlineNormal;
state.fencedChars = null;
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = true;
state.code = 1
var returnType = getType(state);
state.code = false;
state.code = 0
return returnType;
}

Expand Down Expand Up @@ -405,21 +403,18 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (ch === '`') {
var previousFormatting = state.formatting;
if (modeCfg.highlightFormatting) state.formatting = "code";
var t = getType(state);
var before = stream.pos;
stream.eatWhile('`');
var difference = 1 + stream.pos - before;
if (!state.code) {
codeDepth = difference;
state.code = true;
return getType(state);
var count = stream.current().length
if (state.code == 0) {
state.code = count
return getType(state)
} else if (count == state.code) { // Must be exact
var t = getType(state)
state.code = 0
return t
} else {
if (difference === codeDepth) { // Must be exact
state.code = false;
return t;
}
state.formatting = previousFormatting;
return getType(state);
state.formatting = previousFormatting
return getType(state)
}
} else if (state.code) {
return getType(state);
Expand Down Expand Up @@ -692,6 +687,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
linkText: false,
linkHref: false,
linkTitle: false,
code: 0,
em: false,
strong: false,
header: 0,
Expand Down

0 comments on commit 933aedc

Please sign in to comment.