codemirror
Advanced tools
Comparing version 4.8.0 to 4.9.0
@@ -76,3 +76,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
} | ||
if (e.keyCode == 13) callback(inp.value); | ||
if (e.keyCode == 13) callback(inp.value, e); | ||
}); | ||
@@ -79,0 +79,0 @@ |
@@ -14,5 +14,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var listRE = /^(\s*)([> ]+|[*+-]|(\d+)\.)(\s+)/, | ||
emptyListRE = /^(\s*)([> ]+|[*+-]|(\d+)\.)(\s*)$/, | ||
unorderedBullets = "*+-"; | ||
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)\.)(\s*)/, | ||
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)\.)(\s*)$/, | ||
unorderedListRE = /[*+-]\s/; | ||
@@ -42,3 +42,3 @@ CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { | ||
var indent = match[1], after = match[4]; | ||
var bullet = unorderedBullets.indexOf(match[2]) >= 0 || match[2].indexOf(">") >= 0 | ||
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0 | ||
? match[2] | ||
@@ -45,0 +45,0 @@ : (parseInt(match[3], 10) + 1) + "."; |
@@ -20,4 +20,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var cur = editor.getCursor(), curLine = editor.getLine(cur.line); | ||
var start = cur.ch, end = start; | ||
while (end < curLine.length && word.test(curLine.charAt(end))) ++end; | ||
var end = cur.ch, start = end; | ||
while (start && word.test(curLine.charAt(start - 1))) --start; | ||
@@ -24,0 +23,0 @@ var curWord = start != end && curLine.slice(start, end); |
@@ -23,3 +23,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var word = token.string, start = token.start, end = token.end; | ||
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start); | ||
if (/[^\w$_-]/.test(word)) { | ||
@@ -26,0 +26,0 @@ word = ""; start = end = cur.ch; |
@@ -6,3 +6,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (typeof exports == "object" && typeof module == "object") // CommonJS | ||
mod(require("../../lib/codemirror", "./xml-hint")); | ||
mod(require("../../lib/codemirror"), require("./xml-hint")); | ||
else if (typeof define == "function" && define.amd) // AMD | ||
@@ -9,0 +9,0 @@ define(["../../lib/codemirror", "./xml-hint"], mod); |
@@ -33,3 +33,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
// Find the token at the cursor | ||
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token; | ||
var cur = editor.getCursor(), token = getToken(editor, cur); | ||
if (/\b(?:string|comment)\b/.test(token.type)) return; | ||
@@ -40,5 +40,10 @@ token.state = CodeMirror.innerMode(editor.getMode(), token.state).state; | ||
if (!/^[\w$_]*$/.test(token.string)) { | ||
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state, | ||
type: token.string == "." ? "property" : null}; | ||
token = {start: cur.ch, end: cur.ch, string: "", state: token.state, | ||
type: token.string == "." ? "property" : null}; | ||
} else if (token.end > cur.ch) { | ||
token.end = cur.ch; | ||
token.string = token.string.slice(0, cur.ch - token.start); | ||
} | ||
var tprop = token; | ||
// If it is a property, find out what it is a property of. | ||
@@ -45,0 +50,0 @@ while (tprop.type == "property") { |
@@ -246,3 +246,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
} | ||
var overlapX = box.left - winW; | ||
var overlapX = box.right - winW; | ||
if (overlapX > 0) { | ||
@@ -249,0 +249,0 @@ if (box.right - box.left > winW) { |
@@ -47,5 +47,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
function nameCompletion(result, editor) { | ||
var cur = editor.getCursor(); | ||
var token = editor.getTokenAt(cur); | ||
function nameCompletion(cur, token, result, editor) { | ||
var useBacktick = (token.string.charAt(0) == "`"); | ||
@@ -177,2 +175,7 @@ var string = token.string.substr(1); | ||
var token = editor.getTokenAt(cur), start, end, search; | ||
if (token.end > cur.ch) { | ||
token.end = cur.ch; | ||
token.string = token.string.slice(0, cur.ch - token.start); | ||
} | ||
if (token.string.match(/^[.`\w@]\w*$/)) { | ||
@@ -187,3 +190,3 @@ search = token.string; | ||
if (search.charAt(0) == "." || search.charAt(0) == "`") { | ||
nameCompletion(result, editor); | ||
nameCompletion(cur, token, result, editor); | ||
} else { | ||
@@ -190,0 +193,0 @@ addMatches(result, search, tables, function(w) {return w;}); |
@@ -21,6 +21,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var cur = cm.getCursor(), token = cm.getTokenAt(cur); | ||
if (/^<\/?$/.test(token.string) && token.end == cur.ch) { | ||
var nextToken = cm.getTokenAt(Pos(cur.line, cur.ch + 1)); | ||
if (nextToken.start == cur.ch && /\btag\b/.test(nextToken.type)) | ||
token = nextToken; | ||
if (token.end > cur.ch) { | ||
token.end = cur.ch; | ||
token.string = token.string.slice(0, cur.ch - token.start); | ||
} | ||
@@ -27,0 +26,0 @@ var inner = CodeMirror.innerMode(cm.getMode(), token.state); |
@@ -34,2 +34,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
connect: "CodeMirror-merge-r-connect"}; | ||
if (mv.options.connect == "align") | ||
this.aligners = []; | ||
} | ||
@@ -85,3 +87,3 @@ | ||
} | ||
drawConnectors(dv); | ||
makeConnections(dv); | ||
} | ||
@@ -113,6 +115,6 @@ function set(slow) { | ||
dv.edit.on("scroll", function() { | ||
syncScroll(dv, DIFF_INSERT) && drawConnectors(dv); | ||
syncScroll(dv, DIFF_INSERT) && makeConnections(dv); | ||
}); | ||
dv.orig.on("scroll", function() { | ||
syncScroll(dv, DIFF_DELETE) && drawConnectors(dv); | ||
syncScroll(dv, DIFF_DELETE) && makeConnections(dv); | ||
}); | ||
@@ -132,20 +134,25 @@ } | ||
var sInfo = editor.getScrollInfo(), halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen; | ||
var mid = editor.lineAtHeight(midY, "local"); | ||
var around = chunkBoundariesAround(dv.diff, mid, type == DIFF_INSERT); | ||
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig); | ||
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit); | ||
var ratio = (midY - off.top) / (off.bot - off.top); | ||
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top); | ||
var sInfo = editor.getScrollInfo(); | ||
if (dv.mv.options.connect == "align") { | ||
targetPos = sInfo.top; | ||
} else { | ||
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen; | ||
var mid = editor.lineAtHeight(midY, "local"); | ||
var around = chunkBoundariesAround(dv.diff, mid, type == DIFF_INSERT); | ||
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig); | ||
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit); | ||
var ratio = (midY - off.top) / (off.bot - off.top); | ||
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top); | ||
var botDist, mix; | ||
// Some careful tweaking to make sure no space is left out of view | ||
// when scrolling to top or bottom. | ||
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) { | ||
targetPos = targetPos * mix + sInfo.top * (1 - mix); | ||
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) { | ||
var otherInfo = other.getScrollInfo(); | ||
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos; | ||
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1) | ||
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix); | ||
var botDist, mix; | ||
// Some careful tweaking to make sure no space is left out of view | ||
// when scrolling to top or bottom. | ||
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) { | ||
targetPos = targetPos * mix + sInfo.top * (1 - mix); | ||
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) { | ||
var otherInfo = other.getScrollInfo(); | ||
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos; | ||
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1) | ||
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix); | ||
} | ||
} | ||
@@ -168,3 +175,3 @@ | ||
dv.lockScroll = val; | ||
if (val && action != false) syncScroll(dv, DIFF_INSERT) && drawConnectors(dv); | ||
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv); | ||
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db \u21da"; | ||
@@ -257,5 +264,16 @@ } | ||
function drawConnectors(dv) { | ||
function makeConnections(dv) { | ||
if (!dv.showDifferences) return; | ||
var align = dv.mv.options.connect == "align"; | ||
if (align) { | ||
if (!dv.orig.curOp) return dv.orig.operation(function() { | ||
makeConnections(dv); | ||
}); | ||
for (var i = 0; i < dv.aligners.length; i++) | ||
dv.aligners[i].clear(); | ||
dv.aligners.length = 0; | ||
var extraSpaceAbove = {edit: 0, orig: 0}; | ||
} | ||
if (dv.svg) { | ||
@@ -268,43 +286,80 @@ clear(dv.svg); | ||
var flip = dv.type == "left"; | ||
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport(); | ||
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top; | ||
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) { | ||
if (topEdit > vpEdit.to || botEdit < vpEdit.from || | ||
topOrig > vpOrig.to || botOrig < vpOrig.from) | ||
return; | ||
var topLpx = dv.orig.heightAtLine(topOrig, "local") - sTopOrig, top = topLpx; | ||
if (dv.svg) { | ||
var topRpx = dv.edit.heightAtLine(topEdit, "local") - sTopEdit; | ||
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; } | ||
var botLpx = dv.orig.heightAtLine(botOrig, "local") - sTopOrig; | ||
var botRpx = dv.edit.heightAtLine(botEdit, "local") - sTopEdit; | ||
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; } | ||
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx; | ||
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx; | ||
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")), | ||
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z", | ||
"class", dv.classes.connect); | ||
if (topEdit <= vpEdit.to && botEdit >= vpEdit.from && | ||
topOrig <= vpOrig.to && botOrig >= vpOrig.from) | ||
drawConnectorsForChunk(dv, topOrig, botOrig, topEdit, botEdit, sTopOrig, sTopEdit, w); | ||
if (align && (topEdit <= vpEdit.to || topOrig <= vpOrig.to)) { | ||
var above = (botEdit < vpEdit.from && botOrig < vpOrig.from); | ||
alignChunks(dv, topOrig, botOrig, topEdit, botEdit, above && extraSpaceAbove); | ||
} | ||
if (dv.copyButtons) { | ||
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc", | ||
"CodeMirror-merge-copy")); | ||
var editOriginals = dv.mv.options.allowEditingOriginals; | ||
copy.title = editOriginals ? "Push to left" : "Revert chunk"; | ||
copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig}; | ||
copy.style.top = top + "px"; | ||
}); | ||
if (align) { | ||
if (extraSpaceAbove.edit) | ||
dv.aligners.push(padBelow(dv.edit, 0, extraSpaceAbove.edit)); | ||
if (extraSpaceAbove.orig) | ||
dv.aligners.push(padBelow(dv.orig, 0, extraSpaceAbove.orig)); | ||
} | ||
} | ||
if (editOriginals) { | ||
var topReverse = dv.orig.heightAtLine(topEdit, "local") - sTopEdit; | ||
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc", | ||
"CodeMirror-merge-copy-reverse")); | ||
copyReverse.title = "Push to right"; | ||
copyReverse.chunk = {topEdit: topOrig, botEdit: botOrig, topOrig: topEdit, botOrig: botEdit}; | ||
copyReverse.style.top = topReverse + "px"; | ||
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px"; | ||
} | ||
function drawConnectorsForChunk(dv, topOrig, botOrig, topEdit, botEdit, sTopOrig, sTopEdit, w) { | ||
var flip = dv.type == "left"; | ||
var top = dv.orig.heightAtLine(topOrig, "local") - sTopOrig; | ||
if (dv.svg) { | ||
var topLpx = top; | ||
var topRpx = dv.edit.heightAtLine(topEdit, "local") - sTopEdit; | ||
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; } | ||
var botLpx = dv.orig.heightAtLine(botOrig, "local") - sTopOrig; | ||
var botRpx = dv.edit.heightAtLine(botEdit, "local") - sTopEdit; | ||
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; } | ||
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx; | ||
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx; | ||
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")), | ||
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z", | ||
"class", dv.classes.connect); | ||
} | ||
if (dv.copyButtons) { | ||
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc", | ||
"CodeMirror-merge-copy")); | ||
var editOriginals = dv.mv.options.allowEditingOriginals; | ||
copy.title = editOriginals ? "Push to left" : "Revert chunk"; | ||
copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig}; | ||
copy.style.top = top + "px"; | ||
if (editOriginals) { | ||
var topReverse = dv.orig.heightAtLine(topEdit, "local") - sTopEdit; | ||
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc", | ||
"CodeMirror-merge-copy-reverse")); | ||
copyReverse.title = "Push to right"; | ||
copyReverse.chunk = {topEdit: topOrig, botEdit: botOrig, topOrig: topEdit, botOrig: botEdit}; | ||
copyReverse.style.top = topReverse + "px"; | ||
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px"; | ||
} | ||
}); | ||
} | ||
} | ||
function alignChunks(dv, topOrig, botOrig, topEdit, botEdit, aboveViewport) { | ||
var topOrigPx = dv.orig.heightAtLine(topOrig, "local"); | ||
var botOrigPx = dv.orig.heightAtLine(botOrig, "local"); | ||
var topEditPx = dv.edit.heightAtLine(topEdit, "local"); | ||
var botEditPx = dv.edit.heightAtLine(botEdit, "local"); | ||
var origH = botOrigPx -topOrigPx, editH = botEditPx - topEditPx; | ||
var diff = editH - origH; | ||
if (diff > 1) { | ||
if (aboveViewport) aboveViewport.orig += diff; | ||
else dv.aligners.push(padBelow(dv.orig, botOrig - 1, diff)); | ||
} else if (diff < -1) { | ||
if (aboveViewport) aboveViewport.edit -= diff; | ||
else dv.aligners.push(padBelow(dv.edit, botEdit - 1, -diff)); | ||
} | ||
return 0; | ||
} | ||
function padBelow(cm, line, size) { | ||
var elt = document.createElement("div"); | ||
elt.style.height = size + "px"; elt.style.minWidth = "1px"; | ||
return cm.addLineWidget(line, elt, {height: size}); | ||
} | ||
function copyChunk(dv, to, from, chunk) { | ||
@@ -323,2 +378,9 @@ if (dv.diffOutOfDate) return; | ||
var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight; | ||
if (origLeft && origRight) { | ||
if (options.connect == "align") | ||
throw new Error("connect: \"align\" is not supported for three-way merge views"); | ||
if (options.collapseIdentical) | ||
throw new Error("collapseIdentical option is not supported for three-way merge views"); | ||
} | ||
var hasLeft = origLeft != null, hasRight = origRight != null; | ||
@@ -355,5 +417,8 @@ var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0); | ||
if (options.collapseIdentical) | ||
collapseIdenticalStretches(left || right, options.collapseIdentical); | ||
var onResize = function() { | ||
if (left) drawConnectors(left); | ||
if (right) drawConnectors(right); | ||
if (left) makeConnections(left); | ||
if (right) makeConnections(right); | ||
}; | ||
@@ -386,6 +451,8 @@ CodeMirror.on(window, "resize", onResize); | ||
} | ||
var svg = document.createElementNS && document.createElementNS(svgNS, "svg"); | ||
if (svg && !svg.createSVGRect) svg = null; | ||
dv.svg = svg; | ||
if (svg) gapElts.push(svg); | ||
if (dv.mv.options.connect != "align") { | ||
var svg = document.createElementNS && document.createElementNS(svgNS, "svg"); | ||
if (svg && !svg.createSVGRect) svg = null; | ||
dv.svg = svg; | ||
if (svg) gapElts.push(svg); | ||
} | ||
@@ -502,2 +569,42 @@ return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap"); | ||
function collapseSingle(cm, from, to) { | ||
cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); | ||
var widget = document.createElement("span"); | ||
widget.className = "CodeMirror-merge-collapsed-widget"; | ||
widget.title = "Identical text collapsed. Click to expand."; | ||
var mark = cm.markText(Pos(from, 0), Pos(to - 1), { | ||
inclusiveLeft: true, | ||
inclusiveRight: true, | ||
replacedWith: widget, | ||
clearOnEnter: true | ||
}); | ||
function clear() { | ||
mark.clear(); | ||
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line"); | ||
} | ||
widget.addEventListener("click", clear); | ||
return {mark: mark, clear: clear}; | ||
} | ||
function collapseStretch(dv, origStart, editStart, size) { | ||
var mOrig = collapseSingle(dv.orig, origStart, origStart + size); | ||
var mEdit = collapseSingle(dv.edit, editStart, editStart + size); | ||
mOrig.mark.on("clear", function() { mEdit.clear(); }); | ||
mEdit.mark.on("clear", function() { mOrig.clear(); }); | ||
} | ||
function collapseIdenticalStretches(dv, margin) { | ||
if (typeof margin != "number") margin = 2; | ||
var lastOrig = dv.orig.firstLine(), lastEdit = dv.edit.firstLine(); | ||
iterateChunks(dv.diff, function(topOrig, botOrig, _topEdit, botEdit) { | ||
var identicalSize = topOrig - margin - lastOrig; | ||
if (identicalSize > margin) | ||
collapseStretch(dv, lastOrig, lastEdit, identicalSize); | ||
lastOrig = botOrig + margin; lastEdit = botEdit + margin; | ||
}); | ||
var bottomSize = dv.orig.lastLine() + 1 - lastOrig; | ||
if (bottomSize > margin) | ||
collapseStretch(dv, lastOrig, lastEdit, bottomSize); | ||
} | ||
// General utilities | ||
@@ -504,0 +611,0 @@ |
@@ -14,5 +14,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
CodeMirror.defineSimpleMode = function(name, states, props) { | ||
CodeMirror.defineSimpleMode = function(name, states) { | ||
CodeMirror.defineMode(name, function(config) { | ||
return CodeMirror.simpleMode(config, states, props); | ||
return CodeMirror.simpleMode(config, states); | ||
}); | ||
@@ -198,8 +198,11 @@ }; | ||
for (var i = 0; i < rules.length; i++) { | ||
var rule = rules[i], m = rule.regex.exec(textAfter); | ||
if (m && m[0]) { | ||
if (rule.data.dedent && rule.data.dedentIfLineStart !== false) pos--; | ||
if (rule.next || rule.push) rules = states[rule.next || rule.push]; | ||
textAfter = textAfter.slice(m[0].length); | ||
continue scan; | ||
var rule = rules[i]; | ||
if (rule.data.dedent && rule.data.dedentIfLineStart !== false) { | ||
var m = rule.regex.exec(textAfter); | ||
if (m && m[0]) { | ||
pos--; | ||
if (rule.next || rule.push) rules = states[rule.next || rule.push]; | ||
textAfter = textAfter.slice(m[0].length); | ||
continue scan; | ||
} | ||
} | ||
@@ -206,0 +209,0 @@ } |
@@ -66,7 +66,7 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (isRE) { | ||
query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); | ||
if (query.test("")) query = /x^/; | ||
} else if (query == "") { | ||
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); } | ||
catch(e) {} // Not a regular expression after all, do a string search | ||
} | ||
if (typeof query == "string" ? query == "" : query.test("")) | ||
query = /x^/; | ||
} | ||
return query; | ||
@@ -86,2 +86,6 @@ } | ||
cm.addOverlay(state.overlay); | ||
if (cm.showMatchesOnScrollbar) { | ||
if (state.annotate) { state.annotate.clear(); state.annotate = null; } | ||
state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); | ||
} | ||
state.posFrom = state.posTo = cm.getCursor(); | ||
@@ -108,2 +112,3 @@ findNext(cm, rev); | ||
cm.removeOverlay(state.overlay); | ||
if (state.annotate) { state.annotate.clear(); state.annotate = null; } | ||
});} | ||
@@ -110,0 +115,0 @@ |
@@ -109,4 +109,6 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
showType: function(cm, pos, c) { showType(this, cm, pos, c); }, | ||
showType: function(cm, pos, c) { showContextInfo(this, cm, pos, "type", c); }, | ||
showDocs: function(cm, pos, c) { showContextInfo(this, cm, pos, "documentation", c); }, | ||
updateArgHints: function(cm) { updateArgHints(this, cm); }, | ||
@@ -243,4 +245,4 @@ | ||
function showType(ts, cm, pos, c) { | ||
ts.request(cm, "type", function(error, data) { | ||
function showContextInfo(ts, cm, pos, queryName, c) { | ||
ts.request(cm, queryName, function(error, data) { | ||
if (error) return showError(ts, cm, error); | ||
@@ -247,0 +249,0 @@ if (ts.options.typeTip) { |
{ | ||
"name": "codemirror", | ||
"version":"4.8.0", | ||
"version":"4.9.0", | ||
"main": ["lib/codemirror.js", "lib/codemirror.css"], | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -135,4 +135,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
function findEnd(cm, by, dir) { | ||
var pos = cm.getCursor(), prefix = getPrefix(cm); | ||
function findEnd(cm, pos, by, dir) { | ||
var prefix = getPrefix(cm); | ||
if (prefix < 0) { dir = -dir; prefix = -prefix; } | ||
@@ -149,3 +149,3 @@ for (var i = 0; i < prefix; ++i) { | ||
var f = function(cm) { | ||
cm.extendSelection(findEnd(cm, by, dir)); | ||
cm.extendSelection(findEnd(cm, cm.getCursor(), by, dir)); | ||
}; | ||
@@ -157,5 +157,22 @@ f.motion = true; | ||
function killTo(cm, by, dir) { | ||
kill(cm, cm.getCursor(), findEnd(cm, by, dir), true); | ||
var selections = cm.listSelections(), cursor; | ||
var i = selections.length; | ||
while (i--) { | ||
cursor = selections[i].head; | ||
kill(cm, cursor, findEnd(cm, cursor, by, dir), true); | ||
} | ||
} | ||
function killRegion(cm) { | ||
if (cm.somethingSelected()) { | ||
var selections = cm.listSelections(), selection; | ||
var i = selections.length; | ||
while (i--) { | ||
selection = selections[i]; | ||
kill(cm, selection.anchor, selection.head); | ||
} | ||
return true; | ||
} | ||
} | ||
function addPrefix(cm, digit) { | ||
@@ -289,5 +306,5 @@ if (cm.state.emacsPrefix) { | ||
"Ctrl-D": function(cm) { killTo(cm, byChar, 1); }, | ||
"Delete": function(cm) { killTo(cm, byChar, 1); }, | ||
"Delete": function(cm) { killRegion(cm) || killTo(cm, byChar, 1); }, | ||
"Ctrl-H": function(cm) { killTo(cm, byChar, -1); }, | ||
"Backspace": function(cm) { killTo(cm, byChar, -1); }, | ||
"Backspace": function(cm) { killRegion(cm) || killTo(cm, byChar, -1); }, | ||
@@ -316,3 +333,4 @@ "Alt-F": move(byWord, 1), "Alt-B": move(byWord, -1), | ||
"Shift-Ctrl-Alt-2": function(cm) { | ||
cm.setSelection(findEnd(cm, byExpr, 1), cm.getCursor()); | ||
var cursor = cm.getCursor(); | ||
cm.setSelection(findEnd(cm, cursor, byExpr, 1), cursor); | ||
}, | ||
@@ -319,0 +337,0 @@ "Ctrl-Alt-T": function(cm) { |
@@ -18,3 +18,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
CodeMirror.defineMode("coffeescript", function(conf) { | ||
CodeMirror.defineMode("coffeescript", function(conf, parserConf) { | ||
var ERRORCLASS = "error"; | ||
@@ -195,3 +195,3 @@ | ||
if (singleline) { | ||
if (conf.mode.singleLineStringErrors) { | ||
if (parserConf.singleLineStringErrors) { | ||
outclass = ERRORCLASS; | ||
@@ -198,0 +198,0 @@ } else { |
@@ -15,2 +15,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
CodeMirror.defineMode("commonlisp", function (config) { | ||
var specialForm = /^(block|let*|return-from|catch|load-time-value|setq|eval-when|locally|symbol-macrolet|flet|macrolet|tagbody|function|multiple-value-call|the|go|multiple-value-prog1|throw|if|progn|unwind-protect|labels|progv|let|quote)$/; | ||
var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/; | ||
@@ -56,4 +57,4 @@ var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/; | ||
type = "symbol"; | ||
if (name == "nil" || name == "t") return "atom"; | ||
if (name.charAt(0) == ":") return "keyword"; | ||
if (name == "nil" || name == "t" || name.charAt(0) == ":") return "atom"; | ||
if (state.lastType == "open" && (specialForm.test(name) || assumeBody.test(name))) return "keyword"; | ||
if (name.charAt(0) == "&") return "variable-2"; | ||
@@ -85,3 +86,3 @@ return "variable"; | ||
startState: function () { | ||
return {ctx: {prev: null, start: 0, indentTo: 0}, tokenize: base}; | ||
return {ctx: {prev: null, start: 0, indentTo: 0}, lastType: null, tokenize: base}; | ||
}, | ||
@@ -104,2 +105,3 @@ | ||
} | ||
state.lastType = type; | ||
} | ||
@@ -106,0 +108,0 @@ if (type == "open") state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null}; |
@@ -65,3 +65,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var preds = wordRegexp(["all", "and", "any", "has", "in", "none", "not", "or", "single", "xor"]); | ||
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "distinct", "drop", "else", "end", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "remove", "return", "scan", "set", "skip", "start", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]); | ||
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "distinct", "drop", "else", "end", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]); | ||
var operatorChars = /[*+\-<>=&|~%^]/; | ||
@@ -68,0 +68,0 @@ |
@@ -27,4 +27,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
regex: /#.*$/, | ||
token: "comment", | ||
next: "start" | ||
token: "comment" | ||
}, | ||
@@ -34,4 +33,3 @@ // Highlight an instruction without any arguments (for convenience) | ||
regex: instructionOnlyLine, | ||
token: "variable-2", | ||
next: "start" | ||
token: "variable-2" | ||
}, | ||
@@ -44,6 +42,5 @@ // Highlight an instruction followed by arguments | ||
}, | ||
// Fail-safe return to start | ||
{ | ||
token: null, | ||
next: "start" | ||
regex: /./, | ||
token: null | ||
} | ||
@@ -60,4 +57,3 @@ ], | ||
regex: /[^#]+\\$/, | ||
token: null, | ||
next: "arguments" | ||
token: null | ||
}, | ||
@@ -64,0 +60,0 @@ { |
@@ -208,2 +208,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
sawSomething = true; | ||
} else if (/["'\/]/.test(ch)) { | ||
return; | ||
} else if (sawSomething && !depth) { | ||
@@ -210,0 +212,0 @@ ++pos; |
@@ -64,2 +64,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
MT("quotedStringAddition", | ||
"[keyword let] [variable f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];"); | ||
MT("quotedFatArrow", | ||
"[keyword let] [variable f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];"); | ||
MT("fatArrow", | ||
@@ -66,0 +72,0 @@ "[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);", |
@@ -6,3 +6,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (typeof exports == "object" && typeof module == "object") // CommonJS | ||
mod(require("../../lib/codemirror", require("../xml/xml"), require("../meta"))); | ||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta")); | ||
else if (typeof define == "function" && define.amd) // AMD | ||
@@ -400,3 +400,3 @@ define(["../../lib/codemirror", "../xml/xml", "../meta"], mod); | ||
if (ch === '[' && stream.match(/.*\](\(| ?\[)/, false)) { | ||
if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) { | ||
state.linkText = true; | ||
@@ -407,3 +407,3 @@ if (modeCfg.highlightFormatting) state.formatting = "link"; | ||
if (ch === ']' && state.linkText) { | ||
if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) { | ||
if (modeCfg.highlightFormatting) state.formatting = "link"; | ||
@@ -410,0 +410,0 @@ var type = getType(state); |
@@ -29,2 +29,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]}, | ||
{name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]}, | ||
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]}, | ||
@@ -35,5 +36,7 @@ {name: "Django", mime: "text/x-django", mode: "django"}, | ||
{name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]}, | ||
{name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"}, | ||
{name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]}, | ||
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]}, | ||
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]}, | ||
{name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]}, | ||
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]}, | ||
@@ -68,3 +71,3 @@ {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]}, | ||
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]}, | ||
{name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]}, | ||
{name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]}, | ||
{name: "mIRC", mime: "text/mirc", mode: "mirc"}, | ||
@@ -108,3 +111,5 @@ {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"}, | ||
{name: "Solr", mime: "text/x-solr", mode: "solr"}, | ||
{name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]}, | ||
{name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]}, | ||
{name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]}, | ||
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, | ||
@@ -111,0 +116,0 @@ {name: "MariaDB", mime: "text/x-mariadb", mode: "sql"}, |
@@ -143,7 +143,7 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
// Is there a match on a reference? | ||
if (/(\s+)?[A-Z]/.test(word)) { | ||
if (/(^|\s+)[A-Z][\w:_]+/.test(word)) { | ||
// Negate the next() | ||
stream.backUp(1); | ||
// Match the full reference | ||
stream.match(/(\s+)?[A-Z][\w:_]+/); | ||
stream.match(/(^|\s+)[A-Z][\w:_]+/); | ||
return 'def'; | ||
@@ -150,0 +150,0 @@ } |
@@ -132,3 +132,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
}, | ||
lineComment: '#' | ||
lineComment: '#', | ||
fold: "brace" | ||
}; | ||
@@ -135,0 +136,0 @@ }); |
@@ -133,4 +133,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
return "comment"; | ||
} | ||
else if (ch == '}' || ch == ']') { | ||
} else if (ch == '}' || ch == ']') { | ||
plug = peekCommand(state); | ||
@@ -149,8 +148,6 @@ if (plug) { | ||
return "bracket"; | ||
} | ||
else if (/\d/.test(ch)) { | ||
} else if (/\d/.test(ch)) { | ||
source.eatWhile(/[\w.%]/); | ||
return "atom"; | ||
} | ||
else { | ||
} else { | ||
source.eatWhile(/[\w\-_]/); | ||
@@ -247,2 +244,3 @@ plug = getMostPowerful(state); | ||
state.f = normal; | ||
state.cmdState.length = 0; | ||
}, | ||
@@ -249,0 +247,0 @@ lineComment: "%" |
@@ -171,12 +171,12 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
MT('ulFormatting', | ||
'[variable-2 * ][variable-2&em _foo_][variable-2 bar]', | ||
'[variable-2 * ][variable-2&em _foo_][variable-2 bar]', | ||
'[variable-2 * ][variable-2&strong *][variable-2&em&strong _foo_]' + | ||
'[variable-2&strong *][variable-2 bar]', | ||
'[variable-2 * ][variable-2&strong *foo*][variable-2 bar]'); | ||
'[variable-2 * ][variable-2&strong *foo*][variable-2 bar]'); | ||
MT('olFormatting', | ||
'[variable-2 # ][variable-2&em _foo_][variable-2 bar]', | ||
'[variable-2 # ][variable-2&em _foo_][variable-2 bar]', | ||
'[variable-2 # ][variable-2&strong *][variable-2&em&strong _foo_]' + | ||
'[variable-2&strong *][variable-2 bar]', | ||
'[variable-2 # ][variable-2&strong *foo*][variable-2 bar]'); | ||
'[variable-2 # ][variable-2&strong *foo*][variable-2 bar]'); | ||
@@ -407,2 +407,13 @@ MT('ulNested', | ||
'[operator *No* formatting]'); | ||
/* Only toggling phrases between non-word chars. */ | ||
MT('phrase-in-word', | ||
'foo_bar_baz'); | ||
MT('phrase-non-word', | ||
'[negative -x-] aaa-bbb ccc-ddd [negative -eee-] fff [negative -ggg-]'); | ||
MT('phrase-lone-dash', | ||
'foo - bar - baz'); | ||
})(); |
@@ -5,6 +5,6 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
(function(mod) { | ||
if (typeof exports == 'object' && typeof module == 'object') { // CommonJS | ||
mod(require('../../lib/codemirror')); | ||
} else if (typeof define == 'function' && define.amd) { // AMD | ||
define(['../../lib/codemirror'], mod); | ||
if (typeof exports == "object" && typeof module == "object") { // CommonJS | ||
mod(require("../../lib/codemirror")); | ||
} else if (typeof define == "function" && define.amd) { // AMD | ||
define(["../../lib/codemirror"], mod); | ||
} else { // Plain browser env | ||
@@ -14,542 +14,458 @@ mod(CodeMirror); | ||
})(function(CodeMirror) { | ||
'use strict'; | ||
"use strict"; | ||
var TOKEN_STYLES = { | ||
addition: 'positive', | ||
attributes: 'attribute', | ||
bold: 'strong', | ||
cite: 'keyword', | ||
code: 'atom', | ||
definitionList: 'number', | ||
deletion: 'negative', | ||
div: 'punctuation', | ||
em: 'em', | ||
footnote: 'variable', | ||
footCite: 'qualifier', | ||
header: 'header', | ||
html: 'comment', | ||
image: 'string', | ||
italic: 'em', | ||
link: 'link', | ||
linkDefinition: 'link', | ||
list1: 'variable-2', | ||
list2: 'variable-3', | ||
list3: 'keyword', | ||
notextile: 'string-2', | ||
pre: 'operator', | ||
p: 'property', | ||
quote: 'bracket', | ||
span: 'quote', | ||
specialChar: 'tag', | ||
strong: 'strong', | ||
sub: 'builtin', | ||
sup: 'builtin', | ||
table: 'variable-3', | ||
tableHeading: 'operator' | ||
}; | ||
var TOKEN_STYLES = { | ||
addition: "positive", | ||
attributes: "attribute", | ||
bold: "strong", | ||
cite: "keyword", | ||
code: "atom", | ||
definitionList: "number", | ||
deletion: "negative", | ||
div: "punctuation", | ||
em: "em", | ||
footnote: "variable", | ||
footCite: "qualifier", | ||
header: "header", | ||
html: "comment", | ||
image: "string", | ||
italic: "em", | ||
link: "link", | ||
linkDefinition: "link", | ||
list1: "variable-2", | ||
list2: "variable-3", | ||
list3: "keyword", | ||
notextile: "string-2", | ||
pre: "operator", | ||
p: "property", | ||
quote: "bracket", | ||
span: "quote", | ||
specialChar: "tag", | ||
strong: "strong", | ||
sub: "builtin", | ||
sup: "builtin", | ||
table: "variable-3", | ||
tableHeading: "operator" | ||
}; | ||
function Parser(regExpFactory, state, stream) { | ||
this.regExpFactory = regExpFactory; | ||
this.state = state; | ||
this.stream = stream; | ||
this.styles = TOKEN_STYLES; | ||
function startNewLine(stream, state) { | ||
state.mode = Modes.newLayout; | ||
state.tableHeading = false; | ||
this.state.specialChar = null; | ||
} | ||
if (state.layoutType === "definitionList" && state.spanningLayout && | ||
stream.match(RE("definitionListEnd"), false)) | ||
state.spanningLayout = false; | ||
} | ||
Parser.prototype.eat = function(name) { | ||
return this.stream.match(this.regExpFactory.pattern(name), true); | ||
}; | ||
function handlePhraseModifier(stream, state, ch) { | ||
if (ch === "_") { | ||
if (stream.eat("_")) | ||
return togglePhraseModifier(stream, state, "italic", /__/, 2); | ||
else | ||
return togglePhraseModifier(stream, state, "em", /_/, 1); | ||
} | ||
Parser.prototype.check = function(name) { | ||
return this.stream.match(this.regExpFactory.pattern(name), false); | ||
}; | ||
if (ch === "*") { | ||
if (stream.eat("*")) { | ||
return togglePhraseModifier(stream, state, "bold", /\*\*/, 2); | ||
} | ||
return togglePhraseModifier(stream, state, "strong", /\*/, 1); | ||
} | ||
Parser.prototype.setModeForNextToken = function(mode) { | ||
return this.state.mode = mode; | ||
}; | ||
if (ch === "[") { | ||
if (stream.match(/\d+\]/)) state.footCite = true; | ||
return tokenStyles(state); | ||
} | ||
Parser.prototype.execMode = function(newMode) { | ||
return this.setModeForNextToken(newMode).call(this); | ||
}; | ||
if (ch === "(") { | ||
var spec = stream.match(/^(r|tm|c)\)/); | ||
if (spec) | ||
return tokenStylesWith(state, TOKEN_STYLES.specialChar); | ||
} | ||
Parser.prototype.startNewLine = function() { | ||
this.setModeForNextToken(Modes.newLayout); | ||
this.state.tableHeading = false; | ||
if (ch === "<" && stream.match(/(\w+)[^>]+>[^<]+<\/\1>/)) | ||
return tokenStylesWith(state, TOKEN_STYLES.html); | ||
if (this.state.layoutType === 'definitionList' && this.state.spanningLayout) { | ||
if (this.check('definitionListEnd')) { | ||
this.state.spanningLayout = false; | ||
} | ||
} | ||
}; | ||
if (ch === "?" && stream.eat("?")) | ||
return togglePhraseModifier(stream, state, "cite", /\?\?/, 2); | ||
Parser.prototype.nextToken = function() { | ||
return this.state.mode.call(this); | ||
}; | ||
if (ch === "=" && stream.eat("=")) | ||
return togglePhraseModifier(stream, state, "notextile", /==/, 2); | ||
Parser.prototype.styleFor = function(token) { | ||
if (this.styles.hasOwnProperty(token)) { | ||
return this.styles[token]; | ||
} | ||
throw 'unknown token'; | ||
}; | ||
if (ch === "-" && !stream.eat("-")) | ||
return togglePhraseModifier(stream, state, "deletion", /-/, 1); | ||
Parser.prototype.handlePhraseModifier = function(ch) { | ||
if (ch === '_') { | ||
if (this.stream.eat('_')) { | ||
return this.togglePhraseModifier('italic', /^.*__/); | ||
} | ||
return this.togglePhraseModifier('em', /^.*_/); | ||
} | ||
if (ch === "+") | ||
return togglePhraseModifier(stream, state, "addition", /\+/, 1); | ||
if (ch === '*') { | ||
if (this.stream.eat('*')) { | ||
return this.togglePhraseModifier('bold', /^.*\*\*/); | ||
} | ||
return this.togglePhraseModifier('strong', /^.*\*/); | ||
} | ||
if (ch === "~") | ||
return togglePhraseModifier(stream, state, "sub", /~/, 1); | ||
if (ch === '[') { | ||
if (this.stream.match(/\d+\]/)) { | ||
this.state.footCite = true; | ||
} | ||
return this.tokenStyles(); | ||
} | ||
if (ch === "^") | ||
return togglePhraseModifier(stream, state, "sup", /\^/, 1); | ||
if (ch === '(') { | ||
if (this.stream.match('r)')) { | ||
this.state.specialChar = 'r'; | ||
} else if (this.stream.match('tm)')) { | ||
this.state.specialChar = 'tm'; | ||
} else if (this.stream.match('c)')) { | ||
this.state.specialChar = 'c'; | ||
if (ch === "%") | ||
return togglePhraseModifier(stream, state, "span", /%/, 1); | ||
if (ch === "@") | ||
return togglePhraseModifier(stream, state, "code", /@/, 1); | ||
if (ch === "!") { | ||
var type = togglePhraseModifier(stream, state, "image", /(?:\([^\)]+\))?!/, 1); | ||
stream.match(/^:\S+/); // optional Url portion | ||
return type; | ||
} | ||
return this.tokenStyles(); | ||
return tokenStyles(state); | ||
} | ||
if (ch === '<') { | ||
if (this.stream.match(/(\w+)[^>]+>[^<]+<\/\1>/)) { | ||
return this.tokenStylesWith(this.styleFor('html')); | ||
function togglePhraseModifier(stream, state, phraseModifier, closeRE, openSize) { | ||
var charBefore = stream.pos > openSize ? stream.string.charAt(stream.pos - openSize - 1) : null; | ||
var charAfter = stream.peek(); | ||
if (state[phraseModifier]) { | ||
if ((!charAfter || /\W/.test(charAfter)) && charBefore && /\S/.test(charBefore)) { | ||
var type = tokenStyles(state); | ||
state[phraseModifier] = false; | ||
return type; | ||
} | ||
} else if ((!charBefore || /\W/.test(charBefore)) && charAfter && /\S/.test(charAfter) && | ||
stream.match(new RegExp("^.*\\S" + closeRE.source + "(?:\\W|$)"), false)) { | ||
state[phraseModifier] = true; | ||
state.mode = Modes.attributes; | ||
} | ||
} | ||
return tokenStyles(state); | ||
}; | ||
if (ch === '?' && this.stream.eat('?')) { | ||
return this.togglePhraseModifier('cite', /^.*\?\?/); | ||
} | ||
if (ch === '=' && this.stream.eat('=')) { | ||
return this.togglePhraseModifier('notextile', /^.*==/); | ||
} | ||
if (ch === '-') { | ||
return this.togglePhraseModifier('deletion', /^.*-/); | ||
} | ||
if (ch === '+') { | ||
return this.togglePhraseModifier('addition', /^.*\+/); | ||
} | ||
if (ch === '~') { | ||
return this.togglePhraseModifier('sub', /^.*~/); | ||
} | ||
if (ch === '^') { | ||
return this.togglePhraseModifier('sup', /^.*\^/); | ||
} | ||
if (ch === '%') { | ||
return this.togglePhraseModifier('span', /^.*%/); | ||
} | ||
if (ch === '@') { | ||
return this.togglePhraseModifier('code', /^.*@/); | ||
} | ||
if (ch === '!') { | ||
var type = this.togglePhraseModifier('image', /^.*(?:\([^\)]+\))?!/); | ||
this.stream.match(/^:\S+/); // optional Url portion | ||
return type; | ||
} | ||
return this.tokenStyles(); | ||
}; | ||
function tokenStyles(state) { | ||
var disabled = textileDisabled(state); | ||
if (disabled) return disabled; | ||
Parser.prototype.togglePhraseModifier = function(phraseModifier, closeRE) { | ||
if (this.state[phraseModifier]) { // remove phrase modifier | ||
var type = this.tokenStyles(); | ||
this.state[phraseModifier] = false; | ||
return type; | ||
} | ||
if (this.stream.match(closeRE, false)) { // add phrase modifier | ||
this.state[phraseModifier] = true; | ||
this.setModeForNextToken(Modes.attributes); | ||
} | ||
return this.tokenStyles(); | ||
}; | ||
var styles = []; | ||
if (state.layoutType) styles.push(TOKEN_STYLES[state.layoutType]); | ||
Parser.prototype.tokenStyles = function() { | ||
var disabled = this.textileDisabled(), | ||
styles = []; | ||
styles = styles.concat(activeStyles( | ||
state, "addition", "bold", "cite", "code", "deletion", "em", "footCite", | ||
"image", "italic", "link", "span", "strong", "sub", "sup", "table", "tableHeading")); | ||
if (disabled) return disabled; | ||
if (state.layoutType === "header") | ||
styles.push(TOKEN_STYLES.header + "-" + state.header); | ||
if (this.state.layoutType) { | ||
styles.push(this.styleFor(this.state.layoutType)); | ||
return styles.length ? styles.join(" ") : null; | ||
} | ||
styles = styles.concat(this.activeStyles('addition', 'bold', 'cite', 'code', | ||
'deletion', 'em', 'footCite', 'image', 'italic', 'link', 'span', 'specialChar', 'strong', | ||
'sub', 'sup', 'table', 'tableHeading')); | ||
function textileDisabled(state) { | ||
var type = state.layoutType; | ||
if (this.state.layoutType === 'header') { | ||
styles.push(this.styleFor('header') + '-' + this.state.header); | ||
} | ||
return styles.length ? styles.join(' ') : null; | ||
}; | ||
Parser.prototype.textileDisabled = function() { | ||
var type = this.state.layoutType; | ||
switch(type) { | ||
case 'notextile': | ||
case 'code': | ||
case 'pre': | ||
return this.styleFor(type); | ||
switch(type) { | ||
case "notextile": | ||
case "code": | ||
case "pre": | ||
return TOKEN_STYLES[type]; | ||
default: | ||
if (this.state.notextile) { | ||
return this.styleFor('notextile') + (type ? (' ' + this.styleFor(type)) : ''); | ||
} | ||
if (state.notextile) | ||
return TOKEN_STYLES.notextile + (type ? (" " + TOKEN_STYLES[type]) : ""); | ||
return null; | ||
} | ||
} | ||
}; | ||
Parser.prototype.tokenStylesWith = function(extraStyles) { | ||
var disabled = this.textileDisabled(), | ||
type; | ||
function tokenStylesWith(state, extraStyles) { | ||
var disabled = textileDisabled(state); | ||
if (disabled) return disabled; | ||
if (disabled) return disabled; | ||
type = this.tokenStyles(); | ||
if(extraStyles) { | ||
return type ? (type + ' ' + extraStyles) : extraStyles; | ||
var type = tokenStyles(state); | ||
if (extraStyles) | ||
return type ? (type + " " + extraStyles) : extraStyles; | ||
else | ||
return type; | ||
} | ||
return type; | ||
}; | ||
Parser.prototype.activeStyles = function() { | ||
var styles = [], | ||
i; | ||
for (i = 0; i < arguments.length; ++i) { | ||
if (this.state[arguments[i]]) { | ||
styles.push(this.styleFor(arguments[i])); | ||
function activeStyles(state) { | ||
var styles = []; | ||
for (var i = 1; i < arguments.length; ++i) { | ||
if (state[arguments[i]]) | ||
styles.push(TOKEN_STYLES[arguments[i]]); | ||
} | ||
return styles; | ||
} | ||
return styles; | ||
}; | ||
Parser.prototype.blankLine = function() { | ||
var spanningLayout = this.state.spanningLayout, | ||
type = this.state.layoutType, | ||
key; | ||
function blankLine(state) { | ||
var spanningLayout = state.spanningLayout, type = state.layoutType; | ||
for (key in this.state) { | ||
if (this.state.hasOwnProperty(key)) { | ||
delete this.state[key]; | ||
for (var key in state) if (state.hasOwnProperty(key)) | ||
delete state[key]; | ||
state.mode = Modes.newLayout; | ||
if (spanningLayout) { | ||
state.layoutType = type; | ||
state.spanningLayout = true; | ||
} | ||
} | ||
this.setModeForNextToken(Modes.newLayout); | ||
if (spanningLayout) { | ||
this.state.layoutType = type; | ||
this.state.spanningLayout = true; | ||
} | ||
}; | ||
var REs = { | ||
cache: {}, | ||
single: { | ||
bc: "bc", | ||
bq: "bq", | ||
definitionList: /- [^(?::=)]+:=+/, | ||
definitionListEnd: /.*=:\s*$/, | ||
div: "div", | ||
drawTable: /\|.*\|/, | ||
foot: /fn\d+/, | ||
header: /h[1-6]/, | ||
html: /\s*<(?:\/)?(\w+)(?:[^>]+)?>(?:[^<]+<\/\1>)?/, | ||
link: /[^"]+":\S/, | ||
linkDefinition: /\[[^\s\]]+\]\S+/, | ||
list: /(?:#+|\*+)/, | ||
notextile: "notextile", | ||
para: "p", | ||
pre: "pre", | ||
table: "table", | ||
tableCellAttributes: /[\/\\]\d+/, | ||
tableHeading: /\|_\./, | ||
tableText: /[^"_\*\[\(\?\+~\^%@|-]+/, | ||
text: /[^!"_=\*\[\(<\?\+~\^%@-]+/ | ||
}, | ||
attributes: { | ||
align: /(?:<>|<|>|=)/, | ||
selector: /\([^\(][^\)]+\)/, | ||
lang: /\[[^\[\]]+\]/, | ||
pad: /(?:\(+|\)+){1,2}/, | ||
css: /\{[^\}]+\}/ | ||
}, | ||
createRe: function(name) { | ||
switch (name) { | ||
case "drawTable": | ||
return REs.makeRe("^", REs.single.drawTable, "$"); | ||
case "html": | ||
return REs.makeRe("^", REs.single.html, "(?:", REs.single.html, ")*", "$"); | ||
case "linkDefinition": | ||
return REs.makeRe("^", REs.single.linkDefinition, "$"); | ||
case "listLayout": | ||
return REs.makeRe("^", REs.single.list, RE("allAttributes"), "*\\s+"); | ||
case "tableCellAttributes": | ||
return REs.makeRe("^", REs.choiceRe(REs.single.tableCellAttributes, | ||
RE("allAttributes")), "+\\."); | ||
case "type": | ||
return REs.makeRe("^", RE("allTypes")); | ||
case "typeLayout": | ||
return REs.makeRe("^", RE("allTypes"), RE("allAttributes"), | ||
"*\\.\\.?", "(\\s+|$)"); | ||
case "attributes": | ||
return REs.makeRe("^", RE("allAttributes"), "+"); | ||
case "allTypes": | ||
return REs.choiceRe(REs.single.div, REs.single.foot, | ||
REs.single.header, REs.single.bc, REs.single.bq, | ||
REs.single.notextile, REs.single.pre, REs.single.table, | ||
REs.single.para); | ||
function RegExpFactory() { | ||
this.cache = {}; | ||
this.single = { | ||
bc: 'bc', | ||
bq: 'bq', | ||
definitionList: /- [^(?::=)]+:=+/, | ||
definitionListEnd: /.*=:\s*$/, | ||
div: 'div', | ||
drawTable: /\|.*\|/, | ||
foot: /fn\d+/, | ||
header: /h[1-6]/, | ||
html: /\s*<(?:\/)?(\w+)(?:[^>]+)?>(?:[^<]+<\/\1>)?/, | ||
link: /[^"]+":\S/, | ||
linkDefinition: /\[[^\s\]]+\]\S+/, | ||
list: /(?:#+|\*+)/, | ||
notextile: 'notextile', | ||
para: 'p', | ||
pre: 'pre', | ||
table: 'table', | ||
tableCellAttributes: /[/\\]\d+/, | ||
tableHeading: /\|_\./, | ||
tableText: /[^"_\*\[\(\?\+~\^%@|-]+/, | ||
text: /[^!"_=\*\[\(<\?\+~\^%@-]+/ | ||
}; | ||
this.attributes = { | ||
align: /(?:<>|<|>|=)/, | ||
selector: /\([^\(][^\)]+\)/, | ||
lang: /\[[^\[\]]+\]/, | ||
pad: /(?:\(+|\)+){1,2}/, | ||
css: /\{[^\}]+\}/ | ||
}; | ||
} | ||
case "allAttributes": | ||
return REs.choiceRe(REs.attributes.selector, REs.attributes.css, | ||
REs.attributes.lang, REs.attributes.align, REs.attributes.pad); | ||
RegExpFactory.prototype.pattern = function(name) { | ||
return (this.cache[name] || this.createRe(name)); | ||
}; | ||
default: | ||
return REs.makeRe("^", REs.single[name]); | ||
} | ||
}, | ||
makeRe: function() { | ||
var pattern = ""; | ||
for (var i = 0; i < arguments.length; ++i) { | ||
var arg = arguments[i]; | ||
pattern += (typeof arg === "string") ? arg : arg.source; | ||
} | ||
return new RegExp(pattern); | ||
}, | ||
choiceRe: function() { | ||
var parts = [arguments[0]]; | ||
for (var i = 1; i < arguments.length; ++i) { | ||
parts[i * 2 - 1] = "|"; | ||
parts[i * 2] = arguments[i]; | ||
} | ||
RegExpFactory.prototype.createRe = function(name) { | ||
switch (name) { | ||
case 'drawTable': | ||
return this.makeRe('^', this.single.drawTable, '$'); | ||
case 'html': | ||
return this.makeRe('^', this.single.html, '(?:', this.single.html, ')*', '$'); | ||
case 'linkDefinition': | ||
return this.makeRe('^', this.single.linkDefinition, '$'); | ||
case 'listLayout': | ||
return this.makeRe('^', this.single.list, this.pattern('allAttributes'), '*\\s+'); | ||
case 'tableCellAttributes': | ||
return this.makeRe('^', this.choiceRe(this.single.tableCellAttributes, | ||
this.pattern('allAttributes')), '+\\.'); | ||
case 'type': | ||
return this.makeRe('^', this.pattern('allTypes')); | ||
case 'typeLayout': | ||
return this.makeRe('^', this.pattern('allTypes'), this.pattern('allAttributes'), | ||
'*\\.\\.?', '(\\s+|$)'); | ||
case 'attributes': | ||
return this.makeRe('^', this.pattern('allAttributes'), '+'); | ||
parts.unshift("(?:"); | ||
parts.push(")"); | ||
return REs.makeRe.apply(null, parts); | ||
} | ||
}; | ||
case 'allTypes': | ||
return this.choiceRe(this.single.div, this.single.foot, | ||
this.single.header, this.single.bc, this.single.bq, | ||
this.single.notextile, this.single.pre, this.single.table, | ||
this.single.para); | ||
case 'allAttributes': | ||
return this.choiceRe(this.attributes.selector, this.attributes.css, | ||
this.attributes.lang, this.attributes.align, this.attributes.pad); | ||
default: | ||
return this.makeRe('^', this.single[name]); | ||
function RE(name) { | ||
return (REs.cache[name] || (REs.cache[name] = REs.createRe(name))); | ||
} | ||
}; | ||
var Modes = { | ||
newLayout: function(stream, state) { | ||
if (stream.match(RE("typeLayout"), false)) { | ||
state.spanningLayout = false; | ||
return (state.mode = Modes.blockType)(stream, state); | ||
} | ||
var newMode; | ||
if (!textileDisabled(state)) { | ||
if (stream.match(RE("listLayout"), false)) | ||
newMode = Modes.list; | ||
else if (stream.match(RE("drawTable"), false)) | ||
newMode = Modes.table; | ||
else if (stream.match(RE("linkDefinition"), false)) | ||
newMode = Modes.linkDefinition; | ||
else if (stream.match(RE("definitionList"))) | ||
newMode = Modes.definitionList; | ||
else if (stream.match(RE("html"), false)) | ||
newMode = Modes.html; | ||
} | ||
return (state.mode = (newMode || Modes.text))(stream, state); | ||
}, | ||
RegExpFactory.prototype.makeRe = function() { | ||
var pattern = '', | ||
i, | ||
arg; | ||
blockType: function(stream, state) { | ||
var match, type; | ||
state.layoutType = null; | ||
for (i = 0; i < arguments.length; ++i) { | ||
arg = arguments[i]; | ||
pattern += (typeof arg === 'string') ? arg : arg.source; | ||
} | ||
return new RegExp(pattern); | ||
}; | ||
if (match = stream.match(RE("type"))) | ||
type = match[0]; | ||
else | ||
return (state.mode = Modes.text)(stream, state); | ||
RegExpFactory.prototype.choiceRe = function() { | ||
var parts = [arguments[0]], | ||
i; | ||
for (i = 1; i < arguments.length; ++i) { | ||
parts[i * 2 - 1] = '|'; | ||
parts[i * 2] = arguments[i]; | ||
} | ||
parts.unshift('(?:'); | ||
parts.push(')'); | ||
return this.makeRe.apply(this, parts); | ||
}; | ||
var Modes = { | ||
newLayout: function() { | ||
if (this.check('typeLayout')) { | ||
this.state.spanningLayout = false; | ||
return this.execMode(Modes.blockType); | ||
} | ||
if (!this.textileDisabled()) { | ||
if (this.check('listLayout')) { | ||
return this.execMode(Modes.list); | ||
} else if (this.check('drawTable')) { | ||
return this.execMode(Modes.table); | ||
} else if (this.check('linkDefinition')) { | ||
return this.execMode(Modes.linkDefinition); | ||
} else if (this.check('definitionList')) { | ||
return this.execMode(Modes.definitionList); | ||
} else if (this.check('html')) { | ||
return this.execMode(Modes.html); | ||
if (match = type.match(RE("header"))) { | ||
state.layoutType = "header"; | ||
state.header = parseInt(match[0][1]); | ||
} else if (type.match(RE("bq"))) { | ||
state.layoutType = "quote"; | ||
} else if (type.match(RE("bc"))) { | ||
state.layoutType = "code"; | ||
} else if (type.match(RE("foot"))) { | ||
state.layoutType = "footnote"; | ||
} else if (type.match(RE("notextile"))) { | ||
state.layoutType = "notextile"; | ||
} else if (type.match(RE("pre"))) { | ||
state.layoutType = "pre"; | ||
} else if (type.match(RE("div"))) { | ||
state.layoutType = "div"; | ||
} else if (type.match(RE("table"))) { | ||
state.layoutType = "table"; | ||
} | ||
} | ||
return this.execMode(Modes.text); | ||
}, | ||
blockType: function() { | ||
var match, | ||
type; | ||
this.state.layoutType = null; | ||
state.mode = Modes.attributes; | ||
return tokenStyles(state); | ||
}, | ||
if (match = this.eat('type')) { | ||
type = match[0]; | ||
} else { | ||
return this.execMode(Modes.text); | ||
} | ||
text: function(stream, state) { | ||
if (stream.match(RE("text"))) return tokenStyles(state); | ||
if(match = type.match(this.regExpFactory.pattern('header'))) { | ||
this.state.layoutType = 'header'; | ||
this.state.header = parseInt(match[0][1]); | ||
} else if (type.match(this.regExpFactory.pattern('bq'))) { | ||
this.state.layoutType = 'quote'; | ||
} else if (type.match(this.regExpFactory.pattern('bc'))) { | ||
this.state.layoutType = 'code'; | ||
} else if (type.match(this.regExpFactory.pattern('foot'))) { | ||
this.state.layoutType = 'footnote'; | ||
} else if (type.match(this.regExpFactory.pattern('notextile'))) { | ||
this.state.layoutType = 'notextile'; | ||
} else if (type.match(this.regExpFactory.pattern('pre'))) { | ||
this.state.layoutType = 'pre'; | ||
} else if (type.match(this.regExpFactory.pattern('div'))) { | ||
this.state.layoutType = 'div'; | ||
} else if (type.match(this.regExpFactory.pattern('table'))) { | ||
this.state.layoutType = 'table'; | ||
} | ||
var ch = stream.next(); | ||
if (ch === '"') | ||
return (state.mode = Modes.link)(stream, state); | ||
return handlePhraseModifier(stream, state, ch); | ||
}, | ||
this.setModeForNextToken(Modes.attributes); | ||
return this.tokenStyles(); | ||
}, | ||
attributes: function(stream, state) { | ||
state.mode = Modes.layoutLength; | ||
text: function() { | ||
if (this.eat('text')) { | ||
return this.tokenStyles(); | ||
} | ||
if (stream.match(RE("attributes"))) | ||
return tokenStylesWith(state, TOKEN_STYLES.attributes); | ||
else | ||
return tokenStyles(state); | ||
}, | ||
var ch = this.stream.next(); | ||
layoutLength: function(stream, state) { | ||
if (stream.eat(".") && stream.eat(".")) | ||
state.spanningLayout = true; | ||
if (ch === '"') { | ||
return this.execMode(Modes.link); | ||
} | ||
return this.handlePhraseModifier(ch); | ||
}, | ||
state.mode = Modes.text; | ||
return tokenStyles(state); | ||
}, | ||
attributes: function() { | ||
this.setModeForNextToken(Modes.layoutLength); | ||
list: function(stream, state) { | ||
var match = stream.match(RE("list")); | ||
state.listDepth = match[0].length; | ||
var listMod = (state.listDepth - 1) % 3; | ||
if (!listMod) | ||
state.layoutType = "list1"; | ||
else if (listMod === 1) | ||
state.layoutType = "list2"; | ||
else | ||
state.layoutType = "list3"; | ||
if (this.eat('attributes')) { | ||
return this.tokenStylesWith(this.styleFor('attributes')); | ||
} | ||
return this.tokenStyles(); | ||
}, | ||
state.mode = Modes.attributes; | ||
return tokenStyles(state); | ||
}, | ||
layoutLength: function() { | ||
if (this.stream.eat('.') && this.stream.eat('.')) { | ||
this.state.spanningLayout = true; | ||
} | ||
link: function(stream, state) { | ||
state.mode = Modes.text; | ||
if (stream.match(RE("link"))) { | ||
stream.match(/\S+/); | ||
return tokenStylesWith(state, TOKEN_STYLES.link); | ||
} | ||
return tokenStyles(state); | ||
}, | ||
this.setModeForNextToken(Modes.text); | ||
return this.tokenStyles(); | ||
}, | ||
linkDefinition: function(stream, state) { | ||
stream.skipToEnd(); | ||
return tokenStylesWith(state, TOKEN_STYLES.linkDefinition); | ||
}, | ||
list: function() { | ||
var match = this.eat('list'), | ||
listMod; | ||
this.state.listDepth = match[0].length; | ||
listMod = (this.state.listDepth - 1) % 3; | ||
if (!listMod) { | ||
this.state.layoutType = 'list1'; | ||
} else if (listMod === 1) { | ||
this.state.layoutType = 'list2'; | ||
} else { | ||
this.state.layoutType = 'list3'; | ||
} | ||
this.setModeForNextToken(Modes.attributes); | ||
return this.tokenStyles(); | ||
}, | ||
definitionList: function(stream, state) { | ||
stream.match(RE("definitionList")); | ||
link: function() { | ||
this.setModeForNextToken(Modes.text); | ||
if (this.eat('link')) { | ||
this.stream.match(/\S+/); | ||
return this.tokenStylesWith(this.styleFor('link')); | ||
} | ||
return this.tokenStyles(); | ||
}, | ||
state.layoutType = "definitionList"; | ||
linkDefinition: function() { | ||
this.stream.skipToEnd(); | ||
return this.tokenStylesWith(this.styleFor('linkDefinition')); | ||
}, | ||
if (stream.match(/\s*$/)) | ||
state.spanningLayout = true; | ||
else | ||
state.mode = Modes.attributes; | ||
definitionList: function() { | ||
this.eat('definitionList'); | ||
return tokenStyles(state); | ||
}, | ||
this.state.layoutType = 'definitionList'; | ||
html: function(stream, state) { | ||
stream.skipToEnd(); | ||
return tokenStylesWith(state, TOKEN_STYLES.html); | ||
}, | ||
if (this.stream.match(/\s*$/)) { | ||
this.state.spanningLayout = true; | ||
} else { | ||
this.setModeForNextToken(Modes.attributes); | ||
} | ||
return this.tokenStyles(); | ||
}, | ||
table: function(stream, state) { | ||
state.layoutType = "table"; | ||
return (state.mode = Modes.tableCell)(stream, state); | ||
}, | ||
html: function() { | ||
this.stream.skipToEnd(); | ||
return this.tokenStylesWith(this.styleFor('html')); | ||
}, | ||
tableCell: function(stream, state) { | ||
if (stream.match(RE("tableHeading"))) | ||
state.tableHeading = true; | ||
else | ||
stream.eat("|"); | ||
table: function() { | ||
this.state.layoutType = 'table'; | ||
return this.execMode(Modes.tableCell); | ||
}, | ||
state.mode = Modes.tableCellAttributes; | ||
return tokenStyles(state); | ||
}, | ||
tableCell: function() { | ||
if (this.eat('tableHeading')) { | ||
this.state.tableHeading = true; | ||
} else { | ||
this.stream.eat('|'); | ||
} | ||
this.setModeForNextToken(Modes.tableCellAttributes); | ||
return this.tokenStyles(); | ||
}, | ||
tableCellAttributes: function(stream, state) { | ||
state.mode = Modes.tableText; | ||
tableCellAttributes: function() { | ||
this.setModeForNextToken(Modes.tableText); | ||
if (stream.match(RE("tableCellAttributes"))) | ||
return tokenStylesWith(state, TOKEN_STYLES.attributes); | ||
else | ||
return tokenStyles(state); | ||
}, | ||
if (this.eat('tableCellAttributes')) { | ||
return this.tokenStylesWith(this.styleFor('attributes')); | ||
} | ||
return this.tokenStyles(); | ||
}, | ||
tableText: function(stream, state) { | ||
if (stream.match(RE("tableText"))) | ||
return tokenStyles(state); | ||
tableText: function() { | ||
if (this.eat('tableText')) { | ||
return this.tokenStyles(); | ||
if (stream.peek() === "|") { // end of cell | ||
state.mode = Modes.tableCell; | ||
return tokenStyles(state); | ||
} | ||
return handlePhraseModifier(stream, state, stream.next()); | ||
} | ||
}; | ||
if (this.stream.peek() === '|') { // end of cell | ||
this.setModeForNextToken(Modes.tableCell); | ||
return this.tokenStyles(); | ||
} | ||
return this.handlePhraseModifier(this.stream.next()); | ||
} | ||
}; | ||
CodeMirror.defineMode("textile", function() { | ||
return { | ||
startState: function() { | ||
return { mode: Modes.newLayout }; | ||
}, | ||
token: function(stream, state) { | ||
if (stream.sol()) startNewLine(stream, state); | ||
return state.mode(stream, state); | ||
}, | ||
blankLine: blankLine | ||
}; | ||
}); | ||
CodeMirror.defineMode('textile', function() { | ||
var regExpFactory = new RegExpFactory(); | ||
return { | ||
startState: function() { | ||
return { mode: Modes.newLayout }; | ||
}, | ||
token: function(stream, state) { | ||
var parser = new Parser(regExpFactory, state, stream); | ||
if (stream.sol()) { parser.startNewLine(); } | ||
return parser.nextToken(); | ||
}, | ||
blankLine: function(state) { | ||
new Parser(regExpFactory, state).blankLine(); | ||
} | ||
}; | ||
CodeMirror.defineMIME("text/x-textile", "textile"); | ||
}); | ||
CodeMirror.defineMIME('text/x-textile', 'textile'); | ||
}); |
@@ -154,3 +154,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
return context.indent + (closing ? 0 : indentUnit); | ||
} | ||
}, | ||
lineComment: "#" | ||
}; | ||
@@ -157,0 +159,0 @@ }); |
{ | ||
"name": "codemirror", | ||
"version":"4.8.0", | ||
"version":"4.9.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
@@ -131,2 +131,5 @@ (function() { | ||
sim("delRegion", "abcde", "Ctrl-Space", "Ctrl-F", "Ctrl-F", "Delete", txt("cde")); | ||
sim("backspaceRegion", "abcde", "Ctrl-Space", "Ctrl-F", "Ctrl-F", "Backspace", txt("cde")); | ||
testCM("save", function(cm) { | ||
@@ -133,0 +136,0 @@ var saved = false; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3082543
397
53965