codemirror
Advanced tools
Comparing version 3.21.0 to 3.22.0
(function() { | ||
var modes = ["clike", "css", "javascript"]; | ||
for (var i = 0; i < modes.length; ++i) | ||
@@ -15,3 +16,3 @@ CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "}); | ||
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found; | ||
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) { | ||
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) { | ||
// Comment ended, don't continue it | ||
@@ -31,3 +32,3 @@ } else if (token.string.indexOf(mode.blockCommentStart) == 0) { | ||
} | ||
if (insert == null && mode.lineComment) { | ||
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) { | ||
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment); | ||
@@ -47,2 +48,9 @@ if (found > -1) { | ||
function continueLineCommentEnabled(cm) { | ||
var opt = cm.getOption("continueComments"); | ||
if (opt && typeof opt == "object") | ||
return opt.continueLineComment !== false; | ||
return true; | ||
} | ||
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) { | ||
@@ -52,4 +60,9 @@ if (prev && prev != CodeMirror.Init) | ||
if (val) { | ||
var key = "Enter"; | ||
if (typeof val == "string") | ||
key = val; | ||
else if (typeof val == "object" && val.key) | ||
key = val.key; | ||
var map = {name: "continueComment"}; | ||
map[typeof val == "string" ? val : "Enter"] = continueComment; | ||
map[key] = continueComment; | ||
cm.addKeyMap(map); | ||
@@ -56,0 +69,0 @@ } |
@@ -42,2 +42,3 @@ // Open simple dialogs on top of an editor. Relies on dialog.css. | ||
if (e.keyCode == 13 || e.keyCode == 27) { | ||
inp.blur(); | ||
CodeMirror.e_stop(e); | ||
@@ -44,0 +45,0 @@ close(); |
@@ -85,2 +85,3 @@ /** | ||
if (tagName) cm.replaceSelection("/" + tagName + ">", "end"); | ||
else return CodeMirror.Pass; | ||
} | ||
@@ -87,0 +88,0 @@ |
@@ -65,2 +65,8 @@ (function() { | ||
CodeMirror.defineExtension("isFolded", function(pos) { | ||
var marks = this.findMarksAt(pos); | ||
for (var i = 0; i < marks.length; ++i) | ||
if (marks[i].__isFold) return true; | ||
}); | ||
CodeMirror.commands.fold = function(cm) { | ||
@@ -67,0 +73,0 @@ cm.foldCode(cm.getCursor()); |
@@ -18,4 +18,4 @@ (function() { | ||
for (var dir = -1; dir <= 1; dir += 2) { | ||
var line = cur.line, end = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; | ||
for (; line != end; line += dir) { | ||
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; | ||
for (; line != endLine; line += dir) { | ||
var text = editor.getLine(line), m; | ||
@@ -22,0 +22,0 @@ while (m = re.exec(text)) { |
@@ -49,3 +49,3 @@ (function() { | ||
if (completion.hint) completion.hint(this.cm, data, completion); | ||
else this.cm.replaceRange(getText(completion), data.from, data.to); | ||
else this.cm.replaceRange(getText(completion), completion.from||data.from, completion.to||data.to); | ||
CodeMirror.signal(data, "pick", completion); | ||
@@ -197,4 +197,20 @@ this.close(); | ||
(options.container || document.body).appendChild(hints); | ||
var box = hints.getBoundingClientRect(); | ||
var overlapX = box.right - winW, overlapY = box.bottom - winH; | ||
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; | ||
if (overlapY > 0) { | ||
var height = box.bottom - box.top, curTop = box.top - (pos.bottom - pos.top); | ||
if (curTop - height > 0) { // Fits above cursor | ||
hints.style.top = (top = curTop - height) + "px"; | ||
below = false; | ||
} else if (height > winH) { | ||
hints.style.height = (winH - 5) + "px"; | ||
hints.style.top = (top = pos.bottom - box.top) + "px"; | ||
var cursor = cm.getCursor(); | ||
if (data.from.ch != cursor.ch) { | ||
pos = cm.cursorCoords(cursor); | ||
hints.style.left = (left = pos.left) + "px"; | ||
box = hints.getBoundingClientRect(); | ||
} | ||
} | ||
} | ||
var overlapX = box.left - winW; | ||
if (overlapX > 0) { | ||
@@ -207,13 +223,2 @@ if (box.right - box.left > winW) { | ||
} | ||
if (overlapY > 0) { | ||
var height = box.bottom - box.top; | ||
if (box.top - (pos.bottom - pos.top) - height > 0) { | ||
overlapY = height + (pos.bottom - pos.top); | ||
below = false; | ||
} else if (height > winH) { | ||
hints.style.height = (winH - 5) + "px"; | ||
overlapY -= height - winH; | ||
} | ||
hints.style.top = (top = pos.bottom - overlapY) + "px"; | ||
} | ||
@@ -226,3 +231,4 @@ cm.addKeyMap(this.keyMap = buildKeyMap(options, { | ||
close: function() { completion.close(); }, | ||
pick: function() { widget.pick(); } | ||
pick: function() { widget.pick(); }, | ||
data: data | ||
})); | ||
@@ -310,3 +316,3 @@ | ||
CodeMirror.registerHelper("hint", "auto", function(cm, options) { | ||
var helpers = cm.getHelpers(cm.getCursor(), "hint"); | ||
var helpers = cm.getHelpers(cm.getCursor(), "hint"), words; | ||
if (helpers.length) { | ||
@@ -317,5 +323,6 @@ for (var i = 0; i < helpers.length; i++) { | ||
} | ||
} else { | ||
var words = cm.getHelper(cm.getCursor(), "hintWords"); | ||
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) { | ||
if (words) return CodeMirror.hint.fromList(cm, {words: words}); | ||
} else if (CodeMirror.hint.anyword) { | ||
return CodeMirror.hint.anyword(cm, options); | ||
} | ||
@@ -322,0 +329,0 @@ }); |
@@ -50,2 +50,2 @@ // From https://code.google.com/p/google-diff-match-patch/ , licensed under the Apache License 2.0 | ||
diff_match_patch.patch_obj.prototype.toString=function(){var a,b;a=0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1;b=0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2;a=["@@ -"+a+" +"+b+" @@\n"];var c;for(b=0;b<this.diffs.length;b++){switch(this.diffs[b][0]){case 1:c="+";break;case -1:c="-";break;case 0:c=" "}a[b+1]=c+encodeURI(this.diffs[b][1])+"\n"}return a.join("").replace(/%20/g," ")}; | ||
this.diff_match_patch=diff_match_patch;this.DIFF_DELETE=-1;this.DIFF_INSERT=1;this.DIFF_EQUAL=0;})() | ||
this.diff_match_patch=diff_match_patch;this.DIFF_DELETE=-1;this.DIFF_INSERT=1;this.DIFF_EQUAL=0;})(); |
@@ -95,3 +95,3 @@ /* Just enough of CodeMirror to run runMode under node.js */ | ||
exports.getMode = function(options, spec) { | ||
spec = exports.resolveMode(mimeModes[spec]); | ||
spec = exports.resolveMode(spec); | ||
var mfactory = modes[spec.name]; | ||
@@ -103,3 +103,3 @@ if (!mfactory) throw new Error("Unknown mode: " + spec); | ||
exports.runMode = function(string, modespec, callback) { | ||
exports.runMode = function(string, modespec, callback, options) { | ||
var mode = exports.getMode({indentUnit: 2}, modespec); | ||
@@ -106,0 +106,0 @@ var lines = splitLines(string), state = (options && options.state) || exports.startState(mode); |
@@ -7,2 +7,3 @@ (function() { | ||
cm.off("change", onChange); | ||
cm.off("refresh", updateBottomMargin); | ||
cm.display.lineSpace.parentNode.style.paddingBottom = ""; | ||
@@ -13,2 +14,3 @@ cm.state.scrollPastEndPadding = null; | ||
cm.on("change", onChange); | ||
cm.on("refresh", updateBottomMargin); | ||
updateBottomMargin(cm); | ||
@@ -15,0 +17,0 @@ } |
@@ -59,3 +59,9 @@ // Define search commands. Depends on dialog.js or another | ||
var isRE = query.match(/^\/(.*)\/([a-z]*)$/); | ||
return isRE ? new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i") : query; | ||
if (isRE) { | ||
query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); | ||
if (query.test("")) query = /x^/; | ||
} else if (query == "") { | ||
query = /x^/; | ||
} | ||
return query; | ||
} | ||
@@ -111,3 +117,3 @@ var queryDialog = | ||
var match = cm.getRange(cursor.from(), cursor.to()).match(query); | ||
cursor.replace(text.replace(/\$(\d)/, function(_, i) {return match[i];})); | ||
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); | ||
} else cursor.replace(text); | ||
@@ -133,3 +139,3 @@ } | ||
cursor.replace(typeof query == "string" ? text : | ||
text.replace(/\$(\d)/, function(_, i) {return match[i];})); | ||
text.replace(/\$(\d)/g, function(_, i) {return match[i];})); | ||
advance(); | ||
@@ -136,0 +142,0 @@ }; |
@@ -5,6 +5,7 @@ /** | ||
*/ | ||
CodeMirror.defineMode("clojure", function () { | ||
CodeMirror.defineMode("clojure", function (options) { | ||
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2", | ||
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword"; | ||
var INDENT_WORD_SKIP = 2; | ||
var INDENT_WORD_SKIP = options.indentUnit || 2; | ||
var NORMAL_INDENT_UNIT = options.indentUnit || 2; | ||
@@ -48,3 +49,3 @@ function makeKeywords(str) { | ||
keyword_char: /[^\s\(\[\;\)\]]/, | ||
symbol: /[\w*+!\-\._?:\/]/ | ||
symbol: /[\w*+!\-\._?:<>\/]/ | ||
}; | ||
@@ -184,4 +185,4 @@ | ||
// nothing significant after | ||
// we restart indentation 1 space after | ||
pushStack(state, indentTemp + 1, ch); | ||
// we restart indentation the user defined spaces after | ||
pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch); | ||
} else { | ||
@@ -188,0 +189,0 @@ pushStack(state, indentTemp + stream.current().length, ch); // else we match |
@@ -143,2 +143,4 @@ CodeMirror.defineMode("css", function(config, parserConfig) { | ||
return "font_face_before"; | ||
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) { | ||
return "keyframes"; | ||
} else if (type && type.charAt(0) == "@") { | ||
@@ -268,2 +270,8 @@ return pushContext(state, stream, "at"); | ||
states.keyframes = function(type, stream, state) { | ||
if (type == "word") { override = "variable"; return "keyframes"; } | ||
if (type == "{") return pushContext(state, stream, "top"); | ||
return pass(type, stream, state); | ||
}; | ||
states.at = function(type, stream, state) { | ||
@@ -313,2 +321,3 @@ if (type == ";") return popContext(state); | ||
var indent = cx.indent; | ||
if (cx.type == "prop" && ch == "}") cx = cx.prev; | ||
if (cx.prev && | ||
@@ -359,6 +368,6 @@ (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") || | ||
"alignment-baseline", "anchor-point", "animation", "animation-delay", | ||
"animation-direction", "animation-duration", "animation-iteration-count", | ||
"animation-name", "animation-play-state", "animation-timing-function", | ||
"appearance", "azimuth", "backface-visibility", "background", | ||
"background-attachment", "background-clip", "background-color", | ||
"animation-direction", "animation-duration", "animation-fill-mode", | ||
"animation-iteration-count", "animation-name", "animation-play-state", | ||
"animation-timing-function", "appearance", "azimuth", "backface-visibility", | ||
"background", "background-attachment", "background-clip", "background-color", | ||
"background-image", "background-origin", "background-position", | ||
@@ -394,6 +403,7 @@ "background-repeat", "background-size", "baseline-shift", "binding", | ||
"font-variant-ligatures", "font-variant-numeric", "font-variant-position", | ||
"font-weight", "grid-cell", "grid-column", "grid-column-align", | ||
"grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow", | ||
"grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span", | ||
"grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens", | ||
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", | ||
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end", | ||
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start", | ||
"grid-template", "grid-template-areas", "grid-template-columns", | ||
"grid-template-rows", "hanging-punctuation", "height", "hyphens", | ||
"icon", "image-orientation", "image-rendering", "image-resolution", | ||
@@ -675,3 +685,3 @@ "inline-box-align", "justify-content", "left", "letter-spacing", | ||
"@": function(stream) { | ||
if (stream.match(/^(charset|document|font-face|import|keyframes|media|namespace|page|supports)\b/, false)) return false; | ||
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false; | ||
stream.eatWhile(/[\w\\\-]/); | ||
@@ -678,0 +688,0 @@ if (stream.match(/^\s*:/, false)) |
@@ -214,3 +214,3 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) { | ||
var arch = parserConfig.architecture.toLowerCase(); | ||
var arch = (parserConfig.architecture || "x86").toLowerCase(); | ||
if (arch === "x86") { | ||
@@ -217,0 +217,0 @@ x86(parserConfig); |
CodeMirror.defineMode("htmlmixed", function(config, parserConfig) { | ||
var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true}); | ||
var htmlMode = CodeMirror.getMode(config, {name: "xml", | ||
htmlMode: true, | ||
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, | ||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag}); | ||
var cssMode = CodeMirror.getMode(config, "css"); | ||
@@ -4,0 +7,0 @@ |
@@ -6,3 +6,4 @@ // TODO actually recognize syntax of TypeScript constructs | ||
var statementIndent = parserConfig.statementIndent; | ||
var jsonMode = parserConfig.json; | ||
var jsonldMode = parserConfig.jsonld; | ||
var jsonMode = parserConfig.json || jsonldMode; | ||
var isTS = parserConfig.typescript; | ||
@@ -57,2 +58,3 @@ | ||
var isOperatorChar = /[+\-*&%=<>!?|~^]/; | ||
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/; | ||
@@ -133,2 +135,6 @@ function readRegexp(stream) { | ||
var escaped = false, next; | ||
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){ | ||
state.tokenize = tokenBase; | ||
return ret("jsonld-keyword", "meta"); | ||
} | ||
while ((next = stream.next()) != null) { | ||
@@ -201,3 +207,3 @@ if (next == quote && !escaped) break; | ||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true}; | ||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true}; | ||
@@ -415,3 +421,3 @@ function JSLexical(indented, column, type, align, prev, info) { | ||
} else if (type == "number" || type == "string") { | ||
cx.marked = type + " property"; | ||
cx.marked = jsonldMode ? "property" : (type + " property"); | ||
} else if (type == "[") { | ||
@@ -624,2 +630,3 @@ return cont(expression, expect("]"), afterprop); | ||
helperType: jsonMode ? "json" : "javascript", | ||
jsonldMode: jsonldMode, | ||
jsonMode: jsonMode | ||
@@ -635,3 +642,4 @@ }; | ||
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); | ||
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); | ||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); | ||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); |
@@ -113,2 +113,40 @@ (function() { | ||
"[string-2 /foo[[/]]bar/];"); | ||
var jsonld_mode = CodeMirror.getMode( | ||
{indentUnit: 2}, | ||
{name: "javascript", jsonld: true} | ||
); | ||
function LD(name) { | ||
test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1)); | ||
} | ||
LD("json_ld_keywords", | ||
'{', | ||
' [meta "@context"]: {', | ||
' [meta "@base"]: [string "http://example.com"],', | ||
' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],', | ||
' [property "likesFlavor"]: {', | ||
' [meta "@container"]: [meta "@list"]', | ||
' [meta "@reverse"]: [string "@beFavoriteOf"]', | ||
' },', | ||
' [property "nick"]: { [meta "@container"]: [meta "@set"] },', | ||
' [property "nick"]: { [meta "@container"]: [meta "@index"] }', | ||
' },', | ||
' [meta "@graph"]: [[ {', | ||
' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],', | ||
' [property "name"]: [string "John Lennon"],', | ||
' [property "modified"]: {', | ||
' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],', | ||
' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]', | ||
' }', | ||
' } ]]', | ||
'}'); | ||
LD("json_ld_fake", | ||
'{', | ||
' [property "@fake"]: [string "@fake"],', | ||
' [property "@contextual"]: [string "@identifier"],', | ||
' [property "user@domain.com"]: [string "@graphical"],', | ||
' [property "@ID"]: [string "@@ID"]', | ||
'}'); | ||
})(); |
@@ -8,12 +8,12 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) { | ||
var operators = parserConf.operators || /^(?:\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|<:|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b|\.{3})/; | ||
var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b/; | ||
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/; | ||
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*!*/; | ||
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch"]; | ||
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"]; | ||
var blockClosers = ["end", "else", "elseif", "catch", "finally"]; | ||
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype', 'ccall']; | ||
var builtinList = ['true', 'false', 'enumerate', 'open', 'close', 'nothing', 'NaN', 'Inf', 'print', 'println', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Int64', 'Uint64', 'Int128', 'Uint128', 'Bool', 'Char', 'Float16', 'Float32', 'Float64', 'Array', 'Vector', 'Matrix', 'String', 'UTF8String', 'ASCIIString', 'error', 'warn', 'info', '@printf']; | ||
var builtinList = ['true', 'false', 'enumerate', 'open', 'close', 'nothing', 'NaN', 'Inf', 'print', 'println', 'Int', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Int64', 'Uint64', 'Int128', 'Uint128', 'Bool', 'Char', 'Float16', 'Float32', 'Float64', 'Array', 'Vector', 'Matrix', 'String', 'UTF8String', 'ASCIIString', 'error', 'warn', 'info', '@printf']; | ||
//var stringPrefixes = new RegExp("^[br]?('|\")") | ||
var stringPrefixes = /^[br]?('|"{3}|")/; | ||
var stringPrefixes = /^(`|'|"{3}|([br]?"))/; | ||
var keywords = wordRegexp(keywordList); | ||
@@ -23,3 +23,4 @@ var builtins = wordRegexp(builtinList); | ||
var closers = wordRegexp(blockClosers); | ||
var macro = /@[_A-Za-z][_A-Za-z0-9]*!*/; | ||
var macro = /^@[_A-Za-z][_A-Za-z0-9]*/; | ||
var symbol = /^:[_A-Za-z][_A-Za-z0-9]*/; | ||
var indentInfo = null; | ||
@@ -48,2 +49,5 @@ | ||
var leaving_expr = state.leaving_expr; | ||
if(stream.sol()) { | ||
leaving_expr = false; | ||
} | ||
state.leaving_expr = false; | ||
@@ -54,7 +58,9 @@ if(leaving_expr) { | ||
} | ||
if(stream.match("...")) { | ||
return 'operator'; | ||
} | ||
} | ||
if(stream.match(/^\.{2,3}/)) { | ||
return 'operator'; | ||
} | ||
if (stream.eatSpace()) { | ||
@@ -90,4 +96,8 @@ return null; | ||
if(ch===')') { | ||
state.leaving_expr = true; | ||
} | ||
var match; | ||
if(match=stream.match(openers, false)) { | ||
if(!in_array(state) && (match=stream.match(openers, false))) { | ||
state.scopes.push(match); | ||
@@ -101,3 +111,3 @@ } | ||
if(in_array(state)) { | ||
if(stream.match("end")) { | ||
if(stream.match(/^end/)) { | ||
return 'number'; | ||
@@ -107,5 +117,8 @@ } | ||
} | ||
if(stream.match("=>")) { | ||
if(stream.match(/^=>/)) { | ||
return 'operator'; | ||
} | ||
// Handle Number Literals | ||
@@ -116,4 +129,4 @@ if (stream.match(/^[0-9\.]/, false)) { | ||
// Floats | ||
if (stream.match(/^\d*\.\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; } | ||
if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; } | ||
if (stream.match(/^\d*\.(?!\.)\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; } | ||
if (stream.match(/^\d+\.(?!\.)\d*/)) { floatLiteral = true; } | ||
if (stream.match(/^\.\d+/)) { floatLiteral = true; } | ||
@@ -123,2 +136,3 @@ if (floatLiteral) { | ||
stream.match(imMatcher); | ||
state.leaving_expr = true; | ||
return 'number'; | ||
@@ -136,5 +150,2 @@ } | ||
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { | ||
// Decimal literals may be "imaginary" | ||
stream.eat(/J/i); | ||
// TODO - Can you have imaginary longs? | ||
intLiteral = true; | ||
@@ -147,2 +158,3 @@ } | ||
stream.match(imMatcher); | ||
state.leaving_expr = true; | ||
return 'number'; | ||
@@ -152,2 +164,17 @@ } | ||
if(stream.match(/^(::)|(<:)/)) { | ||
return 'operator'; | ||
} | ||
// Handle symbols | ||
if(!leaving_expr && stream.match(symbol)) { | ||
return 'string'; | ||
} | ||
// Handle operators and Delimiters | ||
if (stream.match(operators)) { | ||
return 'operator'; | ||
} | ||
// Handle Strings | ||
@@ -159,7 +186,7 @@ if (stream.match(stringPrefixes)) { | ||
// Handle operators and Delimiters | ||
if (stream.match(operators)) { | ||
return 'operator'; | ||
if (stream.match(macro)) { | ||
return 'meta'; | ||
} | ||
if (stream.match(delimiters)) { | ||
@@ -177,5 +204,2 @@ return null; | ||
if (stream.match(macro)) { | ||
return 'meta'; | ||
} | ||
@@ -265,3 +289,3 @@ if (stream.match(identifiers)) { | ||
} | ||
return (state.scopes.length + delta) * 2; | ||
return (state.scopes.length + delta) * 4; | ||
}, | ||
@@ -268,0 +292,0 @@ |
@@ -242,3 +242,3 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { | ||
if (state.formatting[i] === "header") { | ||
styles.push(formatting + "-" + state.formatting[i] + state.header); | ||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header); | ||
} | ||
@@ -279,3 +279,3 @@ | ||
if (state.header) { styles.push(header); styles.push(header + state.header); } | ||
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); } | ||
@@ -743,3 +743,5 @@ if (state.quote) { | ||
getType: getType | ||
getType: getType, | ||
fold: "markdown" | ||
}; | ||
@@ -746,0 +748,0 @@ return mode; |
@@ -26,7 +26,7 @@ (function() { | ||
FT("formatting_atxHeader", | ||
"[header&header1&formatting&formatting-header&formatting-header1 #][header&header1 foo # bar ][header&header1&formatting&formatting-header&formatting-header1 #]"); | ||
"[header&header-1&formatting&formatting-header&formatting-header-1 #][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]"); | ||
FT("formatting_setextHeader", | ||
"foo", | ||
"[header&header1&formatting&formatting-header&formatting-header1 =]"); | ||
"[header&header-1&formatting&formatting-header&formatting-header-1 =]"); | ||
@@ -142,18 +142,18 @@ FT("formatting_blockquote", | ||
MT("atxH1", | ||
"[header&header1 # foo]"); | ||
"[header&header-1 # foo]"); | ||
MT("atxH2", | ||
"[header&header2 ## foo]"); | ||
"[header&header-2 ## foo]"); | ||
MT("atxH3", | ||
"[header&header3 ### foo]"); | ||
"[header&header-3 ### foo]"); | ||
MT("atxH4", | ||
"[header&header4 #### foo]"); | ||
"[header&header-4 #### foo]"); | ||
MT("atxH5", | ||
"[header&header5 ##### foo]"); | ||
"[header&header-5 ##### foo]"); | ||
MT("atxH6", | ||
"[header&header6 ###### foo]"); | ||
"[header&header-6 ###### foo]"); | ||
@@ -163,7 +163,7 @@ // H6 - 7x '#' should still be H6, per Dingus | ||
MT("atxH6NotH7", | ||
"[header&header6 ####### foo]"); | ||
"[header&header-6 ####### foo]"); | ||
// Inline styles should be parsed inside headers | ||
MT("atxH1inline", | ||
"[header&header1 # foo ][header&header1&em *bar*]"); | ||
"[header&header-1 # foo ][header&header-1&em *bar*]"); | ||
@@ -180,3 +180,3 @@ // Setext headers - H1, H2 | ||
"foo", | ||
"[header&header1 =]"); | ||
"[header&header-1 =]"); | ||
@@ -186,3 +186,3 @@ // Check if 3+ ='s work | ||
"foo", | ||
"[header&header1 ===]"); | ||
"[header&header-1 ===]"); | ||
@@ -192,3 +192,3 @@ // Check if single underlining - works | ||
"foo", | ||
"[header&header2 -]"); | ||
"[header&header-2 -]"); | ||
@@ -198,3 +198,3 @@ // Check if 3+ -'s work | ||
"foo", | ||
"[header&header2 ---]"); | ||
"[header&header-2 ---]"); | ||
@@ -288,3 +288,3 @@ // Single-line blockquote with trailing space | ||
MT("listAfterHeader", | ||
"[header&header1 # foo]", | ||
"[header&header-1 # foo]", | ||
"[variable-2 - bar]"); | ||
@@ -291,0 +291,0 @@ |
@@ -39,2 +39,3 @@ CodeMirror.modeInfo = [ | ||
{name: 'JSON', mime: 'application/json', mode: 'javascript'}, | ||
{name: 'JSON-LD', mime: 'application/ld+json', mode: 'javascript'}, | ||
{name: 'TypeScript', mime: 'application/typescript', mode: 'javascript'}, | ||
@@ -61,2 +62,3 @@ {name: 'Jinja2', mime: null, mode: 'jinja2'}, | ||
{name: 'Python', mime: 'text/x-python', mode: 'python'}, | ||
{name: 'Puppet', mime: 'text/x-puppet', mode: 'puppet'}, | ||
{name: 'Cython', mime: 'text/x-cython', mode: 'python'}, | ||
@@ -75,2 +77,3 @@ {name: 'R', mime: 'text/x-rsrc', mode: 'r'}, | ||
{name: 'SmartyMixed', mime: 'text/x-smarty', mode: 'smartymixed'}, | ||
{name: 'Solr', mime: 'text/x-solr', mode: 'solr'}, | ||
{name: 'SPARQL', mime: 'application/x-sparql-query', mode: 'sparql'}, | ||
@@ -77,0 +80,0 @@ {name: 'SQL', mime: 'text/x-sql', mode: 'sql'}, |
@@ -16,7 +16,8 @@ CodeMirror.defineMode("octave", function() { | ||
'error', 'eval', 'function', 'abs', 'acos', 'atan', 'asin', 'cos', | ||
'cosh', 'exp', 'log', 'prod', 'log10', 'max', 'min', 'sign', 'sin', 'sinh', | ||
'cosh', 'exp', 'log', 'prod', 'sum', 'log10', 'max', 'min', 'sign', 'sin', 'sinh', | ||
'sqrt', 'tan', 'reshape', 'break', 'zeros', 'default', 'margin', 'round', 'ones', | ||
'rand', 'syn', 'ceil', 'floor', 'size', 'clear', 'zeros', 'eye', 'mean', 'std', 'cov', | ||
'det', 'eig', 'inv', 'norm', 'rank', 'trace', 'expm', 'logm', 'sqrtm', 'linspace', 'plot', | ||
'title', 'xlabel', 'ylabel', 'legend', 'text', 'meshgrid', 'mesh', 'num2str' | ||
'title', 'xlabel', 'ylabel', 'legend', 'text', 'grid', 'meshgrid', 'mesh', 'num2str', | ||
'fft', 'ifft', 'arrayfun', 'cellfun', 'input', 'fliplr', 'flipud', 'ismember' | ||
]); | ||
@@ -27,3 +28,4 @@ | ||
'if', 'otherwise', 'do', 'for', 'while', 'try', 'catch', 'classdef', 'properties', 'events', | ||
'methods', 'global', 'persistent', 'endfor', 'endwhile', 'printf', 'disp', 'until', 'continue' | ||
'methods', 'global', 'persistent', 'endfor', 'endwhile', 'printf', 'sprintf', 'disp', 'until', | ||
'continue', 'pkg' | ||
]); | ||
@@ -64,3 +66,3 @@ | ||
if (stream.match(/^(%)|(\.\.\.)/)){ | ||
if (stream.match(/^[%#]/)){ | ||
stream.skipToEnd(); | ||
@@ -67,0 +69,0 @@ return 'comment'; |
@@ -154,2 +154,6 @@ CodeMirror.defineMode("python", function(conf, parserConf) { | ||
if (stream.match(/^(self|cls)\b/)) { | ||
return "variable-2"; | ||
} | ||
if (stream.match(identifiers)) { | ||
@@ -156,0 +160,0 @@ if (state.lastToken == 'def' || state.lastToken == 'class') { |
@@ -1,552 +0,555 @@ | ||
CodeMirror.defineMode('rst-base', function (config) { | ||
CodeMirror.defineMode('rst', function (config, options) { | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
var rx_strong = /^\*\*[^\*\s](?:[^\*]*[^\*\s])?\*\*/; | ||
var rx_emphasis = /^\*[^\*\s](?:[^\*]*[^\*\s])?\*/; | ||
var rx_literal = /^``[^`\s](?:[^`]*[^`\s])``/; | ||
function format(string) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
return string.replace(/{(\d+)}/g, function (match, n) { | ||
return typeof args[n] != 'undefined' ? args[n] : match; | ||
}); | ||
} | ||
var rx_number = /^(?:[\d]+(?:[\.,]\d+)*)/; | ||
var rx_positive = /^(?:\s\+[\d]+(?:[\.,]\d+)*)/; | ||
var rx_negative = /^(?:\s\-[\d]+(?:[\.,]\d+)*)/; | ||
function AssertException(message) { | ||
this.message = message; | ||
} | ||
var rx_uri_protocol = "[Hh][Tt][Tt][Pp][Ss]?://"; | ||
var rx_uri_domain = "(?:[\\d\\w.-]+)\\.(?:\\w{2,6})"; | ||
var rx_uri_path = "(?:/[\\d\\w\\#\\%\\&\\-\\.\\,\\/\\:\\=\\?\\~]+)*"; | ||
var rx_uri = new RegExp("^" + rx_uri_protocol + rx_uri_domain + rx_uri_path); | ||
AssertException.prototype.toString = function () { | ||
return 'AssertException: ' + this.message; | ||
}; | ||
var overlay = { | ||
token: function (stream) { | ||
function assert(expression, message) { | ||
if (!expression) throw new AssertException(message); | ||
return expression; | ||
} | ||
if (stream.match(rx_strong) && stream.match (/\W+|$/, false)) | ||
return 'strong'; | ||
if (stream.match(rx_emphasis) && stream.match (/\W+|$/, false)) | ||
return 'em'; | ||
if (stream.match(rx_literal) && stream.match (/\W+|$/, false)) | ||
return 'string-2'; | ||
if (stream.match(rx_number)) | ||
return 'number'; | ||
if (stream.match(rx_positive)) | ||
return 'positive'; | ||
if (stream.match(rx_negative)) | ||
return 'negative'; | ||
if (stream.match(rx_uri)) | ||
return 'link'; | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
while (stream.next() != null) { | ||
if (stream.match(rx_strong, false)) break; | ||
if (stream.match(rx_emphasis, false)) break; | ||
if (stream.match(rx_literal, false)) break; | ||
if (stream.match(rx_number, false)) break; | ||
if (stream.match(rx_positive, false)) break; | ||
if (stream.match(rx_negative, false)) break; | ||
if (stream.match(rx_uri, false)) break; | ||
} | ||
var mode_python = CodeMirror.getMode(config, 'python'); | ||
var mode_stex = CodeMirror.getMode(config, 'stex'); | ||
return null; | ||
} | ||
}; | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
var mode = CodeMirror.getMode( | ||
config, options.backdrop || 'rst-base' | ||
); | ||
var SEPA = "\\s+"; | ||
var TAIL = "(?:\\s*|\\W|$)", | ||
rx_TAIL = new RegExp(format('^{0}', TAIL)); | ||
return CodeMirror.overlayMode(mode, overlay, true); // combine | ||
}, 'python', 'stex'); | ||
var NAME = | ||
"(?:[^\\W\\d_](?:[\\w!\"#$%&'()\\*\\+,\\-\\.\/:;<=>\\?]*[^\\W_])?)", | ||
rx_NAME = new RegExp(format('^{0}', NAME)); | ||
var NAME_WWS = | ||
"(?:[^\\W\\d_](?:[\\w\\s!\"#$%&'()\\*\\+,\\-\\.\/:;<=>\\?]*[^\\W_])?)"; | ||
var REF_NAME = format('(?:{0}|`{1}`)', NAME, NAME_WWS); | ||
/////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
var TEXT1 = "(?:[^\\s\\|](?:[^\\|]*[^\\s\\|])?)"; | ||
var TEXT2 = "(?:[^\\`]+)", | ||
rx_TEXT2 = new RegExp(format('^{0}', TEXT2)); | ||
CodeMirror.defineMode('rst-base', function (config) { | ||
var rx_section = new RegExp( | ||
"^([!'#$%&\"()*+,-./:;<=>?@\\[\\\\\\]^_`{|}~])\\1{3,}\\s*$"); | ||
var rx_explicit = new RegExp( | ||
format('^\\.\\.{0}', SEPA)); | ||
var rx_link = new RegExp( | ||
format('^_{0}:{1}|^__:{1}', REF_NAME, TAIL)); | ||
var rx_directive = new RegExp( | ||
format('^{0}::{1}', REF_NAME, TAIL)); | ||
var rx_substitution = new RegExp( | ||
format('^\\|{0}\\|{1}{2}::{3}', TEXT1, SEPA, REF_NAME, TAIL)); | ||
var rx_footnote = new RegExp( | ||
format('^\\[(?:\\d+|#{0}?|\\*)]{1}', REF_NAME, TAIL)); | ||
var rx_citation = new RegExp( | ||
format('^\\[{0}\\]{1}', REF_NAME, TAIL)); | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
var rx_substitution_ref = new RegExp( | ||
format('^\\|{0}\\|', TEXT1)); | ||
var rx_footnote_ref = new RegExp( | ||
format('^\\[(?:\\d+|#{0}?|\\*)]_', REF_NAME)); | ||
var rx_citation_ref = new RegExp( | ||
format('^\\[{0}\\]_', REF_NAME)); | ||
var rx_link_ref1 = new RegExp( | ||
format('^{0}__?', REF_NAME)); | ||
var rx_link_ref2 = new RegExp( | ||
format('^`{0}`_', TEXT2)); | ||
function format(string) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
return string.replace(/{(\d+)}/g, function (match, n) { | ||
return typeof args[n] != 'undefined' ? args[n] : match; | ||
}); | ||
} | ||
var rx_role_pre = new RegExp( | ||
format('^:{0}:`{1}`{2}', NAME, TEXT2, TAIL)); | ||
var rx_role_suf = new RegExp( | ||
format('^`{1}`:{0}:{2}', NAME, TEXT2, TAIL)); | ||
var rx_role = new RegExp( | ||
format('^:{0}:{1}', NAME, TAIL)); | ||
function AssertException(message) { | ||
this.message = message; | ||
} | ||
var rx_directive_name = new RegExp(format('^{0}', REF_NAME)); | ||
var rx_directive_tail = new RegExp(format('^::{0}', TAIL)); | ||
var rx_substitution_text = new RegExp(format('^\\|{0}\\|', TEXT1)); | ||
var rx_substitution_sepa = new RegExp(format('^{0}', SEPA)); | ||
var rx_substitution_name = new RegExp(format('^{0}', REF_NAME)); | ||
var rx_substitution_tail = new RegExp(format('^::{0}', TAIL)); | ||
var rx_link_head = new RegExp("^_"); | ||
var rx_link_name = new RegExp(format('^{0}|_', REF_NAME)); | ||
var rx_link_tail = new RegExp(format('^:{0}', TAIL)); | ||
AssertException.prototype.toString = function () { | ||
return 'AssertException: ' + this.message; | ||
}; | ||
var rx_verbatim = new RegExp('^::\\s*$'); | ||
var rx_examples = new RegExp('^\\s+(?:>>>|In \\[\\d+\\]:)\\s'); | ||
function assert(expression, message) { | ||
if (!expression) throw new AssertException(message); | ||
return expression; | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
function to_normal(stream, state) { | ||
var token = null; | ||
var mode_python = CodeMirror.getMode(config, 'python'); | ||
var mode_stex = CodeMirror.getMode(config, 'stex'); | ||
if (stream.sol() && stream.match(rx_examples, false)) { | ||
change(state, to_mode, { | ||
mode: mode_python, local: mode_python.startState() | ||
}); | ||
} else if (stream.sol() && stream.match(rx_explicit)) { | ||
change(state, to_explicit); | ||
token = 'meta'; | ||
} else if (stream.sol() && stream.match(rx_section)) { | ||
change(state, to_normal); | ||
token = 'header'; | ||
} else if (phase(state) == rx_role_pre || | ||
stream.match(rx_role_pre, false)) { | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_role_pre, 1)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_role_pre, 2)); | ||
assert(stream.match(rx_NAME)); | ||
token = 'keyword'; | ||
var SEPA = "\\s+"; | ||
var TAIL = "(?:\\s*|\\W|$)", | ||
rx_TAIL = new RegExp(format('^{0}', TAIL)); | ||
if (stream.current().match(/^(?:math|latex)/)) { | ||
state.tmp_stex = true; | ||
} | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_role_pre, 3)); | ||
assert(stream.match(/^:`/)); | ||
token = 'meta'; | ||
break; | ||
case 3: | ||
if (state.tmp_stex) { | ||
state.tmp_stex = undefined; state.tmp = { | ||
mode: mode_stex, local: mode_stex.startState() | ||
}; | ||
} | ||
var NAME = | ||
"(?:[^\\W\\d_](?:[\\w!\"#$%&'()\\*\\+,\\-\\.\/:;<=>\\?]*[^\\W_])?)", | ||
rx_NAME = new RegExp(format('^{0}', NAME)); | ||
var NAME_WWS = | ||
"(?:[^\\W\\d_](?:[\\w\\s!\"#$%&'()\\*\\+,\\-\\.\/:;<=>\\?]*[^\\W_])?)"; | ||
var REF_NAME = format('(?:{0}|`{1}`)', NAME, NAME_WWS); | ||
if (state.tmp) { | ||
if (stream.peek() == '`') { | ||
change(state, to_normal, context(rx_role_pre, 4)); | ||
state.tmp = undefined; | ||
break; | ||
} | ||
var TEXT1 = "(?:[^\\s\\|](?:[^\\|]*[^\\s\\|])?)"; | ||
var TEXT2 = "(?:[^\\`]+)", | ||
rx_TEXT2 = new RegExp(format('^{0}', TEXT2)); | ||
token = state.tmp.mode.token(stream, state.tmp.local); | ||
break; | ||
} | ||
var rx_section = new RegExp( | ||
"^([!'#$%&\"()*+,-./:;<=>?@\\[\\\\\\]^_`{|}~])\\1{3,}\\s*$"); | ||
var rx_explicit = new RegExp( | ||
format('^\\.\\.{0}', SEPA)); | ||
var rx_link = new RegExp( | ||
format('^_{0}:{1}|^__:{1}', REF_NAME, TAIL)); | ||
var rx_directive = new RegExp( | ||
format('^{0}::{1}', REF_NAME, TAIL)); | ||
var rx_substitution = new RegExp( | ||
format('^\\|{0}\\|{1}{2}::{3}', TEXT1, SEPA, REF_NAME, TAIL)); | ||
var rx_footnote = new RegExp( | ||
format('^\\[(?:\\d+|#{0}?|\\*)]{1}', REF_NAME, TAIL)); | ||
var rx_citation = new RegExp( | ||
format('^\\[{0}\\]{1}', REF_NAME, TAIL)); | ||
change(state, to_normal, context(rx_role_pre, 4)); | ||
assert(stream.match(rx_TEXT2)); | ||
token = 'string'; | ||
break; | ||
case 4: | ||
change(state, to_normal, context(rx_role_pre, 5)); | ||
assert(stream.match(/^`/)); | ||
token = 'meta'; | ||
break; | ||
case 5: | ||
change(state, to_normal, context(rx_role_pre, 6)); | ||
assert(stream.match(rx_TAIL)); | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_role_suf || | ||
stream.match(rx_role_suf, false)) { | ||
var rx_substitution_ref = new RegExp( | ||
format('^\\|{0}\\|', TEXT1)); | ||
var rx_footnote_ref = new RegExp( | ||
format('^\\[(?:\\d+|#{0}?|\\*)]_', REF_NAME)); | ||
var rx_citation_ref = new RegExp( | ||
format('^\\[{0}\\]_', REF_NAME)); | ||
var rx_link_ref1 = new RegExp( | ||
format('^{0}__?', REF_NAME)); | ||
var rx_link_ref2 = new RegExp( | ||
format('^`{0}`_', TEXT2)); | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_role_suf, 1)); | ||
assert(stream.match(/^`/)); | ||
token = 'meta'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_role_suf, 2)); | ||
assert(stream.match(rx_TEXT2)); | ||
token = 'string'; | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_role_suf, 3)); | ||
assert(stream.match(/^`:/)); | ||
token = 'meta'; | ||
break; | ||
case 3: | ||
change(state, to_normal, context(rx_role_suf, 4)); | ||
assert(stream.match(rx_NAME)); | ||
token = 'keyword'; | ||
break; | ||
case 4: | ||
change(state, to_normal, context(rx_role_suf, 5)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 5: | ||
change(state, to_normal, context(rx_role_suf, 6)); | ||
assert(stream.match(rx_TAIL)); | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_role || stream.match(rx_role, false)) { | ||
var rx_role_pre = new RegExp( | ||
format('^:{0}:`{1}`{2}', NAME, TEXT2, TAIL)); | ||
var rx_role_suf = new RegExp( | ||
format('^`{1}`:{0}:{2}', NAME, TEXT2, TAIL)); | ||
var rx_role = new RegExp( | ||
format('^:{0}:{1}', NAME, TAIL)); | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_role, 1)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_role, 2)); | ||
assert(stream.match(rx_NAME)); | ||
token = 'keyword'; | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_role, 3)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 3: | ||
change(state, to_normal, context(rx_role, 4)); | ||
assert(stream.match(rx_TAIL)); | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_substitution_ref || | ||
stream.match(rx_substitution_ref, false)) { | ||
var rx_directive_name = new RegExp(format('^{0}', REF_NAME)); | ||
var rx_directive_tail = new RegExp(format('^::{0}', TAIL)); | ||
var rx_substitution_text = new RegExp(format('^\\|{0}\\|', TEXT1)); | ||
var rx_substitution_sepa = new RegExp(format('^{0}', SEPA)); | ||
var rx_substitution_name = new RegExp(format('^{0}', REF_NAME)); | ||
var rx_substitution_tail = new RegExp(format('^::{0}', TAIL)); | ||
var rx_link_head = new RegExp("^_"); | ||
var rx_link_name = new RegExp(format('^{0}|_', REF_NAME)); | ||
var rx_link_tail = new RegExp(format('^:{0}', TAIL)); | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_substitution_ref, 1)); | ||
assert(stream.match(rx_substitution_text)); | ||
token = 'variable-2'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_substitution_ref, 2)); | ||
if (stream.match(/^_?_?/)) token = 'link'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (stream.match(rx_footnote_ref)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} else if (stream.match(rx_citation_ref)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} else if (stream.match(rx_link_ref1)) { | ||
change(state, to_normal); | ||
if (!stream.peek() || stream.peek().match(/^\W$/)) { | ||
token = 'link'; | ||
} | ||
} else if (phase(state) == rx_link_ref2 || | ||
stream.match(rx_link_ref2, false)) { | ||
var rx_verbatim = new RegExp('^::\\s*$'); | ||
var rx_examples = new RegExp('^\\s+(?:>>>|In \\[\\d+\\]:)\\s'); | ||
switch (stage(state)) { | ||
case 0: | ||
if (!stream.peek() || stream.peek().match(/^\W$/)) { | ||
change(state, to_normal, context(rx_link_ref2, 1)); | ||
} else { | ||
stream.match(rx_link_ref2); | ||
} | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_link_ref2, 2)); | ||
assert(stream.match(/^`/)); | ||
token = 'link'; | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_link_ref2, 3)); | ||
assert(stream.match(rx_TEXT2)); | ||
break; | ||
case 3: | ||
change(state, to_normal, context(rx_link_ref2, 4)); | ||
assert(stream.match(/^`_/)); | ||
token = 'link'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (stream.match(rx_verbatim)) { | ||
change(state, to_verbatim); | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
else { | ||
if (stream.next()) change(state, to_normal); | ||
} | ||
function to_normal(stream, state) { | ||
var token = null; | ||
return token; | ||
} | ||
if (stream.sol() && stream.match(rx_examples, false)) { | ||
change(state, to_mode, { | ||
mode: mode_python, local: CodeMirror.startState(mode_python) | ||
}); | ||
} else if (stream.sol() && stream.match(rx_explicit)) { | ||
change(state, to_explicit); | ||
token = 'meta'; | ||
} else if (stream.sol() && stream.match(rx_section)) { | ||
change(state, to_normal); | ||
token = 'header'; | ||
} else if (phase(state) == rx_role_pre || | ||
stream.match(rx_role_pre, false)) { | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_role_pre, 1)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_role_pre, 2)); | ||
assert(stream.match(rx_NAME)); | ||
token = 'keyword'; | ||
function to_explicit(stream, state) { | ||
var token = null; | ||
if (stream.current().match(/^(?:math|latex)/)) { | ||
state.tmp_stex = true; | ||
} | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_role_pre, 3)); | ||
assert(stream.match(/^:`/)); | ||
token = 'meta'; | ||
break; | ||
case 3: | ||
if (state.tmp_stex) { | ||
state.tmp_stex = undefined; state.tmp = { | ||
mode: mode_stex, local: CodeMirror.startState(mode_stex) | ||
}; | ||
} | ||
if (phase(state) == rx_substitution || | ||
stream.match(rx_substitution, false)) { | ||
if (state.tmp) { | ||
if (stream.peek() == '`') { | ||
change(state, to_normal, context(rx_role_pre, 4)); | ||
state.tmp = undefined; | ||
break; | ||
} | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_explicit, context(rx_substitution, 1)); | ||
assert(stream.match(rx_substitution_text)); | ||
token = 'variable-2'; | ||
break; | ||
case 1: | ||
change(state, to_explicit, context(rx_substitution, 2)); | ||
assert(stream.match(rx_substitution_sepa)); | ||
break; | ||
case 2: | ||
change(state, to_explicit, context(rx_substitution, 3)); | ||
assert(stream.match(rx_substitution_name)); | ||
token = 'keyword'; | ||
break; | ||
case 3: | ||
change(state, to_explicit, context(rx_substitution, 4)); | ||
assert(stream.match(rx_substitution_tail)); | ||
token = 'meta'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_directive || | ||
stream.match(rx_directive, false)) { | ||
token = state.tmp.mode.token(stream, state.tmp.local); | ||
break; | ||
} | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_explicit, context(rx_directive, 1)); | ||
assert(stream.match(rx_directive_name)); | ||
token = 'keyword'; | ||
change(state, to_normal, context(rx_role_pre, 4)); | ||
assert(stream.match(rx_TEXT2)); | ||
token = 'string'; | ||
break; | ||
case 4: | ||
change(state, to_normal, context(rx_role_pre, 5)); | ||
assert(stream.match(/^`/)); | ||
token = 'meta'; | ||
break; | ||
case 5: | ||
change(state, to_normal, context(rx_role_pre, 6)); | ||
assert(stream.match(rx_TAIL)); | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_role_suf || | ||
stream.match(rx_role_suf, false)) { | ||
if (stream.current().match(/^(?:math|latex)/)) | ||
state.tmp_stex = true; | ||
else if (stream.current().match(/^python/)) | ||
state.tmp_py = true; | ||
break; | ||
case 1: | ||
change(state, to_explicit, context(rx_directive, 2)); | ||
assert(stream.match(rx_directive_tail)); | ||
token = 'meta'; | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_role_suf, 1)); | ||
assert(stream.match(/^`/)); | ||
token = 'meta'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_role_suf, 2)); | ||
assert(stream.match(rx_TEXT2)); | ||
token = 'string'; | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_role_suf, 3)); | ||
assert(stream.match(/^`:/)); | ||
token = 'meta'; | ||
break; | ||
case 3: | ||
change(state, to_normal, context(rx_role_suf, 4)); | ||
assert(stream.match(rx_NAME)); | ||
token = 'keyword'; | ||
break; | ||
case 4: | ||
change(state, to_normal, context(rx_role_suf, 5)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 5: | ||
change(state, to_normal, context(rx_role_suf, 6)); | ||
assert(stream.match(rx_TAIL)); | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_role || stream.match(rx_role, false)) { | ||
if (stream.match(/^latex\s*$/) || state.tmp_stex) { | ||
state.tmp_stex = undefined; change(state, to_mode, { | ||
mode: mode_stex, local: mode_stex.startState() | ||
}); | ||
} | ||
break; | ||
case 2: | ||
change(state, to_explicit, context(rx_directive, 3)); | ||
if (stream.match(/^python\s*$/) || state.tmp_py) { | ||
state.tmp_py = undefined; change(state, to_mode, { | ||
mode: mode_python, local: mode_python.startState() | ||
}); | ||
} | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_link || stream.match(rx_link, false)) { | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_role, 1)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_role, 2)); | ||
assert(stream.match(rx_NAME)); | ||
token = 'keyword'; | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_role, 3)); | ||
assert(stream.match(/^:/)); | ||
token = 'meta'; | ||
break; | ||
case 3: | ||
change(state, to_normal, context(rx_role, 4)); | ||
assert(stream.match(rx_TAIL)); | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_substitution_ref || | ||
stream.match(rx_substitution_ref, false)) { | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_explicit, context(rx_link, 1)); | ||
assert(stream.match(rx_link_head)); | ||
assert(stream.match(rx_link_name)); | ||
token = 'link'; | ||
break; | ||
case 1: | ||
change(state, to_explicit, context(rx_link, 2)); | ||
assert(stream.match(rx_link_tail)); | ||
token = 'meta'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (stream.match(rx_footnote)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} else if (stream.match(rx_citation)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_normal, context(rx_substitution_ref, 1)); | ||
assert(stream.match(rx_substitution_text)); | ||
token = 'variable-2'; | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_substitution_ref, 2)); | ||
if (stream.match(/^_?_?/)) token = 'link'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (stream.match(rx_footnote_ref)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} else if (stream.match(rx_citation_ref)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} else if (stream.match(rx_link_ref1)) { | ||
change(state, to_normal); | ||
if (!stream.peek() || stream.peek().match(/^\W$/)) { | ||
token = 'link'; | ||
} | ||
} else if (phase(state) == rx_link_ref2 || | ||
stream.match(rx_link_ref2, false)) { | ||
else { | ||
stream.eatSpace(); | ||
if (stream.eol()) { | ||
change(state, to_normal); | ||
} else { | ||
stream.skipToEnd(); | ||
change(state, to_comment); | ||
token = 'comment'; | ||
} | ||
switch (stage(state)) { | ||
case 0: | ||
if (!stream.peek() || stream.peek().match(/^\W$/)) { | ||
change(state, to_normal, context(rx_link_ref2, 1)); | ||
} else { | ||
stream.match(rx_link_ref2); | ||
} | ||
break; | ||
case 1: | ||
change(state, to_normal, context(rx_link_ref2, 2)); | ||
assert(stream.match(/^`/)); | ||
token = 'link'; | ||
break; | ||
case 2: | ||
change(state, to_normal, context(rx_link_ref2, 3)); | ||
assert(stream.match(rx_TEXT2)); | ||
break; | ||
case 3: | ||
change(state, to_normal, context(rx_link_ref2, 4)); | ||
assert(stream.match(/^`_/)); | ||
token = 'link'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (stream.match(rx_verbatim)) { | ||
change(state, to_verbatim); | ||
} | ||
return token; | ||
else { | ||
if (stream.next()) change(state, to_normal); | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
return token; | ||
} | ||
function to_comment(stream, state) { | ||
return as_block(stream, state, 'comment'); | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
function to_verbatim(stream, state) { | ||
return as_block(stream, state, 'meta'); | ||
} | ||
function to_explicit(stream, state) { | ||
var token = null; | ||
function as_block(stream, state, token) { | ||
if (stream.eol() || stream.eatSpace()) { | ||
stream.skipToEnd(); | ||
return token; | ||
} else { | ||
change(state, to_normal); | ||
return null; | ||
} | ||
} | ||
if (phase(state) == rx_substitution || | ||
stream.match(rx_substitution, false)) { | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_explicit, context(rx_substitution, 1)); | ||
assert(stream.match(rx_substitution_text)); | ||
token = 'variable-2'; | ||
break; | ||
case 1: | ||
change(state, to_explicit, context(rx_substitution, 2)); | ||
assert(stream.match(rx_substitution_sepa)); | ||
break; | ||
case 2: | ||
change(state, to_explicit, context(rx_substitution, 3)); | ||
assert(stream.match(rx_substitution_name)); | ||
token = 'keyword'; | ||
break; | ||
case 3: | ||
change(state, to_explicit, context(rx_substitution, 4)); | ||
assert(stream.match(rx_substitution_tail)); | ||
token = 'meta'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_directive || | ||
stream.match(rx_directive, false)) { | ||
function to_mode(stream, state) { | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_explicit, context(rx_directive, 1)); | ||
assert(stream.match(rx_directive_name)); | ||
token = 'keyword'; | ||
if (state.ctx.mode && state.ctx.local) { | ||
if (stream.current().match(/^(?:math|latex)/)) | ||
state.tmp_stex = true; | ||
else if (stream.current().match(/^python/)) | ||
state.tmp_py = true; | ||
break; | ||
case 1: | ||
change(state, to_explicit, context(rx_directive, 2)); | ||
assert(stream.match(rx_directive_tail)); | ||
token = 'meta'; | ||
if (stream.sol()) { | ||
if (!stream.eatSpace()) change(state, to_normal); | ||
return null; | ||
} | ||
return state.ctx.mode.token(stream, state.ctx.local); | ||
if (stream.match(/^latex\s*$/) || state.tmp_stex) { | ||
state.tmp_stex = undefined; change(state, to_mode, { | ||
mode: mode_stex, local: CodeMirror.startState(mode_stex) | ||
}); | ||
} | ||
break; | ||
case 2: | ||
change(state, to_explicit, context(rx_directive, 3)); | ||
if (stream.match(/^python\s*$/) || state.tmp_py) { | ||
state.tmp_py = undefined; change(state, to_mode, { | ||
mode: mode_python, local: CodeMirror.startState(mode_python) | ||
}); | ||
} | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
} else if (phase(state) == rx_link || stream.match(rx_link, false)) { | ||
switch (stage(state)) { | ||
case 0: | ||
change(state, to_explicit, context(rx_link, 1)); | ||
assert(stream.match(rx_link_head)); | ||
assert(stream.match(rx_link_name)); | ||
token = 'link'; | ||
break; | ||
case 1: | ||
change(state, to_explicit, context(rx_link, 2)); | ||
assert(stream.match(rx_link_tail)); | ||
token = 'meta'; | ||
break; | ||
default: | ||
change(state, to_normal); | ||
return null; | ||
assert(stream.current() == ''); | ||
} | ||
} else if (stream.match(rx_footnote)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} else if (stream.match(rx_citation)) { | ||
change(state, to_normal); | ||
token = 'quote'; | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
function context(phase, stage, mode, local) { | ||
return {phase: phase, stage: stage, mode: mode, local: local}; | ||
else { | ||
stream.eatSpace(); | ||
if (stream.eol()) { | ||
change(state, to_normal); | ||
} else { | ||
stream.skipToEnd(); | ||
change(state, to_comment); | ||
token = 'comment'; | ||
} | ||
} | ||
function change(state, tok, ctx) { | ||
state.tok = tok; | ||
state.ctx = ctx || {}; | ||
} | ||
return token; | ||
} | ||
function stage(state) { | ||
return state.ctx.stage || 0; | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
function phase(state) { | ||
return state.ctx.phase; | ||
function to_comment(stream, state) { | ||
return as_block(stream, state, 'comment'); | ||
} | ||
function to_verbatim(stream, state) { | ||
return as_block(stream, state, 'meta'); | ||
} | ||
function as_block(stream, state, token) { | ||
if (stream.eol() || stream.eatSpace()) { | ||
stream.skipToEnd(); | ||
return token; | ||
} else { | ||
change(state, to_normal); | ||
return null; | ||
} | ||
} | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
return { | ||
startState: function () { | ||
return {tok: to_normal, ctx: context(undefined, 0)}; | ||
}, | ||
function to_mode(stream, state) { | ||
copyState: function (state) { | ||
return {tok: state.tok, ctx: state.ctx}; | ||
}, | ||
if (state.ctx.mode && state.ctx.local) { | ||
innerMode: function (state) { | ||
return state.tmp ? {state: state.tmp.local, mode: state.tmp.mode} | ||
: state.ctx ? {state: state.ctx.local, mode: state.ctx.mode} | ||
: null; | ||
}, | ||
if (stream.sol()) { | ||
if (!stream.eatSpace()) change(state, to_normal); | ||
return null; | ||
} | ||
token: function (stream, state) { | ||
return state.tok(stream, state); | ||
} | ||
}; | ||
}, 'python', 'stex'); | ||
return state.ctx.mode.token(stream, state.ctx.local); | ||
} | ||
/////////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
change(state, to_normal); | ||
return null; | ||
} | ||
CodeMirror.defineMode('rst', function (config, options) { | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
var rx_strong = /^\*\*[^\*\s](?:[^\*]*[^\*\s])?\*\*/; | ||
var rx_emphasis = /^\*[^\*\s](?:[^\*]*[^\*\s])?\*/; | ||
var rx_literal = /^``[^`\s](?:[^`]*[^`\s])``/; | ||
function context(phase, stage, mode, local) { | ||
return {phase: phase, stage: stage, mode: mode, local: local}; | ||
} | ||
var rx_number = /^(?:[\d]+(?:[\.,]\d+)*)/; | ||
var rx_positive = /^(?:\s\+[\d]+(?:[\.,]\d+)*)/; | ||
var rx_negative = /^(?:\s\-[\d]+(?:[\.,]\d+)*)/; | ||
function change(state, tok, ctx) { | ||
state.tok = tok; | ||
state.ctx = ctx || {}; | ||
} | ||
var rx_uri_protocol = "[Hh][Tt][Tt][Pp][Ss]?://"; | ||
var rx_uri_domain = "(?:[\\d\\w.-]+)\\.(?:\\w{2,6})"; | ||
var rx_uri_path = "(?:/[\\d\\w\\#\\%\\&\\-\\.\\,\\/\\:\\=\\?\\~]+)*"; | ||
var rx_uri = new RegExp("^" + | ||
rx_uri_protocol + rx_uri_domain + rx_uri_path | ||
); | ||
function stage(state) { | ||
return state.ctx.stage || 0; | ||
} | ||
var overlay = { | ||
token: function (stream) { | ||
function phase(state) { | ||
return state.ctx.phase; | ||
} | ||
if (stream.match(rx_strong) && stream.match (/\W+|$/, false)) | ||
return 'strong'; | ||
if (stream.match(rx_emphasis) && stream.match (/\W+|$/, false)) | ||
return 'em'; | ||
if (stream.match(rx_literal) && stream.match (/\W+|$/, false)) | ||
return 'string-2'; | ||
if (stream.match(rx_number)) | ||
return 'number'; | ||
if (stream.match(rx_positive)) | ||
return 'positive'; | ||
if (stream.match(rx_negative)) | ||
return 'negative'; | ||
if (stream.match(rx_uri)) | ||
return 'link'; | ||
/////////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////////// | ||
while (stream.next() != null) { | ||
if (stream.match(rx_strong, false)) break; | ||
if (stream.match(rx_emphasis, false)) break; | ||
if (stream.match(rx_literal, false)) break; | ||
if (stream.match(rx_number, false)) break; | ||
if (stream.match(rx_positive, false)) break; | ||
if (stream.match(rx_negative, false)) break; | ||
if (stream.match(rx_uri, false)) break; | ||
} | ||
return { | ||
startState: function () { | ||
return {tok: to_normal, ctx: context(undefined, 0)}; | ||
}, | ||
return null; | ||
} | ||
}; | ||
copyState: function (state) { | ||
var ctx = state.ctx, tmp = state.tmp; | ||
if (ctx.local) | ||
ctx = {mode: ctx.mode, local: CodeMirror.copyState(ctx.mode, ctx.local)}; | ||
if (tmp) | ||
tmp = {mode: tmp.mode, local: CodeMirror.copyState(tmp.mode, tmp.local)}; | ||
return {tok: state.tok, ctx: ctx, tmp: tmp}; | ||
}, | ||
var mode = CodeMirror.getMode( | ||
config, options.backdrop || 'rst-base' | ||
); | ||
innerMode: function (state) { | ||
return state.tmp ? {state: state.tmp.local, mode: state.tmp.mode} | ||
: state.ctx.mode ? {state: state.ctx.local, mode: state.ctx.mode} | ||
: null; | ||
}, | ||
return CodeMirror.overlayMode(mode, overlay, true); // combine | ||
token: function (stream, state) { | ||
return state.tok(stream, state); | ||
} | ||
}; | ||
}, 'python', 'stex'); | ||
@@ -553,0 +556,0 @@ |
@@ -37,2 +37,3 @@ CodeMirror.defineMode("ruby", function(config) { | ||
} else if (ch == "/" && !stream.eol() && stream.peek() != " ") { | ||
if (stream.eat("=")) return "operator"; | ||
return chain(readQuoted(ch, "string-2", true), stream, state); | ||
@@ -39,0 +40,0 @@ } else if (ch == "%") { |
@@ -329,4 +329,4 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { | ||
client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"), | ||
keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"), | ||
builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid upper user userenv varchar varchar2 variance varying vsize xml"), | ||
keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"), | ||
builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"), | ||
operatorChars: /^[*+\-%<>!=~]/, | ||
@@ -333,0 +333,0 @@ dateSQL: set("date time timestamp"), |
CodeMirror.defineMode("xml", function(config, parserConfig) { | ||
var indentUnit = config.indentUnit; | ||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1; | ||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag || true; | ||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag; | ||
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true; | ||
@@ -6,0 +7,0 @@ var Kludges = parserConfig.htmlMode ? { |
{ | ||
"name": "codemirror", | ||
"version":"3.21.0", | ||
"version":"3.22.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
@@ -175,3 +175,3 @@ var Pos = CodeMirror.Pos; | ||
defs.value = "uu"; | ||
defs.enterMode = "keep"; | ||
defs.indentWithTabs = true; | ||
defs.tabindex = 55; | ||
@@ -184,3 +184,3 @@ var place = document.getElementById("testground"), cm = CodeMirror(place); | ||
eq(cm.getValue(), "uu"); | ||
eq(cm.getOption("enterMode"), "keep"); | ||
eq(cm.getOption("indentWithTabs"), true); | ||
eq(cm.getInputField().tabIndex, 55); | ||
@@ -1138,2 +1138,6 @@ } | ||
cm.execCommand("goGroupRight"); | ||
eqPos(cm.getCursor(), Pos(1, 0)); | ||
cm.execCommand("goGroupRight"); | ||
eqPos(cm.getCursor(), Pos(1, 2)); | ||
cm.execCommand("goGroupRight"); | ||
eqPos(cm.getCursor(), Pos(1, 5)); | ||
@@ -1143,5 +1147,20 @@ cm.execCommand("goGroupLeft"); cm.execCommand("goGroupLeft"); | ||
cm.execCommand("goGroupLeft"); | ||
eqPos(cm.getCursor(), Pos(0, 20)); | ||
cm.execCommand("goGroupLeft"); | ||
eqPos(cm.getCursor(), Pos(0, 16)); | ||
}, {value: "booo ba---quux. ffff\n abc d"}); | ||
testCM("groupsAndWhitespace", function(cm) { | ||
var positions = [Pos(0, 0), Pos(0, 2), Pos(0, 5), Pos(0, 9), Pos(0, 11), | ||
Pos(1, 0), Pos(1, 2), Pos(1, 5)]; | ||
for (var i = 1; i < positions.length; i++) { | ||
cm.execCommand("goGroupRight"); | ||
eqPos(cm.getCursor(), positions[i]); | ||
} | ||
for (var i = positions.length - 2; i >= 0; i--) { | ||
cm.execCommand("goGroupLeft"); | ||
eqPos(cm.getCursor(), i == 2 ? Pos(0, 6) : positions[i]); | ||
} | ||
}, {value: " foo +++ \n bar"}); | ||
testCM("charMovementCommands", function(cm) { | ||
@@ -1632,4 +1651,5 @@ cm.execCommand("goCharLeft"); cm.execCommand("goColumnLeft"); | ||
return {token: function(stream) { | ||
if (stream.match(/^\[[^\]]*\]/)) return "line-brackets"; | ||
if (stream.match(/^\([^\]]*\)/)) return "line-background-parens"; | ||
if (stream.match(/^\[[^\]]*\]/)) return " line-brackets "; | ||
if (stream.match(/^\([^\)]*\)/)) return " line-background-parens "; | ||
if (stream.match(/^<[^>]*>/)) return " span line-line line-background-bg "; | ||
stream.match(/^\s+|^\S+/); | ||
@@ -1647,4 +1667,11 @@ }}; | ||
is(!/parens.*parens/.test(parenElts[0].className)); | ||
}, {value: "line1: [br] [br]\nline2: (par) (par)\nline3: nothing"}); | ||
eq(parenElts[0].parentElement.nodeName, "DIV"); | ||
eq(byClassName(cm.getWrapperElement(), "bg").length, 1); | ||
eq(byClassName(cm.getWrapperElement(), "line").length, 1); | ||
var spanElts = byClassName(cm.getWrapperElement(), "cm-span"); | ||
eq(spanElts.length, 2); | ||
is(/^\s*cm-span\s*$/.test(spanElts[0].className)); | ||
}, {value: "line1: [br] [br]\nline2: (par) (par)\nline3: <tag> <tag>"}); | ||
CodeMirror.registerHelper("xxx", "a", "A"); | ||
@@ -1651,0 +1678,0 @@ CodeMirror.registerHelper("xxx", "b", "B"); |
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 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 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 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
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
2510016
352
41317