1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2010, Ajax.org B.V.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the name of Ajax.org B.V. nor the
15
* names of its contributors may be used to endorse or promote products
16
* derived from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
* ***** END LICENSE BLOCK ***** */
31
define('ace/mode/markdown', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/xml', 'ace/mode/html', 'ace/tokenizer', 'ace/mode/markdown_highlight_rules', 'ace/mode/folding/markdown'], function(require, exports, module) {
34
var oop = require("../lib/oop");
35
var TextMode = require("./text").Mode;
36
var JavaScriptMode = require("./javascript").Mode;
37
var XmlMode = require("./xml").Mode;
38
var HtmlMode = require("./html").Mode;
39
var Tokenizer = require("../tokenizer").Tokenizer;
40
var MarkdownHighlightRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
41
var MarkdownFoldMode = require("./folding/markdown").FoldMode;
43
var Mode = function() {
44
var highlighter = new MarkdownHighlightRules();
46
this.$tokenizer = new Tokenizer(highlighter.getRules());
47
this.$embeds = highlighter.getEmbeds();
48
this.createModeDelegates({
49
"js-": JavaScriptMode,
54
this.foldingRules = new MarkdownFoldMode();
56
oop.inherits(Mode, TextMode);
60
this.lineCommentStart = ">";
62
this.getNextLineIndent = function(state, line, tab) {
63
if (state == "listblock") {
64
var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
67
var marker = match[2];
69
marker = parseInt(match[3], 10) + 1 + ".";
70
return match[1] + marker + match[4];
72
return this.$getIndent(line);
75
}).call(Mode.prototype);
80
define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
83
var oop = require("../lib/oop");
84
var TextMode = require("./text").Mode;
85
var Tokenizer = require("../tokenizer").Tokenizer;
86
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
87
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
88
var Range = require("../range").Range;
89
var WorkerClient = require("../worker/worker_client").WorkerClient;
90
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
91
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
93
var Mode = function() {
94
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
95
this.$outdent = new MatchingBraceOutdent();
96
this.$behaviour = new CstyleBehaviour();
97
this.foldingRules = new CStyleFoldMode();
99
oop.inherits(Mode, TextMode);
103
this.lineCommentStart = "//";
104
this.blockComment = {start: "/*", end: "*/"};
106
this.getNextLineIndent = function(state, line, tab) {
107
var indent = this.$getIndent(line);
109
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
110
var tokens = tokenizedLine.tokens;
111
var endState = tokenizedLine.state;
113
if (tokens.length && tokens[tokens.length-1].type == "comment") {
117
if (state == "start" || state == "no_regex") {
118
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
122
} else if (state == "doc-start") {
123
if (endState == "start" || endState == "no_regex") {
126
var match = line.match(/^\s*(\/?)\*/);
138
this.checkOutdent = function(state, line, input) {
139
return this.$outdent.checkOutdent(line, input);
142
this.autoOutdent = function(state, doc, row) {
143
this.$outdent.autoOutdent(doc, row);
146
this.createWorker = function(session) {
147
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
148
worker.attachToDocument(session.getDocument());
150
worker.on("jslint", function(results) {
151
session.setAnnotations(results.data);
154
worker.on("terminate", function() {
155
session.clearAnnotations();
161
}).call(Mode.prototype);
166
define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
169
var oop = require("../lib/oop");
170
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
171
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
173
var JavaScriptHighlightRules = function() {
174
var keywordMapper = this.createKeywordMapper({
176
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
177
"Namespace|QName|XML|XMLList|" + // E4X
178
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
179
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
180
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
181
"SyntaxError|TypeError|URIError|" +
182
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
183
"isNaN|parseFloat|parseInt|" +
184
"JSON|Math|" + // Other
185
"this|arguments|prototype|window|document" , // Pseudo
187
"const|yield|import|get|set|" +
188
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
189
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
190
"__parent__|__count__|escape|unescape|with|__proto__|" +
191
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
193
"const|let|var|function",
195
"null|Infinity|NaN|undefined",
198
"constant.language.boolean": "true|false"
200
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
201
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
203
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
204
"u[0-9a-fA-F]{4}|" + // unicode
205
"[0-2][0-7]{0,2}|" + // oct
206
"3[0-6][0-7]?|" + // oct
208
"[4-7][0-7]?|" + //oct
217
DocCommentHighlightRules.getStartRule("doc-start"),
219
token : "comment", // multi line comment
231
token : "constant.numeric", // hex
232
regex : /0[xX][0-9a-fA-F]+\b/
234
token : "constant.numeric", // float
235
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
238
"storage.type", "punctuation.operator", "support.function",
239
"punctuation.operator", "entity.name.function", "text","keyword.operator"
241
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
242
next: "function_arguments"
245
"storage.type", "punctuation.operator", "entity.name.function", "text",
246
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
248
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
249
next: "function_arguments"
252
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
253
"text", "paren.lparen"
255
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
256
next: "function_arguments"
259
"storage.type", "punctuation.operator", "entity.name.function", "text",
260
"keyword.operator", "text",
261
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
263
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
264
next: "function_arguments"
267
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
269
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
270
next: "function_arguments"
273
"entity.name.function", "text", "punctuation.operator",
274
"text", "storage.type", "text", "paren.lparen"
276
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
277
next: "function_arguments"
280
"text", "text", "storage.type", "text", "paren.lparen"
282
regex : "(:)(\\s*)(function)(\\s*)(\\()",
283
next: "function_arguments"
286
regex : "(?:" + kwBeforeRe + ")\\b",
289
token : ["punctuation.operator", "support.function"],
290
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
292
token : ["punctuation.operator", "support.function.dom"],
293
regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
295
token : ["punctuation.operator", "support.constant"],
296
regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
298
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
299
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
301
token : keywordMapper,
304
token : "keyword.operator",
305
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
308
token : "punctuation.operator",
309
regex : /\?|\:|\,|\;|\./,
312
token : "paren.lparen",
316
token : "paren.rparen",
319
token : "keyword.operator",
328
DocCommentHighlightRules.getStartRule("doc-start"),
330
token : "comment", // multi line comment
332
next : "comment_regex_allowed"
338
token: "string.regexp",
353
token: "regexp.keyword.operator",
354
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
356
token: "string.regexp",
361
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
363
token : "constant.language.escape",
364
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
366
token : "constant.language.delimiter",
369
token: "constant.language.escape",
371
next: "regex_character_class",
377
defaultToken: "string.regexp"
380
"regex_character_class": [
382
token: "regexp.keyword.operator",
383
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
385
token: "constant.language.escape",
389
token: "constant.language.escape",
396
defaultToken: "string.regexp.charachterclass"
399
"function_arguments": [
401
token: "variable.parameter",
404
token: "punctuation.operator",
407
token: "punctuation.operator",
415
"comment_regex_allowed" : [
416
{token : "comment", regex : "\\*\\/", next : "start"},
417
{defaultToken : "comment"}
420
{token : "comment", regex : "\\*\\/", next : "no_regex"},
421
{defaultToken : "comment"}
425
token : "constant.language.escape",
436
defaultToken: "string"
441
token : "constant.language.escape",
452
defaultToken: "string"
457
this.embedRules(DocCommentHighlightRules, "doc-",
458
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
461
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
463
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
466
define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
469
var oop = require("../lib/oop");
470
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
472
var DocCommentHighlightRules = function() {
476
token : "comment.doc.tag",
477
regex : "@[\\w\\d_]+" // TODO: fix email addresses
479
token : "comment.doc.tag",
482
defaultToken : "comment.doc"
487
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
489
DocCommentHighlightRules.getStartRule = function(start) {
491
token : "comment.doc", // doc comment
492
regex : "\\/\\*(?=\\*)",
497
DocCommentHighlightRules.getEndRule = function (start) {
499
token : "comment.doc", // closing comment
506
exports.DocCommentHighlightRules = DocCommentHighlightRules;
510
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
513
var Range = require("../range").Range;
515
var MatchingBraceOutdent = function() {};
519
this.checkOutdent = function(line, input) {
520
if (! /^\s+$/.test(line))
523
return /^\s*\}/.test(input);
526
this.autoOutdent = function(doc, row) {
527
var line = doc.getLine(row);
528
var match = line.match(/^(\s*\})/);
530
if (!match) return 0;
532
var column = match[1].length;
533
var openBracePos = doc.findMatchingBracket({row: row, column: column});
535
if (!openBracePos || openBracePos.row == row) return 0;
537
var indent = this.$getIndent(doc.getLine(openBracePos.row));
538
doc.replace(new Range(row, 0, row, column-1), indent);
541
this.$getIndent = function(line) {
542
return line.match(/^\s*/)[0];
545
}).call(MatchingBraceOutdent.prototype);
547
exports.MatchingBraceOutdent = MatchingBraceOutdent;
550
define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
553
var oop = require("../../lib/oop");
554
var Behaviour = require("../behaviour").Behaviour;
555
var TokenIterator = require("../../token_iterator").TokenIterator;
556
var lang = require("../../lib/lang");
558
var SAFE_INSERT_IN_TOKENS =
559
["text", "paren.rparen", "punctuation.operator"];
560
var SAFE_INSERT_BEFORE_TOKENS =
561
["text", "paren.rparen", "punctuation.operator", "comment"];
564
var autoInsertedBrackets = 0;
565
var autoInsertedRow = -1;
566
var autoInsertedLineEnd = "";
567
var maybeInsertedBrackets = 0;
568
var maybeInsertedRow = -1;
569
var maybeInsertedLineStart = "";
570
var maybeInsertedLineEnd = "";
572
var CstyleBehaviour = function () {
574
CstyleBehaviour.isSaneInsertion = function(editor, session) {
575
var cursor = editor.getCursorPosition();
576
var iterator = new TokenIterator(session, cursor.row, cursor.column);
577
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
578
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
579
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
582
iterator.stepForward();
583
return iterator.getCurrentTokenRow() !== cursor.row ||
584
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
587
CstyleBehaviour.$matchTokenType = function(token, types) {
588
return types.indexOf(token.type || token) > -1;
591
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
592
var cursor = editor.getCursorPosition();
593
var line = session.doc.getLine(cursor.row);
594
if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
595
autoInsertedBrackets = 0;
596
autoInsertedRow = cursor.row;
597
autoInsertedLineEnd = bracket + line.substr(cursor.column);
598
autoInsertedBrackets++;
601
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
602
var cursor = editor.getCursorPosition();
603
var line = session.doc.getLine(cursor.row);
604
if (!this.isMaybeInsertedClosing(cursor, line))
605
maybeInsertedBrackets = 0;
606
maybeInsertedRow = cursor.row;
607
maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
608
maybeInsertedLineEnd = line.substr(cursor.column);
609
maybeInsertedBrackets++;
612
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
613
return autoInsertedBrackets > 0 &&
614
cursor.row === autoInsertedRow &&
615
bracket === autoInsertedLineEnd[0] &&
616
line.substr(cursor.column) === autoInsertedLineEnd;
619
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
620
return maybeInsertedBrackets > 0 &&
621
cursor.row === maybeInsertedRow &&
622
line.substr(cursor.column) === maybeInsertedLineEnd &&
623
line.substr(0, cursor.column) == maybeInsertedLineStart;
626
CstyleBehaviour.popAutoInsertedClosing = function() {
627
autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
628
autoInsertedBrackets--;
631
CstyleBehaviour.clearMaybeInsertedClosing = function() {
632
maybeInsertedBrackets = 0;
633
maybeInsertedRow = -1;
636
this.add("braces", "insertion", function (state, action, editor, session, text) {
637
var cursor = editor.getCursorPosition();
638
var line = session.doc.getLine(cursor.row);
640
var selection = editor.getSelectionRange();
641
var selected = session.doc.getTextRange(selection);
642
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
644
text: '{' + selected + '}',
647
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
648
if (/[\]\}\)]/.test(line[cursor.column])) {
649
CstyleBehaviour.recordAutoInsert(editor, session, "}");
655
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
662
} else if (text == '}') {
663
var rightChar = line.substring(cursor.column, cursor.column + 1);
664
if (rightChar == '}') {
665
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
666
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
667
CstyleBehaviour.popAutoInsertedClosing();
674
} else if (text == "\n" || text == "\r\n") {
676
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
677
closing = lang.stringRepeat("}", maybeInsertedBrackets);
678
CstyleBehaviour.clearMaybeInsertedClosing();
680
var rightChar = line.substring(cursor.column, cursor.column + 1);
681
if (rightChar == '}' || closing !== "") {
682
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
686
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
687
var next_indent = this.$getIndent(line);
690
text: '\n' + indent + '\n' + next_indent + closing,
691
selection: [1, indent.length, 1, indent.length]
697
this.add("braces", "deletion", function (state, action, editor, session, range) {
698
var selected = session.doc.getTextRange(range);
699
if (!range.isMultiLine() && selected == '{') {
700
var line = session.doc.getLine(range.start.row);
701
var rightChar = line.substring(range.end.column, range.end.column + 1);
702
if (rightChar == '}') {
706
maybeInsertedBrackets--;
711
this.add("parens", "insertion", function (state, action, editor, session, text) {
713
var selection = editor.getSelectionRange();
714
var selected = session.doc.getTextRange(selection);
715
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
717
text: '(' + selected + ')',
720
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
721
CstyleBehaviour.recordAutoInsert(editor, session, ")");
727
} else if (text == ')') {
728
var cursor = editor.getCursorPosition();
729
var line = session.doc.getLine(cursor.row);
730
var rightChar = line.substring(cursor.column, cursor.column + 1);
731
if (rightChar == ')') {
732
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
733
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
734
CstyleBehaviour.popAutoInsertedClosing();
744
this.add("parens", "deletion", function (state, action, editor, session, range) {
745
var selected = session.doc.getTextRange(range);
746
if (!range.isMultiLine() && selected == '(') {
747
var line = session.doc.getLine(range.start.row);
748
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
749
if (rightChar == ')') {
756
this.add("brackets", "insertion", function (state, action, editor, session, text) {
758
var selection = editor.getSelectionRange();
759
var selected = session.doc.getTextRange(selection);
760
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
762
text: '[' + selected + ']',
765
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
766
CstyleBehaviour.recordAutoInsert(editor, session, "]");
772
} else if (text == ']') {
773
var cursor = editor.getCursorPosition();
774
var line = session.doc.getLine(cursor.row);
775
var rightChar = line.substring(cursor.column, cursor.column + 1);
776
if (rightChar == ']') {
777
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
778
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
779
CstyleBehaviour.popAutoInsertedClosing();
789
this.add("brackets", "deletion", function (state, action, editor, session, range) {
790
var selected = session.doc.getTextRange(range);
791
if (!range.isMultiLine() && selected == '[') {
792
var line = session.doc.getLine(range.start.row);
793
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
794
if (rightChar == ']') {
801
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
802
if (text == '"' || text == "'") {
804
var selection = editor.getSelectionRange();
805
var selected = session.doc.getTextRange(selection);
806
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
808
text: quote + selected + quote,
812
var cursor = editor.getCursorPosition();
813
var line = session.doc.getLine(cursor.row);
814
var leftChar = line.substring(cursor.column-1, cursor.column);
815
if (leftChar == '\\') {
818
var tokens = session.getTokens(selection.start.row);
820
var quotepos = -1; // Track whether we're inside an open quote.
822
for (var x = 0; x < tokens.length; x++) {
824
if (token.type == "string") {
826
} else if (quotepos < 0) {
827
quotepos = token.value.indexOf(quote);
829
if ((token.value.length + col) > selection.start.column) {
832
col += tokens[x].value.length;
834
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
835
if (!CstyleBehaviour.isSaneInsertion(editor, session))
841
} else if (token && token.type === "string") {
842
var rightChar = line.substring(cursor.column, cursor.column + 1);
843
if (rightChar == quote) {
854
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
855
var selected = session.doc.getTextRange(range);
856
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
857
var line = session.doc.getLine(range.start.row);
858
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
859
if (rightChar == selected) {
868
oop.inherits(CstyleBehaviour, Behaviour);
870
exports.CstyleBehaviour = CstyleBehaviour;
873
define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
876
var oop = require("../../lib/oop");
877
var Range = require("../../range").Range;
878
var BaseFoldMode = require("./fold_mode").FoldMode;
880
var FoldMode = exports.FoldMode = function(commentRegex) {
882
this.foldingStartMarker = new RegExp(
883
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
885
this.foldingStopMarker = new RegExp(
886
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
890
oop.inherits(FoldMode, BaseFoldMode);
894
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
895
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
897
this.getFoldWidgetRange = function(session, foldStyle, row) {
898
var line = session.getLine(row);
899
var match = line.match(this.foldingStartMarker);
904
return this.openingBracketBlock(session, match[1], row, i);
906
return session.getCommentFoldRange(row, i + match[0].length, 1);
909
if (foldStyle !== "markbeginend")
912
var match = line.match(this.foldingStopMarker);
914
var i = match.index + match[0].length;
917
return this.closingBracketBlock(session, match[1], row, i);
919
return session.getCommentFoldRange(row, i, -1);
923
}).call(FoldMode.prototype);
927
define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) {
930
var oop = require("../lib/oop");
931
var TextMode = require("./text").Mode;
932
var Tokenizer = require("../tokenizer").Tokenizer;
933
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
934
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
935
var XmlFoldMode = require("./folding/xml").FoldMode;
937
var Mode = function() {
938
this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
939
this.$behaviour = new XmlBehaviour();
940
this.foldingRules = new XmlFoldMode();
943
oop.inherits(Mode, TextMode);
947
this.blockComment = {start: "<!--", end: "-->"};
949
}).call(Mode.prototype);
954
define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
957
var oop = require("../lib/oop");
958
var xmlUtil = require("./xml_util");
959
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
961
var XmlHighlightRules = function() {
964
{token : "text", regex : "<\\!\\[CDATA\\[", next : "cdata"},
965
{token : "xml-pe", regex : "<\\?.*?\\?>"},
966
{token : "comment", regex : "<\\!--", next : "comment"},
967
{token : "xml-pe", regex : "<\\!.*?>"},
968
{token : "meta.tag", regex : "<\\/?", next : "tag"},
969
{token : "text", regex : "\\s+"},
971
token : "constant.character.entity",
972
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
977
{token : "text", regex : "\\]\\]>", next : "start"},
978
{token : "text", regex : "\\s+"},
979
{token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
983
{token : "comment", regex : ".*?-->", next : "start"},
984
{token : "comment", regex : ".+"}
988
xmlUtil.tag(this.$rules, "tag", "start");
991
oop.inherits(XmlHighlightRules, TextHighlightRules);
993
exports.XmlHighlightRules = XmlHighlightRules;
996
define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
999
function string(state) {
1003
next : state + "_qqstring"
1007
next : state + "_qstring"
1011
function multiLineString(quote, state) {
1013
{token : "string", regex : quote, next : state},
1015
token : "constant.language.escape",
1016
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1018
{defaultToken : "string"}
1022
exports.tag = function(states, name, nextState, tagMap) {
1028
token : !tagMap ? "meta.tag.tag-name" : function(value) {
1030
return "meta.tag.tag-name." + tagMap[value];
1032
return "meta.tag.tag-name";
1034
regex : "[-_a-zA-Z0-9:]+",
1035
next : name + "_embed_attribute_list"
1039
next : name + "_embed_attribute_list"
1042
states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
1043
states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
1045
states[name + "_embed_attribute_list"] = [{
1046
token : "meta.tag.r",
1050
token : "keyword.operator",
1053
token : "entity.other.attribute-name",
1054
regex : "[-_a-zA-Z0-9:]+"
1056
token : "constant.numeric", // float
1057
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
1061
}].concat(string(name));
1066
define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
1069
var oop = require("../../lib/oop");
1070
var Behaviour = require("../behaviour").Behaviour;
1071
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1072
var TokenIterator = require("../../token_iterator").TokenIterator;
1074
function hasType(token, type) {
1076
var typeList = token.type.split('.');
1077
var needleList = type.split('.');
1078
needleList.forEach(function(needle){
1079
if (typeList.indexOf(needle) == -1) {
1087
var XmlBehaviour = function () {
1089
this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
1091
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1093
var position = editor.getCursorPosition();
1094
var iterator = new TokenIterator(session, position.row, position.column);
1095
var token = iterator.getCurrentToken();
1096
var atCursor = false;
1097
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1099
token = iterator.stepBackward();
1100
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1104
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1107
var tag = token.value;
1109
var tag = tag.substring(0, position.column - token.start);
1113
text: '>' + '</' + tag + '>',
1119
this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
1121
var cursor = editor.getCursorPosition();
1122
var line = session.doc.getLine(cursor.row);
1123
var rightChars = line.substring(cursor.column, cursor.column + 2);
1124
if (rightChars == '</') {
1125
var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
1126
var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
1129
text: '\n' + indent + '\n' + next_indent,
1130
selection: [1, indent.length, 1, indent.length]
1137
oop.inherits(XmlBehaviour, Behaviour);
1139
exports.XmlBehaviour = XmlBehaviour;
1142
define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) {
1145
var oop = require("../../lib/oop");
1146
var lang = require("../../lib/lang");
1147
var Range = require("../../range").Range;
1148
var BaseFoldMode = require("./fold_mode").FoldMode;
1149
var TokenIterator = require("../../token_iterator").TokenIterator;
1151
var FoldMode = exports.FoldMode = function(voidElements) {
1152
BaseFoldMode.call(this);
1153
this.voidElements = voidElements || {};
1155
oop.inherits(FoldMode, BaseFoldMode);
1159
this.getFoldWidget = function(session, foldStyle, row) {
1160
var tag = this._getFirstTagInLine(session, row);
1163
return foldStyle == "markbeginend" ? "end" : "";
1165
if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
1168
if (tag.selfClosing)
1171
if (tag.value.indexOf("/" + tag.tagName) !== -1)
1177
this._getFirstTagInLine = function(session, row) {
1178
var tokens = session.getTokens(row);
1180
for (var i = 0; i < tokens.length; i++) {
1181
var token = tokens[i];
1182
if (token.type.indexOf("meta.tag") === 0)
1183
value += token.value;
1185
value += lang.stringRepeat(" ", token.value.length);
1188
return this._parseTag(value);
1191
this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
1192
this._parseTag = function(tag) {
1194
var match = this.tagRe.exec(tag);
1195
var column = this.tagRe.lastIndex || 0;
1196
this.tagRe.lastIndex = 0;
1200
match: match ? match[2] : "",
1201
closing: match ? !!match[3] : false,
1202
selfClosing: match ? !!match[5] || match[2] == "/>" : false,
1203
tagName: match ? match[4] : "",
1204
column: match[1] ? column + match[1].length : column
1207
this._readTagForward = function(iterator) {
1208
var token = iterator.getCurrentToken();
1216
if (token.type.indexOf("meta.tag") === 0) {
1219
row: iterator.getCurrentTokenRow(),
1220
column: iterator.getCurrentTokenColumn()
1223
value += token.value;
1224
if (value.indexOf(">") !== -1) {
1225
var tag = this._parseTag(value);
1228
row: iterator.getCurrentTokenRow(),
1229
column: iterator.getCurrentTokenColumn() + token.value.length
1231
iterator.stepForward();
1235
} while(token = iterator.stepForward());
1240
this._readTagBackward = function(iterator) {
1241
var token = iterator.getCurrentToken();
1249
if (token.type.indexOf("meta.tag") === 0) {
1252
row: iterator.getCurrentTokenRow(),
1253
column: iterator.getCurrentTokenColumn() + token.value.length
1256
value = token.value + value;
1257
if (value.indexOf("<") !== -1) {
1258
var tag = this._parseTag(value);
1261
row: iterator.getCurrentTokenRow(),
1262
column: iterator.getCurrentTokenColumn()
1264
iterator.stepBackward();
1268
} while(token = iterator.stepBackward());
1273
this._pop = function(stack, tag) {
1274
while (stack.length) {
1276
var top = stack[stack.length-1];
1277
if (!tag || top.tagName == tag.tagName) {
1280
else if (this.voidElements[tag.tagName]) {
1283
else if (this.voidElements[top.tagName]) {
1292
this.getFoldWidgetRange = function(session, foldStyle, row) {
1293
var firstTag = this._getFirstTagInLine(session, row);
1295
if (!firstTag.match)
1298
var isBackward = firstTag.closing || firstTag.selfClosing;
1303
var iterator = new TokenIterator(session, row, firstTag.column);
1306
column: firstTag.column + firstTag.tagName.length + 2
1308
while (tag = this._readTagForward(iterator)) {
1309
if (tag.selfClosing) {
1310
if (!stack.length) {
1311
tag.start.column += tag.tagName.length + 2;
1312
tag.end.column -= 2;
1313
return Range.fromPoints(tag.start, tag.end);
1319
this._pop(stack, tag);
1320
if (stack.length == 0)
1321
return Range.fromPoints(start, tag.start);
1329
var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
1332
column: firstTag.column
1335
while (tag = this._readTagBackward(iterator)) {
1336
if (tag.selfClosing) {
1337
if (!stack.length) {
1338
tag.start.column += tag.tagName.length + 2;
1339
tag.end.column -= 2;
1340
return Range.fromPoints(tag.start, tag.end);
1346
this._pop(stack, tag);
1347
if (stack.length == 0) {
1348
tag.start.column += tag.tagName.length + 2;
1349
return Range.fromPoints(tag.start, end);
1360
}).call(FoldMode.prototype);
1364
define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html'], function(require, exports, module) {
1367
var oop = require("../lib/oop");
1368
var TextMode = require("./text").Mode;
1369
var JavaScriptMode = require("./javascript").Mode;
1370
var CssMode = require("./css").Mode;
1371
var Tokenizer = require("../tokenizer").Tokenizer;
1372
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
1373
var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
1374
var HtmlFoldMode = require("./folding/html").FoldMode;
1376
var Mode = function() {
1377
var highlighter = new HtmlHighlightRules();
1378
this.$tokenizer = new Tokenizer(highlighter.getRules());
1379
this.$behaviour = new HtmlBehaviour();
1381
this.$embeds = highlighter.getEmbeds();
1382
this.createModeDelegates({
1383
"js-": JavaScriptMode,
1387
this.foldingRules = new HtmlFoldMode();
1389
oop.inherits(Mode, TextMode);
1393
this.blockComment = {start: "<!--", end: "-->"};
1395
this.getNextLineIndent = function(state, line, tab) {
1396
return this.$getIndent(line);
1399
this.checkOutdent = function(state, line, input) {
1403
}).call(Mode.prototype);
1405
exports.Mode = Mode;
1408
define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/behaviour/css', 'ace/mode/folding/cstyle'], function(require, exports, module) {
1411
var oop = require("../lib/oop");
1412
var TextMode = require("./text").Mode;
1413
var Tokenizer = require("../tokenizer").Tokenizer;
1414
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1415
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1416
var WorkerClient = require("../worker/worker_client").WorkerClient;
1417
var CssBehaviour = require("./behaviour/css").CssBehaviour;
1418
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1420
var Mode = function() {
1421
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
1422
this.$outdent = new MatchingBraceOutdent();
1423
this.$behaviour = new CssBehaviour();
1424
this.foldingRules = new CStyleFoldMode();
1426
oop.inherits(Mode, TextMode);
1430
this.foldingRules = "cStyle";
1431
this.blockComment = {start: "/*", end: "*/"};
1433
this.getNextLineIndent = function(state, line, tab) {
1434
var indent = this.$getIndent(line);
1435
var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
1436
if (tokens.length && tokens[tokens.length-1].type == "comment") {
1440
var match = line.match(/^.*\{\s*$/);
1448
this.checkOutdent = function(state, line, input) {
1449
return this.$outdent.checkOutdent(line, input);
1452
this.autoOutdent = function(state, doc, row) {
1453
this.$outdent.autoOutdent(doc, row);
1456
this.createWorker = function(session) {
1457
var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1458
worker.attachToDocument(session.getDocument());
1460
worker.on("csslint", function(e) {
1461
session.setAnnotations(e.data);
1464
worker.on("terminate", function() {
1465
session.clearAnnotations();
1471
}).call(Mode.prototype);
1473
exports.Mode = Mode;
1477
define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1480
var oop = require("../lib/oop");
1481
var lang = require("../lib/lang");
1482
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1483
var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
1484
var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
1485
var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
1486
var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
1487
var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
1489
var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1490
var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1491
var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
1493
var CssHighlightRules = function() {
1495
var keywordMapper = this.createKeywordMapper({
1496
"support.function": supportFunction,
1497
"support.constant": supportConstant,
1498
"support.type": supportType,
1499
"support.constant.color": supportConstantColor,
1500
"support.constant.fonts": supportConstantFonts
1503
var base_ruleset = [
1505
token : "comment", // multi line comment
1507
next : "ruleset_comment"
1509
token : "string", // single line
1510
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1512
token : "string", // single line
1513
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1515
token : ["constant.numeric", "keyword"],
1516
regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
1518
token : "constant.numeric",
1521
token : "constant.numeric", // hex6 color
1522
regex : "#[a-f0-9]{6}"
1524
token : "constant.numeric", // hex3 color
1525
regex : "#[a-f0-9]{3}"
1527
token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1528
regex : pseudoElements
1530
token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1531
regex : pseudoClasses
1533
token : ["support.function", "string", "support.function"],
1534
regex : "(url\\()(.*)(\\))"
1536
token : keywordMapper,
1537
regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1539
caseInsensitive: true
1543
var ruleset = lang.copyArray(base_ruleset);
1545
token : "paren.rparen",
1550
var media_ruleset = lang.copyArray( base_ruleset );
1551
media_ruleset.unshift({
1552
token : "paren.rparen",
1557
var base_comment = [{
1558
token : "comment", // comment spanning whole line
1562
var comment = lang.copyArray(base_comment);
1564
token : "comment", // closing comment
1565
regex : ".*?\\*\\/",
1569
var media_comment = lang.copyArray(base_comment);
1570
media_comment.unshift({
1571
token : "comment", // closing comment
1572
regex : ".*?\\*\\/",
1576
var ruleset_comment = lang.copyArray(base_comment);
1577
ruleset_comment.unshift({
1578
token : "comment", // closing comment
1579
regex : ".*?\\*\\/",
1585
token : "comment", // multi line comment
1589
token: "paren.lparen",
1598
regex: "#[a-z0-9-_]+"
1601
regex: "\\.[a-z0-9-_]+"
1604
regex: ":[a-z0-9-_]+"
1607
regex: "[a-z0-9-_]+"
1609
caseInsensitive: true
1613
token : "comment", // multi line comment
1615
next : "media_comment"
1617
token: "paren.lparen",
1619
next: "media_ruleset"
1626
regex: "#[a-z0-9-_]+"
1629
regex: "\\.[a-z0-9-_]+"
1632
regex: ":[a-z0-9-_]+"
1635
regex: "[a-z0-9-_]+"
1637
caseInsensitive: true
1640
"comment" : comment,
1642
"ruleset" : ruleset,
1643
"ruleset_comment" : ruleset_comment,
1645
"media_ruleset" : media_ruleset,
1646
"media_comment" : media_comment
1650
oop.inherits(CssHighlightRules, TextHighlightRules);
1652
exports.CssHighlightRules = CssHighlightRules;
1656
define('ace/mode/behaviour/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
1659
var oop = require("../../lib/oop");
1660
var Behaviour = require("../behaviour").Behaviour;
1661
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1662
var TokenIterator = require("../../token_iterator").TokenIterator;
1664
var CssBehaviour = function () {
1666
this.inherit(CstyleBehaviour);
1668
this.add("colon", "insertion", function (state, action, editor, session, text) {
1670
var cursor = editor.getCursorPosition();
1671
var iterator = new TokenIterator(session, cursor.row, cursor.column);
1672
var token = iterator.getCurrentToken();
1673
if (token && token.value.match(/\s+/)) {
1674
token = iterator.stepBackward();
1676
if (token && token.type === 'support.type') {
1677
var line = session.doc.getLine(cursor.row);
1678
var rightChar = line.substring(cursor.column, cursor.column + 1);
1679
if (rightChar === ':') {
1685
if (!line.substring(cursor.column).match(/^\s*;/)) {
1695
this.add("colon", "deletion", function (state, action, editor, session, range) {
1696
var selected = session.doc.getTextRange(range);
1697
if (!range.isMultiLine() && selected === ':') {
1698
var cursor = editor.getCursorPosition();
1699
var iterator = new TokenIterator(session, cursor.row, cursor.column);
1700
var token = iterator.getCurrentToken();
1701
if (token && token.value.match(/\s+/)) {
1702
token = iterator.stepBackward();
1704
if (token && token.type === 'support.type') {
1705
var line = session.doc.getLine(range.start.row);
1706
var rightChar = line.substring(range.end.column, range.end.column + 1);
1707
if (rightChar === ';') {
1708
range.end.column ++;
1715
this.add("semicolon", "insertion", function (state, action, editor, session, text) {
1717
var cursor = editor.getCursorPosition();
1718
var line = session.doc.getLine(cursor.row);
1719
var rightChar = line.substring(cursor.column, cursor.column + 1);
1720
if (rightChar === ';') {
1730
oop.inherits(CssBehaviour, CstyleBehaviour);
1732
exports.CssBehaviour = CssBehaviour;
1735
define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1738
var oop = require("../lib/oop");
1739
var lang = require("../lib/lang");
1740
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1741
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1742
var xmlUtil = require("./xml_util");
1743
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1745
var tagMap = lang.createMap({
1764
var HtmlHighlightRules = function() {
1768
regex : "<\\!\\[CDATA\\[",
1772
regex : "<\\?.*?\\?>"
1782
regex : "<(?=script\\b)",
1786
regex : "<(?=style\\b)",
1789
token : "meta.tag", // opening tag
1796
token : "constant.character.entity",
1797
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1811
defaultToken : "comment"
1815
xmlUtil.tag(this.$rules, "tag", "start", tagMap);
1816
xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
1817
xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
1819
this.embedRules(JavaScriptHighlightRules, "js-", [{
1821
regex: "\\/\\/.*(?=<\\/script>)",
1825
regex: "<\\/(?=script)",
1829
this.embedRules(CssHighlightRules, "css-", [{
1831
regex: "<\\/(?=style)",
1836
oop.inherits(HtmlHighlightRules, TextHighlightRules);
1838
exports.HtmlHighlightRules = HtmlHighlightRules;
1841
define('ace/mode/behaviour/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour/xml', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
1844
var oop = require("../../lib/oop");
1845
var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
1846
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1847
var TokenIterator = require("../../token_iterator").TokenIterator;
1848
var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
1850
function hasType(token, type) {
1852
var typeList = token.type.split('.');
1853
var needleList = type.split('.');
1854
needleList.forEach(function(needle){
1855
if (typeList.indexOf(needle) == -1) {
1863
var HtmlBehaviour = function () {
1865
this.inherit(XmlBehaviour); // Get xml behaviour
1867
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
1869
var position = editor.getCursorPosition();
1870
var iterator = new TokenIterator(session, position.row, position.column);
1871
var token = iterator.getCurrentToken();
1872
var atCursor = false;
1873
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1875
token = iterator.stepBackward();
1876
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
1880
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1883
var element = token.value;
1885
var element = element.substring(0, position.column - token.start);
1887
if (voidElements.indexOf(element) !== -1){
1891
text: '>' + '</' + element + '>',
1897
oop.inherits(HtmlBehaviour, XmlBehaviour);
1899
exports.HtmlBehaviour = HtmlBehaviour;
1902
define('ace/mode/folding/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) {
1905
var oop = require("../../lib/oop");
1906
var MixedFoldMode = require("./mixed").FoldMode;
1907
var XmlFoldMode = require("./xml").FoldMode;
1908
var CStyleFoldMode = require("./cstyle").FoldMode;
1910
var FoldMode = exports.FoldMode = function() {
1911
MixedFoldMode.call(this, new XmlFoldMode({
1940
"js-": new CStyleFoldMode(),
1941
"css-": new CStyleFoldMode()
1945
oop.inherits(FoldMode, MixedFoldMode);
1949
define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1952
var oop = require("../../lib/oop");
1953
var BaseFoldMode = require("./fold_mode").FoldMode;
1955
var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
1956
this.defaultMode = defaultMode;
1957
this.subModes = subModes;
1959
oop.inherits(FoldMode, BaseFoldMode);
1964
this.$getMode = function(state) {
1965
for (var key in this.subModes) {
1966
if (state.indexOf(key) === 0)
1967
return this.subModes[key];
1972
this.$tryMode = function(state, session, foldStyle, row) {
1973
var mode = this.$getMode(state);
1974
return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
1977
this.getFoldWidget = function(session, foldStyle, row) {
1979
this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
1980
this.$tryMode(session.getState(row), session, foldStyle, row) ||
1981
this.defaultMode.getFoldWidget(session, foldStyle, row)
1985
this.getFoldWidgetRange = function(session, foldStyle, row) {
1986
var mode = this.$getMode(session.getState(row-1));
1988
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1989
mode = this.$getMode(session.getState(row));
1991
if (!mode || !mode.getFoldWidget(session, foldStyle, row))
1992
mode = this.defaultMode;
1994
return mode.getFoldWidgetRange(session, foldStyle, row);
1997
}).call(FoldMode.prototype);
2001
define('ace/mode/markdown_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules', 'ace/mode/html_highlight_rules', 'ace/mode/css_highlight_rules'], function(require, exports, module) {
2004
var oop = require("../lib/oop");
2005
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
2006
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
2007
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
2008
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
2009
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
2011
function github_embed(tag, prefix) {
2012
return { // Github style block
2013
token : "support.function",
2014
regex : "^```" + tag + "\\s*$",
2015
next : prefix + "start"
2019
var MarkdownHighlightRules = function() {
2022
"basic" : [{ // code span `
2023
token : "support.function",
2024
regex : "(`+)(.*?[^`])(\\1)"
2026
token : ["text", "constant", "text", "url", "string", "text"],
2027
regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
2028
}, { // link by reference
2029
token : ["text", "string", "text", "constant", "text"],
2030
regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])"
2032
token : ["text", "string", "text", "markup.underline", "string", "text"],
2034
"(\\[[^\\]]*\\]|[^\\[\\]]*)"+
2036
"(<?(?:(?:[^\\(]*?\\([^\\)]*?\\)\\S*?)|(?:.*?))>?)"+
2037
"((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+
2039
}, { // strong ** __
2041
regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
2042
}, { // emphasis * _
2044
regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
2046
token : ["text", "url", "text"],
2048
"(?:https?|ftp|dict):[^'\">\\s]+"+
2050
"(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
2054
{token : "support.function", regex : "^ {4}.+", next : "allowBlock"},
2055
{token : "empty", regex : "", next : "start"}
2059
token : "empty_line",
2063
token: "markup.heading.1",
2064
regex: "^=+(?=\\s*$)"
2066
token: "markup.heading.2",
2067
regex: "^\\-+(?=\\s*$)"
2069
token : function(value) {
2070
return "markup.heading." + value.length;
2072
regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
2075
github_embed("(?:javascript|js)", "js-"),
2076
github_embed("xml", "xml-"),
2077
github_embed("html", "html-"),
2078
github_embed("css", "css-"),
2079
{ // Github style block
2080
token : "support.function",
2081
regex : "^```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
2082
next : "githubblock"
2089
regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
2092
token : "markup.list",
2093
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
2094
next : "listblock-start"
2105
defaultToken : "markup.heading"
2108
"listblock-start" : [{
2109
token : "support.variable",
2110
regex : /(?:\[[ x]\])?/,
2114
"listblock" : [ { // Lists only escape on completely blank lines.
2115
token : "empty_line",
2119
token : "markup.list",
2120
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
2121
next : "listblock-start"
2123
include : "basic", noEscape: true
2125
defaultToken : "markup.list"
2128
"blockquote" : [ { // BLockquotes only escape on blank lines.
2129
token : "empty_line",
2138
token : "support.function",
2142
token : "support.function",
2147
this.embedRules(JavaScriptHighlightRules, "js-", [{
2148
token : "support.function",
2153
this.embedRules(HtmlHighlightRules, "html-", [{
2154
token : "support.function",
2159
this.embedRules(CssHighlightRules, "css-", [{
2160
token : "support.function",
2165
this.embedRules(XmlHighlightRules, "xml-", [{
2166
token : "support.function",
2171
var html = new HtmlHighlightRules().getRules();
2172
for (var i in html) {
2174
this.$rules[i] = this.$rules[i].concat(html[i]);
2176
this.$rules[i] = html[i];
2179
this.normalizeRules();
2181
oop.inherits(MarkdownHighlightRules, TextHighlightRules);
2183
exports.MarkdownHighlightRules = MarkdownHighlightRules;
2186
define('ace/mode/folding/markdown', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
2189
var oop = require("../../lib/oop");
2190
var BaseFoldMode = require("./fold_mode").FoldMode;
2191
var Range = require("../../range").Range;
2193
var FoldMode = exports.FoldMode = function() {};
2194
oop.inherits(FoldMode, BaseFoldMode);
2197
this.foldingStartMarker = /^(?:[=-]+\s*$|#{1,6} |`{3})/;
2199
this.getFoldWidget = function(session, foldStyle, row) {
2200
var line = session.getLine(row);
2201
if (!this.foldingStartMarker.test(line))
2204
if (line[0] == "`") {
2205
if (session.bgTokenizer.getState(row) == "start")
2213
this.getFoldWidgetRange = function(session, foldStyle, row) {
2214
var line = session.getLine(row);
2215
var startColumn = line.length;
2216
var maxRow = session.getLength();
2219
if (!line.match(this.foldingStartMarker))
2222
if (line[0] == "`") {
2223
if (session.bgTokenizer.getState(row) !== "start") {
2224
while (++row < maxRow) {
2225
line = session.getLine(row);
2226
if (line[0] == "`" & line.substring(0, 3) == "```")
2229
return new Range(startRow, startColumn, row, 0);
2231
while (row -- > 0) {
2232
line = session.getLine(row);
2233
if (line[0] == "`" & line.substring(0, 3) == "```")
2236
return new Range(row, line.length, startRow, 0);
2241
function isHeading(row) {
2242
token = session.getTokens(row)[0];
2243
return token && token.type.lastIndexOf(heading, 0) === 0;
2246
var heading = "markup.heading";
2247
function getLevel() {
2248
var ch = token.value[0];
2249
if (ch == "=") return 6;
2250
if (ch == "-") return 5;
2251
return 7 - token.value.search(/[^#]/);
2254
if (isHeading(row)) {
2255
var startHeadingLevel = getLevel();
2256
while (++row < maxRow) {
2257
if (!isHeading(row))
2259
var level = getLevel();
2260
if (level >= startHeadingLevel)
2264
endRow = row - (!token || ["=", "-"].indexOf(token.value[0]) == -1 ? 1 : 2);
2266
if (endRow > startRow) {
2267
while (endRow > startRow && /^\s*$/.test(session.getLine(endRow)))
2271
if (endRow > startRow) {
2272
var endColumn = session.getLine(endRow).length;
2273
return new Range(startRow, startColumn, endRow, endColumn);
2278
}).call(FoldMode.prototype);