You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mode-html.js 72KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Ajax.org Code Editor (ACE).
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Ajax.org B.V.
  18. * Portions created by the Initial Developer are Copyright (C) 2010
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Fabian Jakobs <fabian AT ajax DOT org>
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. ace.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/xml', 'ace/mode/folding/html'], function(require, exports, module) {
  38. var oop = require("../lib/oop");
  39. var TextMode = require("./text").Mode;
  40. var JavaScriptMode = require("./javascript").Mode;
  41. var CssMode = require("./css").Mode;
  42. var Tokenizer = require("../tokenizer").Tokenizer;
  43. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  44. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  45. var HtmlFoldMode = require("./folding/html").FoldMode;
  46. var Mode = function() {
  47. var highlighter = new HtmlHighlightRules();
  48. this.$tokenizer = new Tokenizer(highlighter.getRules());
  49. this.$behaviour = new XmlBehaviour();
  50. this.$embeds = highlighter.getEmbeds();
  51. this.createModeDelegates({
  52. "js-": JavaScriptMode,
  53. "css-": CssMode
  54. });
  55. this.foldingRules = new HtmlFoldMode();
  56. };
  57. oop.inherits(Mode, TextMode);
  58. (function() {
  59. this.toggleCommentLines = function(state, doc, startRow, endRow) {
  60. return 0;
  61. };
  62. this.getNextLineIndent = function(state, line, tab) {
  63. return this.$getIndent(line);
  64. };
  65. this.checkOutdent = function(state, line, input) {
  66. return false;
  67. };
  68. }).call(Mode.prototype);
  69. exports.Mode = Mode;
  70. });
  71. ace.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) {
  72. var oop = require("../lib/oop");
  73. var TextMode = require("./text").Mode;
  74. var Tokenizer = require("../tokenizer").Tokenizer;
  75. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  76. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  77. var Range = require("../range").Range;
  78. var WorkerClient = require("../worker/worker_client").WorkerClient;
  79. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  80. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  81. var Mode = function() {
  82. this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
  83. this.$outdent = new MatchingBraceOutdent();
  84. this.$behaviour = new CstyleBehaviour();
  85. this.foldingRules = new CStyleFoldMode();
  86. };
  87. oop.inherits(Mode, TextMode);
  88. (function() {
  89. this.toggleCommentLines = function(state, doc, startRow, endRow) {
  90. var outdent = true;
  91. var re = /^(\s*)\/\//;
  92. for (var i=startRow; i<= endRow; i++) {
  93. if (!re.test(doc.getLine(i))) {
  94. outdent = false;
  95. break;
  96. }
  97. }
  98. if (outdent) {
  99. var deleteRange = new Range(0, 0, 0, 0);
  100. for (var i=startRow; i<= endRow; i++)
  101. {
  102. var line = doc.getLine(i);
  103. var m = line.match(re);
  104. deleteRange.start.row = i;
  105. deleteRange.end.row = i;
  106. deleteRange.end.column = m[0].length;
  107. doc.replace(deleteRange, m[1]);
  108. }
  109. }
  110. else {
  111. doc.indentRows(startRow, endRow, "//");
  112. }
  113. };
  114. this.getNextLineIndent = function(state, line, tab) {
  115. var indent = this.$getIndent(line);
  116. var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
  117. var tokens = tokenizedLine.tokens;
  118. var endState = tokenizedLine.state;
  119. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  120. return indent;
  121. }
  122. if (state == "start" || state == "regex_allowed") {
  123. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  124. if (match) {
  125. indent += tab;
  126. }
  127. } else if (state == "doc-start") {
  128. if (endState == "start" || state == "regex_allowed") {
  129. return "";
  130. }
  131. var match = line.match(/^\s*(\/?)\*/);
  132. if (match) {
  133. if (match[1]) {
  134. indent += " ";
  135. }
  136. indent += "* ";
  137. }
  138. }
  139. return indent;
  140. };
  141. this.checkOutdent = function(state, line, input) {
  142. return this.$outdent.checkOutdent(line, input);
  143. };
  144. this.autoOutdent = function(state, doc, row) {
  145. this.$outdent.autoOutdent(doc, row);
  146. };
  147. this.createWorker = function(session) {
  148. var worker = new WorkerClient(["ace"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker");
  149. worker.attachToDocument(session.getDocument());
  150. worker.on("jslint", function(results) {
  151. var errors = [];
  152. for (var i=0; i<results.data.length; i++) {
  153. var error = results.data[i];
  154. if (error)
  155. errors.push({
  156. row: error.line-1,
  157. column: error.character-1,
  158. text: error.reason,
  159. type: "warning",
  160. lint: error
  161. });
  162. }
  163. session.setAnnotations(errors);
  164. });
  165. worker.on("narcissus", function(e) {
  166. session.setAnnotations([e.data]);
  167. });
  168. worker.on("terminate", function() {
  169. session.clearAnnotations();
  170. });
  171. return worker;
  172. };
  173. }).call(Mode.prototype);
  174. exports.Mode = Mode;
  175. });
  176. ace.define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  177. var oop = require("../lib/oop");
  178. var lang = require("../lib/lang");
  179. var unicode = require("../unicode");
  180. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  181. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  182. var JavaScriptHighlightRules = function() {
  183. // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
  184. var globals = lang.arrayToMap(
  185. // Constructors
  186. ("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
  187. // E4X
  188. "Namespace|QName|XML|XMLList|" +
  189. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  190. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  191. // Errors
  192. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
  193. "SyntaxError|TypeError|URIError|" +
  194. // Non-constructor functions
  195. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
  196. "isNaN|parseFloat|parseInt|" +
  197. // Other
  198. "JSON|Math|" +
  199. // Pseudo
  200. "this|arguments|prototype|window|document"
  201. ).split("|")
  202. );
  203. var keywords = lang.arrayToMap(
  204. ("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  205. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
  206. "const|yield|import|get|set").split("|")
  207. );
  208. // keywords which can be followed by regular expressions
  209. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
  210. var deprecated = lang.arrayToMap(
  211. ("__parent__|__count__|escape|unescape|with|__proto__").split("|")
  212. );
  213. var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
  214. var buildinConstants = lang.arrayToMap(
  215. ("null|Infinity|NaN|undefined").split("|")
  216. );
  217. var futureReserved = lang.arrayToMap(
  218. ("class|enum|extends|super|export|implements|private|" +
  219. "public|interface|package|protected|static").split("|")
  220. );
  221. // TODO: Unicode escape sequences
  222. var identifierRe = "[" + unicode.packages.L + "\\$_]["
  223. + unicode.packages.L
  224. + unicode.packages.Mn + unicode.packages.Mc
  225. + unicode.packages.Nd
  226. + unicode.packages.Pc + "\\$_]*\\b";
  227. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  228. "u[0-9a-fA-F]{4}|" + // unicode
  229. "[0-2][0-7]{0,2}|" + // oct
  230. "3[0-6][0-7]?|" + // oct
  231. "37[0-7]?|" + // oct
  232. "[4-7][0-7]?|" + //oct
  233. ".)";
  234. // regexp must not have capturing parentheses. Use (?:) instead.
  235. // regexps are ordered -> the first match is used
  236. this.$rules = {
  237. "start" : [
  238. {
  239. token : "comment",
  240. regex : /\/\/.*$/
  241. },
  242. DocCommentHighlightRules.getStartRule("doc-start"),
  243. {
  244. token : "comment", // multi line comment
  245. merge : true,
  246. regex : /\/\*/,
  247. next : "comment"
  248. }, {
  249. token : "string",
  250. regex : "'(?=.)",
  251. next : "qstring"
  252. }, {
  253. token : "string",
  254. regex : '"(?=.)',
  255. next : "qqstring"
  256. }, {
  257. token : "constant.numeric", // hex
  258. regex : /0[xX][0-9a-fA-F]+\b/
  259. }, {
  260. token : "constant.numeric", // float
  261. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  262. }, { // match stuff like: Sound.prototype.play = function() { }
  263. token : [
  264. "storage.type",
  265. "punctuation.operator",
  266. "support.function",
  267. "punctuation.operator",
  268. "entity.name.function",
  269. "text",
  270. "keyword.operator",
  271. "text",
  272. "storage.type",
  273. "text",
  274. "paren.lparen"
  275. ],
  276. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  277. next: "function_arguments"
  278. }, { // match stuff like: Sound.prototype.play = myfunc
  279. token : [
  280. "storage.type",
  281. "punctuation.operator",
  282. "support.function",
  283. "punctuation.operator",
  284. "entity.name.function",
  285. "text",
  286. "keyword.operator",
  287. "text"
  288. ],
  289. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)",
  290. next: "function_arguments"
  291. }, { // match stuff like: Sound.play = function() { }
  292. token : [
  293. "storage.type",
  294. "punctuation.operator",
  295. "entity.name.function",
  296. "text",
  297. "keyword.operator",
  298. "text",
  299. "storage.type",
  300. "text",
  301. "paren.lparen"
  302. ],
  303. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  304. next: "function_arguments"
  305. }, { // match stuff like: play = function() { }
  306. token : [
  307. "entity.name.function",
  308. "text",
  309. "keyword.operator",
  310. "text",
  311. "storage.type",
  312. "text",
  313. "paren.lparen"
  314. ],
  315. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  316. next: "function_arguments"
  317. }, { // match stuff like: Sound.play = function play() { }
  318. token : [
  319. "storage.type",
  320. "punctuation.operator",
  321. "entity.name.function",
  322. "text",
  323. "keyword.operator",
  324. "text",
  325. "storage.type",
  326. "text",
  327. "entity.name.function",
  328. "text",
  329. "paren.lparen"
  330. ],
  331. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  332. next: "function_arguments"
  333. }, { // match regular function like: function myFunc(arg) { }
  334. token : [
  335. "storage.type",
  336. "text",
  337. "entity.name.function",
  338. "text",
  339. "paren.lparen"
  340. ],
  341. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  342. next: "function_arguments"
  343. }, { // match stuff like: foobar: function() { }
  344. token : [
  345. "entity.name.function",
  346. "text",
  347. "punctuation.operator",
  348. "text",
  349. "storage.type",
  350. "text",
  351. "paren.lparen"
  352. ],
  353. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  354. next: "function_arguments"
  355. }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
  356. token : [
  357. "text",
  358. "text",
  359. "storage.type",
  360. "text",
  361. "paren.lparen"
  362. ],
  363. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  364. next: "function_arguments"
  365. }, {
  366. token : "constant.language.boolean",
  367. regex : /(?:true|false)\b/
  368. }, {
  369. token : "keyword",
  370. regex : "(?:" + kwBeforeRe + ")\\b",
  371. next : "regex_allowed"
  372. }, {
  373. token : ["punctuation.operator", "support.function"],
  374. 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(?=\()/
  375. }, {
  376. token : ["punctuation.operator", "support.function.dom"],
  377. 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(?=\()/
  378. }, {
  379. token : ["punctuation.operator", "support.constant"],
  380. 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/
  381. }, {
  382. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  383. regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
  384. }, {
  385. token : function(value) {
  386. if (globals.hasOwnProperty(value))
  387. return "variable.language";
  388. else if (deprecated.hasOwnProperty(value))
  389. return "invalid.deprecated";
  390. else if (definitions.hasOwnProperty(value))
  391. return "storage.type";
  392. else if (keywords.hasOwnProperty(value))
  393. return "keyword";
  394. else if (buildinConstants.hasOwnProperty(value))
  395. return "constant.language";
  396. else if (futureReserved.hasOwnProperty(value))
  397. return "invalid.illegal";
  398. else if (value == "debugger")
  399. return "invalid.deprecated";
  400. else
  401. return "identifier";
  402. },
  403. regex : identifierRe
  404. }, {
  405. token : "keyword.operator",
  406. regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
  407. next : "regex_allowed"
  408. }, {
  409. token : "punctuation.operator",
  410. regex : /\?|\:|\,|\;|\./,
  411. next : "regex_allowed"
  412. }, {
  413. token : "paren.lparen",
  414. regex : /[\[({]/,
  415. next : "regex_allowed"
  416. }, {
  417. token : "paren.rparen",
  418. regex : /[\])}]/
  419. }, {
  420. token : "keyword.operator",
  421. regex : /\/=?/,
  422. next : "regex_allowed"
  423. }, {
  424. token: "comment",
  425. regex: /^#!.*$/
  426. }, {
  427. token : "text",
  428. regex : /\s+/
  429. }
  430. ],
  431. // regular expressions are only allowed after certain tokens. This
  432. // makes sure we don't mix up regexps with the divison operator
  433. "regex_allowed": [
  434. DocCommentHighlightRules.getStartRule("doc-start"),
  435. {
  436. token : "comment", // multi line comment
  437. merge : true,
  438. regex : "\\/\\*",
  439. next : "comment_regex_allowed"
  440. }, {
  441. token : "comment",
  442. regex : "\\/\\/.*$"
  443. }, {
  444. token: "string.regexp",
  445. regex: "\\/",
  446. next: "regex",
  447. merge: true
  448. }, {
  449. token : "text",
  450. regex : "\\s+"
  451. }, {
  452. // immediately return to the start mode without matching
  453. // anything
  454. token: "empty",
  455. regex: "",
  456. next: "start"
  457. }
  458. ],
  459. "regex": [
  460. {
  461. token: "regexp.keyword.operator",
  462. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  463. }, {
  464. // flag
  465. token: "string.regexp",
  466. regex: "/\\w*",
  467. next: "start",
  468. merge: true
  469. }, {
  470. token: "string.regexp",
  471. regex: "[^\\\\/\\[]+",
  472. merge: true
  473. }, {
  474. token: "string.regexp.charachterclass",
  475. regex: "\\[",
  476. next: "regex_character_class",
  477. merge: true
  478. }, {
  479. token: "empty",
  480. regex: "",
  481. next: "start"
  482. }
  483. ],
  484. "regex_character_class": [
  485. {
  486. token: "regexp.keyword.operator",
  487. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  488. }, {
  489. token: "string.regexp.charachterclass",
  490. regex: "]",
  491. next: "regex",
  492. merge: true
  493. }, {
  494. token: "string.regexp.charachterclass",
  495. regex: "[^\\\\\\]]+",
  496. merge: true
  497. }, {
  498. token: "empty",
  499. regex: "",
  500. next: "start"
  501. }
  502. ],
  503. "function_arguments": [
  504. {
  505. token: "variable.parameter",
  506. regex: identifierRe,
  507. }, {
  508. token: "punctuation.operator",
  509. regex: "[, ]+",
  510. merge: true
  511. }, {
  512. token: "punctuation.operator",
  513. regex: "$",
  514. merge: true
  515. }, {
  516. token: "empty",
  517. regex: "",
  518. next: "start"
  519. }
  520. ],
  521. "comment_regex_allowed" : [
  522. {
  523. token : "comment", // closing comment
  524. regex : ".*?\\*\\/",
  525. merge : true,
  526. next : "regex_allowed"
  527. }, {
  528. token : "comment", // comment spanning whole line
  529. merge : true,
  530. regex : ".+"
  531. }
  532. ],
  533. "comment" : [
  534. {
  535. token : "comment", // closing comment
  536. regex : ".*?\\*\\/",
  537. merge : true,
  538. next : "start"
  539. }, {
  540. token : "comment", // comment spanning whole line
  541. merge : true,
  542. regex : ".+"
  543. }
  544. ],
  545. "qqstring" : [
  546. {
  547. token : "constant.language.escape",
  548. regex : escapedRe
  549. }, {
  550. token : "string",
  551. regex : '[^"\\\\]+',
  552. merge : true
  553. }, {
  554. token : "string",
  555. regex : "\\\\$",
  556. next : "qqstring",
  557. merge : true
  558. }, {
  559. token : "string",
  560. regex : '"|$',
  561. next : "start",
  562. merge : true
  563. }
  564. ],
  565. "qstring" : [
  566. {
  567. token : "constant.language.escape",
  568. regex : escapedRe
  569. }, {
  570. token : "string",
  571. regex : "[^'\\\\]+",
  572. merge : true
  573. }, {
  574. token : "string",
  575. regex : "\\\\$",
  576. next : "qstring",
  577. merge : true
  578. }, {
  579. token : "string",
  580. regex : "'|$",
  581. next : "start",
  582. merge : true
  583. }
  584. ]
  585. };
  586. this.embedRules(DocCommentHighlightRules, "doc-",
  587. [ DocCommentHighlightRules.getEndRule("start") ]);
  588. };
  589. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  590. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  591. });
  592. ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  593. var oop = require("../lib/oop");
  594. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  595. var DocCommentHighlightRules = function() {
  596. this.$rules = {
  597. "start" : [ {
  598. token : "comment.doc.tag",
  599. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  600. }, {
  601. token : "comment.doc",
  602. merge : true,
  603. regex : "\\s+"
  604. }, {
  605. token : "comment.doc",
  606. merge : true,
  607. regex : "TODO"
  608. }, {
  609. token : "comment.doc",
  610. merge : true,
  611. regex : "[^@\\*]+"
  612. }, {
  613. token : "comment.doc",
  614. merge : true,
  615. regex : "."
  616. }]
  617. };
  618. };
  619. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  620. DocCommentHighlightRules.getStartRule = function(start) {
  621. return {
  622. token : "comment.doc", // doc comment
  623. merge : true,
  624. regex : "\\/\\*(?=\\*)",
  625. next : start
  626. };
  627. };
  628. DocCommentHighlightRules.getEndRule = function (start) {
  629. return {
  630. token : "comment.doc", // closing comment
  631. merge : true,
  632. regex : "\\*\\/",
  633. next : start
  634. };
  635. };
  636. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  637. });
  638. ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  639. var Range = require("../range").Range;
  640. var MatchingBraceOutdent = function() {};
  641. (function() {
  642. this.checkOutdent = function(line, input) {
  643. if (! /^\s+$/.test(line))
  644. return false;
  645. return /^\s*\}/.test(input);
  646. };
  647. this.autoOutdent = function(doc, row) {
  648. var line = doc.getLine(row);
  649. var match = line.match(/^(\s*\})/);
  650. if (!match) return 0;
  651. var column = match[1].length;
  652. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  653. if (!openBracePos || openBracePos.row == row) return 0;
  654. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  655. doc.replace(new Range(row, 0, row, column-1), indent);
  656. };
  657. this.$getIndent = function(line) {
  658. var match = line.match(/^(\s+)/);
  659. if (match) {
  660. return match[1];
  661. }
  662. return "";
  663. };
  664. }).call(MatchingBraceOutdent.prototype);
  665. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  666. });
  667. ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
  668. var oop = require("../../lib/oop");
  669. var Behaviour = require("../behaviour").Behaviour;
  670. var CstyleBehaviour = function () {
  671. this.add("braces", "insertion", function (state, action, editor, session, text) {
  672. if (text == '{') {
  673. var selection = editor.getSelectionRange();
  674. var selected = session.doc.getTextRange(selection);
  675. if (selected !== "") {
  676. return {
  677. text: '{' + selected + '}',
  678. selection: false
  679. };
  680. } else {
  681. return {
  682. text: '{}',
  683. selection: [1, 1]
  684. };
  685. }
  686. } else if (text == '}') {
  687. var cursor = editor.getCursorPosition();
  688. var line = session.doc.getLine(cursor.row);
  689. var rightChar = line.substring(cursor.column, cursor.column + 1);
  690. if (rightChar == '}') {
  691. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  692. if (matching !== null) {
  693. return {
  694. text: '',
  695. selection: [1, 1]
  696. };
  697. }
  698. }
  699. } else if (text == "\n") {
  700. var cursor = editor.getCursorPosition();
  701. var line = session.doc.getLine(cursor.row);
  702. var rightChar = line.substring(cursor.column, cursor.column + 1);
  703. if (rightChar == '}') {
  704. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
  705. if (!openBracePos)
  706. return null;
  707. var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
  708. var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
  709. return {
  710. text: '\n' + indent + '\n' + next_indent,
  711. selection: [1, indent.length, 1, indent.length]
  712. };
  713. }
  714. }
  715. });
  716. this.add("braces", "deletion", function (state, action, editor, session, range) {
  717. var selected = session.doc.getTextRange(range);
  718. if (!range.isMultiLine() && selected == '{') {
  719. var line = session.doc.getLine(range.start.row);
  720. var rightChar = line.substring(range.end.column, range.end.column + 1);
  721. if (rightChar == '}') {
  722. range.end.column++;
  723. return range;
  724. }
  725. }
  726. });
  727. this.add("parens", "insertion", function (state, action, editor, session, text) {
  728. if (text == '(') {
  729. var selection = editor.getSelectionRange();
  730. var selected = session.doc.getTextRange(selection);
  731. if (selected !== "") {
  732. return {
  733. text: '(' + selected + ')',
  734. selection: false
  735. };
  736. } else {
  737. return {
  738. text: '()',
  739. selection: [1, 1]
  740. };
  741. }
  742. } else if (text == ')') {
  743. var cursor = editor.getCursorPosition();
  744. var line = session.doc.getLine(cursor.row);
  745. var rightChar = line.substring(cursor.column, cursor.column + 1);
  746. if (rightChar == ')') {
  747. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  748. if (matching !== null) {
  749. return {
  750. text: '',
  751. selection: [1, 1]
  752. };
  753. }
  754. }
  755. }
  756. });
  757. this.add("parens", "deletion", function (state, action, editor, session, range) {
  758. var selected = session.doc.getTextRange(range);
  759. if (!range.isMultiLine() && selected == '(') {
  760. var line = session.doc.getLine(range.start.row);
  761. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  762. if (rightChar == ')') {
  763. range.end.column++;
  764. return range;
  765. }
  766. }
  767. });
  768. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  769. if (text == '"' || text == "'") {
  770. var quote = text;
  771. var selection = editor.getSelectionRange();
  772. var selected = session.doc.getTextRange(selection);
  773. if (selected !== "") {
  774. return {
  775. text: quote + selected + quote,
  776. selection: false
  777. };
  778. } else {
  779. var cursor = editor.getCursorPosition();
  780. var line = session.doc.getLine(cursor.row);
  781. var leftChar = line.substring(cursor.column-1, cursor.column);
  782. // We're escaped.
  783. if (leftChar == '\\') {
  784. return null;
  785. }
  786. // Find what token we're inside.
  787. var tokens = session.getTokens(selection.start.row);
  788. var col = 0, token;
  789. var quotepos = -1; // Track whether we're inside an open quote.
  790. for (var x = 0; x < tokens.length; x++) {
  791. token = tokens[x];
  792. if (token.type == "string") {
  793. quotepos = -1;
  794. } else if (quotepos < 0) {
  795. quotepos = token.value.indexOf(quote);
  796. }
  797. if ((token.value.length + col) > selection.start.column) {
  798. break;
  799. }
  800. col += tokens[x].value.length;
  801. }
  802. // Try and be smart about when we auto insert.
  803. 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)))) {
  804. return {
  805. text: quote + quote,
  806. selection: [1,1]
  807. };
  808. } else if (token && token.type === "string") {
  809. // Ignore input and move right one if we're typing over the closing quote.
  810. var rightChar = line.substring(cursor.column, cursor.column + 1);
  811. if (rightChar == quote) {
  812. return {
  813. text: '',
  814. selection: [1, 1]
  815. };
  816. }
  817. }
  818. }
  819. }
  820. });
  821. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  822. var selected = session.doc.getTextRange(range);
  823. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  824. var line = session.doc.getLine(range.start.row);
  825. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  826. if (rightChar == '"') {
  827. range.end.column++;
  828. return range;
  829. }
  830. }
  831. });
  832. };
  833. oop.inherits(CstyleBehaviour, Behaviour);
  834. exports.CstyleBehaviour = CstyleBehaviour;
  835. });
  836. ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
  837. var oop = require("../../lib/oop");
  838. var Range = require("../../range").Range;
  839. var BaseFoldMode = require("./fold_mode").FoldMode;
  840. var FoldMode = exports.FoldMode = function() {};
  841. oop.inherits(FoldMode, BaseFoldMode);
  842. (function() {
  843. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  844. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  845. this.getFoldWidgetRange = function(session, foldStyle, row) {
  846. var line = session.getLine(row);
  847. var match = line.match(this.foldingStartMarker);
  848. if (match) {
  849. var i = match.index;
  850. if (match[1])
  851. return this.openingBracketBlock(session, match[1], row, i);
  852. var range = session.getCommentFoldRange(row, i + match[0].length);
  853. range.end.column -= 2;
  854. return range;
  855. }
  856. if (foldStyle !== "markbeginend")
  857. return;
  858. var match = line.match(this.foldingStopMarker);
  859. if (match) {
  860. var i = match.index + match[0].length;
  861. if (match[2]) {
  862. var range = session.getCommentFoldRange(row, i);
  863. range.end.column -= 2;
  864. return range;
  865. }
  866. var end = {row: row, column: i};
  867. var start = session.$findOpeningBracket(match[1], end);
  868. if (!start)
  869. return;
  870. start.column++;
  871. end.column--;
  872. return Range.fromPoints(start, end);
  873. }
  874. };
  875. }).call(FoldMode.prototype);
  876. });
  877. ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  878. var Range = require("../../range").Range;
  879. var FoldMode = exports.FoldMode = function() {};
  880. (function() {
  881. this.foldingStartMarker = null;
  882. this.foldingStopMarker = null;
  883. // must return "" if there's no fold, to enable caching
  884. this.getFoldWidget = function(session, foldStyle, row) {
  885. var line = session.getLine(row);
  886. if (this.foldingStartMarker.test(line))
  887. return "start";
  888. if (foldStyle == "markbeginend"
  889. && this.foldingStopMarker
  890. && this.foldingStopMarker.test(line))
  891. return "end";
  892. return "";
  893. };
  894. this.getFoldWidgetRange = function(session, foldStyle, row) {
  895. return null;
  896. };
  897. this.indentationBlock = function(session, row, column) {
  898. var re = /^\s*/;
  899. var startRow = row;
  900. var endRow = row;
  901. var line = session.getLine(row);
  902. var startColumn = column || line.length;
  903. var startLevel = line.match(re)[0].length;
  904. var maxRow = session.getLength()
  905. while (++row < maxRow) {
  906. line = session.getLine(row);
  907. var level = line.match(re)[0].length;
  908. if (level == line.length)
  909. continue;
  910. if (level <= startLevel)
  911. break;
  912. endRow = row;
  913. }
  914. if (endRow > startRow) {
  915. var endColumn = session.getLine(endRow).length;
  916. return new Range(startRow, startColumn, endRow, endColumn);
  917. }
  918. };
  919. this.openingBracketBlock = function(session, bracket, row, column, typeRe, allowBlankLine) {
  920. var start = {row: row, column: column + 1};
  921. var end = session.$findClosingBracket(bracket, start, typeRe, allowBlankLine);
  922. if (!end)
  923. return;
  924. var fw = session.foldWidgets[end.row];
  925. if (fw == null)
  926. fw = this.getFoldWidget(session, end.row);
  927. if (fw == "start") {
  928. end.row --;
  929. end.column = session.getLine(end.row).length;
  930. }
  931. return Range.fromPoints(start, end);
  932. };
  933. }).call(FoldMode.prototype);
  934. });
  935. ace.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/folding/cstyle'], function(require, exports, module) {
  936. var oop = require("../lib/oop");
  937. var TextMode = require("./text").Mode;
  938. var Tokenizer = require("../tokenizer").Tokenizer;
  939. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  940. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  941. var WorkerClient = require("../worker/worker_client").WorkerClient;
  942. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  943. var Mode = function() {
  944. this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i");
  945. this.$outdent = new MatchingBraceOutdent();
  946. this.foldingRules = new CStyleFoldMode();
  947. };
  948. oop.inherits(Mode, TextMode);
  949. (function() {
  950. this.foldingRules = "cStyle";
  951. this.getNextLineIndent = function(state, line, tab) {
  952. var indent = this.$getIndent(line);
  953. // ignore braces in comments
  954. var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
  955. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  956. return indent;
  957. }
  958. var match = line.match(/^.*\{\s*$/);
  959. if (match) {
  960. indent += tab;
  961. }
  962. return indent;
  963. };
  964. this.checkOutdent = function(state, line, input) {
  965. return this.$outdent.checkOutdent(line, input);
  966. };
  967. this.autoOutdent = function(state, doc, row) {
  968. this.$outdent.autoOutdent(doc, row);
  969. };
  970. this.createWorker = function(session) {
  971. var worker = new WorkerClient(["ace"], "worker-css.js", "ace/mode/css_worker", "Worker");
  972. worker.attachToDocument(session.getDocument());
  973. worker.on("csslint", function(e) {
  974. var errors = [];
  975. e.data.forEach(function(message) {
  976. errors.push({
  977. row: message.line - 1,
  978. column: message.col - 1,
  979. text: message.message,
  980. type: message.type,
  981. lint: message
  982. });
  983. });
  984. session.setAnnotations(errors);
  985. });
  986. return worker;
  987. };
  988. }).call(Mode.prototype);
  989. exports.Mode = Mode;
  990. });
  991. ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  992. var oop = require("../lib/oop");
  993. var lang = require("../lib/lang");
  994. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  995. var CssHighlightRules = function() {
  996. var properties = lang.arrayToMap(
  997. ("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").split("|")
  998. );
  999. var functions = lang.arrayToMap(
  1000. ("rgb|rgba|url|attr|counter|counters").split("|")
  1001. );
  1002. var constants = lang.arrayToMap(
  1003. ("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|font-size|font|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|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero").split("|")
  1004. );
  1005. var colors = lang.arrayToMap(
  1006. ("aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|" +
  1007. "purple|red|silver|teal|white|yellow").split("|")
  1008. );
  1009. var fonts = lang.arrayToMap(
  1010. ("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
  1011. "symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
  1012. "serif|monospace").split("|")
  1013. );
  1014. // regexp must not have capturing parentheses. Use (?:) instead.
  1015. // regexps are ordered -> the first match is used
  1016. var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  1017. var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  1018. var 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";
  1019. var base_ruleset = [
  1020. {
  1021. token : "comment", // multi line comment
  1022. merge : true,
  1023. regex : "\\/\\*",
  1024. next : "ruleset_comment"
  1025. }, {
  1026. token : "string", // single line
  1027. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1028. }, {
  1029. token : "string", // single line
  1030. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1031. }, {
  1032. token : ["constant.numeric", "keyword"],
  1033. 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|%)"
  1034. }, {
  1035. token : ["constant.numeric"],
  1036. regex : "([0-9]+)"
  1037. }, {
  1038. token : "constant.numeric", // hex6 color
  1039. regex : "#[a-f0-9]{6}"
  1040. }, {
  1041. token : "constant.numeric", // hex3 color
  1042. regex : "#[a-f0-9]{3}"
  1043. }, {
  1044. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  1045. regex : pseudoElements
  1046. }, {
  1047. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  1048. regex : pseudoClasses
  1049. }, {
  1050. token : function(value) {
  1051. if (properties.hasOwnProperty(value.toLowerCase())) {
  1052. return "support.type";
  1053. }
  1054. else if (functions.hasOwnProperty(value.toLowerCase())) {
  1055. return "support.function";
  1056. }
  1057. else if (constants.hasOwnProperty(value.toLowerCase())) {
  1058. return "support.constant";
  1059. }
  1060. else if (colors.hasOwnProperty(value.toLowerCase())) {
  1061. return "support.constant.color";
  1062. }
  1063. else if (fonts.hasOwnProperty(value.toLowerCase())) {
  1064. return "support.constant.fonts";
  1065. }
  1066. else {
  1067. return "text";
  1068. }
  1069. },
  1070. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  1071. }
  1072. ];
  1073. var ruleset = lang.copyArray(base_ruleset);
  1074. ruleset.unshift({
  1075. token : "paren.rparen",
  1076. regex : "\\}",
  1077. next: "start"
  1078. });
  1079. var media_ruleset = lang.copyArray( base_ruleset );
  1080. media_ruleset.unshift({
  1081. token : "paren.rparen",
  1082. regex : "\\}",
  1083. next: "media"
  1084. });
  1085. var base_comment = [{
  1086. token : "comment", // comment spanning whole line
  1087. merge : true,
  1088. regex : ".+"
  1089. }];
  1090. var comment = lang.copyArray(base_comment);
  1091. comment.unshift({
  1092. token : "comment", // closing comment
  1093. regex : ".*?\\*\\/",
  1094. next : "start"
  1095. });
  1096. var media_comment = lang.copyArray(base_comment);
  1097. media_comment.unshift({
  1098. token : "comment", // closing comment
  1099. regex : ".*?\\*\\/",
  1100. next : "media"
  1101. });
  1102. var ruleset_comment = lang.copyArray(base_comment);
  1103. ruleset_comment.unshift({
  1104. token : "comment", // closing comment
  1105. regex : ".*?\\*\\/",
  1106. next : "ruleset"
  1107. });
  1108. this.$rules = {
  1109. "start" : [{
  1110. token : "comment", // multi line comment
  1111. merge : true,
  1112. regex : "\\/\\*",
  1113. next : "comment"
  1114. }, {
  1115. token: "paren.lparen",
  1116. regex: "\\{",
  1117. next: "ruleset"
  1118. }, {
  1119. token: "string",
  1120. regex: "@.*?{",
  1121. next: "media"
  1122. },{
  1123. token: "keyword",
  1124. regex: "#[a-z0-9-_]+"
  1125. },{
  1126. token: "variable",
  1127. regex: "\\.[a-z0-9-_]+"
  1128. },{
  1129. token: "string",
  1130. regex: ":[a-z0-9-_]+"
  1131. },{
  1132. token: "constant",
  1133. regex: "[a-z0-9-_]+"
  1134. }],
  1135. "media" : [ {
  1136. token : "comment", // multi line comment
  1137. merge : true,
  1138. regex : "\\/\\*",
  1139. next : "media_comment"
  1140. }, {
  1141. token: "paren.lparen",
  1142. regex: "\\{",
  1143. next: "media_ruleset"
  1144. },{
  1145. token: "string",
  1146. regex: "\\}",
  1147. next: "start"
  1148. },{
  1149. token: "keyword",
  1150. regex: "#[a-z0-9-_]+"
  1151. },{
  1152. token: "variable",
  1153. regex: "\\.[a-z0-9-_]+"
  1154. },{
  1155. token: "string",
  1156. regex: ":[a-z0-9-_]+"
  1157. },{
  1158. token: "constant",
  1159. regex: "[a-z0-9-_]+"
  1160. }],
  1161. "comment" : comment,
  1162. "ruleset" : ruleset,
  1163. "ruleset_comment" : ruleset_comment,
  1164. "media_ruleset" : media_ruleset,
  1165. "media_comment" : media_comment
  1166. };
  1167. };
  1168. oop.inherits(CssHighlightRules, TextHighlightRules);
  1169. exports.CssHighlightRules = CssHighlightRules;
  1170. });
  1171. ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  1172. var oop = require("../lib/oop");
  1173. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1174. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1175. var xmlUtil = require("./xml_util");
  1176. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1177. var HtmlHighlightRules = function() {
  1178. // regexp must not have capturing parentheses
  1179. // regexps are ordered -> the first match is used
  1180. this.$rules = {
  1181. start : [{
  1182. token : "text",
  1183. merge : true,
  1184. regex : "<\\!\\[CDATA\\[",
  1185. next : "cdata"
  1186. }, {
  1187. token : "xml_pe",
  1188. regex : "<\\?.*?\\?>"
  1189. }, {
  1190. token : "comment",
  1191. merge : true,
  1192. regex : "<\\!--",
  1193. next : "comment"
  1194. }, {
  1195. token : "xml_pe",
  1196. regex : "<\\!.*?>"
  1197. }, {
  1198. token : "meta.tag",
  1199. regex : "<(?=\s*script\\b)",
  1200. next : "script"
  1201. }, {
  1202. token : "meta.tag",
  1203. regex : "<(?=\s*style\\b)",
  1204. next : "style"
  1205. }, {
  1206. token : "meta.tag", // opening tag
  1207. regex : "<\\/?",
  1208. next : "tag"
  1209. }, {
  1210. token : "text",
  1211. regex : "\\s+"
  1212. }, {
  1213. token : "constant.character.entity",
  1214. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1215. }, {
  1216. token : "text",
  1217. regex : "[^<]+"
  1218. } ],
  1219. cdata : [ {
  1220. token : "text",
  1221. regex : "\\]\\]>",
  1222. next : "start"
  1223. }, {
  1224. token : "text",
  1225. merge : true,
  1226. regex : "\\s+"
  1227. }, {
  1228. token : "text",
  1229. merge : true,
  1230. regex : ".+"
  1231. } ],
  1232. comment : [ {
  1233. token : "comment",
  1234. regex : ".*?-->",
  1235. next : "start"
  1236. }, {
  1237. token : "comment",
  1238. merge : true,
  1239. regex : ".+"
  1240. } ]
  1241. };
  1242. xmlUtil.tag(this.$rules, "tag", "start");
  1243. xmlUtil.tag(this.$rules, "style", "css-start");
  1244. xmlUtil.tag(this.$rules, "script", "js-start");
  1245. this.embedRules(JavaScriptHighlightRules, "js-", [{
  1246. token: "comment",
  1247. regex: "\\/\\/.*(?=<\\/script>)",
  1248. next: "tag"
  1249. }, {
  1250. token: "meta.tag",
  1251. regex: "<\\/(?=script)",
  1252. next: "tag"
  1253. }]);
  1254. this.embedRules(CssHighlightRules, "css-", [{
  1255. token: "meta.tag",
  1256. regex: "<\\/(?=style)",
  1257. next: "tag"
  1258. }]);
  1259. };
  1260. oop.inherits(HtmlHighlightRules, TextHighlightRules);
  1261. exports.HtmlHighlightRules = HtmlHighlightRules;
  1262. });
  1263. ace.define('ace/mode/xml_util', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
  1264. var lang = require("../lib/lang");
  1265. var formTags = lang.arrayToMap(
  1266. ("button|form|input|label|select|textarea").split("|")
  1267. );
  1268. var tableTags = lang.arrayToMap(
  1269. ("table|tbody|td|tfoot|th|tr").split("|")
  1270. );
  1271. function string(state) {
  1272. return [{
  1273. token : "string",
  1274. regex : '".*?"'
  1275. }, {
  1276. token : "string", // multi line string start
  1277. merge : true,
  1278. regex : '["].*',
  1279. next : state + "_qqstring"
  1280. }, {
  1281. token : "string",
  1282. regex : "'.*?'"
  1283. }, {
  1284. token : "string", // multi line string start
  1285. merge : true,
  1286. regex : "['].*",
  1287. next : state + "_qstring"
  1288. }];
  1289. }
  1290. function multiLineString(quote, state) {
  1291. return [{
  1292. token : "string",
  1293. merge : true,
  1294. regex : ".*?" + quote,
  1295. next : state
  1296. }, {
  1297. token : "string",
  1298. merge : true,
  1299. regex : '.+'
  1300. }];
  1301. }
  1302. exports.tag = function(states, name, nextState) {
  1303. states[name] = [{
  1304. token : "text",
  1305. regex : "\\s+"
  1306. }, {
  1307. //token : "meta.tag",
  1308. token : function(value) {
  1309. if ( value==='a' ) {
  1310. return "meta.tag.anchor";
  1311. }
  1312. else if ( value==='img' ) {
  1313. return "meta.tag.image";
  1314. }
  1315. else if ( value==='script' ) {
  1316. return "meta.tag.script";
  1317. }
  1318. else if ( value==='style' ) {
  1319. return "meta.tag.style";
  1320. }
  1321. else if (formTags.hasOwnProperty(value.toLowerCase())) {
  1322. return "meta.tag.form";
  1323. }
  1324. else if (tableTags.hasOwnProperty(value.toLowerCase())) {
  1325. return "meta.tag.table";
  1326. }
  1327. else {
  1328. return "meta.tag";
  1329. }
  1330. },
  1331. merge : true,
  1332. regex : "[-_a-zA-Z0-9:]+",
  1333. next : name + "_embed_attribute_list"
  1334. }, {
  1335. token: "empty",
  1336. regex: "",
  1337. next : name + "_embed_attribute_list"
  1338. }];
  1339. states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
  1340. states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
  1341. states[name + "_embed_attribute_list"] = [{
  1342. token : "meta.tag",
  1343. merge : true,
  1344. regex : "\/?>",
  1345. next : nextState
  1346. }, {
  1347. token : "keyword.operator",
  1348. regex : "="
  1349. }, {
  1350. token : "entity.other.attribute-name",
  1351. regex : "[-_a-zA-Z0-9:]+"
  1352. }, {
  1353. token : "constant.numeric", // float
  1354. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  1355. }, {
  1356. token : "text",
  1357. regex : "\\s+"
  1358. }].concat(string(name));
  1359. };
  1360. });
  1361. ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle'], function(require, exports, module) {
  1362. var oop = require("../../lib/oop");
  1363. var Behaviour = require("../behaviour").Behaviour;
  1364. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1365. var XmlBehaviour = function () {
  1366. this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
  1367. this.add("brackets", "insertion", function (state, action, editor, session, text) {
  1368. if (text == '<') {
  1369. var selection = editor.getSelectionRange();
  1370. var selected = session.doc.getTextRange(selection);
  1371. if (selected !== "") {
  1372. return false;
  1373. } else {
  1374. return {
  1375. text: '<>',
  1376. selection: [1, 1]
  1377. }
  1378. }
  1379. } else if (text == '>') {
  1380. var cursor = editor.getCursorPosition();
  1381. var line = session.doc.getLine(cursor.row);
  1382. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1383. if (rightChar == '>') { // need some kind of matching check here
  1384. return {
  1385. text: '',
  1386. selection: [1, 1]
  1387. }
  1388. }
  1389. } else if (text == "\n") {
  1390. var cursor = editor.getCursorPosition();
  1391. var line = session.doc.getLine(cursor.row);
  1392. var rightChars = line.substring(cursor.column, cursor.column + 2);
  1393. if (rightChars == '</') {
  1394. var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
  1395. var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
  1396. return {
  1397. text: '\n' + indent + '\n' + next_indent,
  1398. selection: [1, indent.length, 1, indent.length]
  1399. }
  1400. }
  1401. }
  1402. });
  1403. }
  1404. oop.inherits(XmlBehaviour, Behaviour);
  1405. exports.XmlBehaviour = XmlBehaviour;
  1406. });
  1407. ace.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) {
  1408. var oop = require("../../lib/oop");
  1409. var MixedFoldMode = require("./mixed").FoldMode;
  1410. var XmlFoldMode = require("./xml").FoldMode;
  1411. var CStyleFoldMode = require("./cstyle").FoldMode;
  1412. var FoldMode = exports.FoldMode = function() {
  1413. MixedFoldMode.call(this, new XmlFoldMode({
  1414. // void elements
  1415. "area": 1,
  1416. "base": 1,
  1417. "br": 1,
  1418. "col": 1,
  1419. "command": 1,
  1420. "embed": 1,
  1421. "hr": 1,
  1422. "img": 1,
  1423. "input": 1,
  1424. "keygen": 1,
  1425. "link": 1,
  1426. "meta": 1,
  1427. "param": 1,
  1428. "source": 1,
  1429. "track": 1,
  1430. "wbr": 1,
  1431. // optional tags
  1432. "li": 1,
  1433. "dt": 1,
  1434. "dd": 1,
  1435. "p": 1,
  1436. "rt": 1,
  1437. "rp": 1,
  1438. "optgroup": 1,
  1439. "option": 1,
  1440. "colgroup": 1,
  1441. "td": 1,
  1442. "th": 1
  1443. }), {
  1444. "js-": new CStyleFoldMode(),
  1445. "css-": new CStyleFoldMode()
  1446. });
  1447. };
  1448. oop.inherits(FoldMode, MixedFoldMode);
  1449. });
  1450. ace.define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
  1451. var oop = require("../../lib/oop");
  1452. var BaseFoldMode = require("./fold_mode").FoldMode;
  1453. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1454. this.defaultMode = defaultMode;
  1455. this.subModes = subModes;
  1456. };
  1457. oop.inherits(FoldMode, BaseFoldMode);
  1458. (function() {
  1459. this.$getMode = function(state) {
  1460. for (var key in this.subModes) {
  1461. if (state.indexOf(key) === 0)
  1462. return this.subModes[key];
  1463. }
  1464. return null;
  1465. };
  1466. this.$tryMode = function(state, session, foldStyle, row) {
  1467. var mode = this.$getMode(state);
  1468. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1469. };
  1470. this.getFoldWidget = function(session, foldStyle, row) {
  1471. return (
  1472. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1473. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1474. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1475. );
  1476. };
  1477. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1478. var mode = this.$getMode(session.getState(row-1));
  1479. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1480. mode = this.$getMode(session.getState(row));
  1481. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1482. mode = this.defaultMode;
  1483. return mode.getFoldWidgetRange(session, foldStyle, row);
  1484. };
  1485. }).call(FoldMode.prototype);
  1486. });
  1487. ace.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) {
  1488. var oop = require("../../lib/oop");
  1489. var lang = require("../../lib/lang");
  1490. var Range = require("../../range").Range;
  1491. var BaseFoldMode = require("./fold_mode").FoldMode;
  1492. var TokenIterator = require("../../token_iterator").TokenIterator;
  1493. var FoldMode = exports.FoldMode = function(voidElements) {
  1494. BaseFoldMode.call(this);
  1495. this.voidElements = voidElements || {};
  1496. };
  1497. oop.inherits(FoldMode, BaseFoldMode);
  1498. (function() {
  1499. this.getFoldWidget = function(session, foldStyle, row) {
  1500. var tag = this._getFirstTagInLine(session, row);
  1501. if (tag.closing)
  1502. return foldStyle == "markbeginend" ? "end" : "";
  1503. if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
  1504. return "";
  1505. if (tag.selfClosing)
  1506. return "";
  1507. if (tag.value.indexOf("/" + tag.tagName) !== -1)
  1508. return "";
  1509. return "start";
  1510. };
  1511. this._getFirstTagInLine = function(session, row) {
  1512. var tokens = session.getTokens(row);
  1513. var value = "";
  1514. for (var i = 0; i < tokens.length; i++) {
  1515. var token = tokens[i];
  1516. if (token.type.indexOf("meta.tag") === 0)
  1517. value += token.value;
  1518. else
  1519. value += lang.stringRepeat(" ", token.value.length);
  1520. }
  1521. return this._parseTag(value);
  1522. };
  1523. this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
  1524. this._parseTag = function(tag) {
  1525. var match = this.tagRe.exec(tag);
  1526. var column = this.tagRe.lastIndex || 0;
  1527. this.tagRe.lastIndex = 0;
  1528. return {
  1529. value: tag,
  1530. match: match ? match[2] : "",
  1531. closing: match ? !!match[3] : false,
  1532. selfClosing: match ? !!match[5] || match[2] == "/>" : false,
  1533. tagName: match ? match[4] : "",
  1534. column: match[1] ? column + match[1].length : column
  1535. };
  1536. };
  1537. this._readTagForward = function(iterator) {
  1538. var token = iterator.getCurrentToken();
  1539. if (!token)
  1540. return null;
  1541. var value = "";
  1542. var start;
  1543. do {
  1544. if (token.type.indexOf("meta.tag") === 0) {
  1545. if (!start) {
  1546. var start = {
  1547. row: iterator.getCurrentTokenRow(),
  1548. column: iterator.getCurrentTokenColumn()
  1549. };
  1550. }
  1551. value += token.value;
  1552. if (value.indexOf(">") !== -1) {
  1553. var tag = this._parseTag(value);
  1554. tag.start = start;
  1555. tag.end = {
  1556. row: iterator.getCurrentTokenRow(),
  1557. column: iterator.getCurrentTokenColumn() + token.value.length
  1558. };
  1559. iterator.stepForward();
  1560. return tag;
  1561. }
  1562. }
  1563. } while(token = iterator.stepForward());
  1564. return null;
  1565. };
  1566. this._readTagBackward = function(iterator) {
  1567. var token = iterator.getCurrentToken();
  1568. if (!token)
  1569. return null;
  1570. var value = "";
  1571. var end;
  1572. do {
  1573. if (token.type.indexOf("meta.tag") === 0) {
  1574. if (!end) {
  1575. end = {
  1576. row: iterator.getCurrentTokenRow(),
  1577. column: iterator.getCurrentTokenColumn() + token.value.length
  1578. };
  1579. }
  1580. value = token.value + value;
  1581. if (value.indexOf("<") !== -1) {
  1582. var tag = this._parseTag(value);
  1583. tag.end = end;
  1584. tag.start = {
  1585. row: iterator.getCurrentTokenRow(),
  1586. column: iterator.getCurrentTokenColumn()
  1587. };
  1588. iterator.stepBackward();
  1589. return tag;
  1590. }
  1591. }
  1592. } while(token = iterator.stepBackward());
  1593. return null;
  1594. };
  1595. this._pop = function(stack, tag) {
  1596. while (stack.length) {
  1597. var top = stack[stack.length-1];
  1598. if (!tag || top.tagName == tag.tagName) {
  1599. return stack.pop();
  1600. }
  1601. else if (this.voidElements[tag.tagName]) {
  1602. return;
  1603. }
  1604. else if (this.voidElements[top.tagName]) {
  1605. stack.pop();
  1606. continue;
  1607. } else {
  1608. return null;
  1609. }
  1610. }
  1611. };
  1612. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1613. var firstTag = this._getFirstTagInLine(session, row);
  1614. if (!firstTag.match)
  1615. return null;
  1616. var isBackward = firstTag.closing || firstTag.selfClosing;
  1617. var stack = [];
  1618. var tag;
  1619. if (!isBackward) {
  1620. var iterator = new TokenIterator(session, row, firstTag.column);
  1621. var start = {
  1622. row: row,
  1623. column: firstTag.column + firstTag.tagName.length + 2
  1624. };
  1625. while (tag = this._readTagForward(iterator)) {
  1626. if (tag.selfClosing) {
  1627. if (!stack.length) {
  1628. tag.start.column += tag.tagName.length + 2;
  1629. tag.end.column -= 2;
  1630. return Range.fromPoints(tag.start, tag.end);
  1631. } else
  1632. continue;
  1633. }
  1634. if (tag.closing) {
  1635. this._pop(stack, tag);
  1636. if (stack.length == 0)
  1637. return Range.fromPoints(start, tag.start);
  1638. }
  1639. else {
  1640. stack.push(tag)
  1641. }
  1642. }
  1643. }
  1644. else {
  1645. var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
  1646. var end = {
  1647. row: row,
  1648. column: firstTag.column
  1649. };
  1650. while (tag = this._readTagBackward(iterator)) {
  1651. if (tag.selfClosing) {
  1652. if (!stack.length) {
  1653. tag.start.column += tag.tagName.length + 2;
  1654. tag.end.column -= 2;
  1655. return Range.fromPoints(tag.start, tag.end);
  1656. } else
  1657. continue;
  1658. }
  1659. if (!tag.closing) {
  1660. this._pop(stack, tag);
  1661. if (stack.length == 0) {
  1662. tag.start.column += tag.tagName.length + 2;
  1663. return Range.fromPoints(tag.start, end);
  1664. }
  1665. }
  1666. else {
  1667. stack.push(tag)
  1668. }
  1669. }
  1670. }
  1671. };
  1672. }).call(FoldMode.prototype);
  1673. });