Added very basic Textile mode implementation.
This commit is contained in:
parent
cc8685c11d
commit
075f789d6c
3 changed files with 168 additions and 5 deletions
51
index.html
51
index.html
|
|
@ -14,16 +14,18 @@
|
|||
<td align="right">
|
||||
<label for="doc">Document:</label>
|
||||
<select id="doc" size="1">
|
||||
<option value="js">JS Document</option>
|
||||
<option value="js">JavaScript Document</option>
|
||||
<option value="html">HTML Document</option>
|
||||
<option value="css">CSS Document</option>
|
||||
<option value="coffee">CoffeeScript Document</option>
|
||||
<option value="python">Python Document</option>
|
||||
<option value="ruby">Ruby Document</option>
|
||||
<option value="perl">Perl Document</option>
|
||||
<option value="php">PHP Document</option>
|
||||
<option value="java">Java Document</option>
|
||||
<option value="ruby">Ruby Document</option>
|
||||
<option value="csharp">C# Document</option>
|
||||
<option value="c_cpp">C++ Document</option>
|
||||
<option value="coffee">CoffeeScript Document</option>
|
||||
<option value="perl">Perl Document</option>
|
||||
<option value="textile" selected>Textile Document</option>
|
||||
<option value="plain">Text Document</option>
|
||||
</select>
|
||||
</td>
|
||||
|
|
@ -86,6 +88,8 @@
|
|||
<option value="c_cpp">C/C++</option>
|
||||
<option value="coffee">CoffeeScript</option>
|
||||
<option value="perl">Perl</option>
|
||||
<option value="csharp">C-Sharp</option>
|
||||
<option value="textile">Textile</option>
|
||||
</select>
|
||||
</td>
|
||||
<td align="right">
|
||||
|
|
@ -123,7 +127,10 @@
|
|||
|
||||
<div id="editor">
|
||||
</div>
|
||||
|
||||
<script type="text/editor" id="csharptext">public void HelloWorld() {
|
||||
//Say Hello!
|
||||
Console.WriteLine("Hello World");
|
||||
}</script>
|
||||
<script type="text/editor" id="jstext">function foo(items) {
|
||||
for (var i=0; i<items.length; i++) {
|
||||
alert(items[i] + "juhu");
|
||||
|
|
@ -310,6 +317,40 @@ for my $p (0 .. ($num_primes-1))
|
|||
}
|
||||
print "\n";
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="textile">
|
||||
|
||||
h1. Textile document
|
||||
|
||||
h2. Heading Two
|
||||
|
||||
h3. A two-line
|
||||
header
|
||||
|
||||
h2. Another two-line
|
||||
header
|
||||
|
||||
Paragraph:
|
||||
one, two,
|
||||
thee lines!
|
||||
|
||||
p(classone two three). This is a paragraph with classes
|
||||
|
||||
p(#id). (one with an id)
|
||||
|
||||
p(one two three#my_id). ..classes + id
|
||||
|
||||
* Unordered list
|
||||
** sublist
|
||||
* back again!
|
||||
** sublist again..
|
||||
|
||||
# ordered
|
||||
|
||||
bg. Blockquote!
|
||||
This is a two-list blockquote..!
|
||||
|
||||
</script>
|
||||
|
||||
<input id="cockpitInput" type="text"/>
|
||||
|
|
|
|||
44
lib/ace/mode/textile.js
Normal file
44
lib/ace/mode/textile.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
/*
|
||||
TODO license etc
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("pilot/oop");
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var TextileHighlightRules = require("ace/mode/textile_highlight_rules").TextileHighlightRules;
|
||||
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var Mode = function()
|
||||
{
|
||||
this.$tokenizer = new Tokenizer(new TextileHighlightRules().getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function()
|
||||
{
|
||||
this.getNextLineIndent = function(state, line, tab)
|
||||
{
|
||||
if (state == "intag")
|
||||
return tab;
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
});
|
||||
78
lib/ace/mode/textile_highlight_rules.js
Normal file
78
lib/ace/mode/textile_highlight_rules.js
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
/*
|
||||
TODO license etc
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("pilot/oop");
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var TextileHighlightRules = function()
|
||||
{
|
||||
/*
|
||||
var phraseModifiers = lang.arrayToMap(
|
||||
("_|*|__|**|??|-|+|^|%|@").split("|")
|
||||
);
|
||||
|
||||
var blockModifiers = lang.arrayToMap(
|
||||
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
|
||||
);
|
||||
*/
|
||||
/*
|
||||
var punctuation = lang.arrayToMap(
|
||||
("-|--|(tm)|(r)|(c)").split("|")
|
||||
);
|
||||
*/
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "keyword", // start of block
|
||||
regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre",
|
||||
next : "blocktag"
|
||||
},
|
||||
{
|
||||
token : "keyword",
|
||||
regex : "[\\*]+|[#]+"
|
||||
},
|
||||
{
|
||||
token : "text",
|
||||
regex : ".+"
|
||||
}
|
||||
],
|
||||
"blocktag" : [
|
||||
{
|
||||
token : "keyword",
|
||||
regex : "\\. ",
|
||||
next : "start",
|
||||
},
|
||||
{
|
||||
token : "keyword",
|
||||
regex : "\\(",
|
||||
next : "blocktagproperties"
|
||||
},
|
||||
],
|
||||
"blocktagproperties" : [
|
||||
{
|
||||
token : "keyword",
|
||||
regex : "\\)",
|
||||
next : "blocktag"
|
||||
},
|
||||
{
|
||||
token : "string",
|
||||
regex : "[a-zA-Z0-9\\-_]+"
|
||||
},
|
||||
{
|
||||
token : "keyword",
|
||||
regex : "#"
|
||||
},
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(TextileHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.TextileHighlightRules = TextileHighlightRules;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue