Start haml
This commit is contained in:
parent
4348a9dd23
commit
3dce122f8c
5 changed files with 366 additions and 0 deletions
60
lib/ace/mode/haml.js
Normal file
60
lib/ace/mode/haml.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* ***** 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.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Garen J. Torikian < gjtorikian AT gmail DOT com >
|
||||
*
|
||||
* ***** 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 Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var HamlHighlightRules = require("./haml_highlight_rules").HamlHighlightRules;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new HamlHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
// Extra logic goes here.
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
264
lib/ace/mode/haml_highlight_rules.js
Normal file
264
lib/ace/mode/haml_highlight_rules.js
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
/* ***** 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.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Garen J. Torikian < gjtorikian AT gmail DOT com >
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
THIS FILE WAS AUTOGENERATED BY Haml.tmlanguage (UUID: 3D727049-DD05-45DF-92A5-D50EA36FD035) */
|
||||
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
|
||||
|
||||
var HamlHighlightRules = function() {
|
||||
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules =
|
||||
{
|
||||
"start": [
|
||||
{
|
||||
"token": "string.quoted.double",
|
||||
"regex": "==.+?=="
|
||||
},
|
||||
{
|
||||
"token": "keyword.other.doctype",
|
||||
"regex": "^!!!\\s*(?:[a-zA-Z0-9-_]+)?"
|
||||
},
|
||||
{
|
||||
token : "comment",
|
||||
regex : /\/.*$/
|
||||
},
|
||||
//{
|
||||
// "token": [
|
||||
// {
|
||||
// "2": {
|
||||
// "name": "punctuation.section.comment.haml"
|
||||
// }
|
||||
// },
|
||||
// "comment.block.haml"
|
||||
// ],
|
||||
// "regex": "^( *)(/)\\s*$",
|
||||
// "next": "state_4"
|
||||
//},
|
||||
{
|
||||
"token": ["meta.tag.haml", "punctuation.definition.tag.haml", "entity.name.tag.haml"],
|
||||
"regex": /^\s*(?:((%)([\w:]+))|(?=\.|#))/,
|
||||
"next": "tag_single"
|
||||
},
|
||||
{
|
||||
"token": [ "meta.escape.haml" ],
|
||||
"regex": "^\\s*\\\\."
|
||||
},
|
||||
//{
|
||||
// "token": [
|
||||
// null
|
||||
// ],
|
||||
// "regex": "^\\s*(?==|-|~)",
|
||||
// "next": "state_7"
|
||||
//}
|
||||
],
|
||||
/*"interpolated_ruby": [
|
||||
{
|
||||
"token": [ "punctuation.section.embedded.ruby", "source.ruby.embedded.source.empty",
|
||||
"regex": "(?:#\\{(\\}))",
|
||||
},
|
||||
{
|
||||
"begin": "#\\{",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "punctuation.section.embedded.ruby"
|
||||
}
|
||||
},
|
||||
"end": "(\\})",
|
||||
"name": "source.ruby.embedded.source",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#nest_curly_and_self"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.definition.variable.ruby"
|
||||
}
|
||||
},
|
||||
"regex": "(#@)[a-zA-Z_]\\w*",
|
||||
"name": "variable.other.readwrite.instance.ruby"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.definition.variable.ruby"
|
||||
}
|
||||
},
|
||||
"regex": "(#@@)[a-zA-Z_]\\w*",
|
||||
"name": "variable.other.readwrite.class.ruby"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.definition.variable.ruby"
|
||||
}
|
||||
},
|
||||
"regex": "(#\\$)[a-zA-Z_]\\w*",
|
||||
"name": "variable.other.readwrite.global.ruby"
|
||||
}
|
||||
]
|
||||
],*//*
|
||||
"state_4": [
|
||||
{
|
||||
"include": "text.haml"
|
||||
},
|
||||
{
|
||||
"token": "TODO",
|
||||
"regex": "^(?!\\1 )",
|
||||
"next": "start"
|
||||
}
|
||||
],*/
|
||||
"tag_single": [
|
||||
{
|
||||
"token": "suport.type.attribute.class.jade",
|
||||
"regex": "\\.[\\w-]+"
|
||||
},
|
||||
{
|
||||
"token": "suport.type.attribute.id.jade",
|
||||
"regex": "#[\\w-]+"
|
||||
},
|
||||
//{
|
||||
// "token": "meta.section.attributes.haml",
|
||||
// "regex": ""
|
||||
//},
|
||||
//{
|
||||
// "token": "meta.section.object.haml",
|
||||
// "regex": ""
|
||||
//},
|
||||
//{
|
||||
// "include": "#rubyline"
|
||||
//},
|
||||
//{
|
||||
// "token": "punctuation.terminator.tag.haml",
|
||||
// "regex": "/"
|
||||
//},
|
||||
//{
|
||||
// "token": "TODO",
|
||||
// "regex": "$|(?!\\.|#|\\{|\\[|=|-|~|/)",
|
||||
// "next": "start"
|
||||
//}
|
||||
]/*,
|
||||
"state_7": [
|
||||
{
|
||||
"include": "#rubyline"
|
||||
},
|
||||
{
|
||||
"token": "TODO",
|
||||
"regex": "$",
|
||||
"next": "start"
|
||||
}
|
||||
]*/
|
||||
}
|
||||
|
||||
/*** START REPOSITORY RULES
|
||||
{
|
||||
"continuation": {
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.separator.continuation.haml"
|
||||
}
|
||||
},
|
||||
"regex": "(\\|)\\s*\\n"
|
||||
},
|
||||
|
||||
},
|
||||
"nest_curly_and_self": {
|
||||
"patterns": [
|
||||
{
|
||||
"begin": "\\{",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "punctuation.section.scope.ruby"
|
||||
}
|
||||
},
|
||||
"end": "\\}",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#nest_curly_and_self"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"include": "source.ruby"
|
||||
}
|
||||
]
|
||||
},
|
||||
"rubyline": {
|
||||
"begin": "=|-|~",
|
||||
"contentName": "source.ruby.embedded.haml",
|
||||
"end": "((do|\\{)( \\|[^|]+\\|)?)$|$|^(?!.*\\|\\s*$)",
|
||||
"endCaptures": {
|
||||
"1": {
|
||||
"name": "source.ruby.embedded.html"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.control.ruby.start-block"
|
||||
}
|
||||
},
|
||||
"name": "meta.line.ruby.haml",
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "Hack to let ruby comments work in this context properly",
|
||||
"regex": "#.*$",
|
||||
"name": "comment.line.number-sign.ruby"
|
||||
},
|
||||
{
|
||||
"include": "source.ruby.rails"
|
||||
},
|
||||
{
|
||||
"include": "#continuation"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
END REPOSITORY RULES ***/
|
||||
};
|
||||
|
||||
oop.inherits(HamlHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.HamlHighlightRules = HamlHighlightRules;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue