Inherit all HTML+server_side_directives rules from HTML rules.
This commit is contained in:
parent
7c6f40e41e
commit
a6ba61e11a
12 changed files with 373 additions and 549 deletions
|
|
@ -32,92 +32,18 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
|
|
||||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
var xml_util = require("./xml_util");
|
|
||||||
|
|
||||||
var ColdfusionHighlightRules = function() {
|
var ColdfusionHighlightRules = function() {
|
||||||
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
// regexp must not have capturing parentheses
|
this.embedTagRules(JavaScriptHighlightRules, "cfjs-", "cfscript");
|
||||||
// regexps are ordered -> the first match is used
|
|
||||||
|
|
||||||
this.$rules = {
|
this.normalizeRules();
|
||||||
start : [ {
|
|
||||||
token : "text",
|
|
||||||
regex : "<\\!\\[CDATA\\[",
|
|
||||||
next : "cdata"
|
|
||||||
}, {
|
|
||||||
token : "xml-pe",
|
|
||||||
regex : "<\\?.*?\\?>"
|
|
||||||
}, {
|
|
||||||
token : "comment",
|
|
||||||
regex : "<\\!--",
|
|
||||||
next : "comment"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag",
|
|
||||||
regex : "<(?=script)",
|
|
||||||
next : "script"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag",
|
|
||||||
regex : "<(?=cfscript)",
|
|
||||||
next : "cfscript"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag",
|
|
||||||
regex : "<(?=style)",
|
|
||||||
next : "style"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag", // opening tag
|
|
||||||
regex : "<\\/?",
|
|
||||||
next : "tag"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
cdata : [ {
|
|
||||||
token : "text",
|
|
||||||
regex : "\\]\\]>",
|
|
||||||
next : "start"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
comment : [ {
|
|
||||||
token : "comment",
|
|
||||||
regex : ".*?-->",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
defaultToken : "comment"
|
|
||||||
} ]
|
|
||||||
};
|
|
||||||
|
|
||||||
xml_util.tag(this.$rules, "tag", "start");
|
|
||||||
xml_util.tag(this.$rules, "style", "css-start");
|
|
||||||
xml_util.tag(this.$rules, "script", "js-start");
|
|
||||||
xml_util.tag(this.$rules, "cfscript", "js-start");
|
|
||||||
|
|
||||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
|
||||||
token: "comment",
|
|
||||||
regex: "\\/\\/.*(?=<\\/script>)",
|
|
||||||
next: "tag"
|
|
||||||
}, {
|
|
||||||
token: "meta.tag",
|
|
||||||
regex: "<\\/(?=script)",
|
|
||||||
next: "tag"
|
|
||||||
}, {
|
|
||||||
token: "comment",
|
|
||||||
regex: "\\/\\/.*(?=<\\/cfscript>)",
|
|
||||||
next: "tag"
|
|
||||||
}, {
|
|
||||||
token: "meta.tag",
|
|
||||||
regex: "<\\/(?=cfscript)",
|
|
||||||
next: "tag"
|
|
||||||
}]);
|
|
||||||
|
|
||||||
this.embedRules(CssHighlightRules, "css-", [{
|
|
||||||
token: "meta.tag",
|
|
||||||
regex: "<\\/(?=style)",
|
|
||||||
next: "tag"
|
|
||||||
}]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(ColdfusionHighlightRules, TextHighlightRules);
|
oop.inherits(ColdfusionHighlightRules, HtmlHighlightRules);
|
||||||
|
|
||||||
exports.ColdfusionHighlightRules = ColdfusionHighlightRules;
|
exports.ColdfusionHighlightRules = ColdfusionHighlightRules;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,34 +42,21 @@ var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
|
|
||||||
|
|
||||||
var CurlyHighlightRules = function() {
|
var CurlyHighlightRules = function() {
|
||||||
var CurlyRules = {
|
HtmlHighlightRules.call(this);
|
||||||
"start" : [
|
|
||||||
{
|
|
||||||
token: "variable",
|
|
||||||
regex: "{{",
|
|
||||||
next: "curly_mode"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"curly_mode" : [
|
this.$rules["start"].unshift({
|
||||||
{
|
token: "variable",
|
||||||
token: "variable",
|
regex: "{{",
|
||||||
regex: "}}",
|
push: "curly-start"
|
||||||
next: "start"
|
});
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
var htmlRules = new HtmlHighlightRules().getRules();
|
this.$rules["curly-start"] = [{
|
||||||
|
token: "variable",
|
||||||
|
regex: "}}",
|
||||||
|
next: "pop"
|
||||||
|
}];
|
||||||
|
|
||||||
// Inject Curly start array into HTML rules
|
this.normalizeRules();
|
||||||
htmlRules.start = CurlyRules.start.concat(htmlRules.start);
|
|
||||||
|
|
||||||
// Inject Mustach mode array into HTML rules
|
|
||||||
htmlRules.curly_mode = CurlyRules.curly_mode;
|
|
||||||
|
|
||||||
// Return the augmented HTML rules
|
|
||||||
this.$rules = htmlRules;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(CurlyHighlightRules, HtmlHighlightRules);
|
oop.inherits(CurlyHighlightRules, HtmlHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -131,14 +131,18 @@ var FtlLangHighlightRules = function () {
|
||||||
oop.inherits(FtlLangHighlightRules, TextHighlightRules);
|
oop.inherits(FtlLangHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
var FtlHighlightRules = function() {
|
var FtlHighlightRules = function() {
|
||||||
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
var directives = "assign|attempt|break|case|compress|default|elseif|else|escape|fallback|function|flush|"
|
var directives = "assign|attempt|break|case|compress|default|elseif|else|escape|fallback|function|flush|"
|
||||||
+ "ftl|global|if|import|include|list|local|lt|macro|nested|noescape|noparse|nt|recover|recurse|return|rt|"
|
+ "ftl|global|if|import|include|list|local|lt|macro|nested|noescape|noparse|nt|recover|recurse|return|rt|"
|
||||||
+ "setting|stop|switch|t|visit";
|
+ "setting|stop|switch|t|visit";
|
||||||
|
|
||||||
HtmlHighlightRules.call(this);
|
var startRules = [
|
||||||
|
{
|
||||||
for (var i in this.$rules) {
|
token : "comment",
|
||||||
this.$rules[i].unshift({
|
regex : "<#--",
|
||||||
|
next : "ftl-dcomment"
|
||||||
|
}, {
|
||||||
token : "string.interpolated",
|
token : "string.interpolated",
|
||||||
regex : "\\${",
|
regex : "\\${",
|
||||||
push : "ftl-start"
|
push : "ftl-start"
|
||||||
|
|
@ -150,34 +154,35 @@ var FtlHighlightRules = function() {
|
||||||
token : "keyword.other",
|
token : "keyword.other",
|
||||||
regex : "</?@[a-zA-Z\\.]+",
|
regex : "</?@[a-zA-Z\\.]+",
|
||||||
push : "ftl-start"
|
push : "ftl-start"
|
||||||
});
|
}
|
||||||
}
|
];
|
||||||
|
|
||||||
this.embedRules(FtlLangHighlightRules, "ftl-");
|
var endRules = [
|
||||||
|
{
|
||||||
|
token : "keyword",
|
||||||
|
regex : "/?>",
|
||||||
|
next : "pop"
|
||||||
|
}, {
|
||||||
|
token : "string.interpolated",
|
||||||
|
regex : "}",
|
||||||
|
next : "pop"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
this.$rules["ftl-start"].unshift({
|
for (var key in this.$rules)
|
||||||
token : "keyword",
|
this.$rules[key].unshift.apply(this.$rules[key], startRules);
|
||||||
regex : "/?>",
|
|
||||||
next : "pop"
|
|
||||||
}, {
|
|
||||||
token : "string.interpolated",
|
|
||||||
regex : "}",
|
|
||||||
next : "pop"
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$rules.start.unshift({
|
this.embedRules(FtlLangHighlightRules, "ftl-", endRules, ["start"]);
|
||||||
token : "comment",
|
|
||||||
regex : "<#--",
|
|
||||||
next : "comment"
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$rules.comment.unshift({
|
this.addRules({
|
||||||
token : "comment",
|
"ftl-dcomment" : [{
|
||||||
regex : ".*?-->",
|
token : "comment",
|
||||||
next : "start"
|
regex : ".*?-->",
|
||||||
}, {
|
next : "pop"
|
||||||
token : "comment",
|
}, {
|
||||||
regex : ".+"
|
token : "comment",
|
||||||
|
regex : ".+"
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
|
|
|
||||||
|
|
@ -37,32 +37,37 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var HtmlRubyHighlightRules = function() {
|
var HtmlRubyHighlightRules = function() {
|
||||||
HtmlHighlightRules.call(this);
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
for (var i in this.$rules) {
|
var startRules = [
|
||||||
this.$rules[i].unshift({
|
{
|
||||||
regex: "<%%|%%>",
|
regex: "<%%|%%>",
|
||||||
token: "constant.language.escape"
|
token: "constant.language.escape"
|
||||||
}, {
|
}, {
|
||||||
token : "comment.start.erb",
|
token : "comment.start.erb",
|
||||||
regex : "<%#",
|
regex : "<%#",
|
||||||
push : [{regex: "%>", next: "pop"}]
|
push : [{regex: "%>", next: "pop"}]
|
||||||
}, {
|
}, {
|
||||||
token : "support.ruby_tag",
|
token : "support.ruby_tag",
|
||||||
regex : "<%+(?!>)[-=]?",
|
regex : "<%+(?!>)[-=]?",
|
||||||
push : "ruby-start"
|
push : "ruby-start"
|
||||||
});
|
}
|
||||||
}
|
];
|
||||||
|
|
||||||
this.embedRules(RubyHighlightRules, "ruby-");
|
var endRules = [
|
||||||
|
{
|
||||||
this.$rules["ruby-start"].unshift({
|
token : "support.ruby_tag",
|
||||||
token : "support.ruby_tag",
|
regex : "%>",
|
||||||
regex : "%>",
|
next : "pop"
|
||||||
next : "pop"
|
}, {
|
||||||
}, {
|
token: "comment",
|
||||||
token: "comment",
|
regex: "#(?:[^%]|%[^>])*"
|
||||||
regex: /#(?:[^%]|%[^>])*/
|
}
|
||||||
});
|
];
|
||||||
|
|
||||||
|
for (var key in this.$rules)
|
||||||
|
this.$rules[key].unshift.apply(this.$rules[key], startRules);
|
||||||
|
|
||||||
|
this.embedRules(RubyHighlightRules, "ruby-", endRules, ["start"]);
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,45 +37,52 @@ var JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules;
|
||||||
|
|
||||||
var JspHighlightRules = function() {
|
var JspHighlightRules = function() {
|
||||||
HtmlHighlightRules.call(this);
|
HtmlHighlightRules.call(this);
|
||||||
for (var i in this.$rules) {
|
|
||||||
this.$rules[i].unshift({
|
|
||||||
token : "meta.tag", // jsp open tag
|
|
||||||
regex : "<%@?|<%=?|<jsp:[^>]+>",
|
|
||||||
next : "jsp-start"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var builtinVariables = 'request|response|out|session|' +
|
var builtinVariables = 'request|response|out|session|' +
|
||||||
'application|config|pageContext|page|Exception';
|
'application|config|pageContext|page|Exception';
|
||||||
|
|
||||||
var keywords = 'page|include|taglib';
|
var keywords = 'page|include|taglib';
|
||||||
|
|
||||||
this.embedRules(JavaHighlightRules, "jsp-");
|
var startRules = [
|
||||||
|
{
|
||||||
|
token : "comment",
|
||||||
|
regex : "<%--",
|
||||||
|
push : "jsp-dcomment"
|
||||||
|
}, {
|
||||||
|
token : "meta.tag", // jsp open tag
|
||||||
|
regex : "<%@?|<%=?|<jsp:[^>]+>",
|
||||||
|
push : "jsp-start"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
this.$rules["start"].unshift({
|
var endRules = [
|
||||||
token : "comment",
|
{
|
||||||
regex : "<%--",
|
token : "meta.tag", // jsp close tag
|
||||||
next : "comment"
|
regex : "%>|<\\/jsp:[^>]+>",
|
||||||
|
next : "pop"
|
||||||
|
}, {
|
||||||
|
token: "variable.language",
|
||||||
|
regex : builtinVariables
|
||||||
|
}, {
|
||||||
|
token: "keyword",
|
||||||
|
regex : keywords
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
for (var key in this.$rules)
|
||||||
|
this.$rules[key].unshift.apply(this.$rules[key], startRules);
|
||||||
|
|
||||||
|
this.embedRules(JavaHighlightRules, "jsp-", endRules, ["start"]);
|
||||||
|
|
||||||
|
this.addRules({
|
||||||
|
"jsp-dcomment" : [{
|
||||||
|
token : "comment",
|
||||||
|
regex : ".*?--%>",
|
||||||
|
next : "pop"
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$rules["jsp-start"].unshift({
|
this.normalizeRules();
|
||||||
token : "meta.tag", // jsp close tag
|
|
||||||
regex : "%>|<\\/jsp:[^>]+>",
|
|
||||||
next : "start"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: "variable.language",
|
|
||||||
regex : builtinVariables
|
|
||||||
}, {
|
|
||||||
token: "keyword",
|
|
||||||
regex : keywords
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$rules.comment.unshift({
|
|
||||||
token : "comment",
|
|
||||||
regex : ".*?--%>",
|
|
||||||
next : "start"
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(JspHighlightRules, HtmlHighlightRules);
|
oop.inherits(JspHighlightRules, HtmlHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,11 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
|
|
||||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
|
||||||
var xmlUtil = require("./xml_util");
|
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
|
|
||||||
var LiquidHighlightRules = function() {
|
var LiquidHighlightRules = function() {
|
||||||
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
// see: https://developer.mozilla.org/en/Liquid/Reference/Global_Objects
|
// see: https://developer.mozilla.org/en/Liquid/Reference/Global_Objects
|
||||||
var functions = (
|
var functions = (
|
||||||
|
|
@ -69,65 +68,28 @@ var LiquidHighlightRules = function() {
|
||||||
"keyword.definition": definitions
|
"keyword.definition": definitions
|
||||||
}, "identifier");
|
}, "identifier");
|
||||||
|
|
||||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
// add liquid start tags to the HTML start tags
|
||||||
// regexps are ordered -> the first match is used
|
for (var rule in this.$rules) {
|
||||||
|
this.$rules[rule].unshift({
|
||||||
this.$rules = {
|
|
||||||
start : [{
|
|
||||||
token : "variable",
|
token : "variable",
|
||||||
regex : "{%",
|
regex : "{%",
|
||||||
next : "liquid_start"
|
push : "liquid-start"
|
||||||
}, {
|
}, {
|
||||||
token : "variable",
|
token : "variable",
|
||||||
regex : "{{",
|
regex : "{{",
|
||||||
next : "liquid_start"
|
push : "liquid-start"
|
||||||
}, {
|
});
|
||||||
token : "meta.tag",
|
}
|
||||||
regex : "<\\!\\[CDATA\\[",
|
|
||||||
next : "cdata"
|
|
||||||
}, {
|
|
||||||
token : "xml-pe",
|
|
||||||
regex : "<\\?.*?\\?>"
|
|
||||||
}, {
|
|
||||||
token : "comment",
|
|
||||||
regex : "<\\!--",
|
|
||||||
next : "comment"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag",
|
|
||||||
regex : "<(?=\\s*script\\b)",
|
|
||||||
next : "script"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag",
|
|
||||||
regex : "<(?=\\s*style\\b)",
|
|
||||||
next : "style"
|
|
||||||
}, {
|
|
||||||
token : "meta.tag", // opening tag
|
|
||||||
regex : "<\\/?",
|
|
||||||
next : "tag"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
cdata : [ {
|
this.addRules({
|
||||||
token : "text",
|
"liquid-start" : [{
|
||||||
regex : "\\]\\]>",
|
|
||||||
next : "start"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
comment : [ {
|
|
||||||
token : "comment",
|
|
||||||
regex : ".*?-->",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
defaultToken : "comment"
|
|
||||||
} ] ,
|
|
||||||
|
|
||||||
liquid_start : [{
|
|
||||||
token: "variable",
|
token: "variable",
|
||||||
regex: "}}",
|
regex: "}}",
|
||||||
next: "start"
|
next: "pop"
|
||||||
}, {
|
}, {
|
||||||
token: "variable",
|
token: "variable",
|
||||||
regex: "%}",
|
regex: "%}",
|
||||||
next: "start"
|
next: "pop"
|
||||||
}, {
|
}, {
|
||||||
token : "string", // single line
|
token : "string", // single line
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||||
|
|
@ -159,27 +121,9 @@ var LiquidHighlightRules = function() {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
}]
|
}]
|
||||||
};
|
});
|
||||||
|
|
||||||
xmlUtil.tag(this.$rules, "tag", "start");
|
this.normalizeRules();
|
||||||
xmlUtil.tag(this.$rules, "style", "css-start");
|
|
||||||
xmlUtil.tag(this.$rules, "script", "js-start");
|
|
||||||
|
|
||||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
|
||||||
token: "comment",
|
|
||||||
regex: "\\/\\/.*(?=<\\/script>)",
|
|
||||||
next: "tag"
|
|
||||||
}, {
|
|
||||||
token: "meta.tag",
|
|
||||||
regex: "<\\/(?=script)",
|
|
||||||
next: "tag"
|
|
||||||
}]);
|
|
||||||
|
|
||||||
this.embedRules(CssHighlightRules, "css-", [{
|
|
||||||
token: "meta.tag",
|
|
||||||
regex: "<\\/(?=style)",
|
|
||||||
next: "tag"
|
|
||||||
}]);
|
|
||||||
};
|
};
|
||||||
oop.inherits(LiquidHighlightRules, TextHighlightRules);
|
oop.inherits(LiquidHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,31 +8,38 @@ var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules;
|
var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules;
|
||||||
|
|
||||||
var LuaPageHighlightRules = function() {
|
var LuaPageHighlightRules = function() {
|
||||||
this.$rules = new HtmlHighlightRules().getRules();
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
for (var i in this.$rules) {
|
var startRules = [
|
||||||
this.$rules[i].unshift({
|
{
|
||||||
token: "keyword",
|
token: "keyword",
|
||||||
regex: "<\\%\\=?",
|
regex: "<\\%\\=?",
|
||||||
next: "lua-start"
|
push: "lua-start"
|
||||||
}, {
|
}, {
|
||||||
token: "keyword",
|
token: "keyword",
|
||||||
regex: "<\\?lua\\=?",
|
regex: "<\\?lua\\=?",
|
||||||
next: "lua-start"
|
push: "lua-start"
|
||||||
});
|
}
|
||||||
}
|
];
|
||||||
this.embedRules(LuaHighlightRules, "lua-", [
|
|
||||||
|
var endRules = [
|
||||||
{
|
{
|
||||||
token: "keyword",
|
token: "keyword",
|
||||||
regex: "\\%>",
|
regex: "\\%>",
|
||||||
next: "start"
|
next: "pop"
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
token: "keyword",
|
token: "keyword",
|
||||||
regex: "\\?>",
|
regex: "\\?>",
|
||||||
next: "start"
|
next: "pop"
|
||||||
}
|
}
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
this.embedRules(LuaHighlightRules, "lua-", endRules, ["start"]);
|
||||||
|
|
||||||
|
for (var key in this.$rules)
|
||||||
|
this.$rules[key].unshift.apply(this.$rules[key], startRules);
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(LuaPageHighlightRules, HtmlHighlightRules);
|
oop.inherits(LuaPageHighlightRules, HtmlHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,57 @@ function github_embed(tag, prefix) {
|
||||||
return { // Github style block
|
return { // Github style block
|
||||||
token : "support.function",
|
token : "support.function",
|
||||||
regex : "^```" + tag + "\\s*$",
|
regex : "^```" + tag + "\\s*$",
|
||||||
next : prefix + "start"
|
push : prefix + "start"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var MarkdownHighlightRules = function() {
|
var MarkdownHighlightRules = function() {
|
||||||
|
HtmlHighlightRules.call(this);
|
||||||
// regexp must not have capturing parentheses
|
// regexp must not have capturing parentheses
|
||||||
// regexps are ordered -> the first match is used
|
// regexps are ordered -> the first match is used
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules["start"].unshift({
|
||||||
|
token : "empty_line",
|
||||||
|
regex : '^$',
|
||||||
|
next: "allowBlock"
|
||||||
|
}, { // h1
|
||||||
|
token: "markup.heading.1",
|
||||||
|
regex: "^=+(?=\\s*$)"
|
||||||
|
}, { // h2
|
||||||
|
token: "markup.heading.2",
|
||||||
|
regex: "^\\-+(?=\\s*$)"
|
||||||
|
}, {
|
||||||
|
token : function(value) {
|
||||||
|
return "markup.heading." + value.length;
|
||||||
|
},
|
||||||
|
regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
|
||||||
|
next : "header"
|
||||||
|
},
|
||||||
|
github_embed("(?:javascript|js)", "jscode-"),
|
||||||
|
github_embed("xml", "xmlcode-"),
|
||||||
|
github_embed("html", "htmlcode-"),
|
||||||
|
github_embed("css", "csscode-"),
|
||||||
|
{ // Github style block
|
||||||
|
token : "support.function",
|
||||||
|
regex : "^```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
|
||||||
|
next : "githubblock"
|
||||||
|
}, { // block quote
|
||||||
|
token : "string",
|
||||||
|
regex : "^>[ ].+$",
|
||||||
|
next : "blockquote"
|
||||||
|
}, { // HR * - _
|
||||||
|
token : "constant",
|
||||||
|
regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
|
||||||
|
next: "allowBlock"
|
||||||
|
}, { // list
|
||||||
|
token : "markup.list",
|
||||||
|
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
||||||
|
next : "listblock-start"
|
||||||
|
}, {
|
||||||
|
include : "basic"
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addRules({
|
||||||
"basic" : [{
|
"basic" : [{
|
||||||
token : "constant.language.escape",
|
token : "constant.language.escape",
|
||||||
regex : /\\[\\`*_{}\[\]()#+\-.!]/
|
regex : /\\[\\`*_{}\[\]()#+\-.!]/
|
||||||
|
|
@ -93,47 +134,6 @@ var MarkdownHighlightRules = function() {
|
||||||
{token : "empty", regex : "", next : "start"}
|
{token : "empty", regex : "", next : "start"}
|
||||||
],
|
],
|
||||||
|
|
||||||
"start" : [{
|
|
||||||
token : "empty_line",
|
|
||||||
regex : '^$',
|
|
||||||
next: "allowBlock"
|
|
||||||
}, { // h1
|
|
||||||
token: "markup.heading.1",
|
|
||||||
regex: "^=+(?=\\s*$)"
|
|
||||||
}, { // h2
|
|
||||||
token: "markup.heading.2",
|
|
||||||
regex: "^\\-+(?=\\s*$)"
|
|
||||||
}, {
|
|
||||||
token : function(value) {
|
|
||||||
return "markup.heading." + value.length;
|
|
||||||
},
|
|
||||||
regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
|
|
||||||
next : "header"
|
|
||||||
},
|
|
||||||
github_embed("(?:javascript|js)", "js-"),
|
|
||||||
github_embed("xml", "xml-"),
|
|
||||||
github_embed("html", "html-"),
|
|
||||||
github_embed("css", "css-"),
|
|
||||||
{ // Github style block
|
|
||||||
token : "support.function",
|
|
||||||
regex : "^```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
|
|
||||||
next : "githubblock"
|
|
||||||
}, { // block quote
|
|
||||||
token : "string",
|
|
||||||
regex : "^>[ ].+$",
|
|
||||||
next : "blockquote"
|
|
||||||
}, { // HR * - _
|
|
||||||
token : "constant",
|
|
||||||
regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
|
|
||||||
next: "allowBlock"
|
|
||||||
}, { // list
|
|
||||||
token : "markup.list",
|
|
||||||
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
|
||||||
next : "listblock-start"
|
|
||||||
}, {
|
|
||||||
include : "basic"
|
|
||||||
}],
|
|
||||||
|
|
||||||
"header" : [{
|
"header" : [{
|
||||||
regex: "$",
|
regex: "$",
|
||||||
next : "start"
|
next : "start"
|
||||||
|
|
@ -180,40 +180,32 @@ var MarkdownHighlightRules = function() {
|
||||||
token : "support.function",
|
token : "support.function",
|
||||||
regex : ".+"
|
regex : ".+"
|
||||||
} ]
|
} ]
|
||||||
};
|
});
|
||||||
|
|
||||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
this.embedRules(JavaScriptHighlightRules, "jscode-", [{
|
||||||
token : "support.function",
|
token : "support.function",
|
||||||
regex : "^```",
|
regex : "^```",
|
||||||
next : "start"
|
next : "pop"
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
this.embedRules(HtmlHighlightRules, "html-", [{
|
this.embedRules(HtmlHighlightRules, "htmlcode-", [{
|
||||||
token : "support.function",
|
token : "support.function",
|
||||||
regex : "^```",
|
regex : "^```",
|
||||||
next : "start"
|
next : "pop"
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
this.embedRules(CssHighlightRules, "css-", [{
|
this.embedRules(CssHighlightRules, "csscode-", [{
|
||||||
token : "support.function",
|
token : "support.function",
|
||||||
regex : "^```",
|
regex : "^```",
|
||||||
next : "start"
|
next : "pop"
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
this.embedRules(XmlHighlightRules, "xml-", [{
|
this.embedRules(XmlHighlightRules, "xmlcode-", [{
|
||||||
token : "support.function",
|
token : "support.function",
|
||||||
regex : "^```",
|
regex : "^```",
|
||||||
next : "start"
|
next : "pop"
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
var html = new HtmlHighlightRules().getRules();
|
|
||||||
for (var i in html) {
|
|
||||||
if (this.$rules[i])
|
|
||||||
this.$rules[i] = this.$rules[i].concat(html[i]);
|
|
||||||
else
|
|
||||||
this.$rules[i] = html[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
oop.inherits(MarkdownHighlightRules, TextHighlightRules);
|
oop.inherits(MarkdownHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -1057,21 +1057,27 @@ oop.inherits(PhpLangHighlightRules, TextHighlightRules);
|
||||||
var PhpHighlightRules = function() {
|
var PhpHighlightRules = function() {
|
||||||
HtmlHighlightRules.call(this);
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
for (var i in this.$rules) {
|
var startRules = [
|
||||||
this.$rules[i].unshift({
|
{
|
||||||
token : "support.php_tag", // php open tag
|
token : "support.php_tag", // php open tag
|
||||||
regex : "<\\?(?:php|=)?",
|
regex : "<\\?(?:php|=)?",
|
||||||
push : "php-start"
|
push : "php-start"
|
||||||
});
|
}
|
||||||
}
|
];
|
||||||
|
|
||||||
this.embedRules(PhpLangHighlightRules, "php-");
|
var endRules = [
|
||||||
|
{
|
||||||
|
token : "support.php_tag", // php close tag
|
||||||
|
regex : "\\?>",
|
||||||
|
next : "pop"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
for (var key in this.$rules)
|
||||||
|
this.$rules[key].unshift.apply(this.$rules[key], startRules);
|
||||||
|
|
||||||
|
this.embedRules(PhpLangHighlightRules, "php-", endRules, ["start"]);
|
||||||
|
|
||||||
this.$rules["php-start"].unshift({
|
|
||||||
token : "support.php_tag", // php close tag
|
|
||||||
regex : "\\?>",
|
|
||||||
next : "pop"
|
|
||||||
});
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,24 +24,21 @@ var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var RHtmlHighlightRules = function() {
|
var RHtmlHighlightRules = function() {
|
||||||
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
// regexp must not have capturing parentheses
|
|
||||||
// regexps are ordered -> the first match is used
|
|
||||||
|
|
||||||
this.$rules = new HtmlHighlightRules().getRules();
|
|
||||||
this.$rules["start"].unshift({
|
this.$rules["start"].unshift({
|
||||||
token: "support.function.codebegin",
|
token: "support.function.codebegin",
|
||||||
regex: "^<" + "!--\\s*begin.rcode\\s*(?:.*)",
|
regex: "^<" + "!--\\s*begin.rcode\\s*(?:.*)",
|
||||||
next: "r-start"
|
next: "r-start"
|
||||||
});
|
});
|
||||||
|
|
||||||
var rRules = new RHighlightRules().getRules();
|
this.embedRules(RHighlightRules, "r-", [{
|
||||||
this.addRules(rRules, "r-");
|
|
||||||
this.$rules["r-start"].unshift({
|
|
||||||
token: "support.function.codeend",
|
token: "support.function.codeend",
|
||||||
regex: "^\\s*end.rcode\\s*-->",
|
regex: "^\\s*end.rcode\\s*-->",
|
||||||
next: "start"
|
next: "start"
|
||||||
});
|
}], ["start"]);
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
oop.inherits(RHtmlHighlightRules, TextHighlightRules);
|
oop.inherits(RHtmlHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,35 +56,37 @@ var TwigHighlightRules = function() {
|
||||||
}, "identifier");
|
}, "identifier");
|
||||||
|
|
||||||
// add twig start tags to the HTML start tags
|
// add twig start tags to the HTML start tags
|
||||||
this.$rules.start.unshift({
|
for (var rule in this.$rules) {
|
||||||
token : "variable.other.readwrite.local.twig",
|
this.$rules[rule].unshift({
|
||||||
regex : "\\{\\{-?",
|
token : "variable.other.readwrite.local.twig",
|
||||||
next : "twig-start"
|
regex : "\\{\\{-?",
|
||||||
}, {
|
push : "twig-start"
|
||||||
token : "meta.tag.twig",
|
}, {
|
||||||
regex : "\\{%-?",
|
token : "meta.tag.twig",
|
||||||
next : "twig-start"
|
regex : "\\{%-?",
|
||||||
}, {
|
push : "twig-start"
|
||||||
token : "comment.block.twig",
|
}, {
|
||||||
regex : "\\{#-?",
|
token : "comment.block.twig",
|
||||||
next : "comment"
|
regex : "\\{#-?",
|
||||||
});
|
push : "twig-comment"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// add twig closing comment to HTML comments
|
// add twig closing comment to HTML comments
|
||||||
this.$rules.comment.unshift({
|
this.$rules["twig-comment"] = [{
|
||||||
token : "comment.block.twig",
|
token : "comment.block.twig",
|
||||||
regex : ".*-?#\\}",
|
regex : ".*-?#\\}",
|
||||||
next : "start"
|
next : "pop"
|
||||||
});
|
}];
|
||||||
|
|
||||||
this.$rules["twig-start"] = [{
|
this.$rules["twig-start"] = [{
|
||||||
token : "variable.other.readwrite.local.twig",
|
token : "variable.other.readwrite.local.twig",
|
||||||
regex : "-?\\}\\}",
|
regex : "-?\\}\\}",
|
||||||
next : "start"
|
next : "pop"
|
||||||
}, {
|
}, {
|
||||||
token : "meta.tag.twig",
|
token : "meta.tag.twig",
|
||||||
regex : "-?%\\}",
|
regex : "-?%\\}",
|
||||||
next : "start"
|
next : "pop"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : "'",
|
regex : "'",
|
||||||
|
|
@ -131,8 +133,6 @@ var TwigHighlightRules = function() {
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
} ];
|
} ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.$rules["twig-qqstring"] = [{
|
this.$rules["twig-qqstring"] = [{
|
||||||
token : "constant.language.escape",
|
token : "constant.language.escape",
|
||||||
regex : /\\[\\"$#ntr]|#{[^"}]*}/
|
regex : /\\[\\"$#ntr]|#{[^"}]*}/
|
||||||
|
|
@ -156,6 +156,8 @@ var TwigHighlightRules = function() {
|
||||||
defaultToken : "string"
|
defaultToken : "string"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(TwigHighlightRules, TextHighlightRules);
|
oop.inherits(TwigHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var lang = require("../lib/lang");
|
var lang = require("../lib/lang");
|
||||||
var xmlUtil = require("./xml_util");
|
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
|
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
|
||||||
|
|
||||||
var VelocityHighlightRules = function() {
|
var VelocityHighlightRules = function() {
|
||||||
|
HtmlHighlightRules.call(this);
|
||||||
|
|
||||||
var builtinConstants = lang.arrayToMap(
|
var builtinConstants = lang.arrayToMap(
|
||||||
('true|false|null').split('|')
|
('true|false|null').split('|')
|
||||||
);
|
);
|
||||||
|
|
@ -31,198 +31,144 @@ var VelocityHighlightRules = function() {
|
||||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||||
// regexps are ordered -> the first match is used
|
// regexps are ordered -> the first match is used
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules.start.push(
|
||||||
"start" : [
|
{
|
||||||
{
|
token : "comment",
|
||||||
token : "meta.tag",
|
regex : "##.*$"
|
||||||
regex : "<\\!\\[CDATA\\[",
|
},{
|
||||||
next : "cdata"
|
token : "comment.block", // multi line comment
|
||||||
}, {
|
regex : "#\\*",
|
||||||
token : "xml-pe",
|
next : "vm_comment"
|
||||||
regex : "<\\?.*?\\?>"
|
}, {
|
||||||
}, {
|
token : "string.regexp",
|
||||||
token : "comment",
|
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||||
regex : "<\\!--",
|
}, {
|
||||||
next : "comment"
|
token : "string", // single line
|
||||||
}, {
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||||
token : "meta.tag",
|
}, {
|
||||||
regex : "<(?=\\s*script\\b)",
|
token : "string", // single line
|
||||||
next : "script"
|
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||||
}, {
|
}, {
|
||||||
token : "meta.tag",
|
token : "constant.numeric", // hex
|
||||||
regex : "<(?=\\s*style\\b)",
|
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||||
next : "style"
|
}, {
|
||||||
}, {
|
token : "constant.numeric", // float
|
||||||
token : "meta.tag", // opening tag
|
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||||
regex : "<\\/?(?=[a-z])",
|
}, {
|
||||||
next : "tag"
|
token : "constant.language.boolean",
|
||||||
}, {
|
regex : "(?:true|false)\\b"
|
||||||
token : "comment",
|
}, {
|
||||||
regex : "##.*$"
|
token : function(value) {
|
||||||
},{
|
if (keywords.hasOwnProperty(value))
|
||||||
token : "comment.block", // multi line comment
|
return "keyword";
|
||||||
regex : "#\\*",
|
else if (builtinConstants.hasOwnProperty(value))
|
||||||
next : "comment"
|
return "constant.language";
|
||||||
}, {
|
else if (builtinVariables.hasOwnProperty(value))
|
||||||
token : "string.regexp",
|
return "variable.language";
|
||||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
else if (builtinFunctions.hasOwnProperty(value) || builtinFunctions.hasOwnProperty(value.substring(1)))
|
||||||
}, {
|
return "support.function";
|
||||||
token : "string", // single line
|
else if (value == "debugger")
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
return "invalid.deprecated";
|
||||||
}, {
|
else
|
||||||
token : "string", // single line
|
if(value.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*)$/))
|
||||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
return "variable";
|
||||||
}, {
|
return "identifier";
|
||||||
token : "constant.numeric", // hex
|
},
|
||||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
// TODO: Unicode escape sequences
|
||||||
}, {
|
// TODO: Unicode identifiers
|
||||||
token : "constant.numeric", // float
|
regex : "[a-zA-Z$#][a-zA-Z0-9_]*\\b"
|
||||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
}, {
|
||||||
}, {
|
token : "keyword.operator",
|
||||||
token : "constant.language.boolean",
|
regex : "!|&|\\*|\\-|\\+|=|!=|<=|>=|<|>|&&|\\|\\|"
|
||||||
regex : "(?:true|false)\\b"
|
}, {
|
||||||
}, {
|
token : "lparen",
|
||||||
token : function(value) {
|
regex : "[[({]"
|
||||||
if (keywords.hasOwnProperty(value))
|
}, {
|
||||||
return "keyword";
|
token : "rparen",
|
||||||
else if (builtinConstants.hasOwnProperty(value))
|
regex : "[\\])}]"
|
||||||
return "constant.language";
|
}, {
|
||||||
else if (builtinVariables.hasOwnProperty(value))
|
token : "text",
|
||||||
return "variable.language";
|
regex : "\\s+"
|
||||||
else if (builtinFunctions.hasOwnProperty(value) || builtinFunctions.hasOwnProperty(value.substring(1)))
|
}
|
||||||
return "support.function";
|
);
|
||||||
else if (value == "debugger")
|
|
||||||
return "invalid.deprecated";
|
|
||||||
else
|
|
||||||
if(value.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*)$/))
|
|
||||||
return "variable";
|
|
||||||
return "identifier";
|
|
||||||
},
|
|
||||||
// TODO: Unicode escape sequences
|
|
||||||
// TODO: Unicode identifiers
|
|
||||||
regex : "[a-zA-Z$#][a-zA-Z0-9_]*\\b"
|
|
||||||
}, {
|
|
||||||
token : "keyword.operator",
|
|
||||||
regex : "!|&|\\*|\\-|\\+|=|!=|<=|>=|<|>|&&|\\|\\|"
|
|
||||||
}, {
|
|
||||||
token : "lparen",
|
|
||||||
regex : "[[({]"
|
|
||||||
}, {
|
|
||||||
token : "rparen",
|
|
||||||
regex : "[\\])}]"
|
|
||||||
}, {
|
|
||||||
token : "text",
|
|
||||||
regex : "\\s+"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"cdata" : [
|
|
||||||
{
|
|
||||||
token : "text",
|
|
||||||
regex : "\\]\\]>",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
token : "text",
|
|
||||||
regex : "\\s+"
|
|
||||||
}, {
|
|
||||||
token : "text",
|
|
||||||
regex : ".+"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"comment" : [
|
|
||||||
{
|
|
||||||
token : "comment", // closing comment
|
|
||||||
regex : "\\*#|-->",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
defaultToken: "comment"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"vm_start" : [
|
|
||||||
{
|
|
||||||
token: "variable",
|
|
||||||
regex: "}",
|
|
||||||
next: "start"
|
|
||||||
}, {
|
|
||||||
token : "string.regexp",
|
|
||||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
|
||||||
}, {
|
|
||||||
token : "string", // single line
|
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
|
||||||
}, {
|
|
||||||
token : "string", // single line
|
|
||||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
|
||||||
}, {
|
|
||||||
token : "constant.numeric", // hex
|
|
||||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
|
||||||
}, {
|
|
||||||
token : "constant.numeric", // float
|
|
||||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
|
||||||
}, {
|
|
||||||
token : "constant.language.boolean",
|
|
||||||
regex : "(?:true|false)\\b"
|
|
||||||
}, {
|
|
||||||
token : function(value) {
|
|
||||||
if (keywords.hasOwnProperty(value))
|
|
||||||
return "keyword";
|
|
||||||
else if (builtinConstants.hasOwnProperty(value))
|
|
||||||
return "constant.language";
|
|
||||||
else if (builtinVariables.hasOwnProperty(value))
|
|
||||||
return "variable.language";
|
|
||||||
else if (builtinFunctions.hasOwnProperty(value) || builtinFunctions.hasOwnProperty(value.substring(1)))
|
|
||||||
return "support.function";
|
|
||||||
else if (value == "debugger")
|
|
||||||
return "invalid.deprecated";
|
|
||||||
else
|
|
||||||
if(value.match(/^(\$[a-zA-Z_$][a-zA-Z0-9_]*)$/))
|
|
||||||
return "variable";
|
|
||||||
return "identifier";
|
|
||||||
},
|
|
||||||
// TODO: Unicode escape sequences
|
|
||||||
// TODO: Unicode identifiers
|
|
||||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
|
||||||
}, {
|
|
||||||
token : "keyword.operator",
|
|
||||||
regex : "!|&|\\*|\\-|\\+|=|!=|<=|>=|<|>|&&|\\|\\|"
|
|
||||||
}, {
|
|
||||||
token : "lparen",
|
|
||||||
regex : "[[({]"
|
|
||||||
}, {
|
|
||||||
token : "rparen",
|
|
||||||
regex : "[\\])}]"
|
|
||||||
}, {
|
|
||||||
token : "text",
|
|
||||||
regex : "\\s+"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
xmlUtil.tag(this.$rules, "tag", "start");
|
this.$rules["vm_comment"] = [
|
||||||
xmlUtil.tag(this.$rules, "style", "css-start");
|
{
|
||||||
xmlUtil.tag(this.$rules, "script", "js-start");
|
token : "comment", // closing comment
|
||||||
|
regex : "\\*#|-->",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken: "comment"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
this.$rules["vm_start"] = [
|
||||||
token: "comment",
|
{
|
||||||
regex: "\\/\\/.*(?=<\\/script>)",
|
token: "variable",
|
||||||
next: "tag"
|
regex: "}",
|
||||||
}, {
|
next: "pop"
|
||||||
token: "meta.tag",
|
}, {
|
||||||
regex: "<\\/(?=script)",
|
token : "string.regexp",
|
||||||
next: "tag"
|
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||||
}]);
|
}, {
|
||||||
|
token : "string", // single line
|
||||||
this.embedRules(CssHighlightRules, "css-", [{
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||||
token: "meta.tag",
|
}, {
|
||||||
regex: "<\\/(?=style)",
|
token : "string", // single line
|
||||||
next: "tag"
|
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||||
}]);
|
}, {
|
||||||
|
token : "constant.numeric", // hex
|
||||||
|
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // float
|
||||||
|
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||||
|
}, {
|
||||||
|
token : "constant.language.boolean",
|
||||||
|
regex : "(?:true|false)\\b"
|
||||||
|
}, {
|
||||||
|
token : function(value) {
|
||||||
|
if (keywords.hasOwnProperty(value))
|
||||||
|
return "keyword";
|
||||||
|
else if (builtinConstants.hasOwnProperty(value))
|
||||||
|
return "constant.language";
|
||||||
|
else if (builtinVariables.hasOwnProperty(value))
|
||||||
|
return "variable.language";
|
||||||
|
else if (builtinFunctions.hasOwnProperty(value) || builtinFunctions.hasOwnProperty(value.substring(1)))
|
||||||
|
return "support.function";
|
||||||
|
else if (value == "debugger")
|
||||||
|
return "invalid.deprecated";
|
||||||
|
else
|
||||||
|
if(value.match(/^(\$[a-zA-Z_$][a-zA-Z0-9_]*)$/))
|
||||||
|
return "variable";
|
||||||
|
return "identifier";
|
||||||
|
},
|
||||||
|
// TODO: Unicode escape sequences
|
||||||
|
// TODO: Unicode identifiers
|
||||||
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
|
}, {
|
||||||
|
token : "keyword.operator",
|
||||||
|
regex : "!|&|\\*|\\-|\\+|=|!=|<=|>=|<|>|&&|\\|\\|"
|
||||||
|
}, {
|
||||||
|
token : "lparen",
|
||||||
|
regex : "[[({]"
|
||||||
|
}, {
|
||||||
|
token : "rparen",
|
||||||
|
regex : "[\\])}]"
|
||||||
|
}, {
|
||||||
|
token : "text",
|
||||||
|
regex : "\\s+"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
for (var i in this.$rules) {
|
for (var i in this.$rules) {
|
||||||
this.$rules[i].unshift({
|
this.$rules[i].unshift({
|
||||||
token: "variable",
|
token: "variable",
|
||||||
regex: "\\${",
|
regex: "\\${",
|
||||||
next: "vm_start"
|
push: "vm_start"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(VelocityHighlightRules, TextHighlightRules);
|
oop.inherits(VelocityHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue