Initial commit
This commit is contained in:
parent
86750fbadb
commit
83e0a6b80b
4 changed files with 218 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* 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
|
||||
|
|
@ -96,6 +96,7 @@ var modesByName = {
|
|||
html: ["HTML" , "htm|html|xhtml"],
|
||||
c_cpp: ["C/C++" , "c|cc|cpp|cxx|h|hh|hpp"],
|
||||
clojure: ["Clojure" , "clj"],
|
||||
jade: ["Jade" , "jade"],
|
||||
java: ["Java" , "java"],
|
||||
javascript: ["JavaScript" , "js"],
|
||||
json: ["JSON" , "json"],
|
||||
|
|
@ -176,6 +177,7 @@ var docs = {
|
|||
"docs/groovy.groovy": "Groovy",
|
||||
"docs/Haxe.hx": "haXe",
|
||||
"docs/html.html": "HTML",
|
||||
"docs/jade.jade": "Jade",
|
||||
"docs/java.java": "Java",
|
||||
"docs/json.json": "JSON",
|
||||
"docs/jsx.jsx": "JSX",
|
||||
|
|
|
|||
17
demo/kitchen-sink/docs/jade.jade
Normal file
17
demo/kitchen-sink/docs/jade.jade
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
doctype 5
|
||||
html(lang="en")
|
||||
head
|
||||
title= pageTitle
|
||||
script(type='text/javascript')
|
||||
if (foo) {
|
||||
bar()
|
||||
}
|
||||
body
|
||||
h1 Jade - node template engine
|
||||
#container
|
||||
if youAreUsingJade
|
||||
p You are #{awesome}
|
||||
else
|
||||
p Get on it!
|
||||
|
||||
mixin dialog-title-desc(title, desc)
|
||||
66
lib/ace/mode/jade.js
Normal file
66
lib/ace/mode/jade.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Garen J. Torikian <gjtorikian AT gmail DOT com>
|
||||
* Alexander Hanhikoski <https://github.com/alexhanh>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var JadeHighlightRules = require("./jade_highlight_rules").JadeHighlightRules;
|
||||
// var JavascriptMode = require("ace/mode/javascript").Mode;
|
||||
// var CssMode = require("ace/mode/css").Mode;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new JadeHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
// this.$embeds = highlighter.getEmbeds();
|
||||
// this.createModeDelegates({
|
||||
// "js-": JavascriptMode
|
||||
// "css-": CssMode
|
||||
// });
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
// Extra logic goes here. (see below)
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
131
lib/ace/mode/jade_highlight_rules.js
Normal file
131
lib/ace/mode/jade_highlight_rules.js
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Garen J. Torikian <gjtorikian AT gmail DOT com>
|
||||
* Alexander Hanhikoski <https://github.com/alexhanh>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
// var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
// var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
|
||||
|
||||
var JadeHighlightRules = function() {
|
||||
|
||||
this.$rules = {
|
||||
start: [
|
||||
{
|
||||
token : ["keyword.control.import.include.jade"],
|
||||
regex : "(?:^\\s*\\b)(include)(?:\\b)"
|
||||
},
|
||||
{
|
||||
token : "keyword.other.doctype.jade",
|
||||
regex : "^(?:!!!)(?:\\s*[a-zA-Z0-9-_]+)?"
|
||||
},
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
},
|
||||
// match stuff like: mixin dialog-title-desc(title, desc)
|
||||
{
|
||||
token : ["storage.type.function.jade", "text", "entity.name.function.jade", "punctuation.definition.parameters.begin.jade", "variable.parameter.function.jade", "punctuation.definition.parameters.end.jade"],
|
||||
regex : "(mixin)( )([\\w\\-]+)\\s*(\\()(.*?)(\\))"
|
||||
},
|
||||
// match stuff like: mixin dialog-title-desc
|
||||
{
|
||||
token : ["storage.type.function.jade", "text", "entity.name.function.jade"],
|
||||
regex : "(mixin)( )(\\w\\-]+)"
|
||||
},
|
||||
// Jade's iteration: 'each foo in foos'
|
||||
{
|
||||
token : ["keyword", "text", "variable", "text", "keyword", "text", "variable"],
|
||||
regex : "(each|for)(\\s+)([\\w-]+)(\\s+)(in)(\\s+)([\\w-]+)"
|
||||
},
|
||||
// Jade's iteration: 'each foo, bar in foos'
|
||||
{
|
||||
token : ["keyword", "text", "variable", "text", "variable", "text", "keyword", "text", "variable"],
|
||||
regex : "(each|for)(\\s+)([\\w-]+)(\\s*,\\s*)([\\w-]+)(\\s+)(in)(\\s+)([\\w-]+)"
|
||||
},
|
||||
{
|
||||
token : "string.interpolated.jade",
|
||||
regex : "[#!]\\{[^\\}]+\\}"
|
||||
},
|
||||
{
|
||||
token : ["text", "meta.tag.any.jade", "meta.tag.any.jade"],
|
||||
regex : "(^\\s*)(?:(([\w]+))|(?=\.|#))"
|
||||
},
|
||||
{
|
||||
token : "text",
|
||||
regex : "\\|.*$"
|
||||
}
|
||||
],
|
||||
parentheses: [
|
||||
{
|
||||
token : "meta.tag.attribute.class.jade",
|
||||
regex : "\\.[\\w-]+<"
|
||||
},
|
||||
{
|
||||
token : "meta.tag.attribute.id.jade",
|
||||
regex : "#[\\w-]+<"
|
||||
},
|
||||
{
|
||||
token : "text",
|
||||
regex : "$",
|
||||
next : "start"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// this.embedRules(JavaScriptHighlightRules, "js-", {
|
||||
// start: [{
|
||||
// token: "string",
|
||||
// regex: "^$"
|
||||
// }]
|
||||
// });
|
||||
|
||||
// this.embedRules(CssHighlightRules, "css-", [{
|
||||
// token: "keyword",
|
||||
// regex: "style",
|
||||
// next: "start"
|
||||
// }]);
|
||||
};
|
||||
|
||||
oop.inherits(JadeHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.JadeHighlightRules = JadeHighlightRules;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue