Update CodeMirror to 5.19.0 and rename jade to pug

This commit is contained in:
Wu Cheng-Han 2016-10-10 21:15:29 +08:00
parent fb5d7e4359
commit 795ea21191
30 changed files with 341 additions and 209 deletions

View file

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

View file

@ -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:["("]});

View file

@ -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) {

View file

@ -76,7 +76,6 @@ option.</p>
<li><a href="http/index.html">HTTP</a></li>
<li><a href="idl/index.html">IDL</a></li>
<li><a href="clike/index.html">Java</a></li>
<li><a href="jade/index.html">Jade</a></li>
<li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
<li><a href="jinja2/index.html">Jinja2</a></li>
<li><a href="julia/index.html">Julia</a></li>
@ -107,6 +106,7 @@ option.</p>
<li><a href="powershell/index.html">PowerShell</a></li>
<li><a href="properties/index.html">Properties files</a></li>
<li><a href="protobuf/index.html">ProtoBuf</a></li>
<li><a href="pug/index.html">Pug</a></li>
<li><a href="puppet/index.html">Puppet</a></li>
<li><a href="python/index.html">Python</a></li>
<li><a href="q/index.html">Q</a></li>

View file

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

View file

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

View file

@ -84,6 +84,6 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
<p>JSX Mode for <a href="http://facebook.github.io/react">React</a>'s
JavaScript syntax extension.</p>
<p><strong>MIME types defined:</strong> <code>text/jsx</code>.</p>
<p><strong>MIME types defined:</strong> <code>text/jsx</code>, <code>text/typescript-jsx</code>.</p>
</article>

View file

@ -144,4 +144,5 @@
}, "xml", "javascript")
CodeMirror.defineMIME("text/jsx", "jsx")
CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}})
});

View file

@ -50,7 +50,7 @@
startState: function(){
return {
next: 'start',
lastToken: null
lastToken: {style: null, indent: 0, content: ""}
};
},
token: function(stream, state){

View file

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

View file

@ -1,6 +1,6 @@
<!doctype html>
<title>CodeMirror: Jade Templating Mode</title>
<title>CodeMirror: Pug Templating Mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
@ -10,7 +10,7 @@
<script src="../css/css.js"></script>
<script src="../xml/xml.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="jade.js"></script>
<script src="pug.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
@ -22,17 +22,17 @@
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Jade Templating Mode</a>
<li><a class=active href="#">Pug Templating Mode</a>
</ul>
</div>
<article>
<h2>Jade Templating Mode</h2>
<h2>Pug Templating Mode</h2>
<form><textarea id="code" name="code">
doctype html
html
head
title= "Jade Templating CodeMirror Mode Example"
title= "Pug Templating CodeMirror Mode Example"
link(rel='stylesheet', href='/css/bootstrap.min.css')
link(rel='stylesheet', href='/css/index.css')
script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
@ -60,11 +60,11 @@ doctype html
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: {name: "jade", alignCDATA: true},
mode: {name: "pug", alignCDATA: true},
lineNumbers: true
});
</script>
<h3>The Jade Templating Mode</h3>
<h3>The Pug Templating Mode</h3>
<p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
<p><strong>MIME type defined:</strong> <code>text/x-jade</code>.</p>
<p><strong>MIME type defined:</strong> <code>text/x-pug</code>, <code>text/x-jade</code>.</p>
</article>

View file

@ -11,7 +11,7 @@
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode('jade', function (config) {
CodeMirror.defineMode("pug", function (config) {
// token types
var KEYWORD = 'keyword';
var DOCTYPE = 'meta';
@ -585,6 +585,7 @@ CodeMirror.defineMode('jade', function (config) {
};
}, 'javascript', 'css', 'htmlmixed');
CodeMirror.defineMIME('text/x-jade', 'jade');
CodeMirror.defineMIME('text/x-pug', 'pug');
CodeMirror.defineMIME('text/x-jade', 'pug');
});

View file

@ -176,7 +176,7 @@ def pairwise_cython(double[:, ::1] X):
</script>
<h2>Configuration Options for Python mode:</h2>
<ul>
<li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
<li>version - 2/3 - The version of Python to recognize. Default is 3.</li>
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
<li>hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.</li>
</ul>

View file

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

71
public/vendor/codemirror/mode/sas/sas.js vendored Executable file → Normal file
View file

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

View file

@ -14,7 +14,7 @@
<script src="../css/css.js"></script>
<script src="../coffeescript/coffeescript.js"></script>
<script src="../sass/sass.js"></script>
<script src="../jade/jade.js"></script>
<script src="../pug/pug.js"></script>
<script src="../handlebars/handlebars.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>

View file

@ -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");
});