Manual patch CodeMirror for some minor issues

This commit is contained in:
Cheng-Han, Wu 2016-02-02 13:56:30 -06:00
parent 44ac1b295c
commit 740fde75d3
2 changed files with 28 additions and 32 deletions

File diff suppressed because one or more lines are too long

View file

@ -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,