add more modes
This commit is contained in:
parent
d7501b5b1a
commit
82ee67d49b
10 changed files with 545 additions and 64 deletions
|
|
@ -149,7 +149,8 @@ var docs = {
|
|||
"docs/haskell.hs": "Haskell",
|
||||
"docs/julia.js": "Julia",
|
||||
"docs/prolog/plg": "Prolog",
|
||||
"docs/rust.rs": "Rust"
|
||||
"docs/rust.rs": "Rust",
|
||||
"docs/twig.twig": "Twig"
|
||||
};
|
||||
|
||||
var ownSource = {
|
||||
|
|
|
|||
9
demo/kitchen-sink/docs/twig.twig
Normal file
9
demo/kitchen-sink/docs/twig.twig
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{% autoescape true %}
|
||||
{{ var }}
|
||||
{{ var|raw }} {# var won't be escaped #}
|
||||
{{ var|escape }} {# var won't be doubled-escaped #}
|
||||
{% endautoescape %}
|
||||
|
||||
{{ include('twig.html', sandboxed = true) }}
|
||||
|
||||
{{"string #{with} \" escapes" 'another#one' }}
|
||||
|
|
@ -58,10 +58,12 @@ var supportedModes = {
|
|||
CSharp: ["cs"],
|
||||
CSS: ["css"],
|
||||
Curly: ["curly"],
|
||||
D: ["d|di"],
|
||||
Dart: ["dart"],
|
||||
Diff: ["diff|patch"],
|
||||
Dot: ["dot"],
|
||||
Erlang: ["erl|hrl"],
|
||||
EJS: ["ejs"],
|
||||
Forth: ["frt|fs|ldr"],
|
||||
FreeMarker: ["ftl"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
|
|
@ -93,6 +95,7 @@ var supportedModes = {
|
|||
Makefile: ["^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
|
||||
MATLAB: ["matlab"],
|
||||
Markdown: ["md|markdown"],
|
||||
MySQL: ["mysql"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
ObjectiveC: ["m"],
|
||||
OCaml: ["ml|mli"],
|
||||
|
|
@ -124,6 +127,7 @@ var supportedModes = {
|
|||
Text: ["txt"],
|
||||
Textile: ["textile"],
|
||||
Toml: ["toml"],
|
||||
Twig: ["twig"],
|
||||
Typescript: ["typescript|ts|str"],
|
||||
VBScript: ["vbs"],
|
||||
Velocity: ["vm"],
|
||||
|
|
|
|||
111
lib/ace/mode/ejs.js
Normal file
111
lib/ace/mode/ejs.js
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
|
||||
var EjsHighlightRules = function(start, end) {
|
||||
HtmlHighlightRules.call(this);
|
||||
|
||||
if (!start)
|
||||
start = "(?:<%|<\\?|{{)";
|
||||
if (!end)
|
||||
end = "(?:%>|\\?>|}})";
|
||||
|
||||
for (var i in this.$rules) {
|
||||
this.$rules[i].unshift({
|
||||
token : "markup.list.meta.tag",
|
||||
regex : start + "(?![>}])[-=]?",
|
||||
push : "ejs-start"
|
||||
});
|
||||
}
|
||||
|
||||
this.embedRules(JavaScriptHighlightRules, "ejs-");
|
||||
|
||||
this.$rules["ejs-start"].unshift({
|
||||
token : "markup.list.meta.tag",
|
||||
regex : "-?" + end,
|
||||
next : "pop"
|
||||
}, {
|
||||
token: "comment",
|
||||
regex: "//.*?" + end,
|
||||
next: "pop"
|
||||
});
|
||||
|
||||
this.$rules["ejs-no_regex"].unshift({
|
||||
token : "markup.list.meta.tag",
|
||||
regex : "-?" + end,
|
||||
next : "pop"
|
||||
}, {
|
||||
token: "comment",
|
||||
regex: "//.*?" + end,
|
||||
next: "pop"
|
||||
});
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
|
||||
oop.inherits(EjsHighlightRules, HtmlHighlightRules);
|
||||
|
||||
exports.EjsHighlightRules = EjsHighlightRules;
|
||||
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var HtmlMode = require("./html").Mode;
|
||||
var JavaScriptMode = require("./javascript").Mode;
|
||||
var CssMode = require("./css").Mode;
|
||||
var RubyMode = require("./ruby").Mode;
|
||||
|
||||
var Mode = function() {
|
||||
HtmlMode.call(this);
|
||||
var highlighter = new EjsHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$embeds = highlighter.getEmbeds();
|
||||
this.createModeDelegates({
|
||||
"js-": JavaScriptMode,
|
||||
"css-": CssMode,
|
||||
"ejs-": JavaScriptMode
|
||||
});
|
||||
};
|
||||
oop.inherits(Mode, HtmlMode);
|
||||
|
||||
(function() {
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
|
@ -26,39 +26,26 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var TextMode = require("../mode/text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var x86AssemblyHighlightRules = require("./x86_assembly_highlight_rules").x86AssemblyHighlightRules;
|
||||
// TODO: pick appropriate fold mode
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
var MysqlHighlightRules = require("./mysql_highlight_rules").MysqlHighlightRules;
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new x86AssemblyHighlightRules();
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$tokenizer = new Tokenizer(new MysqlHighlightRules().getRules());
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "/\\*";
|
||||
(function() {
|
||||
this.lineCommentStart = ["--", "#"]; // todo space
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
// Extra logic goes here.
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
});
|
||||
122
lib/ace/mode/mysql_highlight_rules.js
Normal file
122
lib/ace/mode/mysql_highlight_rules.js
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var MysqlHighlightRules = function() {
|
||||
|
||||
var mySqlKeywords = /*sql*/ "alter|and|as|asc|between|count|create|delete|desc|distinct|drop|from|having|in|insert|into|is|join|like|not|on|or|order|select|set|table|union|update|values|where"
|
||||
/*mysql*/ + "|accessible|action|add|after|algorithm|all|analyze|asensitive|at|authors|auto_increment|autocommit|avg|avg_row_length|before|binary|binlog|both|btree|cache|call|cascade|cascaded|case|catalog_name|chain|change|changed|character|check|checkpoint|checksum|class_origin|client_statistics|close|coalesce|code|collate|collation|collations|column|columns|comment|commit|committed|completion|concurrent|condition|connection|consistent|constraint|contains|continue|contributors|convert|cross|current_date|current_time|current_timestamp|current_user|cursor|data|database|databases|day_hour|day_microsecond|day_minute|day_second|deallocate|dec|declare|default|delay_key_write|delayed|delimiter|des_key_file|describe|deterministic|dev_pop|dev_samp|deviance|directory|disable|discard|distinctrow|div|dual|dumpfile|each|elseif|enable|enclosed|end|ends|engine|engines|enum|errors|escape|escaped|even|event|events|every|execute|exists|exit|explain|extended|fast|fetch|field|fields|first|flush|for|force|foreign|found_rows|full|fulltext|function|general|global|grant|grants|group|groupby_concat|handler|hash|help|high_priority|hosts|hour_microsecond|hour_minute|hour_second|if|ignore|ignore_server_ids|import|index|index_statistics|infile|inner|innodb|inout|insensitive|insert_method|install|interval|invoker|isolation|iterate|key|keys|kill|language|last|leading|leave|left|level|limit|linear|lines|list|load|local|localtime|localtimestamp|lock|logs|low_priority|master|master_heartbeat_period|master_ssl_verify_server_cert|masters|match|max|max_rows|maxvalue|message_text|middleint|migrate|min|min_rows|minute_microsecond|minute_second|mod|mode|modifies|modify|mutex|mysql_errno|natural|next|no|no_write_to_binlog|offline|offset|one|online|open|optimize|option|optionally|out|outer|outfile|pack_keys|parser|partition|partitions|password|phase|plugin|plugins|prepare|preserve|prev|primary|privileges|procedure|processlist|profile|profiles|purge|query|quick|range|read|read_write|reads|real|rebuild|recover|references|regexp|relaylog|release|remove|rename|reorganize|repair|repeatable|replace|require|resignal|restrict|resume|return|returns|revoke|right|rlike|rollback|rollup|row|row_format|rtree|savepoint|schedule|schema|schema_name|schemas|second_microsecond|security|sensitive|separator|serializable|server|session|share|show|signal|slave|slow|smallint|snapshot|soname|spatial|specific|sql|sql_big_result|sql_buffer_result|sql_cache|sql_calc_found_rows|sql_no_cache|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|start|starting|starts|status|std|stddev|stddev_pop|stddev_samp|storage|straight_join|subclass_origin|sum|suspend|table_name|table_statistics|tables|tablespace|temporary|terminated|to|trailing|transaction|trigger|triggers|truncate|uncommitted|undo|uninstall|unique|unlock|upgrade|usage|use|use_frm|user|user_resources|user_statistics|using|utc_date|utc_time|utc_timestamp|value|variables|varying|view|views|warnings|when|while|with|work|write|xa|xor|year_month|zerofill|begin|do|then|else|loop|repeat";
|
||||
var builtins = "by|bool|boolean|bit|blob|decimal|double|enum|float|long|longblob|longtext|medium|mediumblob|mediumint|mediumtext|time|timestamp|tinyblob|tinyint|tinytext|text|bigint|int|int1|int2|int3|int4|int8|integer|float|float4|float8|double|char|varbinary|varchar|varcharacter|precision|date|datetime|year|unsigned|signed|numeric"
|
||||
var variable = "charset|clear|connect|edit|ego|exit|go|help|nopager|notee|nowarning|pager|print|prompt|quit|rehash|source|status|system|tee"
|
||||
|
||||
//operatorChars: /^[*+\-%<>!=&|^]/,
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": builtins,
|
||||
"keyword": mySqlKeywords,
|
||||
"constant": "false|true|null|unknown|date|time|timestamp|ODBCdotTable|zerolessFloat",
|
||||
"variable.language": variable
|
||||
}, "identifier", true);
|
||||
|
||||
|
||||
function string(rule) {
|
||||
var start = rule.start;
|
||||
var escapeSeq = rule.escape;
|
||||
return {
|
||||
token: "string.start",
|
||||
regex: start,
|
||||
next: [
|
||||
{token: "constant.language.escape", regex: escapeSeq},
|
||||
{token: "string.end", next: "start", regex: start},
|
||||
{defaultToken: "string"}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment", regex : "(?:-- |#).*$"
|
||||
},
|
||||
string({start: '"', escape: /\\[0'"bnrtZ\\%_]?/}),
|
||||
string({start: "'", escape: /\\[0'"bnrtZ\\%_]?/}),
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : /\/\*/,
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "constant.numeric", // hex
|
||||
regex : /0[xX][0-9a-fA-F]+|[xX]'[0-9a-fA-F]+'|0[bB][01]+|[bB]'[01]+'/
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "constant.class",
|
||||
regex : "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "constant.buildin",
|
||||
regex : "`[^`]*`"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[\\(]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\)]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
} ],
|
||||
"comment" : [
|
||||
{token : "comment", regex : "\\*\\/", next : "start"},
|
||||
{defaultToken : "comment"}
|
||||
],
|
||||
};
|
||||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]);
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(MysqlHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.MysqlHighlightRules = MysqlHighlightRules;
|
||||
});
|
||||
|
||||
|
|
@ -408,8 +408,7 @@ var PgsqlHighlightRules = function() {
|
|||
}, "identifier", true);
|
||||
|
||||
|
||||
var sqlRules = [
|
||||
{
|
||||
var sqlRules = [{
|
||||
token : "string", // single line string -- assume dollar strings if multi-line for now
|
||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||
}, {
|
||||
|
|
@ -420,29 +419,28 @@ var PgsqlHighlightRules = function() {
|
|||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "!|!!|!~|!~\\*|!~~|!~~\\*|#|##|#<|#<=|#<>|#=|#>|#>=|%|\\&|\\&\\&|\\&<|\\&<\\||\\&>|\\*|\\+|" +
|
||||
"\\-|/|<|<#>|<\\->|<<|<<=|<<\\||<=|<>|<\\?>|<@|<\\^|=|>|>=|>>|>>=|>\\^|\\?#|\\?\\-|\\?\\-\\||" +
|
||||
"\\?\\||\\?\\|\\||@|@\\-@|@>|@@|@@@|\\^|\\||\\|\\&>|\\|/|\\|>>|\\|\\||\\|\\|/|~|~\\*|~<=~|~<~|" +
|
||||
"~=|~>=~|~>~|~~|~~\\*"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[\\(]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\)]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}
|
||||
regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "!|!!|!~|!~\\*|!~~|!~~\\*|#|##|#<|#<=|#<>|#=|#>|#>=|%|\\&|\\&\\&|\\&<|\\&<\\||\\&>|\\*|\\+|" +
|
||||
"\\-|/|<|<#>|<\\->|<<|<<=|<<\\||<=|<>|<\\?>|<@|<\\^|=|>|>=|>>|>>=|>\\^|\\?#|\\?\\-|\\?\\-\\||" +
|
||||
"\\?\\||\\?\\|\\||@|@\\-@|@>|@@|@@@|\\^|\\||\\|\\&>|\\|/|\\|>>|\\|\\||\\|\\|/|~|~\\*|~<=~|~<~|" +
|
||||
"~=|~>=~|~>~|~~|~~\\*"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[\\(]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\)]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
"start" : [{
|
||||
token : "comment",
|
||||
regex : "--.*$"
|
||||
},
|
||||
|
|
@ -461,8 +459,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
],
|
||||
|
||||
"statement" : [
|
||||
{
|
||||
"statement" : [{
|
||||
token : "comment",
|
||||
regex : "--.*$"
|
||||
}, {
|
||||
|
|
@ -492,8 +489,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
].concat(sqlRules),
|
||||
|
||||
"dollarSql" : [
|
||||
{
|
||||
"dollarSql" : [{
|
||||
token : "comment",
|
||||
regex : "--.*$"
|
||||
}, {
|
||||
|
|
@ -511,8 +507,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
].concat(sqlRules),
|
||||
|
||||
"comment" : [
|
||||
{
|
||||
"comment" : [{
|
||||
token : "comment", // closing comment
|
||||
regex : ".*?\\*\\/",
|
||||
next : "start"
|
||||
|
|
@ -522,8 +517,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
],
|
||||
|
||||
"commentStatement" : [
|
||||
{
|
||||
"commentStatement" : [{
|
||||
token : "comment", // closing comment
|
||||
regex : ".*?\\*\\/",
|
||||
next : "statement"
|
||||
|
|
@ -533,8 +527,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
],
|
||||
|
||||
"commentDollarSql" : [
|
||||
{
|
||||
"commentDollarSql" : [{
|
||||
token : "comment", // closing comment
|
||||
regex : ".*?\\*\\/",
|
||||
next : "dollarSql"
|
||||
|
|
@ -544,8 +537,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
],
|
||||
|
||||
"dollarStatementString" : [
|
||||
{
|
||||
"dollarStatementString" : [{
|
||||
token : "string", // closing dollarstring
|
||||
regex : ".*?\\$[\\w_0-9]*\\$",
|
||||
next : "statement"
|
||||
|
|
@ -555,8 +547,7 @@ var PgsqlHighlightRules = function() {
|
|||
}
|
||||
],
|
||||
|
||||
"dollarSqlString" : [
|
||||
{
|
||||
"dollarSqlString" : [{
|
||||
token : "string", // closing dollarstring
|
||||
regex : ".*?\\$[\\w_0-9]*\\$",
|
||||
next : "dollarSql"
|
||||
|
|
|
|||
94
lib/ace/mode/twig.js
Normal file
94
lib/ace/mode/twig.js
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2013, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var JavaScriptMode = require("./javascript").Mode;
|
||||
var CssMode = require("./css").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var TwigHighlightRules = require("./twig_highlight_rules").TwigHighlightRules;
|
||||
var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
|
||||
var HtmlFoldMode = require("./folding/html").FoldMode;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new TwigHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new HtmlBehaviour();
|
||||
|
||||
this.$embeds = highlighter.getEmbeds();
|
||||
this.createModeDelegates({
|
||||
"js-": JavaScriptMode,
|
||||
"css-": CssMode
|
||||
});
|
||||
|
||||
this.foldingRules = new HtmlFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.blockComment = {start: "{#", end: "#}"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start") {
|
||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
164
lib/ace/mode/twig_highlight_rules.js
Normal file
164
lib/ace/mode/twig_highlight_rules.js
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2013, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var TwigHighlightRules = function() {
|
||||
// inherit from html
|
||||
HtmlHighlightRules.call(this);
|
||||
|
||||
var tags = "autoescape|block|do|embed|extends|filter|flush|for|from|if|import|include|macro|sandbox|set|spaceless|use|verbatim";
|
||||
tags = tags + "|end" + tags.replace(/\|/g, "|end");
|
||||
var filters = "abs|batch|capitalize|convert_encoding|date|date_modify|default|e|escape|first|format|join|json_encode|keys|last|length|lower|merge|nl2br|number_format|raw|replace|reverse|slice|sort|split|striptags|title|trim|upper|url_encode";
|
||||
var functions = "attribute|constant|cycle|date|dump|parent|random|range|template_from_string";
|
||||
var tests = "constant|divisibleby|sameas|defined|empty|even|iterable|odd";
|
||||
var constants = "null|none|true|false";
|
||||
var operators = "b-and|b-xor|b-or|in|is|and|or|not"
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"keyword.control.twig": tags,
|
||||
"support.function.twig": [filters, functions, tests].join("|"),
|
||||
"keyword.operator.twig": operators,
|
||||
"constant.language.twig": constants
|
||||
}, "identifier");
|
||||
|
||||
// add twig start tags to the HTML start tags
|
||||
this.$rules.start.unshift({
|
||||
token : "variable.other.readwrite.local.twig",
|
||||
regex : "\\{\\{-?",
|
||||
next : "twig-start"
|
||||
}, {
|
||||
token : "meta.tag.twig",
|
||||
regex : "\\{%-?",
|
||||
next : "twig-start"
|
||||
}, {
|
||||
token : "comment.block.twig",
|
||||
regex : "\\{#-?",
|
||||
next : "comment"
|
||||
});
|
||||
|
||||
// add twig closing comment to HTML comments
|
||||
this.$rules.comment.unshift({
|
||||
token : "comment.block.twig",
|
||||
regex : ".*-?#\\}",
|
||||
next : "start"
|
||||
});
|
||||
|
||||
this.$rules["twig-start"] = [{
|
||||
token : "variable.other.readwrite.local.twig",
|
||||
regex : "-?\\}\\}",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "meta.tag.twig",
|
||||
regex : "-?%\\}",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "'",
|
||||
next : "twig-qstring"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '"',
|
||||
next : "twig-qqstring"
|
||||
}, {
|
||||
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 : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator.assignment",
|
||||
regex : "=|~"
|
||||
}, {
|
||||
token : "keyword.operator.comparison",
|
||||
regex : "==|!=|<|>|>=|<=|==="
|
||||
}, {
|
||||
token : "keyword.operator.arithmetic",
|
||||
regex : "\\+|-|/|%|//|\\*|\\*\\*"
|
||||
}, {
|
||||
token : "keyword.operator.other",
|
||||
regex : "\\.\\.|\\|"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : /\?|\:|\,|\;|\./
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : /[\[\({]/
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : /[\])}]/
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
} ];
|
||||
|
||||
|
||||
|
||||
this.$rules["twig-qqstring"] = [{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\[\\"$#ntr]|#{[^"}]*}/
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '"',
|
||||
next : "twig-start",
|
||||
}, {
|
||||
defaultToken : "string"
|
||||
}
|
||||
];
|
||||
|
||||
this.$rules["twig-qstring"] = [{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\[\\'ntr]}/
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "'",
|
||||
next : "twig-start",
|
||||
}, {
|
||||
defaultToken : "string"
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
oop.inherits(TwigHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.TwigHighlightRules = TwigHighlightRules;
|
||||
});
|
||||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
@ -45,11 +41,13 @@ var TextMode = require("./text").Mode;
|
|||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var VelocityHighlightRules = require("./velocity_highlight_rules").VelocityHighlightRules;
|
||||
var FoldMode = require("./folding/velocity").FoldMode;
|
||||
var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new VelocityHighlightRules();
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$behaviour = new HtmlBehaviour();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue