diff options
author | Cheng-Han, Wu | 2016-02-02 13:56:30 -0600 |
---|---|---|
committer | Cheng-Han, Wu | 2016-02-02 13:56:30 -0600 |
commit | 740fde75d34d5df138cbe80c0c30d6fe867ade08 (patch) | |
tree | 51749dd623a868b886bf4c27bf78ab460b023c66 /public/vendor/codemirror/mode/markdown | |
parent | 44ac1b295cfbe9e844d0739f7af7a7eee3c70ebf (diff) |
Manual patch CodeMirror for some minor issues
Diffstat (limited to 'public/vendor/codemirror/mode/markdown')
-rw-r--r-- | public/vendor/codemirror/mode/markdown/markdown.js | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/public/vendor/codemirror/mode/markdown/markdown.js b/public/vendor/codemirror/mode/markdown/markdown.js index 64fb4d60..be855453 100644 --- a/public/vendor/codemirror/mode/markdown/markdown.js +++ b/public/vendor/codemirror/mode/markdown/markdown.js @@ -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", @@ -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); } @@ -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; } @@ -378,15 +376,6 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { var ch = stream.next(); - if (ch === '\\') { - stream.next(); - if (modeCfg.highlightFormatting) { - var type = getType(state); - var formattingEscape = tokenTypes.formatting + "-escape"; - return type ? type + " " + formattingEscape : formattingEscape; - } - } - // Matches link titles present on next line if (state.linkTitle) { state.linkTitle = false; @@ -405,26 +394,32 @@ 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); } + if (ch === '\\') { + stream.next(); + if (modeCfg.highlightFormatting) { + var type = getType(state); + var formattingEscape = tokenTypes.formatting + "-escape"; + return type ? type + " " + formattingEscape : formattingEscape; + } + } + if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { stream.match(/\[[^\]]*\]/); state.inline = state.f = linkHref; @@ -692,6 +687,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { linkText: false, linkHref: false, linkTitle: false, + code: 0, em: false, strong: false, header: 0, @@ -800,4 +796,4 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { CodeMirror.defineMIME("text/x-markdown", "markdown"); -}); +});
\ No newline at end of file |