From 83ae4751f4df3ff32ddf5e11c7bb116689ac0c77 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 10 Oct 2016 00:04:11 +0800 Subject: optimize png images using zopflipng --- public/vendor/codemirror/mode/mediawiki/img/black4.png | Bin 91 -> 87 bytes public/vendor/codemirror/mode/mediawiki/img/ext2.png | Bin 91 -> 86 bytes public/vendor/codemirror/mode/mediawiki/img/ext4.png | Bin 91 -> 86 bytes public/vendor/codemirror/mode/mediawiki/img/link4.png | Bin 91 -> 86 bytes public/vendor/codemirror/mode/mediawiki/img/template4.png | Bin 91 -> 86 bytes public/vendor/codemirror/mode/mediawiki/img/template8.png | Bin 91 -> 86 bytes 6 files changed, 0 insertions(+), 0 deletions(-) (limited to 'public/vendor/codemirror/mode') diff --git a/public/vendor/codemirror/mode/mediawiki/img/black4.png b/public/vendor/codemirror/mode/mediawiki/img/black4.png index c66d7014..d34ee8e8 100755 Binary files a/public/vendor/codemirror/mode/mediawiki/img/black4.png and b/public/vendor/codemirror/mode/mediawiki/img/black4.png differ diff --git a/public/vendor/codemirror/mode/mediawiki/img/ext2.png b/public/vendor/codemirror/mode/mediawiki/img/ext2.png index d78a7429..e64c0564 100755 Binary files a/public/vendor/codemirror/mode/mediawiki/img/ext2.png and b/public/vendor/codemirror/mode/mediawiki/img/ext2.png differ diff --git a/public/vendor/codemirror/mode/mediawiki/img/ext4.png b/public/vendor/codemirror/mode/mediawiki/img/ext4.png index 11b439d4..87ef4e6b 100755 Binary files a/public/vendor/codemirror/mode/mediawiki/img/ext4.png and b/public/vendor/codemirror/mode/mediawiki/img/ext4.png differ diff --git a/public/vendor/codemirror/mode/mediawiki/img/link4.png b/public/vendor/codemirror/mode/mediawiki/img/link4.png index 07eca617..906d9a30 100755 Binary files a/public/vendor/codemirror/mode/mediawiki/img/link4.png and b/public/vendor/codemirror/mode/mediawiki/img/link4.png differ diff --git a/public/vendor/codemirror/mode/mediawiki/img/template4.png b/public/vendor/codemirror/mode/mediawiki/img/template4.png index 7eda15ab..d02f4222 100755 Binary files a/public/vendor/codemirror/mode/mediawiki/img/template4.png and b/public/vendor/codemirror/mode/mediawiki/img/template4.png differ diff --git a/public/vendor/codemirror/mode/mediawiki/img/template8.png b/public/vendor/codemirror/mode/mediawiki/img/template8.png index 4df75b05..f234e04c 100755 Binary files a/public/vendor/codemirror/mode/mediawiki/img/template8.png and b/public/vendor/codemirror/mode/mediawiki/img/template8.png differ -- cgit v1.2.3 From f6f469d0fe6082b046cf156a760324c53fcd72e5 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 10 Oct 2016 20:47:06 +0800 Subject: Update to use modified editor markdown mode to make mathjax expression display correctly --- .../codemirror/mode/markdown/markdown_math.js | 864 +++++++++++++++++++++ 1 file changed, 864 insertions(+) create mode 100644 public/vendor/codemirror/mode/markdown/markdown_math.js (limited to 'public/vendor/codemirror/mode') diff --git a/public/vendor/codemirror/mode/markdown/markdown_math.js b/public/vendor/codemirror/mode/markdown/markdown_math.js new file mode 100644 index 00000000..e46adb79 --- /dev/null +++ b/public/vendor/codemirror/mode/markdown/markdown_math.js @@ -0,0 +1,864 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../xml/xml", "../meta"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { + + var htmlMode = CodeMirror.getMode(cmCfg, "text/html"); + var htmlModeMissing = htmlMode.name == "null" + + function getMode(name) { + if (CodeMirror.findModeByName) { + var found = CodeMirror.findModeByName(name); + if (found) name = found.mime || found.mimes[0]; + } + var mode = CodeMirror.getMode(cmCfg, name); + return mode.name == "null" ? null : mode; + } + + // Should characters that affect highlighting be highlighted separate? + // Does not include characters that will be output (such as `1.` and `-` for lists) + if (modeCfg.highlightFormatting === undefined) + modeCfg.highlightFormatting = false; + + // Maximum number of nested blockquotes. Set to 0 for infinite nesting. + // Excess `>` will emit `error` token. + if (modeCfg.maxBlockquoteDepth === undefined) + modeCfg.maxBlockquoteDepth = 0; + + // Should underscores in words open/close em/strong? + if (modeCfg.underscoresBreakWords === undefined) + modeCfg.underscoresBreakWords = true; + + // Use `fencedCodeBlocks` to configure fenced code blocks. false to + // disable, string to specify a precise regexp that the fence should + // match, and true to allow three or more backticks or tildes (as + // per CommonMark). + + // Turn on task lists? ("- [ ] " and "- [x] ") + if (modeCfg.taskLists === undefined) modeCfg.taskLists = false; + + // Turn on strikethrough syntax + if (modeCfg.strikethrough === undefined) + modeCfg.strikethrough = false; + + // Allow token types to be overridden by user-provided token types. + if (modeCfg.tokenTypeOverrides === undefined) + modeCfg.tokenTypeOverrides = {}; + + var tokenTypes = { + header: "header", + code: "comment", + math: "math", + quote: "quote", + list1: "variable-2", + list2: "variable-3", + list3: "keyword", + hr: "hr", + image: "image", + imageAltText: "image-alt-text", + imageMarker: "image-marker", + formatting: "formatting", + linkInline: "link", + linkEmail: "link", + linkText: "link", + linkHref: "string", + em: "em", + strong: "strong", + strikethrough: "strikethrough" + }; + + for (var tokenType in tokenTypes) { + if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) { + tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType]; + } + } + + var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/ + , ulRE = /^[*\-+]\s+/ + , olRE = /^[0-9]+([.)])\s+/ + , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE + , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/ + , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/ + , textRE = /^[^#!\[\]*_\\<>\$` "'(~]+/ + , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) + + ")[ \\t]*([\\w+#\-]*)") + , fencedMathRE = new RegExp("^(\$\$)[ \\t]*([\\w+#\-]*)"); + + function switchInline(stream, state, f) { + state.f = state.inline = f; + return f(stream, state); + } + + function switchBlock(stream, state, f) { + state.f = state.block = f; + return f(stream, state); + } + + function lineIsEmpty(line) { + return !line || !/\S/.test(line.string) + } + + // Blocks + + function blankLine(state) { + // Reset linkTitle state + state.linkTitle = false; + // Reset EM state + state.em = false; + // Reset STRONG state + state.strong = false; + // Reset strikethrough state + state.strikethrough = false; + // Reset state.quote + state.quote = 0; + // Reset state.indentedCode + state.indentedCode = false; + if (htmlModeMissing && state.f == htmlBlock) { + state.f = inlineNormal; + state.block = blockNormal; + } + // Reset state.trailingSpace + state.trailingSpace = 0; + state.trailingSpaceNewLine = false; + // Mark this line as blank + state.prevLine = state.thisLine + state.thisLine = null + return null; + } + + function blockNormal(stream, state) { + + var sol = stream.sol(); + + var prevLineIsList = state.list !== false, + prevLineIsIndentedCode = state.indentedCode; + + state.indentedCode = false; + + if (prevLineIsList) { + if (state.indentationDiff >= 0) { // Continued list + if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block + state.indentation -= state.indentationDiff; + } + state.list = null; + } else if (state.indentation > 0) { + state.list = null; + } else { // No longer a list + state.list = false; + } + } + + var match = null; + if (state.indentationDiff >= 4) { + stream.skipToEnd(); + if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) { + state.indentation -= 4; + state.indentedCode = true; + return tokenTypes.code; + } else { + return null; + } + } else if (stream.eatSpace()) { + return null; + } else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) { + state.header = match[1].length; + if (modeCfg.highlightFormatting) state.formatting = "header"; + state.f = state.inline; + return getType(state); + } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList && + !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) { + state.header = match[0].charAt(0) == '=' ? 1 : 2; + if (modeCfg.highlightFormatting) state.formatting = "header"; + state.f = state.inline; + return getType(state); + } else if (stream.eat('>')) { + state.quote = sol ? 1 : state.quote + 1; + if (modeCfg.highlightFormatting) state.formatting = "quote"; + stream.eatSpace(); + return getType(state); + } else if (stream.peek() === '[') { + return switchInline(stream, state, footnoteLink); + } else if (stream.match(hrRE, true)) { + state.hr = true; + return tokenTypes.hr; + } else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) { + var listType = null; + if (stream.match(ulRE, true)) { + listType = 'ul'; + } else { + stream.match(olRE, true); + listType = 'ol'; + } + state.indentation = stream.column() + stream.current().length; + state.list = true; + + // While this list item's marker's indentation + // is less than the deepest list item's content's indentation, + // pop the deepest list item indentation off the stack. + while (state.listStack && stream.column() < state.listStack[state.listStack.length - 1]) { + state.listStack.pop(); + } + + // Add this list item's content's indentation to the stack + state.listStack.push(state.indentation); + + if (modeCfg.taskLists && stream.match(taskListRE, false)) { + state.taskList = true; + } + state.f = state.inline; + if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType]; + return getType(state); + } else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) { + state.fencedChars = match[1] + // try switching mode + state.localMode = getMode(match[2]); + if (state.localMode) state.localState = CodeMirror.startState(state.localMode); + state.f = state.block = local; + if (modeCfg.highlightFormatting) state.formatting = "code-block"; + state.code = -1 + return getType(state); + } else if (match = stream.match(fencedCodeRE, true)) { + state.fencedChars = match[1] + // try switching mode + state.localMode = getMode(match[2]); + if (state.localMode) state.localState = CodeMirror.startState(state.localMode); + state.f = state.block = local; + state.formatting = "math"; + state.math = -1 + return getType(state); + } + + return switchInline(stream, state, state.inline); + } + + function htmlBlock(stream, state) { + var style = htmlMode.token(stream, state.htmlState); + if (!htmlModeMissing) { + var inner = CodeMirror.innerMode(htmlMode, state.htmlState) + if ((inner.mode.name == "xml" && inner.state.tagStart === null && + (!inner.state.context && inner.state.tokenize.isInText)) || + (state.md_inside && stream.current().indexOf(">") > -1)) { + state.f = inlineNormal; + state.block = blockNormal; + state.htmlState = null; + } + } + return style; + } + + function local(stream, state) { + if (state.fencedChars && stream.match(state.fencedChars, false)) { + state.localMode = state.localState = null; + state.f = state.block = leavingLocal; + return null; + } else if (state.localMode) { + return state.localMode.token(stream, state.localState); + } else { + stream.skipToEnd(); + if (state.math === -1) { + return tokenTypes.math; + } + return tokenTypes.code; + } + } + + function leavingLocal(stream, state) { + stream.match(state.fencedChars); + state.block = blockNormal; + state.f = inlineNormal; + state.fencedChars = null; + if (state.math === -1) { + state.formatting = "math"; + state.math = 1 + var returnType = getType(state); + state.math = 0 + return returnType; + } + if (modeCfg.highlightFormatting) state.formatting = "code-block"; + state.code = 1 + var returnType = getType(state); + state.code = 0 + return returnType; + } + + // Inline + function getType(state) { + var styles = []; + + if (state.formatting) { + styles.push(tokenTypes.formatting); + + if (typeof state.formatting === "string") state.formatting = [state.formatting]; + + for (var i = 0; i < state.formatting.length; i++) { + styles.push(tokenTypes.formatting + "-" + state.formatting[i]); + + if (state.formatting[i] === "header") { + styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header); + } + + // Add `formatting-quote` and `formatting-quote-#` for blockquotes + // Add `error` instead if the maximum blockquote nesting depth is passed + if (state.formatting[i] === "quote") { + if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { + styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote); + } else { + styles.push("error"); + } + } + } + } + + if (state.taskOpen) { + styles.push("meta"); + return styles.length ? styles.join(' ') : null; + } + if (state.taskClosed) { + styles.push("property"); + return styles.length ? styles.join(' ') : null; + } + + if (state.linkHref) { + styles.push(tokenTypes.linkHref, "url"); + } else { // Only apply inline styles to non-url text + if (state.strong) { styles.push(tokenTypes.strong); } + if (state.em) { styles.push(tokenTypes.em); } + if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } + if (state.linkText) { styles.push(tokenTypes.linkText); } + if (state.code) { styles.push(tokenTypes.code); } + if (state.math) { styles.push(tokenTypes.math); } + if (state.image) { styles.push(tokenTypes.image); } + if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); } + if (state.imageMarker) { styles.push(tokenTypes.imageMarker); } + } + + if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } + + if (state.quote) { + styles.push(tokenTypes.quote); + + // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth + if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) { + styles.push(tokenTypes.quote + "-" + state.quote); + } else { + styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth); + } + } + + if (state.list !== false) { + var listMod = (state.listStack.length - 1) % 3; + if (!listMod) { + styles.push(tokenTypes.list1); + } else if (listMod === 1) { + styles.push(tokenTypes.list2); + } else { + styles.push(tokenTypes.list3); + } + } + + if (state.trailingSpaceNewLine) { + styles.push("trailing-space-new-line"); + } else if (state.trailingSpace) { + styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b")); + } + + return styles.length ? styles.join(' ') : null; + } + + function handleText(stream, state) { + if (stream.match(textRE, true)) { + return getType(state); + } + return undefined; + } + + function inlineNormal(stream, state) { + var style = state.text(stream, state); + if (typeof style !== 'undefined') + return style; + + if (state.list) { // List marker (*, +, -, 1., etc) + state.list = null; + return getType(state); + } + + if (state.taskList) { + var taskOpen = stream.match(taskListRE, true)[1] !== "x"; + if (taskOpen) state.taskOpen = true; + else state.taskClosed = true; + if (modeCfg.highlightFormatting) state.formatting = "task"; + state.taskList = false; + return getType(state); + } + + state.taskOpen = false; + state.taskClosed = false; + + if (state.header && stream.match(/^#+$/, true)) { + if (modeCfg.highlightFormatting) state.formatting = "header"; + return getType(state); + } + + // Get sol() value now, before character is consumed + var sol = stream.sol(); + + var ch = stream.next(); + + // Matches link titles present on next line + if (state.linkTitle) { + state.linkTitle = false; + var matchCh = ch; + if (ch === '(') { + matchCh = ')'; + } + matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); + var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh; + if (stream.match(new RegExp(regex), true)) { + return tokenTypes.linkHref; + } + } + + // If this block is changed, it may need to be updated in GFM mode + if (ch === '`') { + var previousFormatting = state.formatting; + if (modeCfg.highlightFormatting) state.formatting = "code"; + stream.eatWhile('`'); + var count = stream.current().length + if (state.code == 0) { + state.code = count + return getType(state) + } else if (count == state.code) { // Must be exact + var t = getType(state) + state.code = 0 + return t + } else { + state.formatting = previousFormatting + return getType(state) + } + } else if (state.code) { + return getType(state); + } + + // display math correctly + if (ch === '$') { + var previousFormatting = state.formatting; + state.formatting = "math"; + stream.eatWhile('$'); + var count = stream.current().length + if (state.math == 0) { + state.math = count + return getType(state) + } else if (count == state.math) { // Must be exact + var t = getType(state) + state.math = 0 + return t + } else { + state.formatting = previousFormatting + return getType(state) + } + } else if (state.math) { + return getType(state); + } + + if (ch === '\\') { + stream.next(); + if (modeCfg.highlightFormatting) { + var type = getType(state); + var formattingEscape = tokenTypes.formatting + "-escape"; + return type ? type + " " + formattingEscape : formattingEscape; + } + } + + if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { + state.imageMarker = true; + state.image = true; + if (modeCfg.highlightFormatting) state.formatting = "image"; + return getType(state); + } + + if (ch === '[' && state.imageMarker) { + state.imageMarker = false; + state.imageAltText = true + if (modeCfg.highlightFormatting) state.formatting = "image"; + return getType(state); + } + + if (ch === ']' && state.imageAltText) { + if (modeCfg.highlightFormatting) state.formatting = "image"; + var type = getType(state); + state.imageAltText = false; + state.image = false; + state.inline = state.f = linkHref; + return type; + } + + if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) { + state.linkText = true; + if (modeCfg.highlightFormatting) state.formatting = "link"; + return getType(state); + } + + if (ch === ']' && state.linkText && stream.match(/\(.*?\)| ?\[.*?\]/, false)) { + if (modeCfg.highlightFormatting) state.formatting = "link"; + var type = getType(state); + state.linkText = false; + state.inline = state.f = linkHref; + return type; + } + + if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) { + state.f = state.inline = linkInline; + if (modeCfg.highlightFormatting) state.formatting = "link"; + var type = getType(state); + if (type){ + type += " "; + } else { + type = ""; + } + return type + tokenTypes.linkInline; + } + + if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) { + state.f = state.inline = linkInline; + if (modeCfg.highlightFormatting) state.formatting = "link"; + var type = getType(state); + if (type){ + type += " "; + } else { + type = ""; + } + return type + tokenTypes.linkEmail; + } + + if (ch === '<' && stream.match(/^(!--|\w)/, false)) { + var end = stream.string.indexOf(">", stream.pos); + if (end != -1) { + var atts = stream.string.substring(stream.start, end); + if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true; + } + stream.backUp(1); + state.htmlState = CodeMirror.startState(htmlMode); + return switchBlock(stream, state, htmlBlock); + } + + if (ch === '<' && stream.match(/^\/\w*?>/)) { + state.md_inside = false; + return "tag"; + } + + var ignoreUnderscore = false; + if (!modeCfg.underscoresBreakWords) { + if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) { + var prevPos = stream.pos - 2; + if (prevPos >= 0) { + var prevCh = stream.string.charAt(prevPos); + if (prevCh !== '_' && prevCh.match(/(\w)/, false)) { + ignoreUnderscore = true; + } + } + } + } + if (ch === '*' || (ch === '_' && !ignoreUnderscore)) { + if (sol && stream.peek() === ' ') { + // Do nothing, surrounded by newline and space + } else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG + if (modeCfg.highlightFormatting) state.formatting = "strong"; + var t = getType(state); + state.strong = false; + return t; + } else if (!state.strong && stream.eat(ch)) { // Add STRONG + state.strong = ch; + if (modeCfg.highlightFormatting) state.formatting = "strong"; + return getType(state); + } else if (state.em === ch) { // Remove EM + if (modeCfg.highlightFormatting) state.formatting = "em"; + var t = getType(state); + state.em = false; + return t; + } else if (!state.em) { // Add EM + state.em = ch; + if (modeCfg.highlightFormatting) state.formatting = "em"; + return getType(state); + } + } else if (ch === ' ') { + if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces + if (stream.peek() === ' ') { // Surrounded by spaces, ignore + return getType(state); + } else { // Not surrounded by spaces, back up pointer + stream.backUp(1); + } + } + } + + 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 === ' ') { + if (stream.match(/ +$/, false)) { + state.trailingSpace++; + } else if (state.trailingSpace) { + state.trailingSpaceNewLine = true; + } + } + + return getType(state); + } + + function linkInline(stream, state) { + var ch = stream.next(); + + if (ch === ">") { + state.f = state.inline = inlineNormal; + if (modeCfg.highlightFormatting) state.formatting = "link"; + var type = getType(state); + if (type){ + type += " "; + } else { + type = ""; + } + return type + tokenTypes.linkInline; + } + + stream.match(/^[^>]+/, true); + + return tokenTypes.linkInline; + } + + function linkHref(stream, state) { + // Check if space, and return NULL if so (to avoid marking the space) + if(stream.eatSpace()){ + return null; + } + var ch = stream.next(); + if (ch === '(' || ch === '[') { + state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]", 0); + if (modeCfg.highlightFormatting) state.formatting = "link-string"; + state.linkHref = true; + return getType(state); + } + return 'error'; + } + + var linkRE = { + ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/, + "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/ + } + + function getLinkHrefInside(endChar) { + return function(stream, state) { + var ch = stream.next(); + + if (ch === endChar) { + state.f = state.inline = inlineNormal; + if (modeCfg.highlightFormatting) state.formatting = "link-string"; + var returnState = getType(state); + state.linkHref = false; + return returnState; + } + + stream.match(linkRE[endChar]) + state.linkHref = true; + return getType(state); + }; + } + + function footnoteLink(stream, state) { + if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) { + state.f = footnoteLinkInside; + stream.next(); // Consume [ + if (modeCfg.highlightFormatting) state.formatting = "link"; + state.linkText = true; + return getType(state); + } + return switchInline(stream, state, inlineNormal); + } + + function footnoteLinkInside(stream, state) { + if (stream.match(/^\]:/, true)) { + state.f = state.inline = footnoteUrl; + if (modeCfg.highlightFormatting) state.formatting = "link"; + var returnType = getType(state); + state.linkText = false; + return returnType; + } + + stream.match(/^([^\]\\]|\\.)+/, true); + + return tokenTypes.linkText; + } + + function footnoteUrl(stream, state) { + // Check if space, and return NULL if so (to avoid marking the space) + if(stream.eatSpace()){ + return null; + } + // Match URL + stream.match(/^[^\s]+/, true); + // Check for link title + if (stream.peek() === undefined) { // End of line, set flag to check next line + state.linkTitle = true; + } else { // More content on line, check if link title + stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true); + } + state.f = state.inline = inlineNormal; + return tokenTypes.linkHref + " url"; + } + + var mode = { + startState: function() { + return { + f: blockNormal, + + prevLine: null, + thisLine: null, + + block: blockNormal, + htmlState: null, + indentation: 0, + + inline: inlineNormal, + text: handleText, + + formatting: false, + linkText: false, + linkHref: false, + linkTitle: false, + code: 0, + math: 0, + em: false, + strong: false, + header: 0, + hr: false, + taskList: false, + list: false, + listStack: [], + quote: 0, + trailingSpace: 0, + trailingSpaceNewLine: false, + strikethrough: false, + fencedChars: null + }; + }, + + copyState: function(s) { + return { + f: s.f, + + prevLine: s.prevLine, + thisLine: s.thisLine, + + block: s.block, + htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState), + indentation: s.indentation, + + localMode: s.localMode, + localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null, + + inline: s.inline, + text: s.text, + formatting: false, + linkTitle: s.linkTitle, + code: s.code, + math: s.math, + em: s.em, + strong: s.strong, + strikethrough: s.strikethrough, + header: s.header, + hr: s.hr, + taskList: s.taskList, + list: s.list, + listStack: s.listStack.slice(0), + quote: s.quote, + indentedCode: s.indentedCode, + trailingSpace: s.trailingSpace, + trailingSpaceNewLine: s.trailingSpaceNewLine, + md_inside: s.md_inside, + fencedChars: s.fencedChars + }; + }, + + token: function(stream, state) { + + // Reset state.formatting + state.formatting = false; + + if (stream != state.thisLine) { + var forceBlankLine = state.header || state.hr; + + // Reset state.header and state.hr + state.header = 0; + state.hr = false; + + if (stream.match(/^\s*$/, true) || forceBlankLine) { + blankLine(state); + if (!forceBlankLine) return null + state.prevLine = null + } + + state.prevLine = state.thisLine + state.thisLine = stream + + // Reset state.taskList + state.taskList = false; + + // Reset state.trailingSpace + state.trailingSpace = 0; + state.trailingSpaceNewLine = false; + + state.f = state.block; + var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length; + state.indentationDiff = Math.min(indentation - state.indentation, 4); + state.indentation = state.indentation + state.indentationDiff; + if (indentation > 0) return null; + } + return state.f(stream, state); + }, + + innerMode: function(state) { + if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode}; + if (state.localState) return {state: state.localState, mode: state.localMode}; + return {state: state, mode: mode}; + }, + + blankLine: blankLine, + + getType: getType, + + fold: "markdown" + }; + return mode; +}, "xml"); + +CodeMirror.defineMIME("text/x-markdown", "markdown"); + +}); -- cgit v1.2.3 From 795ea21191486a80437d7c535defc503962c5968 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 10 Oct 2016 21:15:29 +0800 Subject: Update CodeMirror to 5.19.0 and rename jade to pug --- public/vendor/codemirror/mode/cypher/cypher.js | 2 +- public/vendor/codemirror/mode/erlang/erlang.js | 5 +- .../vendor/codemirror/mode/htmlmixed/htmlmixed.js | 2 +- public/vendor/codemirror/mode/index.html | 2 +- public/vendor/codemirror/mode/jade/index.html | 70 --- public/vendor/codemirror/mode/jade/jade.js | 590 -------------------- .../codemirror/mode/javascript/javascript.js | 70 ++- public/vendor/codemirror/mode/javascript/test.js | 32 +- public/vendor/codemirror/mode/jsx/index.html | 2 +- public/vendor/codemirror/mode/jsx/jsx.js | 1 + .../codemirror/mode/livescript/livescript.js | 2 +- public/vendor/codemirror/mode/meta.js | 4 +- public/vendor/codemirror/mode/pug/index.html | 70 +++ public/vendor/codemirror/mode/pug/pug.js | 591 +++++++++++++++++++++ public/vendor/codemirror/mode/python/index.html | 2 +- public/vendor/codemirror/mode/python/python.js | 4 +- public/vendor/codemirror/mode/sas/sas.js | 71 +-- public/vendor/codemirror/mode/vue/index.html | 2 +- public/vendor/codemirror/mode/vue/vue.js | 10 +- 19 files changed, 799 insertions(+), 733 deletions(-) delete mode 100644 public/vendor/codemirror/mode/jade/index.html delete mode 100644 public/vendor/codemirror/mode/jade/jade.js create mode 100644 public/vendor/codemirror/mode/pug/index.html create mode 100644 public/vendor/codemirror/mode/pug/pug.js mode change 100755 => 100644 public/vendor/codemirror/mode/sas/sas.js (limited to 'public/vendor/codemirror/mode') diff --git a/public/vendor/codemirror/mode/cypher/cypher.js b/public/vendor/codemirror/mode/cypher/cypher.js index 107e4f6d..f99abe23 100644 --- a/public/vendor/codemirror/mode/cypher/cypher.js +++ b/public/vendor/codemirror/mode/cypher/cypher.js @@ -62,7 +62,7 @@ var curPunc; var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]); var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]); - var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]); + var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]); var operatorChars = /[*+\-<>=&|~%^]/; return { diff --git a/public/vendor/codemirror/mode/erlang/erlang.js b/public/vendor/codemirror/mode/erlang/erlang.js index 5aed76a5..9528e19f 100644 --- a/public/vendor/codemirror/mode/erlang/erlang.js +++ b/public/vendor/codemirror/mode/erlang/erlang.js @@ -433,15 +433,16 @@ CodeMirror.defineMode("erlang", function(cmCfg) { } function maybe_drop_post(s) { + if (!s.length) return s var last = s.length-1; if (s[last].type === "dot") { return []; } - if (s[last].type === "fun" && s[last-1].token === "fun") { + if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") { return s.slice(0,last-1); } - switch (s[s.length-1].token) { + switch (s[last].token) { case "}": return d(s,{g:["{"]}); case "]": return d(s,{i:["["]}); case ")": return d(s,{i:["("]}); diff --git a/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js b/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js index d74083ee..eb21fcc1 100644 --- a/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js +++ b/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js @@ -46,7 +46,7 @@ function getAttrValue(text, attr) { var match = text.match(getAttrRegexp(attr)) - return match ? match[2] : "" + return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "" } function getTagRegexp(tagName, anchored) { diff --git a/public/vendor/codemirror/mode/index.html b/public/vendor/codemirror/mode/index.html index 732e0e52..3a2fe551 100644 --- a/public/vendor/codemirror/mode/index.html +++ b/public/vendor/codemirror/mode/index.html @@ -76,7 +76,6 @@ option.

  • HTTP
  • IDL
  • Java
  • -
  • Jade
  • JavaScript (JSX)
  • Jinja2
  • Julia
  • @@ -107,6 +106,7 @@ option.

  • PowerShell
  • Properties files
  • ProtoBuf
  • +
  • Pug
  • Puppet
  • Python
  • Q
  • diff --git a/public/vendor/codemirror/mode/jade/index.html b/public/vendor/codemirror/mode/jade/index.html deleted file mode 100644 index e534981b..00000000 --- a/public/vendor/codemirror/mode/jade/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - -CodeMirror: Jade Templating Mode - - - - - - - - - - - - - -
    -

    Jade Templating Mode

    -
    - -

    The Jade Templating Mode

    -

    Created by Forbes Lindesay. Managed as part of a Brackets extension at https://github.com/ForbesLindesay/jade-brackets.

    -

    MIME type defined: text/x-jade.

    -
    diff --git a/public/vendor/codemirror/mode/jade/jade.js b/public/vendor/codemirror/mode/jade/jade.js deleted file mode 100644 index 51ed105a..00000000 --- a/public/vendor/codemirror/mode/jade/jade.js +++ /dev/null @@ -1,590 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror"), require("../javascript/javascript"), require("../css/css"), require("../htmlmixed/htmlmixed")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror", "../javascript/javascript", "../css/css", "../htmlmixed/htmlmixed"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { -"use strict"; - -CodeMirror.defineMode('jade', function (config) { - // token types - var KEYWORD = 'keyword'; - var DOCTYPE = 'meta'; - var ID = 'builtin'; - var CLASS = 'qualifier'; - - var ATTRS_NEST = { - '{': '}', - '(': ')', - '[': ']' - }; - - var jsMode = CodeMirror.getMode(config, 'javascript'); - - function State() { - this.javaScriptLine = false; - this.javaScriptLineExcludesColon = false; - - this.javaScriptArguments = false; - this.javaScriptArgumentsDepth = 0; - - this.isInterpolating = false; - this.interpolationNesting = 0; - - this.jsState = CodeMirror.startState(jsMode); - - this.restOfLine = ''; - - this.isIncludeFiltered = false; - this.isEach = false; - - this.lastTag = ''; - this.scriptType = ''; - - // Attributes Mode - this.isAttrs = false; - this.attrsNest = []; - this.inAttributeName = true; - this.attributeIsType = false; - this.attrValue = ''; - - // Indented Mode - this.indentOf = Infinity; - this.indentToken = ''; - - this.innerMode = null; - this.innerState = null; - - this.innerModeForLine = false; - } - /** - * Safely copy a state - * - * @return {State} - */ - State.prototype.copy = function () { - var res = new State(); - res.javaScriptLine = this.javaScriptLine; - res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon; - res.javaScriptArguments = this.javaScriptArguments; - res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth; - res.isInterpolating = this.isInterpolating; - res.interpolationNesting = this.interpolationNesting; - - res.jsState = CodeMirror.copyState(jsMode, this.jsState); - - res.innerMode = this.innerMode; - if (this.innerMode && this.innerState) { - res.innerState = CodeMirror.copyState(this.innerMode, this.innerState); - } - - res.restOfLine = this.restOfLine; - - res.isIncludeFiltered = this.isIncludeFiltered; - res.isEach = this.isEach; - res.lastTag = this.lastTag; - res.scriptType = this.scriptType; - res.isAttrs = this.isAttrs; - res.attrsNest = this.attrsNest.slice(); - res.inAttributeName = this.inAttributeName; - res.attributeIsType = this.attributeIsType; - res.attrValue = this.attrValue; - res.indentOf = this.indentOf; - res.indentToken = this.indentToken; - - res.innerModeForLine = this.innerModeForLine; - - return res; - }; - - function javaScript(stream, state) { - if (stream.sol()) { - // if javaScriptLine was set at end of line, ignore it - state.javaScriptLine = false; - state.javaScriptLineExcludesColon = false; - } - if (state.javaScriptLine) { - if (state.javaScriptLineExcludesColon && stream.peek() === ':') { - state.javaScriptLine = false; - state.javaScriptLineExcludesColon = false; - return; - } - var tok = jsMode.token(stream, state.jsState); - if (stream.eol()) state.javaScriptLine = false; - return tok || true; - } - } - function javaScriptArguments(stream, state) { - if (state.javaScriptArguments) { - if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') { - state.javaScriptArguments = false; - return; - } - if (stream.peek() === '(') { - state.javaScriptArgumentsDepth++; - } else if (stream.peek() === ')') { - state.javaScriptArgumentsDepth--; - } - if (state.javaScriptArgumentsDepth === 0) { - state.javaScriptArguments = false; - return; - } - - var tok = jsMode.token(stream, state.jsState); - return tok || true; - } - } - - function yieldStatement(stream) { - if (stream.match(/^yield\b/)) { - return 'keyword'; - } - } - - function doctype(stream) { - if (stream.match(/^(?:doctype) *([^\n]+)?/)) { - return DOCTYPE; - } - } - - function interpolation(stream, state) { - if (stream.match('#{')) { - state.isInterpolating = true; - state.interpolationNesting = 0; - return 'punctuation'; - } - } - - function interpolationContinued(stream, state) { - if (state.isInterpolating) { - if (stream.peek() === '}') { - state.interpolationNesting--; - if (state.interpolationNesting < 0) { - stream.next(); - state.isInterpolating = false; - return 'punctuation'; - } - } else if (stream.peek() === '{') { - state.interpolationNesting++; - } - return jsMode.token(stream, state.jsState) || true; - } - } - - function caseStatement(stream, state) { - if (stream.match(/^case\b/)) { - state.javaScriptLine = true; - return KEYWORD; - } - } - - function when(stream, state) { - if (stream.match(/^when\b/)) { - state.javaScriptLine = true; - state.javaScriptLineExcludesColon = true; - return KEYWORD; - } - } - - function defaultStatement(stream) { - if (stream.match(/^default\b/)) { - return KEYWORD; - } - } - - function extendsStatement(stream, state) { - if (stream.match(/^extends?\b/)) { - state.restOfLine = 'string'; - return KEYWORD; - } - } - - function append(stream, state) { - if (stream.match(/^append\b/)) { - state.restOfLine = 'variable'; - return KEYWORD; - } - } - function prepend(stream, state) { - if (stream.match(/^prepend\b/)) { - state.restOfLine = 'variable'; - return KEYWORD; - } - } - function block(stream, state) { - if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) { - state.restOfLine = 'variable'; - return KEYWORD; - } - } - - function include(stream, state) { - if (stream.match(/^include\b/)) { - state.restOfLine = 'string'; - return KEYWORD; - } - } - - function includeFiltered(stream, state) { - if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match('include')) { - state.isIncludeFiltered = true; - return KEYWORD; - } - } - - function includeFilteredContinued(stream, state) { - if (state.isIncludeFiltered) { - var tok = filter(stream, state); - state.isIncludeFiltered = false; - state.restOfLine = 'string'; - return tok; - } - } - - function mixin(stream, state) { - if (stream.match(/^mixin\b/)) { - state.javaScriptLine = true; - return KEYWORD; - } - } - - function call(stream, state) { - if (stream.match(/^\+([-\w]+)/)) { - if (!stream.match(/^\( *[-\w]+ *=/, false)) { - state.javaScriptArguments = true; - state.javaScriptArgumentsDepth = 0; - } - return 'variable'; - } - if (stream.match(/^\+#{/, false)) { - stream.next(); - state.mixinCallAfter = true; - return interpolation(stream, state); - } - } - function callArguments(stream, state) { - if (state.mixinCallAfter) { - state.mixinCallAfter = false; - if (!stream.match(/^\( *[-\w]+ *=/, false)) { - state.javaScriptArguments = true; - state.javaScriptArgumentsDepth = 0; - } - return true; - } - } - - function conditional(stream, state) { - if (stream.match(/^(if|unless|else if|else)\b/)) { - state.javaScriptLine = true; - return KEYWORD; - } - } - - function each(stream, state) { - if (stream.match(/^(- *)?(each|for)\b/)) { - state.isEach = true; - return KEYWORD; - } - } - function eachContinued(stream, state) { - if (state.isEach) { - if (stream.match(/^ in\b/)) { - state.javaScriptLine = true; - state.isEach = false; - return KEYWORD; - } else if (stream.sol() || stream.eol()) { - state.isEach = false; - } else if (stream.next()) { - while (!stream.match(/^ in\b/, false) && stream.next()); - return 'variable'; - } - } - } - - function whileStatement(stream, state) { - if (stream.match(/^while\b/)) { - state.javaScriptLine = true; - return KEYWORD; - } - } - - function tag(stream, state) { - var captures; - if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) { - state.lastTag = captures[1].toLowerCase(); - if (state.lastTag === 'script') { - state.scriptType = 'application/javascript'; - } - return 'tag'; - } - } - - function filter(stream, state) { - if (stream.match(/^:([\w\-]+)/)) { - var innerMode; - if (config && config.innerModes) { - innerMode = config.innerModes(stream.current().substring(1)); - } - if (!innerMode) { - innerMode = stream.current().substring(1); - } - if (typeof innerMode === 'string') { - innerMode = CodeMirror.getMode(config, innerMode); - } - setInnerMode(stream, state, innerMode); - return 'atom'; - } - } - - function code(stream, state) { - if (stream.match(/^(!?=|-)/)) { - state.javaScriptLine = true; - return 'punctuation'; - } - } - - function id(stream) { - if (stream.match(/^#([\w-]+)/)) { - return ID; - } - } - - function className(stream) { - if (stream.match(/^\.([\w-]+)/)) { - return CLASS; - } - } - - function attrs(stream, state) { - if (stream.peek() == '(') { - stream.next(); - state.isAttrs = true; - state.attrsNest = []; - state.inAttributeName = true; - state.attrValue = ''; - state.attributeIsType = false; - return 'punctuation'; - } - } - - function attrsContinued(stream, state) { - if (state.isAttrs) { - if (ATTRS_NEST[stream.peek()]) { - state.attrsNest.push(ATTRS_NEST[stream.peek()]); - } - if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) { - state.attrsNest.pop(); - } else if (stream.eat(')')) { - state.isAttrs = false; - return 'punctuation'; - } - if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) { - if (stream.peek() === '=' || stream.peek() === '!') { - state.inAttributeName = false; - state.jsState = CodeMirror.startState(jsMode); - if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') { - state.attributeIsType = true; - } else { - state.attributeIsType = false; - } - } - return 'attribute'; - } - - var tok = jsMode.token(stream, state.jsState); - if (state.attributeIsType && tok === 'string') { - state.scriptType = stream.current().toString(); - } - if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) { - try { - Function('', 'var x ' + state.attrValue.replace(/,\s*$/, '').replace(/^!/, '')); - state.inAttributeName = true; - state.attrValue = ''; - stream.backUp(stream.current().length); - return attrsContinued(stream, state); - } catch (ex) { - //not the end of an attribute - } - } - state.attrValue += stream.current(); - return tok || true; - } - } - - function attributesBlock(stream, state) { - if (stream.match(/^&attributes\b/)) { - state.javaScriptArguments = true; - state.javaScriptArgumentsDepth = 0; - return 'keyword'; - } - } - - function indent(stream) { - if (stream.sol() && stream.eatSpace()) { - return 'indent'; - } - } - - function comment(stream, state) { - if (stream.match(/^ *\/\/(-)?([^\n]*)/)) { - state.indentOf = stream.indentation(); - state.indentToken = 'comment'; - return 'comment'; - } - } - - function colon(stream) { - if (stream.match(/^: */)) { - return 'colon'; - } - } - - function text(stream, state) { - if (stream.match(/^(?:\| ?| )([^\n]+)/)) { - return 'string'; - } - if (stream.match(/^(<[^\n]*)/, false)) { - // html string - setInnerMode(stream, state, 'htmlmixed'); - state.innerModeForLine = true; - return innerMode(stream, state, true); - } - } - - function dot(stream, state) { - if (stream.eat('.')) { - var innerMode = null; - if (state.lastTag === 'script' && state.scriptType.toLowerCase().indexOf('javascript') != -1) { - innerMode = state.scriptType.toLowerCase().replace(/"|'/g, ''); - } else if (state.lastTag === 'style') { - innerMode = 'css'; - } - setInnerMode(stream, state, innerMode); - return 'dot'; - } - } - - function fail(stream) { - stream.next(); - return null; - } - - - function setInnerMode(stream, state, mode) { - mode = CodeMirror.mimeModes[mode] || mode; - mode = config.innerModes ? config.innerModes(mode) || mode : mode; - mode = CodeMirror.mimeModes[mode] || mode; - mode = CodeMirror.getMode(config, mode); - state.indentOf = stream.indentation(); - - if (mode && mode.name !== 'null') { - state.innerMode = mode; - } else { - state.indentToken = 'string'; - } - } - function innerMode(stream, state, force) { - if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) { - if (state.innerMode) { - if (!state.innerState) { - state.innerState = state.innerMode.startState ? CodeMirror.startState(state.innerMode, stream.indentation()) : {}; - } - return stream.hideFirstChars(state.indentOf + 2, function () { - return state.innerMode.token(stream, state.innerState) || true; - }); - } else { - stream.skipToEnd(); - return state.indentToken; - } - } else if (stream.sol()) { - state.indentOf = Infinity; - state.indentToken = null; - state.innerMode = null; - state.innerState = null; - } - } - function restOfLine(stream, state) { - if (stream.sol()) { - // if restOfLine was set at end of line, ignore it - state.restOfLine = ''; - } - if (state.restOfLine) { - stream.skipToEnd(); - var tok = state.restOfLine; - state.restOfLine = ''; - return tok; - } - } - - - function startState() { - return new State(); - } - function copyState(state) { - return state.copy(); - } - /** - * Get the next token in the stream - * - * @param {Stream} stream - * @param {State} state - */ - function nextToken(stream, state) { - var tok = innerMode(stream, state) - || restOfLine(stream, state) - || interpolationContinued(stream, state) - || includeFilteredContinued(stream, state) - || eachContinued(stream, state) - || attrsContinued(stream, state) - || javaScript(stream, state) - || javaScriptArguments(stream, state) - || callArguments(stream, state) - - || yieldStatement(stream, state) - || doctype(stream, state) - || interpolation(stream, state) - || caseStatement(stream, state) - || when(stream, state) - || defaultStatement(stream, state) - || extendsStatement(stream, state) - || append(stream, state) - || prepend(stream, state) - || block(stream, state) - || include(stream, state) - || includeFiltered(stream, state) - || mixin(stream, state) - || call(stream, state) - || conditional(stream, state) - || each(stream, state) - || whileStatement(stream, state) - || tag(stream, state) - || filter(stream, state) - || code(stream, state) - || id(stream, state) - || className(stream, state) - || attrs(stream, state) - || attributesBlock(stream, state) - || indent(stream, state) - || text(stream, state) - || comment(stream, state) - || colon(stream, state) - || dot(stream, state) - || fail(stream, state); - - return tok === true ? null : tok; - } - return { - startState: startState, - copyState: copyState, - token: nextToken - }; -}, 'javascript', 'css', 'htmlmixed'); - -CodeMirror.defineMIME('text/x-jade', 'jade'); - -}); diff --git a/public/vendor/codemirror/mode/javascript/javascript.js b/public/vendor/codemirror/mode/javascript/javascript.js index da6b760f..e2356074 100644 --- a/public/vendor/codemirror/mode/javascript/javascript.js +++ b/public/vendor/codemirror/mode/javascript/javascript.js @@ -1,8 +1,6 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE -// TODO actually recognize syntax of TypeScript constructs - (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); @@ -56,6 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { "namespace": C, "module": kw("module"), "enum": kw("module"), + "type": kw("type"), // scope modifiers "public": kw("modifier"), @@ -345,19 +344,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function statement(type, value) { if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex); - if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex); + if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex); if (type == "keyword b") return cont(pushlex("form"), statement, poplex); if (type == "{") return cont(pushlex("}"), block, poplex); if (type == ";") return cont(); if (type == "if") { if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) cx.state.cc.pop()(); - return cont(pushlex("form"), expression, statement, poplex, maybeelse); + return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse); } if (type == "function") return cont(functiondef); if (type == "for") return cont(pushlex("form"), forspec, statement, poplex); if (type == "variable") return cont(pushlex("stat"), maybelabel); - if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), + if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"), block, poplex, poplex); if (type == "case") return cont(expression, expect(":")); if (type == "default") return cont(expect(":")); @@ -367,6 +366,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "export") return cont(pushlex("stat"), afterExport, poplex); if (type == "import") return cont(pushlex("stat"), afterImport, poplex); if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex) + if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";")); if (type == "async") return cont(statement) return pass(pushlex("stat"), expression, expect(";"), poplex); } @@ -376,6 +376,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { function expressionNoComma(type) { return expressionInner(type, true); } + function parenExpr(type) { + if (type != "(") return pass() + return cont(pushlex(")"), expression, expect(")"), poplex) + } function expressionInner(type, noComma) { if (cx.state.fatArrowAt == cx.stream.start) { var body = noComma ? arrowBodyNoComma : arrowBody; @@ -463,8 +467,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") {cx.marked = "property"; return cont();} } function objprop(type, value) { - if (type == "async") return cont(objprop); - if (type == "variable" || cx.style == "keyword") { + if (type == "async") { + cx.marked = "property"; + return cont(objprop); + } else if (type == "variable" || cx.style == "keyword") { cx.marked = "property"; if (value == "get" || value == "set") return cont(getterSetter); return cont(afterprop); @@ -479,6 +485,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(expression, expect("]"), afterprop); } else if (type == "spread") { return cont(expression); + } else if (type == ":") { + return pass(afterprop) } } function getterSetter(type) { @@ -517,14 +525,34 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "}") return cont(); return pass(statement, block); } - function maybetype(type) { - if (isTS && type == ":") return cont(typeexpr); + function maybetype(type, value) { + if (isTS) { + if (type == ":") return cont(typeexpr); + if (value == "?") return cont(maybetype); + } } function maybedefault(_, value) { if (value == "=") return cont(expressionNoComma); } function typeexpr(type) { if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);} + if (type == "{") return cont(commasep(typeprop, "}")) + if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType) + } + function maybeReturnType(type) { + if (type == "=>") return cont(typeexpr) + } + function typeprop(type) { + if (type == "variable" || cx.style == "keyword") { + cx.marked = "property" + return cont(typeprop) + } else if (type == ":") { + return cont(typeexpr) + } + } + function typearg(type) { + if (type == "variable") return cont(typearg) + else if (type == ":") return cont(typeexpr) } function afterType(type, value) { if (value == "<") return cont(commasep(typeexpr, ">"), afterType) @@ -593,18 +621,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == "variable") {register(value); return cont(classNameAfter);} } function classNameAfter(type, value) { - if (value == "extends") return cont(expression, classNameAfter); + if (value == "extends") return cont(isTS ? typeexpr : expression, classNameAfter); if (type == "{") return cont(pushlex("}"), classBody, poplex); } function classBody(type, value) { if (type == "variable" || cx.style == "keyword") { - if (value == "static") { + if ((value == "static" || value == "get" || value == "set" || + (isTS && (value == "public" || value == "private" || value == "protected"))) && + cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) { cx.marked = "keyword"; return cont(classBody); } cx.marked = "property"; - if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody); - return cont(functiondef, classBody); + return cont(isTS ? classfield : functiondef, classBody); } if (value == "*") { cx.marked = "keyword"; @@ -613,10 +642,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (type == ";") return cont(classBody); if (type == "}") return cont(); } - function classGetterSetter(type) { - if (type != "variable") return pass(); - cx.marked = "property"; - return cont(); + function classfield(type) { + if (type == ":") return cont(typeexpr) + return pass(functiondef) } function afterExport(_type, value) { if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } @@ -685,14 +713,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { indent: function(state, textAfter) { if (state.tokenize == tokenComment) return CodeMirror.Pass; if (state.tokenize != tokenBase) return 0; - var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical; + var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top // Kludge to prevent 'maybelse' from blocking lexical scope pops if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { var c = state.cc[i]; if (c == poplex) lexical = lexical.prev; else if (c != maybeelse) break; } - if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev; + while ((lexical.type == "stat" || lexical.type == "form") && + (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) && + (top == maybeoperatorComma || top == maybeoperatorNoComma) && + !/^[,\.=+\-*:?[\(]/.test(textAfter)))) + lexical = lexical.prev; if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") lexical = lexical.prev; var type = lexical.type, closing = firstChar == type; diff --git a/public/vendor/codemirror/mode/javascript/test.js b/public/vendor/codemirror/mode/javascript/test.js index 8916b755..91c8b743 100644 --- a/public/vendor/codemirror/mode/javascript/test.js +++ b/public/vendor/codemirror/mode/javascript/test.js @@ -31,7 +31,7 @@ MT("class", "[keyword class] [def Point] [keyword extends] [variable SuperThing] {", - " [property get] [property prop]() { [keyword return] [number 24]; }", + " [keyword get] [property prop]() { [keyword return] [number 24]; }", " [property constructor]([def x], [def y]) {", " [keyword super]([string 'something']);", " [keyword this].[property x] [operator =] [variable-2 x];", @@ -140,6 +140,19 @@ " [number 1];", "[number 2];"); + MT("indent_semicolonless_if", + "[keyword function] [def foo]() {", + " [keyword if] ([variable x])", + " [variable foo]()", + "}") + + MT("indent_semicolonless_if_with_statement", + "[keyword function] [def foo]() {", + " [keyword if] ([variable x])", + " [variable foo]()", + " [variable bar]()", + "}") + MT("multilinestring", "[keyword var] [def x] [operator =] [string 'foo\\]", "[string bar'];"); @@ -167,6 +180,23 @@ " }", "}"); + var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript") + function TS(name) { + test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) + } + + TS("extend_type", + "[keyword class] [def Foo] [keyword extends] [variable-3 Some][operator <][variable-3 Type][operator >] {}") + + TS("arrow_type", + "[keyword let] [def x]: ([variable arg]: [variable-3 Type]) [operator =>] [variable-3 ReturnType]") + + TS("typescript_class", + "[keyword class] [def Foo] {", + " [keyword public] [keyword static] [property main]() {}", + " [keyword private] [property _foo]: [variable-3 string];", + "}") + var jsonld_mode = CodeMirror.getMode( {indentUnit: 2}, {name: "javascript", jsonld: true} diff --git a/public/vendor/codemirror/mode/jsx/index.html b/public/vendor/codemirror/mode/jsx/index.html index cb51edb3..1054bbcc 100644 --- a/public/vendor/codemirror/mode/jsx/index.html +++ b/public/vendor/codemirror/mode/jsx/index.html @@ -84,6 +84,6 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {

    JSX Mode for React's JavaScript syntax extension.

    -

    MIME types defined: text/jsx.

    +

    MIME types defined: text/jsx, text/typescript-jsx.

    diff --git a/public/vendor/codemirror/mode/jsx/jsx.js b/public/vendor/codemirror/mode/jsx/jsx.js index aff01b8d..45c3024a 100644 --- a/public/vendor/codemirror/mode/jsx/jsx.js +++ b/public/vendor/codemirror/mode/jsx/jsx.js @@ -144,4 +144,5 @@ }, "xml", "javascript") CodeMirror.defineMIME("text/jsx", "jsx") + CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}}) }); diff --git a/public/vendor/codemirror/mode/livescript/livescript.js b/public/vendor/codemirror/mode/livescript/livescript.js index 4b26e046..1e363f87 100644 --- a/public/vendor/codemirror/mode/livescript/livescript.js +++ b/public/vendor/codemirror/mode/livescript/livescript.js @@ -50,7 +50,7 @@ startState: function(){ return { next: 'start', - lastToken: null + lastToken: {style: null, indent: 0, content: ""} }; }, token: function(stream, state){ diff --git a/public/vendor/codemirror/mode/meta.js b/public/vendor/codemirror/mode/meta.js index eb25e242..1e078eed 100644 --- a/public/vendor/codemirror/mode/meta.js +++ b/public/vendor/codemirror/mode/meta.js @@ -56,7 +56,7 @@ {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]}, {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i}, {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]}, - {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"]}, + {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/}, {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]}, {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]}, {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]}, @@ -66,7 +66,7 @@ {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: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]}, {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]}, {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"], diff --git a/public/vendor/codemirror/mode/pug/index.html b/public/vendor/codemirror/mode/pug/index.html new file mode 100644 index 00000000..1765853a --- /dev/null +++ b/public/vendor/codemirror/mode/pug/index.html @@ -0,0 +1,70 @@ + + +CodeMirror: Pug Templating Mode + + + + + + + + + + + + + +
    +

    Pug Templating Mode

    +
    + +

    The Pug Templating Mode

    +

    Created by Forbes Lindesay. Managed as part of a Brackets extension at https://github.com/ForbesLindesay/jade-brackets.

    +

    MIME type defined: text/x-pug, text/x-jade.

    +
    diff --git a/public/vendor/codemirror/mode/pug/pug.js b/public/vendor/codemirror/mode/pug/pug.js new file mode 100644 index 00000000..40182336 --- /dev/null +++ b/public/vendor/codemirror/mode/pug/pug.js @@ -0,0 +1,591 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("../javascript/javascript"), require("../css/css"), require("../htmlmixed/htmlmixed")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "../javascript/javascript", "../css/css", "../htmlmixed/htmlmixed"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.defineMode("pug", function (config) { + // token types + var KEYWORD = 'keyword'; + var DOCTYPE = 'meta'; + var ID = 'builtin'; + var CLASS = 'qualifier'; + + var ATTRS_NEST = { + '{': '}', + '(': ')', + '[': ']' + }; + + var jsMode = CodeMirror.getMode(config, 'javascript'); + + function State() { + this.javaScriptLine = false; + this.javaScriptLineExcludesColon = false; + + this.javaScriptArguments = false; + this.javaScriptArgumentsDepth = 0; + + this.isInterpolating = false; + this.interpolationNesting = 0; + + this.jsState = CodeMirror.startState(jsMode); + + this.restOfLine = ''; + + this.isIncludeFiltered = false; + this.isEach = false; + + this.lastTag = ''; + this.scriptType = ''; + + // Attributes Mode + this.isAttrs = false; + this.attrsNest = []; + this.inAttributeName = true; + this.attributeIsType = false; + this.attrValue = ''; + + // Indented Mode + this.indentOf = Infinity; + this.indentToken = ''; + + this.innerMode = null; + this.innerState = null; + + this.innerModeForLine = false; + } + /** + * Safely copy a state + * + * @return {State} + */ + State.prototype.copy = function () { + var res = new State(); + res.javaScriptLine = this.javaScriptLine; + res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon; + res.javaScriptArguments = this.javaScriptArguments; + res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth; + res.isInterpolating = this.isInterpolating; + res.interpolationNesting = this.interpolationNesting; + + res.jsState = CodeMirror.copyState(jsMode, this.jsState); + + res.innerMode = this.innerMode; + if (this.innerMode && this.innerState) { + res.innerState = CodeMirror.copyState(this.innerMode, this.innerState); + } + + res.restOfLine = this.restOfLine; + + res.isIncludeFiltered = this.isIncludeFiltered; + res.isEach = this.isEach; + res.lastTag = this.lastTag; + res.scriptType = this.scriptType; + res.isAttrs = this.isAttrs; + res.attrsNest = this.attrsNest.slice(); + res.inAttributeName = this.inAttributeName; + res.attributeIsType = this.attributeIsType; + res.attrValue = this.attrValue; + res.indentOf = this.indentOf; + res.indentToken = this.indentToken; + + res.innerModeForLine = this.innerModeForLine; + + return res; + }; + + function javaScript(stream, state) { + if (stream.sol()) { + // if javaScriptLine was set at end of line, ignore it + state.javaScriptLine = false; + state.javaScriptLineExcludesColon = false; + } + if (state.javaScriptLine) { + if (state.javaScriptLineExcludesColon && stream.peek() === ':') { + state.javaScriptLine = false; + state.javaScriptLineExcludesColon = false; + return; + } + var tok = jsMode.token(stream, state.jsState); + if (stream.eol()) state.javaScriptLine = false; + return tok || true; + } + } + function javaScriptArguments(stream, state) { + if (state.javaScriptArguments) { + if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') { + state.javaScriptArguments = false; + return; + } + if (stream.peek() === '(') { + state.javaScriptArgumentsDepth++; + } else if (stream.peek() === ')') { + state.javaScriptArgumentsDepth--; + } + if (state.javaScriptArgumentsDepth === 0) { + state.javaScriptArguments = false; + return; + } + + var tok = jsMode.token(stream, state.jsState); + return tok || true; + } + } + + function yieldStatement(stream) { + if (stream.match(/^yield\b/)) { + return 'keyword'; + } + } + + function doctype(stream) { + if (stream.match(/^(?:doctype) *([^\n]+)?/)) { + return DOCTYPE; + } + } + + function interpolation(stream, state) { + if (stream.match('#{')) { + state.isInterpolating = true; + state.interpolationNesting = 0; + return 'punctuation'; + } + } + + function interpolationContinued(stream, state) { + if (state.isInterpolating) { + if (stream.peek() === '}') { + state.interpolationNesting--; + if (state.interpolationNesting < 0) { + stream.next(); + state.isInterpolating = false; + return 'punctuation'; + } + } else if (stream.peek() === '{') { + state.interpolationNesting++; + } + return jsMode.token(stream, state.jsState) || true; + } + } + + function caseStatement(stream, state) { + if (stream.match(/^case\b/)) { + state.javaScriptLine = true; + return KEYWORD; + } + } + + function when(stream, state) { + if (stream.match(/^when\b/)) { + state.javaScriptLine = true; + state.javaScriptLineExcludesColon = true; + return KEYWORD; + } + } + + function defaultStatement(stream) { + if (stream.match(/^default\b/)) { + return KEYWORD; + } + } + + function extendsStatement(stream, state) { + if (stream.match(/^extends?\b/)) { + state.restOfLine = 'string'; + return KEYWORD; + } + } + + function append(stream, state) { + if (stream.match(/^append\b/)) { + state.restOfLine = 'variable'; + return KEYWORD; + } + } + function prepend(stream, state) { + if (stream.match(/^prepend\b/)) { + state.restOfLine = 'variable'; + return KEYWORD; + } + } + function block(stream, state) { + if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) { + state.restOfLine = 'variable'; + return KEYWORD; + } + } + + function include(stream, state) { + if (stream.match(/^include\b/)) { + state.restOfLine = 'string'; + return KEYWORD; + } + } + + function includeFiltered(stream, state) { + if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match('include')) { + state.isIncludeFiltered = true; + return KEYWORD; + } + } + + function includeFilteredContinued(stream, state) { + if (state.isIncludeFiltered) { + var tok = filter(stream, state); + state.isIncludeFiltered = false; + state.restOfLine = 'string'; + return tok; + } + } + + function mixin(stream, state) { + if (stream.match(/^mixin\b/)) { + state.javaScriptLine = true; + return KEYWORD; + } + } + + function call(stream, state) { + if (stream.match(/^\+([-\w]+)/)) { + if (!stream.match(/^\( *[-\w]+ *=/, false)) { + state.javaScriptArguments = true; + state.javaScriptArgumentsDepth = 0; + } + return 'variable'; + } + if (stream.match(/^\+#{/, false)) { + stream.next(); + state.mixinCallAfter = true; + return interpolation(stream, state); + } + } + function callArguments(stream, state) { + if (state.mixinCallAfter) { + state.mixinCallAfter = false; + if (!stream.match(/^\( *[-\w]+ *=/, false)) { + state.javaScriptArguments = true; + state.javaScriptArgumentsDepth = 0; + } + return true; + } + } + + function conditional(stream, state) { + if (stream.match(/^(if|unless|else if|else)\b/)) { + state.javaScriptLine = true; + return KEYWORD; + } + } + + function each(stream, state) { + if (stream.match(/^(- *)?(each|for)\b/)) { + state.isEach = true; + return KEYWORD; + } + } + function eachContinued(stream, state) { + if (state.isEach) { + if (stream.match(/^ in\b/)) { + state.javaScriptLine = true; + state.isEach = false; + return KEYWORD; + } else if (stream.sol() || stream.eol()) { + state.isEach = false; + } else if (stream.next()) { + while (!stream.match(/^ in\b/, false) && stream.next()); + return 'variable'; + } + } + } + + function whileStatement(stream, state) { + if (stream.match(/^while\b/)) { + state.javaScriptLine = true; + return KEYWORD; + } + } + + function tag(stream, state) { + var captures; + if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) { + state.lastTag = captures[1].toLowerCase(); + if (state.lastTag === 'script') { + state.scriptType = 'application/javascript'; + } + return 'tag'; + } + } + + function filter(stream, state) { + if (stream.match(/^:([\w\-]+)/)) { + var innerMode; + if (config && config.innerModes) { + innerMode = config.innerModes(stream.current().substring(1)); + } + if (!innerMode) { + innerMode = stream.current().substring(1); + } + if (typeof innerMode === 'string') { + innerMode = CodeMirror.getMode(config, innerMode); + } + setInnerMode(stream, state, innerMode); + return 'atom'; + } + } + + function code(stream, state) { + if (stream.match(/^(!?=|-)/)) { + state.javaScriptLine = true; + return 'punctuation'; + } + } + + function id(stream) { + if (stream.match(/^#([\w-]+)/)) { + return ID; + } + } + + function className(stream) { + if (stream.match(/^\.([\w-]+)/)) { + return CLASS; + } + } + + function attrs(stream, state) { + if (stream.peek() == '(') { + stream.next(); + state.isAttrs = true; + state.attrsNest = []; + state.inAttributeName = true; + state.attrValue = ''; + state.attributeIsType = false; + return 'punctuation'; + } + } + + function attrsContinued(stream, state) { + if (state.isAttrs) { + if (ATTRS_NEST[stream.peek()]) { + state.attrsNest.push(ATTRS_NEST[stream.peek()]); + } + if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) { + state.attrsNest.pop(); + } else if (stream.eat(')')) { + state.isAttrs = false; + return 'punctuation'; + } + if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) { + if (stream.peek() === '=' || stream.peek() === '!') { + state.inAttributeName = false; + state.jsState = CodeMirror.startState(jsMode); + if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') { + state.attributeIsType = true; + } else { + state.attributeIsType = false; + } + } + return 'attribute'; + } + + var tok = jsMode.token(stream, state.jsState); + if (state.attributeIsType && tok === 'string') { + state.scriptType = stream.current().toString(); + } + if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) { + try { + Function('', 'var x ' + state.attrValue.replace(/,\s*$/, '').replace(/^!/, '')); + state.inAttributeName = true; + state.attrValue = ''; + stream.backUp(stream.current().length); + return attrsContinued(stream, state); + } catch (ex) { + //not the end of an attribute + } + } + state.attrValue += stream.current(); + return tok || true; + } + } + + function attributesBlock(stream, state) { + if (stream.match(/^&attributes\b/)) { + state.javaScriptArguments = true; + state.javaScriptArgumentsDepth = 0; + return 'keyword'; + } + } + + function indent(stream) { + if (stream.sol() && stream.eatSpace()) { + return 'indent'; + } + } + + function comment(stream, state) { + if (stream.match(/^ *\/\/(-)?([^\n]*)/)) { + state.indentOf = stream.indentation(); + state.indentToken = 'comment'; + return 'comment'; + } + } + + function colon(stream) { + if (stream.match(/^: */)) { + return 'colon'; + } + } + + function text(stream, state) { + if (stream.match(/^(?:\| ?| )([^\n]+)/)) { + return 'string'; + } + if (stream.match(/^(<[^\n]*)/, false)) { + // html string + setInnerMode(stream, state, 'htmlmixed'); + state.innerModeForLine = true; + return innerMode(stream, state, true); + } + } + + function dot(stream, state) { + if (stream.eat('.')) { + var innerMode = null; + if (state.lastTag === 'script' && state.scriptType.toLowerCase().indexOf('javascript') != -1) { + innerMode = state.scriptType.toLowerCase().replace(/"|'/g, ''); + } else if (state.lastTag === 'style') { + innerMode = 'css'; + } + setInnerMode(stream, state, innerMode); + return 'dot'; + } + } + + function fail(stream) { + stream.next(); + return null; + } + + + function setInnerMode(stream, state, mode) { + mode = CodeMirror.mimeModes[mode] || mode; + mode = config.innerModes ? config.innerModes(mode) || mode : mode; + mode = CodeMirror.mimeModes[mode] || mode; + mode = CodeMirror.getMode(config, mode); + state.indentOf = stream.indentation(); + + if (mode && mode.name !== 'null') { + state.innerMode = mode; + } else { + state.indentToken = 'string'; + } + } + function innerMode(stream, state, force) { + if (stream.indentation() > state.indentOf || (state.innerModeForLine && !stream.sol()) || force) { + if (state.innerMode) { + if (!state.innerState) { + state.innerState = state.innerMode.startState ? CodeMirror.startState(state.innerMode, stream.indentation()) : {}; + } + return stream.hideFirstChars(state.indentOf + 2, function () { + return state.innerMode.token(stream, state.innerState) || true; + }); + } else { + stream.skipToEnd(); + return state.indentToken; + } + } else if (stream.sol()) { + state.indentOf = Infinity; + state.indentToken = null; + state.innerMode = null; + state.innerState = null; + } + } + function restOfLine(stream, state) { + if (stream.sol()) { + // if restOfLine was set at end of line, ignore it + state.restOfLine = ''; + } + if (state.restOfLine) { + stream.skipToEnd(); + var tok = state.restOfLine; + state.restOfLine = ''; + return tok; + } + } + + + function startState() { + return new State(); + } + function copyState(state) { + return state.copy(); + } + /** + * Get the next token in the stream + * + * @param {Stream} stream + * @param {State} state + */ + function nextToken(stream, state) { + var tok = innerMode(stream, state) + || restOfLine(stream, state) + || interpolationContinued(stream, state) + || includeFilteredContinued(stream, state) + || eachContinued(stream, state) + || attrsContinued(stream, state) + || javaScript(stream, state) + || javaScriptArguments(stream, state) + || callArguments(stream, state) + + || yieldStatement(stream, state) + || doctype(stream, state) + || interpolation(stream, state) + || caseStatement(stream, state) + || when(stream, state) + || defaultStatement(stream, state) + || extendsStatement(stream, state) + || append(stream, state) + || prepend(stream, state) + || block(stream, state) + || include(stream, state) + || includeFiltered(stream, state) + || mixin(stream, state) + || call(stream, state) + || conditional(stream, state) + || each(stream, state) + || whileStatement(stream, state) + || tag(stream, state) + || filter(stream, state) + || code(stream, state) + || id(stream, state) + || className(stream, state) + || attrs(stream, state) + || attributesBlock(stream, state) + || indent(stream, state) + || text(stream, state) + || comment(stream, state) + || colon(stream, state) + || dot(stream, state) + || fail(stream, state); + + return tok === true ? null : tok; + } + return { + startState: startState, + copyState: copyState, + token: nextToken + }; +}, 'javascript', 'css', 'htmlmixed'); + +CodeMirror.defineMIME('text/x-pug', 'pug'); +CodeMirror.defineMIME('text/x-jade', 'pug'); + +}); diff --git a/public/vendor/codemirror/mode/python/index.html b/public/vendor/codemirror/mode/python/index.html index 6116a13b..0ac02a33 100644 --- a/public/vendor/codemirror/mode/python/index.html +++ b/public/vendor/codemirror/mode/python/index.html @@ -176,7 +176,7 @@ def pairwise_cython(double[:, ::1] X):

    Configuration Options for Python mode:

    diff --git a/public/vendor/codemirror/mode/python/python.js b/public/vendor/codemirror/mode/python/python.js index be65ad76..efeed7f1 100644 --- a/public/vendor/codemirror/mode/python/python.js +++ b/public/vendor/codemirror/mode/python/python.js @@ -55,7 +55,7 @@ if (parserConf.extra_builtins != undefined) myBuiltins = myBuiltins.concat(parserConf.extra_builtins); - var py3 = parserConf.version && parseInt(parserConf.version, 10) == 3 + var py3 = !(parserConf.version && Number(parserConf.version) < 3) if (py3) { // since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/; @@ -185,7 +185,7 @@ } function tokenStringFactory(delimiter) { - while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) + while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) delimiter = delimiter.substr(1); var singleline = delimiter.length == 1; diff --git a/public/vendor/codemirror/mode/sas/sas.js b/public/vendor/codemirror/mode/sas/sas.js old mode 100755 new mode 100644 index fe114827..a6109eb1 --- a/public/vendor/codemirror/mode/sas/sas.js +++ b/public/vendor/codemirror/mode/sas/sas.js @@ -137,12 +137,13 @@ stream.next(); return 'comment'; } - } else if (!state.continueString && (ch === '"' || ch === "'")) { - // Have we found a string? - state.continueString = ch; //save the matching quote in the state - return "string"; - } else if (state.continueString !== null) { - if (stream.skipTo(state.continueString)) { + } else if ((ch === '"' || ch === "'") && !state.continueString) { + state.continueString = ch + return "string" + } else if (state.continueString) { + if (state.continueString == ch) { + state.continueString = null; + } else if (stream.skipTo(state.continueString)) { // quote found on this line stream.next(); state.continueString = null; @@ -187,12 +188,12 @@ if (stream.peek() === '.') stream.skipTo(' '); state.nextword = false; return 'variable-2'; - } + word = word.toLowerCase() // Are we in a DATA Step? if (state.inDataStep) { - if (word.toLowerCase() === 'run;' || stream.match(/run\s;/)) { + if (word === 'run;' || stream.match(/run\s;/)) { state.inDataStep = false; return 'builtin'; } @@ -203,84 +204,84 @@ else return 'variable'; } // do we have a DATA Step keyword - if (word && words.hasOwnProperty(word.toLowerCase()) && - (words[word.toLowerCase()].state.indexOf("inDataStep") !== -1 || - words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + if (word && words.hasOwnProperty(word) && + (words[word].state.indexOf("inDataStep") !== -1 || + words[word].state.indexOf("ALL") !== -1)) { //backup to the start of the word if (stream.start < stream.pos) stream.backUp(stream.pos - stream.start); //advance the length of the word and return for (var i = 0; i < word.length; ++i) stream.next(); - return words[word.toLowerCase()].style; + return words[word].style; } } // Are we in an Proc statement? if (state.inProc) { - if (word.toLowerCase() === 'run;' || word.toLowerCase() === 'quit;') { + if (word === 'run;' || word === 'quit;') { state.inProc = false; return 'builtin'; } // do we have a proc keyword - if (word && words.hasOwnProperty(word.toLowerCase()) && - (words[word.toLowerCase()].state.indexOf("inProc") !== -1 || - words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + if (word && words.hasOwnProperty(word) && + (words[word].state.indexOf("inProc") !== -1 || + words[word].state.indexOf("ALL") !== -1)) { stream.match(/[\w]+/); return words[word].style; } } // Are we in a Macro statement? if (state.inMacro) { - if (word.toLowerCase() === '%mend') { + if (word === '%mend') { if (stream.peek() === ';') stream.next(); state.inMacro = false; return 'builtin'; } - if (word && words.hasOwnProperty(word.toLowerCase()) && - (words[word.toLowerCase()].state.indexOf("inMacro") !== -1 || - words[word.toLowerCase()].state.indexOf("ALL") !== -1)) { + if (word && words.hasOwnProperty(word) && + (words[word].state.indexOf("inMacro") !== -1 || + words[word].state.indexOf("ALL") !== -1)) { stream.match(/[\w]+/); - return words[word.toLowerCase()].style; + return words[word].style; } return 'atom'; } // Do we have Keywords specific words? - if (word && words.hasOwnProperty(word.toLowerCase())) { + if (word && words.hasOwnProperty(word)) { // Negates the initial next() stream.backUp(1); // Actually move the stream stream.match(/[\w]+/); - if (word.toLowerCase() === 'data' && /=/.test(stream.peek()) === false) { + if (word === 'data' && /=/.test(stream.peek()) === false) { state.inDataStep = true; state.nextword = true; return 'builtin'; } - if (word.toLowerCase() === 'proc') { + if (word === 'proc') { state.inProc = true; state.nextword = true; return 'builtin'; } - if (word.toLowerCase() === '%macro') { + if (word === '%macro') { state.inMacro = true; state.nextword = true; return 'builtin'; } - if (/title[1-9]/i.test(word)) return 'def'; + if (/title[1-9]/.test(word)) return 'def'; - if (word.toLowerCase() === 'footnote') { + if (word === 'footnote') { stream.eat(/[1-9]/); return 'def'; } // Returns their value as state in the prior define methods - if (state.inDataStep === true && words[word.toLowerCase()].state.indexOf("inDataStep") !== -1) - return words[word.toLowerCase()].style; - if (state.inProc === true && words[word.toLowerCase()].state.indexOf("inProc") !== -1) - return words[word.toLowerCase()].style; - if (state.inMacro === true && words[word.toLowerCase()].state.indexOf("inMacro") !== -1) - return words[word.toLowerCase()].style; - if (words[word.toLowerCase()].state.indexOf("ALL") !== -1) - return words[word.toLowerCase()].style; + if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1) + return words[word].style; + if (state.inProc === true && words[word].state.indexOf("inProc") !== -1) + return words[word].style; + if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1) + return words[word].style; + if (words[word].state.indexOf("ALL") !== -1) + return words[word].style; return null; } // Unrecognized syntax diff --git a/public/vendor/codemirror/mode/vue/index.html b/public/vendor/codemirror/mode/vue/index.html index cccb9764..e0b45b94 100644 --- a/public/vendor/codemirror/mode/vue/index.html +++ b/public/vendor/codemirror/mode/vue/index.html @@ -14,7 +14,7 @@ - + diff --git a/public/vendor/codemirror/mode/vue/vue.js b/public/vendor/codemirror/mode/vue/vue.js index d89a5523..f8089af5 100644 --- a/public/vendor/codemirror/mode/vue/vue.js +++ b/public/vendor/codemirror/mode/vue/vue.js @@ -12,7 +12,7 @@ require("../css/css"), require("../sass/sass"), require("../stylus/stylus"), - require("../jade/jade"), + require("../pug/pug"), require("../handlebars/handlebars")); } else if (typeof define === "function" && define.amd) { // AMD define(["../../lib/codemirror", @@ -23,7 +23,7 @@ "../css/css", "../sass/sass", "../stylus/stylus", - "../jade/jade", + "../pug/pug", "../handlebars/handlebars"], mod); } else { // Plain browser env mod(CodeMirror); @@ -42,9 +42,9 @@ ], template: [ ["lang", /^vue-template$/i, "vue"], - ["lang", /^jade$/i, "jade"], + ["lang", /^pug$/i, "pug"], ["lang", /^handlebars$/i, "handlebars"], - ["type", /^(text\/)?(x-)?jade$/i, "jade"], + ["type", /^(text\/)?(x-)?pug$/i, "pug"], ["type", /^text\/x-handlebars-template$/i, "handlebars"], [null, null, "vue-template"] ] @@ -63,7 +63,7 @@ CodeMirror.defineMode("vue", function (config) { return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages}); - }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars"); + }, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars"); CodeMirror.defineMIME("script/x-vue", "vue"); }); -- cgit v1.2.3