codemirror
Advanced tools
Comparing version 4.7.0 to 4.8.0
@@ -74,3 +74,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
for (var i = 0; i < pairs.length; i += 2) (function(left, right) { | ||
if (left != right) closingBrackets += right; | ||
closingBrackets += right; | ||
map["'" + left + "'"] = function(cm) { | ||
@@ -77,0 +77,0 @@ if (cm.getOption("disableInput")) return CodeMirror.Pass; |
@@ -96,3 +96,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
function getCompletions(token, context, keywords, options) { | ||
var found = [], start = token.string; | ||
var found = [], start = token.string, global = options && options.globalScope || window; | ||
function maybeAdd(str) { | ||
@@ -116,3 +116,3 @@ if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str); | ||
if (!options || options.useGlobalScope !== false) | ||
base = base || window[obj.string]; | ||
base = base || global[obj.string]; | ||
} else if (obj.type == "string") { | ||
@@ -123,7 +123,7 @@ base = ""; | ||
} else if (obj.type == "function") { | ||
if (window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') && | ||
(typeof window.jQuery == 'function')) | ||
base = window.jQuery(); | ||
else if (window._ != null && (obj.string == '_') && (typeof window._ == 'function')) | ||
base = window._(); | ||
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') && | ||
(typeof global.jQuery == 'function')) | ||
base = global.jQuery(); | ||
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function')) | ||
base = global._(); | ||
} | ||
@@ -134,3 +134,3 @@ while (base != null && context.length) | ||
} else { | ||
// If not, just look in the window object and any local scope | ||
// If not, just look in the global object and any local scope | ||
// (reading into JS mode internals to get at the local and global variables) | ||
@@ -140,3 +140,3 @@ for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name); | ||
if (!options || options.useGlobalScope !== false) | ||
gatherCompletions(window); | ||
gatherCompletions(global); | ||
forEach(keywords, maybeAdd); | ||
@@ -143,0 +143,0 @@ } |
@@ -21,6 +21,13 @@ // 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; | ||
} | ||
var inner = CodeMirror.innerMode(cm.getMode(), token.state); | ||
if (inner.mode.name != "xml") return; | ||
var result = [], replaceToken = false, prefix; | ||
var tag = /\btag\b/.test(token.type), tagName = tag && /^\w/.test(token.string), tagStart; | ||
var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string); | ||
var tagName = tag && /^\w/.test(token.string), tagStart; | ||
if (tagName) { | ||
@@ -35,2 +42,3 @@ var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start); | ||
} | ||
if (!tag && !inner.state.tagName || tagType) { | ||
@@ -37,0 +45,0 @@ if (tagName) |
@@ -6,8 +6,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (typeof exports == "object" && typeof module == "object") // CommonJS | ||
mod(require("../../lib/codemirror")); | ||
mod(require("../../lib/codemirror"), "cjs"); | ||
else if (typeof define == "function" && define.amd) // AMD | ||
define(["../../lib/codemirror"], mod); | ||
define(["../../lib/codemirror"], function(CM) { mod(CM, "amd"); }); | ||
else // Plain browser env | ||
mod(CodeMirror); | ||
})(function(CodeMirror) { | ||
mod(CodeMirror, "plain"); | ||
})(function(CodeMirror, env) { | ||
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js"; | ||
@@ -39,17 +39,20 @@ | ||
var script = document.createElement("script"); | ||
script.src = CodeMirror.modeURL.replace(/%N/g, mode); | ||
var others = document.getElementsByTagName("script")[0]; | ||
others.parentNode.insertBefore(script, others); | ||
var list = loading[mode] = [cont]; | ||
var count = 0, poll = setInterval(function() { | ||
if (++count > 100) return clearInterval(poll); | ||
if (CodeMirror.modes.hasOwnProperty(mode)) { | ||
clearInterval(poll); | ||
loading[mode] = null; | ||
var file = CodeMirror.modeURL.replace(/%N/g, mode); | ||
if (env == "plain") { | ||
var script = document.createElement("script"); | ||
script.src = file; | ||
var others = document.getElementsByTagName("script")[0]; | ||
var list = loading[mode] = [cont]; | ||
CodeMirror.on(script, "load", function() { | ||
ensureDeps(mode, function() { | ||
for (var i = 0; i < list.length; ++i) list[i](); | ||
}); | ||
} | ||
}, 200); | ||
}); | ||
others.parentNode.insertBefore(script, others); | ||
} else if (env == "cjs") { | ||
require(file); | ||
cont(); | ||
} else if (env == "amd") { | ||
requirejs([file], cont); | ||
} | ||
}; | ||
@@ -56,0 +59,0 @@ |
@@ -31,3 +31,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
overlayPos: 0, overlayCur: null, | ||
lineSeen: null | ||
streamSeen: null | ||
}; | ||
@@ -45,5 +45,5 @@ }, | ||
token: function(stream, state) { | ||
if (stream.sol() || stream.string != state.lineSeen || | ||
if (stream != state.streamSeen || | ||
Math.min(state.basePos, state.overlayPos) < stream.start) { | ||
state.lineSeen = stream.string; | ||
state.streamSeen = stream; | ||
state.basePos = state.overlayPos = stream.start; | ||
@@ -50,0 +50,0 @@ } |
{ | ||
"name": "codemirror", | ||
"version":"4.7.0", | ||
"version":"4.8.0", | ||
"main": ["lib/codemirror.js", "lib/codemirror.css"], | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -10,3 +10,3 @@ # How to contribute | ||
Community discussion, questions, and informal bug reporting is done on the | ||
[CodeMirror Google group](http://groups.google.com/group/codemirror). | ||
[discuss.CodeMirror forum](http://discuss.codemirror.net). | ||
@@ -21,3 +21,3 @@ ## Submitting bug reports | ||
should be asked on the | ||
[CodeMirror Google group](http://groups.google.com/group/codemirror) instead. | ||
[discuss.CodeMirror forum](http://discuss.codemirror.net) instead. | ||
@@ -24,0 +24,0 @@ ### Reporting bugs effectively |
@@ -259,3 +259,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var keyMap = CodeMirror.keyMap.emacs = { | ||
var keyMap = CodeMirror.keyMap.emacs = CodeMirror.normalizeKeyMap({ | ||
"Ctrl-W": function(cm) {kill(cm, cm.getCursor("start"), cm.getCursor("end"));}, | ||
@@ -357,23 +357,3 @@ "Ctrl-K": repeated(function(cm) { | ||
"Alt-G": function(cm) {cm.setOption("keyMap", "emacs-Alt-G");}, | ||
"Ctrl-X": function(cm) {cm.setOption("keyMap", "emacs-Ctrl-X");}, | ||
"Ctrl-Q": function(cm) {cm.setOption("keyMap", "emacs-Ctrl-Q");}, | ||
"Ctrl-U": addPrefixMap | ||
}; | ||
CodeMirror.keyMap["emacs-Ctrl-X"] = { | ||
"Tab": function(cm) { | ||
cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit")); | ||
}, | ||
"Ctrl-X": function(cm) { | ||
cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor")); | ||
}, | ||
"Ctrl-S": "save", "Ctrl-W": "save", "S": "saveAll", "F": "open", "U": repeated("undo"), "K": "close", | ||
"Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); }, | ||
auto: "emacs", nofallthrough: true, disableInput: true | ||
}; | ||
CodeMirror.keyMap["emacs-Alt-G"] = { | ||
"G": function(cm) { | ||
"Alt-G G": function(cm) { | ||
var prefix = getPrefix(cm, true); | ||
@@ -388,10 +368,21 @@ if (prefix != null && prefix > 0) return cm.setCursor(prefix - 1); | ||
}, | ||
auto: "emacs", nofallthrough: true, disableInput: true | ||
}; | ||
CodeMirror.keyMap["emacs-Ctrl-Q"] = { | ||
"Tab": repeated("insertTab"), | ||
auto: "emacs", nofallthrough: true | ||
}; | ||
"Ctrl-X Tab": function(cm) { | ||
cm.indentSelection(getPrefix(cm, true) || cm.getOption("indentUnit")); | ||
}, | ||
"Ctrl-X Ctrl-X": function(cm) { | ||
cm.setSelection(cm.getCursor("head"), cm.getCursor("anchor")); | ||
}, | ||
"Ctrl-X Ctrl-S": "save", | ||
"Ctrl-X Ctrl-W": "save", | ||
"Ctrl-X S": "saveAll", | ||
"Ctrl-X F": "open", | ||
"Ctrl-X U": repeated("undo"), | ||
"Ctrl-X K": "close", | ||
"Ctrl-X Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); }, | ||
"Ctrl-Q Tab": repeated("insertTab"), | ||
"Ctrl-U": addPrefixMap | ||
}); | ||
var prefixMap = {"Ctrl-G": clearPrefix}; | ||
@@ -398,0 +389,0 @@ function regPrefix(d) { |
@@ -389,6 +389,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var mapK = CodeMirror.keyMap["sublime-Ctrl-K"] = {auto: "sublime", nofallthrough: true}; | ||
var cK = ctrl + "K "; | ||
map[ctrl + "K"] = function(cm) {cm.setOption("keyMap", "sublime-Ctrl-K");}; | ||
function modifyWordOrSelection(cm, mod) { | ||
@@ -413,5 +411,5 @@ cm.operation(function() { | ||
mapK[ctrl + "Backspace"] = "delLineLeft"; | ||
map[cK + ctrl + "Backspace"] = "delLineLeft"; | ||
cmds[mapK[ctrl + "K"] = "delLineRight"] = function(cm) { | ||
cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) { | ||
cm.operation(function() { | ||
@@ -425,18 +423,18 @@ var ranges = cm.listSelections(); | ||
cmds[mapK[ctrl + "U"] = "upcaseAtCursor"] = function(cm) { | ||
cmds[map[cK + ctrl + "U"] = "upcaseAtCursor"] = function(cm) { | ||
modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); }); | ||
}; | ||
cmds[mapK[ctrl + "L"] = "downcaseAtCursor"] = function(cm) { | ||
cmds[map[cK + ctrl + "L"] = "downcaseAtCursor"] = function(cm) { | ||
modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); }); | ||
}; | ||
cmds[mapK[ctrl + "Space"] = "setSublimeMark"] = function(cm) { | ||
cmds[map[cK + ctrl + "Space"] = "setSublimeMark"] = function(cm) { | ||
if (cm.state.sublimeMark) cm.state.sublimeMark.clear(); | ||
cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); | ||
}; | ||
cmds[mapK[ctrl + "A"] = "selectToSublimeMark"] = function(cm) { | ||
cmds[map[cK + ctrl + "A"] = "selectToSublimeMark"] = function(cm) { | ||
var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); | ||
if (found) cm.setSelection(cm.getCursor(), found); | ||
}; | ||
cmds[mapK[ctrl + "W"] = "deleteToSublimeMark"] = function(cm) { | ||
cmds[map[cK + ctrl + "W"] = "deleteToSublimeMark"] = function(cm) { | ||
var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); | ||
@@ -450,3 +448,3 @@ if (found) { | ||
}; | ||
cmds[mapK[ctrl + "X"] = "swapWithSublimeMark"] = function(cm) { | ||
cmds[map[cK + ctrl + "X"] = "swapWithSublimeMark"] = function(cm) { | ||
var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); | ||
@@ -459,3 +457,3 @@ if (found) { | ||
}; | ||
cmds[mapK[ctrl + "Y"] = "sublimeYank"] = function(cm) { | ||
cmds[map[cK + ctrl + "Y"] = "sublimeYank"] = function(cm) { | ||
if (cm.state.sublimeKilled != null) | ||
@@ -465,4 +463,4 @@ cm.replaceSelection(cm.state.sublimeKilled, null, "paste"); | ||
mapK[ctrl + "G"] = "clearBookmarks"; | ||
cmds[mapK[ctrl + "C"] = "showInCenter"] = function(cm) { | ||
map[cK + ctrl + "G"] = "clearBookmarks"; | ||
cmds[map[cK + ctrl + "C"] = "showInCenter"] = function(cm) { | ||
var pos = cm.cursorCoords(null, "local"); | ||
@@ -539,3 +537,3 @@ cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); | ||
map["Shift-" + ctrl + "]"] = "unfold"; | ||
mapK[ctrl + "0"] = mapK[ctrl + "j"] = "unfoldAll"; | ||
map[cK + ctrl + "0"] = map[cK + ctrl + "j"] = "unfoldAll"; | ||
@@ -548,2 +546,3 @@ map[ctrl + "I"] = "findIncremental"; | ||
CodeMirror.normalizeKeyMap(map); | ||
}); |
@@ -474,2 +474,17 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
def("text/x-objectivec", { | ||
name: "clike", | ||
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " + | ||
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), | ||
atoms: words("YES NO NULL NILL ON OFF"), | ||
hooks: { | ||
"@": function(stream) { | ||
stream.eatWhile(/[\w\$]/); | ||
return "keyword"; | ||
}, | ||
"#": cppHook | ||
}, | ||
modeProps: {fold: "brace"} | ||
}); | ||
}); |
@@ -185,3 +185,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
} else if (allowNested) { | ||
override = stream.match(/^\s*:/, false) ? "property" : "tag"; | ||
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; | ||
return "block"; | ||
@@ -188,0 +188,0 @@ } else { |
@@ -112,3 +112,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
taskLists: true, | ||
fencedCodeBlocks: true | ||
fencedCodeBlocks: true, | ||
strikethrough: true | ||
}; | ||
@@ -115,0 +116,0 @@ for (var attr in modeConfig) { |
@@ -25,2 +25,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
FT("formatting_strikethrough", | ||
"[strikethrough&formatting&formatting-strikethrough ~~][strikethrough foo][strikethrough&formatting&formatting-strikethrough ~~]"); | ||
FT("formatting_strikethrough", | ||
"foo [strikethrough&formatting&formatting-strikethrough ~~][strikethrough bar][strikethrough&formatting&formatting-strikethrough ~~]"); | ||
MT("emInWordAsterisk", | ||
@@ -165,2 +171,45 @@ "foo[em *bar*]hello"); | ||
"Link: [link http://www.example.com/]"); | ||
MT("strikethrough", | ||
"[strikethrough ~~foo~~]"); | ||
MT("strikethroughWithStartingSpace", | ||
"~~ foo~~"); | ||
MT("strikethroughUnclosedStrayTildes", | ||
"[strikethrough ~~foo~~~]"); | ||
MT("strikethroughUnclosedStrayTildes", | ||
"[strikethrough ~~foo ~~]"); | ||
MT("strikethroughUnclosedStrayTildes", | ||
"[strikethrough ~~foo ~~ bar]"); | ||
MT("strikethroughUnclosedStrayTildes", | ||
"[strikethrough ~~foo ~~ bar~~]hello"); | ||
MT("strikethroughOneLetter", | ||
"[strikethrough ~~a~~]"); | ||
MT("strikethroughWrapped", | ||
"[strikethrough ~~foo]", | ||
"[strikethrough foo~~]"); | ||
MT("strikethroughParagraph", | ||
"[strikethrough ~~foo]", | ||
"", | ||
"foo[strikethrough ~~bar]"); | ||
MT("strikethroughEm", | ||
"[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]"); | ||
MT("strikethroughEm", | ||
"[em *][em&strikethrough ~~foo~~][em *]"); | ||
MT("strikethroughStrong", | ||
"[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]"); | ||
MT("strikethroughStrong", | ||
"[strong **][strong&strikethrough ~~foo~~][strong **]"); | ||
})(); |
@@ -72,3 +72,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
state.localState = state.localMode = null; | ||
return html(stream, state); | ||
return null; | ||
} | ||
@@ -82,3 +82,3 @@ return maybeBackup(stream, /<\/\s*script\s*>/, | ||
state.localState = state.localMode = null; | ||
return html(stream, state); | ||
return null; | ||
} | ||
@@ -85,0 +85,0 @@ return maybeBackup(stream, /<\/\s*style\s*>/, |
@@ -6,5 +6,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (typeof exports == "object" && typeof module == "object") // CommonJS | ||
mod(require("../../lib/codemirror", require("../xml/xml"))); | ||
mod(require("../../lib/codemirror", require("../xml/xml"), require("../meta"))); | ||
else if (typeof define == "function" && define.amd) // AMD | ||
define(["../../lib/codemirror", "../xml/xml"], mod); | ||
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod); | ||
else // Plain browser env | ||
@@ -19,42 +19,12 @@ mod(CodeMirror); | ||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain"); | ||
var aliases = { | ||
html: "htmlmixed", | ||
js: "javascript", | ||
json: "application/json", | ||
c: "text/x-csrc", | ||
"c++": "text/x-c++src", | ||
java: "text/x-java", | ||
csharp: "text/x-csharp", | ||
"c#": "text/x-csharp", | ||
scala: "text/x-scala" | ||
}; | ||
var getMode = (function () { | ||
var i, modes = {}, mimes = {}, mime; | ||
var list = []; | ||
for (var m in CodeMirror.modes) | ||
if (CodeMirror.modes.propertyIsEnumerable(m)) list.push(m); | ||
for (i = 0; i < list.length; i++) { | ||
modes[list[i]] = list[i]; | ||
function getMode(name) { | ||
if (CodeMirror.findModeByName) { | ||
var found = CodeMirror.findModeByName(name); | ||
if (found) name = found.mime || found.mimes[0]; | ||
} | ||
var mimesList = []; | ||
for (var m in CodeMirror.mimeModes) | ||
if (CodeMirror.mimeModes.propertyIsEnumerable(m)) | ||
mimesList.push({mime: m, mode: CodeMirror.mimeModes[m]}); | ||
for (i = 0; i < mimesList.length; i++) { | ||
mime = mimesList[i].mime; | ||
mimes[mime] = mimesList[i].mime; | ||
} | ||
var mode = CodeMirror.getMode(cmCfg, name); | ||
return mode.name == "null" ? null : mode; | ||
} | ||
for (var a in aliases) { | ||
if (aliases[a] in modes || aliases[a] in mimes) | ||
modes[a] = aliases[a]; | ||
} | ||
return function (lang) { | ||
return modes[lang] ? CodeMirror.getMode(cmCfg, modes[lang]) : null; | ||
}; | ||
}()); | ||
// Should characters that affect highlighting be highlighted separate? | ||
@@ -80,2 +50,6 @@ // Does not include characters that will be output (such as `1.` and `-` for lists) | ||
// Turn on strikethrough syntax | ||
if (modeCfg.strikethrough === undefined) | ||
modeCfg.strikethrough = false; | ||
var codeDepth = 0; | ||
@@ -97,3 +71,4 @@ | ||
, em = 'em' | ||
, strong = 'strong'; | ||
, strong = 'strong' | ||
, strikethrough = 'strikethrough'; | ||
@@ -106,3 +81,3 @@ var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/ | ||
, setextHeaderRE = /^(?:\={1,}|-{1,})$/ | ||
, textRE = /^[^#!\[\]*_\\<>` "'(]+/; | ||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/; | ||
@@ -129,2 +104,4 @@ function switchInline(stream, state, f) { | ||
state.strong = false; | ||
// Reset strikethrough state | ||
state.strikethrough = false; | ||
// Reset state.quote | ||
@@ -206,7 +183,7 @@ state.quote = 0; | ||
return getType(state); | ||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```([\w+#]*)/, true)) { | ||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) { | ||
// try switching mode | ||
state.localMode = getMode(RegExp.$1); | ||
if (state.localMode) state.localState = state.localMode.startState(); | ||
switchBlock(stream, state, local); | ||
state.f = state.block = local; | ||
if (modeCfg.highlightFormatting) state.formatting = "code-block"; | ||
@@ -232,11 +209,6 @@ state.code = true; | ||
function local(stream, state) { | ||
if (stream.sol() && stream.match(/^```/, true)) { | ||
if (stream.sol() && stream.match("```", false)) { | ||
state.localMode = state.localState = null; | ||
state.f = inlineNormal; | ||
state.block = blockNormal; | ||
if (modeCfg.highlightFormatting) state.formatting = "code-block"; | ||
state.code = true; | ||
var returnType = getType(state); | ||
state.code = false; | ||
return returnType; | ||
state.f = state.block = leavingLocal; | ||
return null; | ||
} else if (state.localMode) { | ||
@@ -250,2 +222,13 @@ return state.localMode.token(stream, state.localState); | ||
function leavingLocal(stream, state) { | ||
stream.match("```"); | ||
state.block = blockNormal; | ||
state.f = inlineNormal; | ||
if (modeCfg.highlightFormatting) state.formatting = "code-block"; | ||
state.code = true; | ||
var returnType = getType(state); | ||
state.code = false; | ||
return returnType; | ||
} | ||
// Inline | ||
@@ -295,2 +278,3 @@ function getType(state) { | ||
if (state.em) { styles.push(em); } | ||
if (state.strikethrough) { styles.push(strikethrough); } | ||
@@ -524,2 +508,25 @@ if (state.linkText) { styles.push(linktext); } | ||
if (modeCfg.strikethrough) { | ||
if (ch === '~' && stream.eatWhile(ch)) { | ||
if (state.strikethrough) {// Remove strikethrough | ||
if (modeCfg.highlightFormatting) state.formatting = "strikethrough"; | ||
var t = getType(state); | ||
state.strikethrough = false; | ||
return t; | ||
} else if (stream.match(/^[^\s]/, false)) {// Add strikethrough | ||
state.strikethrough = true; | ||
if (modeCfg.highlightFormatting) state.formatting = "strikethrough"; | ||
return getType(state); | ||
} | ||
} else if (ch === ' ') { | ||
if (stream.match(/^~~/, true)) { // Probably surrounded by space | ||
if (stream.peek() === ' ') { // Surrounded by spaces, ignore | ||
return getType(state); | ||
} else { // Not surrounded by spaces, back up pointer | ||
stream.backUp(2); | ||
} | ||
} | ||
} | ||
} | ||
if (ch === ' ') { | ||
@@ -673,3 +680,4 @@ if (stream.match(/ +$/, false)) { | ||
trailingSpace: 0, | ||
trailingSpaceNewLine: false | ||
trailingSpaceNewLine: false, | ||
strikethrough: false | ||
}; | ||
@@ -698,2 +706,3 @@ }, | ||
strong: s.strong, | ||
strikethrough: s.strikethrough, | ||
header: s.header, | ||
@@ -749,5 +758,3 @@ taskList: s.taskList, | ||
} | ||
var result = state.f(stream, state); | ||
if (stream.start == stream.pos) return this.token(stream, state); | ||
else return result; | ||
return state.f(stream, state); | ||
}, | ||
@@ -754,0 +761,0 @@ |
@@ -18,8 +18,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]}, | ||
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"]}, | ||
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"], alias: ["cpp"]}, | ||
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]}, | ||
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"]}, | ||
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]}, | ||
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]}, | ||
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"]}, | ||
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"]}, | ||
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]}, | ||
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]}, | ||
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"}, | ||
@@ -31,2 +31,4 @@ {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]}, | ||
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]}, | ||
{name: "Django", mime: "text/x-django", mode: "django"}, | ||
{name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile"}, | ||
{name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]}, | ||
@@ -39,3 +41,3 @@ {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]}, | ||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]}, | ||
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"]}, | ||
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]}, | ||
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]}, | ||
@@ -50,12 +52,13 @@ {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]}, | ||
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]}, | ||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"]}, | ||
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"]}, | ||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]}, | ||
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]}, | ||
{name: "HTTP", mime: "message/http", mode: "http"}, | ||
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]}, | ||
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]}, | ||
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]}, | ||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"]}, | ||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]}, | ||
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"], | ||
mode: "javascript", ext: ["js"]}, | ||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"]}, | ||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript"}, | ||
mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]}, | ||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]}, | ||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", alias: ["jsonld"]}, | ||
{name: "Jinja2", mime: "null", mode: "jinja2"}, | ||
@@ -65,3 +68,3 @@ {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]}, | ||
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]}, | ||
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"]}, | ||
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]}, | ||
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]}, | ||
@@ -76,2 +79,3 @@ {name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]}, | ||
{name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]}, | ||
{name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]}, | ||
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]}, | ||
@@ -86,9 +90,11 @@ {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]}, | ||
{name: "PLSQL", mime: "text/x-plsql", mode: "sql"}, | ||
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"]}, | ||
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]}, | ||
{name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]}, | ||
{name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]}, | ||
{name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]}, | ||
{name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"]}, | ||
{name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"]}, | ||
{name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"]}, | ||
{name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]}, | ||
{name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]}, | ||
{name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"}, | ||
{name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]}, | ||
{name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]}, | ||
{name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]}, | ||
@@ -99,3 +105,3 @@ {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]}, | ||
{name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]}, | ||
{name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"]}, | ||
{name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"]}, | ||
{name: "Sieve", mime: "application/sieve", mode: "sieve"}, | ||
@@ -107,7 +113,7 @@ {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim"}, | ||
{name: "Solr", mime: "text/x-solr", mode: "solr"}, | ||
{name: "SPARQL", mime: "application/x-sparql-query", mode: "sparql", ext: ["sparql"]}, | ||
{name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]}, | ||
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, | ||
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"}, | ||
{name: "sTeX", mime: "text/x-stex", mode: "stex"}, | ||
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"]}, | ||
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]}, | ||
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]}, | ||
@@ -121,3 +127,3 @@ {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]}, | ||
{name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]}, | ||
{name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"]}, | ||
{name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]}, | ||
{name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]}, | ||
@@ -127,5 +133,5 @@ {name: "VBScript", mime: "text/vbscript", mode: "vbscript"}, | ||
{name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]}, | ||
{name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"]}, | ||
{name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]}, | ||
{name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]}, | ||
{name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml"]}, | ||
{name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml"], alias: ["yml"]}, | ||
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]} | ||
@@ -155,2 +161,12 @@ ]; | ||
}; | ||
CodeMirror.findModeByName = function(name) { | ||
name = name.toLowerCase(); | ||
for (var i = 0; i < CodeMirror.modeInfo.length; i++) { | ||
var info = CodeMirror.modeInfo[i]; | ||
if (info.name.toLowerCase() == name) return info; | ||
if (info.alias) for (var j = 0; j < info.alias.length; j++) | ||
if (info.alias[j].toLowerCase() == name) return info; | ||
} | ||
}; | ||
}); |
@@ -22,2 +22,8 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri", | ||
"iri", "uri", "bnode", "count", "sum", "min", "max", "avg", "sample", | ||
"group_concat", "rand", "abs", "ceil", "floor", "round", "concat", "substr", "strlen", | ||
"replace", "ucase", "lcase", "encode_for_uri", "contains", "strstarts", "strends", | ||
"strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds", | ||
"timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384", | ||
"sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists", | ||
"isblank", "isliteral", "a"]); | ||
@@ -28,4 +34,5 @@ var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe", | ||
"minus", "in", "not", "service", "silent", "using", "insert", "delete", "union", | ||
"true", "false", "with", | ||
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]); | ||
var operatorChars = /[*+\-<>=&|]/; | ||
var operatorChars = /[*+\-<>=&|\^\/!\?]/; | ||
@@ -36,2 +43,5 @@ function tokenBase(stream, state) { | ||
if (ch == "$" || ch == "?") { | ||
if(ch == "?" && stream.match(/\s/, false)){ | ||
return "operator"; | ||
} | ||
stream.match(/^[\w\d]*/); | ||
@@ -50,3 +60,3 @@ return "variable-2"; | ||
curPunc = ch; | ||
return null; | ||
return "bracket"; | ||
} | ||
@@ -59,3 +69,3 @@ else if (ch == "#") { | ||
stream.eatWhile(operatorChars); | ||
return null; | ||
return "operator"; | ||
} | ||
@@ -66,2 +76,6 @@ else if (ch == ":") { | ||
} | ||
else if (ch == "@") { | ||
stream.eatWhile(/[a-z\d\-]/i); | ||
return "meta"; | ||
} | ||
else { | ||
@@ -75,3 +89,3 @@ stream.eatWhile(/[_\w\d]/); | ||
if (ops.test(word)) | ||
return null; | ||
return "builtin"; | ||
else if (keywords.test(word)) | ||
@@ -165,4 +179,4 @@ return "keyword"; | ||
CodeMirror.defineMIME("application/x-sparql-query", "sparql"); | ||
CodeMirror.defineMIME("application/sparql-query", "sparql"); | ||
}); |
@@ -370,4 +370,2 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
A list of keywords you want to be highlighted. | ||
functions: | ||
A list of function names you want to be highlighted. | ||
builtin: | ||
@@ -374,0 +372,0 @@ A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword"). |
@@ -17,24 +17,24 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
})(function(CodeMirror) { | ||
"use strict"; | ||
"use strict"; | ||
CodeMirror.defineMode("stex", function() { | ||
CodeMirror.defineMode("stex", function() { | ||
"use strict"; | ||
function pushCommand(state, command) { | ||
state.cmdState.push(command); | ||
state.cmdState.push(command); | ||
} | ||
function peekCommand(state) { | ||
if (state.cmdState.length > 0) { | ||
return state.cmdState[state.cmdState.length - 1]; | ||
} else { | ||
return null; | ||
} | ||
if (state.cmdState.length > 0) { | ||
return state.cmdState[state.cmdState.length - 1]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
function popCommand(state) { | ||
var plug = state.cmdState.pop(); | ||
if (plug) { | ||
plug.closeBracket(); | ||
} | ||
var plug = state.cmdState.pop(); | ||
if (plug) { | ||
plug.closeBracket(); | ||
} | ||
} | ||
@@ -44,30 +44,30 @@ | ||
function getMostPowerful(state) { | ||
var context = state.cmdState; | ||
for (var i = context.length - 1; i >= 0; i--) { | ||
var plug = context[i]; | ||
if (plug.name == "DEFAULT") { | ||
continue; | ||
} | ||
return plug; | ||
var context = state.cmdState; | ||
for (var i = context.length - 1; i >= 0; i--) { | ||
var plug = context[i]; | ||
if (plug.name == "DEFAULT") { | ||
continue; | ||
} | ||
return { styleIdentifier: function() { return null; } }; | ||
return plug; | ||
} | ||
return { styleIdentifier: function() { return null; } }; | ||
} | ||
function addPluginPattern(pluginName, cmdStyle, styles) { | ||
return function () { | ||
this.name = pluginName; | ||
this.bracketNo = 0; | ||
this.style = cmdStyle; | ||
this.styles = styles; | ||
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin | ||
return function () { | ||
this.name = pluginName; | ||
this.bracketNo = 0; | ||
this.style = cmdStyle; | ||
this.styles = styles; | ||
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin | ||
this.styleIdentifier = function() { | ||
return this.styles[this.bracketNo - 1] || null; | ||
}; | ||
this.openBracket = function() { | ||
this.bracketNo++; | ||
return "bracket"; | ||
}; | ||
this.closeBracket = function() {}; | ||
this.styleIdentifier = function() { | ||
return this.styles[this.bracketNo - 1] || null; | ||
}; | ||
this.openBracket = function() { | ||
this.bracketNo++; | ||
return "bracket"; | ||
}; | ||
this.closeBracket = function() {}; | ||
}; | ||
} | ||
@@ -84,10 +84,10 @@ | ||
plugins["DEFAULT"] = function () { | ||
this.name = "DEFAULT"; | ||
this.style = "tag"; | ||
this.name = "DEFAULT"; | ||
this.style = "tag"; | ||
this.styleIdentifier = this.openBracket = this.closeBracket = function() {}; | ||
this.styleIdentifier = this.openBracket = this.closeBracket = function() {}; | ||
}; | ||
function setState(state, f) { | ||
state.f = f; | ||
state.f = f; | ||
} | ||
@@ -97,170 +97,161 @@ | ||
function normal(source, state) { | ||
var plug; | ||
// Do we look like '\command' ? If so, attempt to apply the plugin 'command' | ||
if (source.match(/^\\[a-zA-Z@]+/)) { | ||
var cmdName = source.current().slice(1); | ||
plug = plugins[cmdName] || plugins["DEFAULT"]; | ||
plug = new plug(); | ||
pushCommand(state, plug); | ||
setState(state, beginParams); | ||
return plug.style; | ||
} | ||
var plug; | ||
// Do we look like '\command' ? If so, attempt to apply the plugin 'command' | ||
if (source.match(/^\\[a-zA-Z@]+/)) { | ||
var cmdName = source.current().slice(1); | ||
plug = plugins[cmdName] || plugins["DEFAULT"]; | ||
plug = new plug(); | ||
pushCommand(state, plug); | ||
setState(state, beginParams); | ||
return plug.style; | ||
} | ||
// escape characters | ||
if (source.match(/^\\[$&%#{}_]/)) { | ||
return "tag"; | ||
} | ||
// escape characters | ||
if (source.match(/^\\[$&%#{}_]/)) { | ||
return "tag"; | ||
} | ||
// white space control characters | ||
if (source.match(/^\\[,;!\/\\]/)) { | ||
return "tag"; | ||
} | ||
// white space control characters | ||
if (source.match(/^\\[,;!\/\\]/)) { | ||
return "tag"; | ||
} | ||
// find if we're starting various math modes | ||
if (source.match("\\[")) { | ||
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); }); | ||
return "keyword"; | ||
} | ||
if (source.match("$$")) { | ||
setState(state, function(source, state){ return inMathMode(source, state, "$$"); }); | ||
return "keyword"; | ||
} | ||
if (source.match("$")) { | ||
setState(state, function(source, state){ return inMathMode(source, state, "$"); }); | ||
return "keyword"; | ||
} | ||
// find if we're starting various math modes | ||
if (source.match("\\[")) { | ||
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); }); | ||
return "keyword"; | ||
} | ||
if (source.match("$$")) { | ||
setState(state, function(source, state){ return inMathMode(source, state, "$$"); }); | ||
return "keyword"; | ||
} | ||
if (source.match("$")) { | ||
setState(state, function(source, state){ return inMathMode(source, state, "$"); }); | ||
return "keyword"; | ||
} | ||
var ch = source.next(); | ||
if (ch == "%") { | ||
// special case: % at end of its own line; stay in same state | ||
if (!source.eol()) { | ||
setState(state, inCComment); | ||
} | ||
return "comment"; | ||
var ch = source.next(); | ||
if (ch == "%") { | ||
source.skipToEnd(); | ||
return "comment"; | ||
} | ||
else if (ch == '}' || ch == ']') { | ||
plug = peekCommand(state); | ||
if (plug) { | ||
plug.closeBracket(ch); | ||
setState(state, beginParams); | ||
} else { | ||
return "error"; | ||
} | ||
else if (ch == '}' || ch == ']') { | ||
plug = peekCommand(state); | ||
if (plug) { | ||
plug.closeBracket(ch); | ||
setState(state, beginParams); | ||
} else { | ||
return "error"; | ||
} | ||
return "bracket"; | ||
} else if (ch == '{' || ch == '[') { | ||
plug = plugins["DEFAULT"]; | ||
plug = new plug(); | ||
pushCommand(state, plug); | ||
return "bracket"; | ||
return "bracket"; | ||
} else if (ch == '{' || ch == '[') { | ||
plug = plugins["DEFAULT"]; | ||
plug = new plug(); | ||
pushCommand(state, plug); | ||
return "bracket"; | ||
} | ||
else if (/\d/.test(ch)) { | ||
source.eatWhile(/[\w.%]/); | ||
return "atom"; | ||
} | ||
else { | ||
source.eatWhile(/[\w\-_]/); | ||
plug = getMostPowerful(state); | ||
if (plug.name == 'begin') { | ||
plug.argument = source.current(); | ||
} | ||
else if (/\d/.test(ch)) { | ||
source.eatWhile(/[\w.%]/); | ||
return "atom"; | ||
} | ||
else { | ||
source.eatWhile(/[\w\-_]/); | ||
plug = getMostPowerful(state); | ||
if (plug.name == 'begin') { | ||
plug.argument = source.current(); | ||
} | ||
return plug.styleIdentifier(); | ||
} | ||
return plug.styleIdentifier(); | ||
} | ||
} | ||
function inCComment(source, state) { | ||
function inMathMode(source, state, endModeSeq) { | ||
if (source.eatSpace()) { | ||
return null; | ||
} | ||
if (source.match(endModeSeq)) { | ||
setState(state, normal); | ||
return "keyword"; | ||
} | ||
if (source.match(/^\\[a-zA-Z@]+/)) { | ||
return "tag"; | ||
} | ||
if (source.match(/^[a-zA-Z]+/)) { | ||
return "variable-2"; | ||
} | ||
// escape characters | ||
if (source.match(/^\\[$&%#{}_]/)) { | ||
return "tag"; | ||
} | ||
// white space control characters | ||
if (source.match(/^\\[,;!\/]/)) { | ||
return "tag"; | ||
} | ||
// special math-mode characters | ||
if (source.match(/^[\^_&]/)) { | ||
return "tag"; | ||
} | ||
// non-special characters | ||
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) { | ||
return null; | ||
} | ||
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) { | ||
return "number"; | ||
} | ||
var ch = source.next(); | ||
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") { | ||
return "bracket"; | ||
} | ||
if (ch == "%") { | ||
source.skipToEnd(); | ||
setState(state, normal); | ||
return "comment"; | ||
} | ||
return "error"; | ||
} | ||
function inMathMode(source, state, endModeSeq) { | ||
if (source.eatSpace()) { | ||
return null; | ||
} | ||
if (source.match(endModeSeq)) { | ||
setState(state, normal); | ||
return "keyword"; | ||
} | ||
if (source.match(/^\\[a-zA-Z@]+/)) { | ||
return "tag"; | ||
} | ||
if (source.match(/^[a-zA-Z]+/)) { | ||
return "variable-2"; | ||
} | ||
// escape characters | ||
if (source.match(/^\\[$&%#{}_]/)) { | ||
return "tag"; | ||
} | ||
// white space control characters | ||
if (source.match(/^\\[,;!\/]/)) { | ||
return "tag"; | ||
} | ||
// special math-mode characters | ||
if (source.match(/^[\^_&]/)) { | ||
return "tag"; | ||
} | ||
// non-special characters | ||
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) { | ||
return null; | ||
} | ||
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) { | ||
return "number"; | ||
} | ||
var ch = source.next(); | ||
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") { | ||
return "bracket"; | ||
} | ||
// eat comments here, because inCComment returns us to normal state! | ||
if (ch == "%") { | ||
if (!source.eol()) { | ||
source.skipToEnd(); | ||
} | ||
return "comment"; | ||
} | ||
return "error"; | ||
} | ||
function beginParams(source, state) { | ||
var ch = source.peek(), lastPlug; | ||
if (ch == '{' || ch == '[') { | ||
lastPlug = peekCommand(state); | ||
lastPlug.openBracket(ch); | ||
source.eat(ch); | ||
setState(state, normal); | ||
return "bracket"; | ||
} | ||
if (/[ \t\r]/.test(ch)) { | ||
source.eat(ch); | ||
return null; | ||
} | ||
var ch = source.peek(), lastPlug; | ||
if (ch == '{' || ch == '[') { | ||
lastPlug = peekCommand(state); | ||
lastPlug.openBracket(ch); | ||
source.eat(ch); | ||
setState(state, normal); | ||
popCommand(state); | ||
return "bracket"; | ||
} | ||
if (/[ \t\r]/.test(ch)) { | ||
source.eat(ch); | ||
return null; | ||
} | ||
setState(state, normal); | ||
popCommand(state); | ||
return normal(source, state); | ||
return normal(source, state); | ||
} | ||
return { | ||
startState: function() { | ||
return { | ||
cmdState: [], | ||
f: normal | ||
}; | ||
}, | ||
copyState: function(s) { | ||
return { | ||
cmdState: s.cmdState.slice(), | ||
f: s.f | ||
}; | ||
}, | ||
token: function(stream, state) { | ||
return state.f(stream, state); | ||
}, | ||
lineComment: "%" | ||
startState: function() { | ||
return { | ||
cmdState: [], | ||
f: normal | ||
}; | ||
}, | ||
copyState: function(s) { | ||
return { | ||
cmdState: s.cmdState.slice(), | ||
f: s.f | ||
}; | ||
}, | ||
token: function(stream, state) { | ||
return state.f(stream, state); | ||
}, | ||
blankLine: function(state) { | ||
state.f = normal; | ||
}, | ||
lineComment: "%" | ||
}; | ||
}); | ||
}); | ||
CodeMirror.defineMIME("text/x-stex", "stex"); | ||
CodeMirror.defineMIME("text/x-latex", "stex"); | ||
CodeMirror.defineMIME("text/x-stex", "stex"); | ||
CodeMirror.defineMIME("text/x-latex", "stex"); | ||
}); |
@@ -26,4 +26,9 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) { | ||
stream.skipToEnd(); return "comment"; | ||
stream.skipToEnd(); | ||
return "comment"; | ||
} | ||
if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/)) | ||
return "string"; | ||
if (state.literal && stream.indentation() > state.keyCol) { | ||
@@ -30,0 +35,0 @@ stream.skipToEnd(); return "string"; |
{ | ||
"name": "codemirror", | ||
"version":"4.7.0", | ||
"version":"4.8.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
@@ -25,3 +25,3 @@ /* | ||
"CodeMirror " + | ||
"test exports require module define") | ||
"test exports require module define requirejs") | ||
.split(" ").forEach(function(n) { topAllowedGlobals[n] = true; }); | ||
@@ -28,0 +28,0 @@ |
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 too big to display
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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
3006766
382
52648
10