mode-mask.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742
  1. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. }
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. ace.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) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
  47. var JavaScriptHighlightRules = function(options) {
  48. var keywordMapper = this.createKeywordMapper({
  49. "variable.language":
  50. "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  51. "Namespace|QName|XML|XMLList|" + // E4X
  52. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  53. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  54. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  55. "SyntaxError|TypeError|URIError|" +
  56. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  57. "isNaN|parseFloat|parseInt|" +
  58. "JSON|Math|" + // Other
  59. "this|arguments|prototype|window|document" , // Pseudo
  60. "keyword":
  61. "const|yield|import|get|set|async|await|" +
  62. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  63. "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  64. "__parent__|__count__|escape|unescape|with|__proto__|" +
  65. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  66. "storage.type":
  67. "const|let|var|function",
  68. "constant.language":
  69. "null|Infinity|NaN|undefined",
  70. "support.function":
  71. "alert",
  72. "constant.language.boolean": "true|false"
  73. }, "identifier");
  74. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  75. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  76. "u[0-9a-fA-F]{4}|" + // unicode
  77. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  78. "[0-2][0-7]{0,2}|" + // oct
  79. "3[0-7][0-7]?|" + // oct
  80. "[4-7][0-7]?|" + //oct
  81. ".)";
  82. this.$rules = {
  83. "no_regex" : [
  84. DocCommentHighlightRules.getStartRule("doc-start"),
  85. comments("no_regex"),
  86. {
  87. token : "string",
  88. regex : "'(?=.)",
  89. next : "qstring"
  90. }, {
  91. token : "string",
  92. regex : '"(?=.)',
  93. next : "qqstring"
  94. }, {
  95. token : "constant.numeric", // hex
  96. regex : /0(?:[xX][0-9a-fA-F]+|[bB][01]+)\b/
  97. }, {
  98. token : "constant.numeric", // float
  99. regex : /[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  100. }, {
  101. token : [
  102. "storage.type", "punctuation.operator", "support.function",
  103. "punctuation.operator", "entity.name.function", "text","keyword.operator"
  104. ],
  105. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  106. next: "function_arguments"
  107. }, {
  108. token : [
  109. "storage.type", "punctuation.operator", "entity.name.function", "text",
  110. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  111. ],
  112. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  113. next: "function_arguments"
  114. }, {
  115. token : [
  116. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  117. "text", "paren.lparen"
  118. ],
  119. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  120. next: "function_arguments"
  121. }, {
  122. token : [
  123. "storage.type", "punctuation.operator", "entity.name.function", "text",
  124. "keyword.operator", "text",
  125. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  126. ],
  127. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  128. next: "function_arguments"
  129. }, {
  130. token : [
  131. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  132. ],
  133. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  134. next: "function_arguments"
  135. }, {
  136. token : [
  137. "entity.name.function", "text", "punctuation.operator",
  138. "text", "storage.type", "text", "paren.lparen"
  139. ],
  140. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  141. next: "function_arguments"
  142. }, {
  143. token : [
  144. "text", "text", "storage.type", "text", "paren.lparen"
  145. ],
  146. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  147. next: "function_arguments"
  148. }, {
  149. token : "keyword",
  150. regex : "(?:" + kwBeforeRe + ")\\b",
  151. next : "start"
  152. }, {
  153. token : ["support.constant"],
  154. regex : /that\b/
  155. }, {
  156. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  157. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  158. }, {
  159. token : keywordMapper,
  160. regex : identifierRe
  161. }, {
  162. token : "punctuation.operator",
  163. regex : /[.](?![.])/,
  164. next : "property"
  165. }, {
  166. token : "keyword.operator",
  167. regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  168. next : "start"
  169. }, {
  170. token : "punctuation.operator",
  171. regex : /[?:,;.]/,
  172. next : "start"
  173. }, {
  174. token : "paren.lparen",
  175. regex : /[\[({]/,
  176. next : "start"
  177. }, {
  178. token : "paren.rparen",
  179. regex : /[\])}]/
  180. }, {
  181. token: "comment",
  182. regex: /^#!.*$/
  183. }
  184. ],
  185. property: [{
  186. token : "text",
  187. regex : "\\s+"
  188. }, {
  189. token : [
  190. "storage.type", "punctuation.operator", "entity.name.function", "text",
  191. "keyword.operator", "text",
  192. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  193. ],
  194. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  195. next: "function_arguments"
  196. }, {
  197. token : "punctuation.operator",
  198. regex : /[.](?![.])/
  199. }, {
  200. token : "support.function",
  201. regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|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(?=\()/
  202. }, {
  203. token : "support.function.dom",
  204. 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|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  205. }, {
  206. token : "support.constant",
  207. 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/
  208. }, {
  209. token : "identifier",
  210. regex : identifierRe
  211. }, {
  212. regex: "",
  213. token: "empty",
  214. next: "no_regex"
  215. }
  216. ],
  217. "start": [
  218. DocCommentHighlightRules.getStartRule("doc-start"),
  219. comments("start"),
  220. {
  221. token: "string.regexp",
  222. regex: "\\/",
  223. next: "regex"
  224. }, {
  225. token : "text",
  226. regex : "\\s+|^$",
  227. next : "start"
  228. }, {
  229. token: "empty",
  230. regex: "",
  231. next: "no_regex"
  232. }
  233. ],
  234. "regex": [
  235. {
  236. token: "regexp.keyword.operator",
  237. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  238. }, {
  239. token: "string.regexp",
  240. regex: "/[sxngimy]*",
  241. next: "no_regex"
  242. }, {
  243. token : "invalid",
  244. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  245. }, {
  246. token : "constant.language.escape",
  247. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  248. }, {
  249. token : "constant.language.delimiter",
  250. regex: /\|/
  251. }, {
  252. token: "constant.language.escape",
  253. regex: /\[\^?/,
  254. next: "regex_character_class"
  255. }, {
  256. token: "empty",
  257. regex: "$",
  258. next: "no_regex"
  259. }, {
  260. defaultToken: "string.regexp"
  261. }
  262. ],
  263. "regex_character_class": [
  264. {
  265. token: "regexp.charclass.keyword.operator",
  266. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  267. }, {
  268. token: "constant.language.escape",
  269. regex: "]",
  270. next: "regex"
  271. }, {
  272. token: "constant.language.escape",
  273. regex: "-"
  274. }, {
  275. token: "empty",
  276. regex: "$",
  277. next: "no_regex"
  278. }, {
  279. defaultToken: "string.regexp.charachterclass"
  280. }
  281. ],
  282. "function_arguments": [
  283. {
  284. token: "variable.parameter",
  285. regex: identifierRe
  286. }, {
  287. token: "punctuation.operator",
  288. regex: "[, ]+"
  289. }, {
  290. token: "punctuation.operator",
  291. regex: "$"
  292. }, {
  293. token: "empty",
  294. regex: "",
  295. next: "no_regex"
  296. }
  297. ],
  298. "qqstring" : [
  299. {
  300. token : "constant.language.escape",
  301. regex : escapedRe
  302. }, {
  303. token : "string",
  304. regex : "\\\\$",
  305. next : "qqstring"
  306. }, {
  307. token : "string",
  308. regex : '"|$',
  309. next : "no_regex"
  310. }, {
  311. defaultToken: "string"
  312. }
  313. ],
  314. "qstring" : [
  315. {
  316. token : "constant.language.escape",
  317. regex : escapedRe
  318. }, {
  319. token : "string",
  320. regex : "\\\\$",
  321. next : "qstring"
  322. }, {
  323. token : "string",
  324. regex : "'|$",
  325. next : "no_regex"
  326. }, {
  327. defaultToken: "string"
  328. }
  329. ]
  330. };
  331. if (!options || !options.noES6) {
  332. this.$rules.no_regex.unshift({
  333. regex: "[{}]", onMatch: function(val, state, stack) {
  334. this.next = val == "{" ? this.nextState : "";
  335. if (val == "{" && stack.length) {
  336. stack.unshift("start", state);
  337. }
  338. else if (val == "}" && stack.length) {
  339. stack.shift();
  340. this.next = stack.shift();
  341. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  342. return "paren.quasi.end";
  343. }
  344. return val == "{" ? "paren.lparen" : "paren.rparen";
  345. },
  346. nextState: "start"
  347. }, {
  348. token : "string.quasi.start",
  349. regex : /`/,
  350. push : [{
  351. token : "constant.language.escape",
  352. regex : escapedRe
  353. }, {
  354. token : "paren.quasi.start",
  355. regex : /\${/,
  356. push : "start"
  357. }, {
  358. token : "string.quasi.end",
  359. regex : /`/,
  360. next : "pop"
  361. }, {
  362. defaultToken: "string.quasi"
  363. }]
  364. });
  365. if (!options || options.jsx != false)
  366. JSX.call(this);
  367. }
  368. this.embedRules(DocCommentHighlightRules, "doc-",
  369. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  370. this.normalizeRules();
  371. };
  372. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  373. function JSX() {
  374. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  375. var jsxTag = {
  376. onMatch : function(val, state, stack) {
  377. var offset = val.charAt(1) == "/" ? 2 : 1;
  378. if (offset == 1) {
  379. if (state != this.nextState)
  380. stack.unshift(this.next, this.nextState, 0);
  381. else
  382. stack.unshift(this.next);
  383. stack[2]++;
  384. } else if (offset == 2) {
  385. if (state == this.nextState) {
  386. stack[1]--;
  387. if (!stack[1] || stack[1] < 0) {
  388. stack.shift();
  389. stack.shift();
  390. }
  391. }
  392. }
  393. return [{
  394. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  395. value: val.slice(0, offset)
  396. }, {
  397. type: "meta.tag.tag-name.xml",
  398. value: val.substr(offset)
  399. }];
  400. },
  401. regex : "</?" + tagRegex + "",
  402. next: "jsxAttributes",
  403. nextState: "jsx"
  404. };
  405. this.$rules.start.unshift(jsxTag);
  406. var jsxJsRule = {
  407. regex: "{",
  408. token: "paren.quasi.start",
  409. push: "start"
  410. };
  411. this.$rules.jsx = [
  412. jsxJsRule,
  413. jsxTag,
  414. {include : "reference"},
  415. {defaultToken: "string"}
  416. ];
  417. this.$rules.jsxAttributes = [{
  418. token : "meta.tag.punctuation.tag-close.xml",
  419. regex : "/?>",
  420. onMatch : function(value, currentState, stack) {
  421. if (currentState == stack[0])
  422. stack.shift();
  423. if (value.length == 2) {
  424. if (stack[0] == this.nextState)
  425. stack[1]--;
  426. if (!stack[1] || stack[1] < 0) {
  427. stack.splice(0, 2);
  428. }
  429. }
  430. this.next = stack[0] || "start";
  431. return [{type: this.token, value: value}];
  432. },
  433. nextState: "jsx"
  434. },
  435. jsxJsRule,
  436. comments("jsxAttributes"),
  437. {
  438. token : "entity.other.attribute-name.xml",
  439. regex : tagRegex
  440. }, {
  441. token : "keyword.operator.attribute-equals.xml",
  442. regex : "="
  443. }, {
  444. token : "text.tag-whitespace.xml",
  445. regex : "\\s+"
  446. }, {
  447. token : "string.attribute-value.xml",
  448. regex : "'",
  449. stateName : "jsx_attr_q",
  450. push : [
  451. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  452. {include : "reference"},
  453. {defaultToken : "string.attribute-value.xml"}
  454. ]
  455. }, {
  456. token : "string.attribute-value.xml",
  457. regex : '"',
  458. stateName : "jsx_attr_qq",
  459. push : [
  460. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  461. {include : "reference"},
  462. {defaultToken : "string.attribute-value.xml"}
  463. ]
  464. },
  465. jsxTag
  466. ];
  467. this.$rules.reference = [{
  468. token : "constant.language.escape.reference.xml",
  469. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  470. }];
  471. }
  472. function comments(next) {
  473. return [
  474. {
  475. token : "comment", // multi line comment
  476. regex : /\/\*/,
  477. next: [
  478. DocCommentHighlightRules.getTagRule(),
  479. {token : "comment", regex : "\\*\\/", next : next || "pop"},
  480. {defaultToken : "comment", caseInsensitive: true}
  481. ]
  482. }, {
  483. token : "comment",
  484. regex : "\\/\\/",
  485. next: [
  486. DocCommentHighlightRules.getTagRule(),
  487. {token : "comment", regex : "$|^", next : next || "pop"},
  488. {defaultToken : "comment", caseInsensitive: true}
  489. ]
  490. }
  491. ];
  492. }
  493. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  494. });
  495. 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) {
  496. "use strict";
  497. var oop = require("../lib/oop");
  498. var lang = require("../lib/lang");
  499. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  500. var supportType = exports.supportType = "align-content|align-items|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|border|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|bottom|box-shadow|box-sizing|caption-side|clear|clip|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|cursor|direction|display|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|font|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|hanging-punctuation|height|justify-content|left|letter-spacing|line-height|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|max-height|max-width|min-height|min-width|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|order|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page-break-after|page-break-before|page-break-inside|perspective|perspective-origin|position|quotes|resize|right|tab-size|table-layout|text-align|text-align-last|text-decoration|text-decoration-color|text-decoration-line|text-decoration-style|text-indent|text-justify|text-overflow|text-shadow|text-transform|top|transform|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index";
  501. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  502. 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";
  503. var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
  504. var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
  505. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  506. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  507. 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";
  508. var CssHighlightRules = function() {
  509. var keywordMapper = this.createKeywordMapper({
  510. "support.function": supportFunction,
  511. "support.constant": supportConstant,
  512. "support.type": supportType,
  513. "support.constant.color": supportConstantColor,
  514. "support.constant.fonts": supportConstantFonts
  515. }, "text", true);
  516. this.$rules = {
  517. "start" : [{
  518. token : "comment", // multi line comment
  519. regex : "\\/\\*",
  520. push : "comment"
  521. }, {
  522. token: "paren.lparen",
  523. regex: "\\{",
  524. push: "ruleset"
  525. }, {
  526. token: "string",
  527. regex: "@.*?{",
  528. push: "media"
  529. }, {
  530. token: "keyword",
  531. regex: "#[a-z0-9-_]+"
  532. }, {
  533. token: "variable",
  534. regex: "\\.[a-z0-9-_]+"
  535. }, {
  536. token: "string",
  537. regex: ":[a-z0-9-_]+"
  538. }, {
  539. token: "constant",
  540. regex: "[a-z0-9-_]+"
  541. }, {
  542. caseInsensitive: true
  543. }],
  544. "media" : [{
  545. token : "comment", // multi line comment
  546. regex : "\\/\\*",
  547. push : "comment"
  548. }, {
  549. token: "paren.lparen",
  550. regex: "\\{",
  551. push: "ruleset"
  552. }, {
  553. token: "string",
  554. regex: "\\}",
  555. next: "pop"
  556. }, {
  557. token: "keyword",
  558. regex: "#[a-z0-9-_]+"
  559. }, {
  560. token: "variable",
  561. regex: "\\.[a-z0-9-_]+"
  562. }, {
  563. token: "string",
  564. regex: ":[a-z0-9-_]+"
  565. }, {
  566. token: "constant",
  567. regex: "[a-z0-9-_]+"
  568. }, {
  569. caseInsensitive: true
  570. }],
  571. "comment" : [{
  572. token : "comment",
  573. regex : "\\*\\/",
  574. next : "pop"
  575. }, {
  576. defaultToken : "comment"
  577. }],
  578. "ruleset" : [
  579. {
  580. token : "paren.rparen",
  581. regex : "\\}",
  582. next: "pop"
  583. }, {
  584. token : "comment", // multi line comment
  585. regex : "\\/\\*",
  586. push : "comment"
  587. }, {
  588. token : "string", // single line
  589. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  590. }, {
  591. token : "string", // single line
  592. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  593. }, {
  594. token : ["constant.numeric", "keyword"],
  595. 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|%)"
  596. }, {
  597. token : "constant.numeric",
  598. regex : numRe
  599. }, {
  600. token : "constant.numeric", // hex6 color
  601. regex : "#[a-f0-9]{6}"
  602. }, {
  603. token : "constant.numeric", // hex3 color
  604. regex : "#[a-f0-9]{3}"
  605. }, {
  606. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  607. regex : pseudoElements
  608. }, {
  609. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  610. regex : pseudoClasses
  611. }, {
  612. token : ["support.function", "string", "support.function"],
  613. regex : "(url\\()(.*)(\\))"
  614. }, {
  615. token : keywordMapper,
  616. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  617. }, {
  618. caseInsensitive: true
  619. }]
  620. };
  621. this.normalizeRules();
  622. };
  623. oop.inherits(CssHighlightRules, TextHighlightRules);
  624. exports.CssHighlightRules = CssHighlightRules;
  625. });
  626. ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  627. "use strict";
  628. var oop = require("../lib/oop");
  629. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  630. var XmlHighlightRules = function(normalize) {
  631. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  632. this.$rules = {
  633. start : [
  634. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  635. {
  636. token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
  637. regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
  638. },
  639. {
  640. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  641. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction"
  642. },
  643. {token : "comment.xml", regex : "<\\!--", next : "comment"},
  644. {
  645. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  646. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  647. },
  648. {include : "tag"},
  649. {token : "text.end-tag-open.xml", regex: "</"},
  650. {token : "text.tag-open.xml", regex: "<"},
  651. {include : "reference"},
  652. {defaultToken : "text.xml"}
  653. ],
  654. xml_decl : [{
  655. token : "entity.other.attribute-name.decl-attribute-name.xml",
  656. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  657. }, {
  658. token : "keyword.operator.decl-attribute-equals.xml",
  659. regex : "="
  660. }, {
  661. include: "whitespace"
  662. }, {
  663. include: "string"
  664. }, {
  665. token : "punctuation.xml-decl.xml",
  666. regex : "\\?>",
  667. next : "start"
  668. }],
  669. processing_instruction : [
  670. {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
  671. {defaultToken : "instruction.xml"}
  672. ],
  673. doctype : [
  674. {include : "whitespace"},
  675. {include : "string"},
  676. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  677. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  678. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  679. ],
  680. int_subset : [{
  681. token : "text.xml",
  682. regex : "\\s+"
  683. }, {
  684. token: "punctuation.int-subset.xml",
  685. regex: "]",
  686. next: "pop"
  687. }, {
  688. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  689. regex : "(<\\!)(" + tagRegex + ")",
  690. push : [{
  691. token : "text",
  692. regex : "\\s+"
  693. },
  694. {
  695. token : "punctuation.markup-decl.xml",
  696. regex : ">",
  697. next : "pop"
  698. },
  699. {include : "string"}]
  700. }],
  701. cdata : [
  702. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  703. {token : "text.xml", regex : "\\s+"},
  704. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  705. ],
  706. comment : [
  707. {token : "comment.xml", regex : "-->", next : "start"},
  708. {defaultToken : "comment.xml"}
  709. ],
  710. reference : [{
  711. token : "constant.language.escape.reference.xml",
  712. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  713. }],
  714. attr_reference : [{
  715. token : "constant.language.escape.reference.attribute-value.xml",
  716. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  717. }],
  718. tag : [{
  719. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  720. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  721. next: [
  722. {include : "attributes"},
  723. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  724. ]
  725. }],
  726. tag_whitespace : [
  727. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  728. ],
  729. whitespace : [
  730. {token : "text.whitespace.xml", regex : "\\s+"}
  731. ],
  732. string: [{
  733. token : "string.xml",
  734. regex : "'",
  735. push : [
  736. {token : "string.xml", regex: "'", next: "pop"},
  737. {defaultToken : "string.xml"}
  738. ]
  739. }, {
  740. token : "string.xml",
  741. regex : '"',
  742. push : [
  743. {token : "string.xml", regex: '"', next: "pop"},
  744. {defaultToken : "string.xml"}
  745. ]
  746. }],
  747. attributes: [{
  748. token : "entity.other.attribute-name.xml",
  749. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  750. }, {
  751. token : "keyword.operator.attribute-equals.xml",
  752. regex : "="
  753. }, {
  754. include: "tag_whitespace"
  755. }, {
  756. include: "attribute_value"
  757. }],
  758. attribute_value: [{
  759. token : "string.attribute-value.xml",
  760. regex : "'",
  761. push : [
  762. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  763. {include : "attr_reference"},
  764. {defaultToken : "string.attribute-value.xml"}
  765. ]
  766. }, {
  767. token : "string.attribute-value.xml",
  768. regex : '"',
  769. push : [
  770. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  771. {include : "attr_reference"},
  772. {defaultToken : "string.attribute-value.xml"}
  773. ]
  774. }]
  775. };
  776. if (this.constructor === XmlHighlightRules)
  777. this.normalizeRules();
  778. };
  779. (function() {
  780. this.embedTagRules = function(HighlightRules, prefix, tag){
  781. this.$rules.tag.unshift({
  782. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  783. regex : "(<)(" + tag + "(?=\\s|>|$))",
  784. next: [
  785. {include : "attributes"},
  786. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  787. ]
  788. });
  789. this.$rules[tag + "-end"] = [
  790. {include : "attributes"},
  791. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  792. onMatch : function(value, currentState, stack) {
  793. stack.splice(0);
  794. return this.token;
  795. }}
  796. ]
  797. this.embedRules(HighlightRules, prefix, [{
  798. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  799. regex : "(</)(" + tag + "(?=\\s|>|$))",
  800. next: tag + "-end"
  801. }, {
  802. token: "string.cdata.xml",
  803. regex : "<\\!\\[CDATA\\["
  804. }, {
  805. token: "string.cdata.xml",
  806. regex : "\\]\\]>"
  807. }]);
  808. };
  809. }).call(TextHighlightRules.prototype);
  810. oop.inherits(XmlHighlightRules, TextHighlightRules);
  811. exports.XmlHighlightRules = XmlHighlightRules;
  812. });
  813. ace.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_highlight_rules"], function(require, exports, module) {
  814. "use strict";
  815. var oop = require("../lib/oop");
  816. var lang = require("../lib/lang");
  817. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  818. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  819. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  820. var tagMap = lang.createMap({
  821. a : 'anchor',
  822. button : 'form',
  823. form : 'form',
  824. img : 'image',
  825. input : 'form',
  826. label : 'form',
  827. option : 'form',
  828. script : 'script',
  829. select : 'form',
  830. textarea : 'form',
  831. style : 'style',
  832. table : 'table',
  833. tbody : 'table',
  834. td : 'table',
  835. tfoot : 'table',
  836. th : 'table',
  837. tr : 'table'
  838. });
  839. var HtmlHighlightRules = function() {
  840. XmlHighlightRules.call(this);
  841. this.addRules({
  842. attributes: [{
  843. include : "tag_whitespace"
  844. }, {
  845. token : "entity.other.attribute-name.xml",
  846. regex : "[-_a-zA-Z0-9:.]+"
  847. }, {
  848. token : "keyword.operator.attribute-equals.xml",
  849. regex : "=",
  850. push : [{
  851. include: "tag_whitespace"
  852. }, {
  853. token : "string.unquoted.attribute-value.html",
  854. regex : "[^<>='\"`\\s]+",
  855. next : "pop"
  856. }, {
  857. token : "empty",
  858. regex : "",
  859. next : "pop"
  860. }]
  861. }, {
  862. include : "attribute_value"
  863. }],
  864. tag: [{
  865. token : function(start, tag) {
  866. var group = tagMap[tag];
  867. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  868. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  869. },
  870. regex : "(</?)([-_a-zA-Z0-9:.]+)",
  871. next: "tag_stuff"
  872. }],
  873. tag_stuff: [
  874. {include : "attributes"},
  875. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  876. ]
  877. });
  878. this.embedTagRules(CssHighlightRules, "css-", "style");
  879. this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script");
  880. if (this.constructor === HtmlHighlightRules)
  881. this.normalizeRules();
  882. };
  883. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  884. exports.HtmlHighlightRules = HtmlHighlightRules;
  885. });
  886. ace.define("ace/mode/markdown_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","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) {
  887. "use strict";
  888. var oop = require("../lib/oop");
  889. var lang = require("../lib/lang");
  890. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  891. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  892. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  893. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  894. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  895. var escaped = function(ch) {
  896. return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
  897. }
  898. function github_embed(tag, prefix) {
  899. return { // Github style block
  900. token : "support.function",
  901. regex : "^\\s*```" + tag + "\\s*$",
  902. push : prefix + "start"
  903. };
  904. }
  905. var MarkdownHighlightRules = function() {
  906. HtmlHighlightRules.call(this);
  907. this.$rules["start"].unshift({
  908. token : "empty_line",
  909. regex : '^$',
  910. next: "allowBlock"
  911. }, { // h1
  912. token: "markup.heading.1",
  913. regex: "^=+(?=\\s*$)"
  914. }, { // h2
  915. token: "markup.heading.2",
  916. regex: "^\\-+(?=\\s*$)"
  917. }, {
  918. token : function(value) {
  919. return "markup.heading." + value.length;
  920. },
  921. regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
  922. next : "header"
  923. },
  924. github_embed("(?:javascript|js)", "jscode-"),
  925. github_embed("xml", "xmlcode-"),
  926. github_embed("html", "htmlcode-"),
  927. github_embed("css", "csscode-"),
  928. { // Github style block
  929. token : "support.function",
  930. regex : "^\\s*```\\s*\\S*(?:{.*?\\})?\\s*$",
  931. next : "githubblock"
  932. }, { // block quote
  933. token : "string.blockquote",
  934. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  935. next : "blockquote"
  936. }, { // HR * - _
  937. token : "constant",
  938. regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
  939. next: "allowBlock"
  940. }, { // list
  941. token : "markup.list",
  942. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  943. next : "listblock-start"
  944. }, {
  945. include : "basic"
  946. });
  947. this.addRules({
  948. "basic" : [{
  949. token : "constant.language.escape",
  950. regex : /\\[\\`*_{}\[\]()#+\-.!]/
  951. }, { // code span `
  952. token : "support.function",
  953. regex : "(`+)(.*?[^`])(\\1)"
  954. }, { // reference
  955. token : ["text", "constant", "text", "url", "string", "text"],
  956. regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
  957. }, { // link by reference
  958. token : ["text", "string", "text", "constant", "text"],
  959. regex : "(\\[)(" + escaped("]") + ")(\\]\\s*\\[)("+ escaped("]") + ")(\\])"
  960. }, { // link by url
  961. token : ["text", "string", "text", "markup.underline", "string", "text"],
  962. regex : "(\\[)(" + // [
  963. escaped("]") + // link text
  964. ")(\\]\\()"+ // ](
  965. '((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
  966. '(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
  967. "(\\))" // )
  968. }, { // strong ** __
  969. token : "string.strong",
  970. regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
  971. }, { // emphasis * _
  972. token : "string.emphasis",
  973. regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
  974. }, { //
  975. token : ["text", "url", "text"],
  976. regex : "(<)("+
  977. "(?:https?|ftp|dict):[^'\">\\s]+"+
  978. "|"+
  979. "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
  980. ")(>)"
  981. }],
  982. "allowBlock": [
  983. {token : "support.function", regex : "^ {4}.+", next : "allowBlock"},
  984. {token : "empty_line", regex : '^$', next: "allowBlock"},
  985. {token : "empty", regex : "", next : "start"}
  986. ],
  987. "header" : [{
  988. regex: "$",
  989. next : "start"
  990. }, {
  991. include: "basic"
  992. }, {
  993. defaultToken : "heading"
  994. } ],
  995. "listblock-start" : [{
  996. token : "support.variable",
  997. regex : /(?:\[[ x]\])?/,
  998. next : "listblock"
  999. }],
  1000. "listblock" : [ { // Lists only escape on completely blank lines.
  1001. token : "empty_line",
  1002. regex : "^$",
  1003. next : "start"
  1004. }, { // list
  1005. token : "markup.list",
  1006. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  1007. next : "listblock-start"
  1008. }, {
  1009. include : "basic", noEscape: true
  1010. }, { // Github style block
  1011. token : "support.function",
  1012. regex : "^\\s*```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
  1013. next : "githubblock"
  1014. }, {
  1015. defaultToken : "list" //do not use markup.list to allow stling leading `*` differntly
  1016. } ],
  1017. "blockquote" : [ { // Blockquotes only escape on blank lines.
  1018. token : "empty_line",
  1019. regex : "^\\s*$",
  1020. next : "start"
  1021. }, { // block quote
  1022. token : "string.blockquote",
  1023. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  1024. next : "blockquote"
  1025. }, {
  1026. include : "basic", noEscape: true
  1027. }, {
  1028. defaultToken : "string.blockquote"
  1029. } ],
  1030. "githubblock" : [ {
  1031. token : "support.function",
  1032. regex : "^\\s*```",
  1033. next : "start"
  1034. }, {
  1035. token : "support.function",
  1036. regex : ".+"
  1037. } ]
  1038. });
  1039. this.embedRules(JavaScriptHighlightRules, "jscode-", [{
  1040. token : "support.function",
  1041. regex : "^\\s*```",
  1042. next : "pop"
  1043. }]);
  1044. this.embedRules(HtmlHighlightRules, "htmlcode-", [{
  1045. token : "support.function",
  1046. regex : "^\\s*```",
  1047. next : "pop"
  1048. }]);
  1049. this.embedRules(CssHighlightRules, "csscode-", [{
  1050. token : "support.function",
  1051. regex : "^\\s*```",
  1052. next : "pop"
  1053. }]);
  1054. this.embedRules(XmlHighlightRules, "xmlcode-", [{
  1055. token : "support.function",
  1056. regex : "^\\s*```",
  1057. next : "pop"
  1058. }]);
  1059. this.normalizeRules();
  1060. };
  1061. oop.inherits(MarkdownHighlightRules, TextHighlightRules);
  1062. exports.MarkdownHighlightRules = MarkdownHighlightRules;
  1063. });
  1064. ace.define("ace/mode/mask_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/javascript_highlight_rules","ace/mode/css_highlight_rules","ace/mode/markdown_highlight_rules","ace/mode/html_highlight_rules"], function(require, exports, module) {
  1065. "use strict";
  1066. exports.MaskHighlightRules = MaskHighlightRules;
  1067. var oop = require("../lib/oop");
  1068. var lang = require("../lib/lang");
  1069. var TextRules = require("./text_highlight_rules").TextHighlightRules;
  1070. var JSRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1071. var CssRules = require("./css_highlight_rules").CssHighlightRules;
  1072. var MDRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
  1073. var HTMLRules = require("./html_highlight_rules").HtmlHighlightRules;
  1074. var token_TAG = "keyword.support.constant.language",
  1075. token_COMPO = "support.function.markup.bold",
  1076. token_KEYWORD = "keyword",
  1077. token_LANG = "constant.language",
  1078. token_UTIL = "keyword.control.markup.italic",
  1079. token_ATTR = "support.variable.class",
  1080. token_PUNKT = "keyword.operator",
  1081. token_ITALIC = "markup.italic",
  1082. token_BOLD = "markup.bold",
  1083. token_LPARE = "paren.lparen",
  1084. token_RPARE = "paren.rparen";
  1085. var const_FUNCTIONS,
  1086. const_KEYWORDS,
  1087. const_CONST,
  1088. const_TAGS;
  1089. (function(){
  1090. const_FUNCTIONS = lang.arrayToMap(
  1091. ("log").split("|")
  1092. );
  1093. const_CONST = lang.arrayToMap(
  1094. (":dualbind|:bind|:import|slot|event|style|html|markdown|md").split("|")
  1095. );
  1096. const_KEYWORDS = lang.arrayToMap(
  1097. ("debugger|define|var|if|each|for|of|else|switch|case|with|visible|+if|+each|+for|+switch|+with|+visible|include|import").split("|")
  1098. );
  1099. const_TAGS = lang.arrayToMap(
  1100. ("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
  1101. "big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
  1102. "command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
  1103. "figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
  1104. "header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
  1105. "link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
  1106. "option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
  1107. "small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
  1108. "textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
  1109. );
  1110. }());
  1111. function MaskHighlightRules () {
  1112. this.$rules = {
  1113. "start" : [
  1114. Token("comment", "\\/\\/.*$"),
  1115. Token("comment", "\\/\\*", [
  1116. Token("comment", ".*?\\*\\/", "start"),
  1117. Token("comment", ".+")
  1118. ]),
  1119. Blocks.string("'''"),
  1120. Blocks.string('"""'),
  1121. Blocks.string('"'),
  1122. Blocks.string("'"),
  1123. Blocks.syntax(/(markdown|md)\b/, "md-multiline", "multiline"),
  1124. Blocks.syntax(/html\b/, "html-multiline", "multiline"),
  1125. Blocks.syntax(/(slot|event)\b/, "js-block", "block"),
  1126. Blocks.syntax(/style\b/, "css-block", "block"),
  1127. Blocks.syntax(/var\b/, "js-statement", "attr"),
  1128. Blocks.tag(),
  1129. Token(token_LPARE, "[[({>]"),
  1130. Token(token_RPARE, "[\\])};]", "start"),
  1131. {
  1132. caseInsensitive: true
  1133. }
  1134. ]
  1135. };
  1136. var rules = this;
  1137. addJavaScript("interpolation", /\]/, token_RPARE + "." + token_ITALIC);
  1138. addJavaScript("statement", /\)|}|;/);
  1139. addJavaScript("block", /\}/);
  1140. addCss();
  1141. addMarkdown();
  1142. addHtml();
  1143. function addJavaScript(name, escape, closeType) {
  1144. var prfx = "js-" + name + "-",
  1145. rootTokens = name === "block" ? ["start"] : ["start", "no_regex"];
  1146. add(
  1147. JSRules
  1148. , prfx
  1149. , escape
  1150. , rootTokens
  1151. , closeType
  1152. );
  1153. }
  1154. function addCss() {
  1155. add(CssRules, "css-block-", /\}/);
  1156. }
  1157. function addMarkdown() {
  1158. add(MDRules, "md-multiline-", /("""|''')/, []);
  1159. }
  1160. function addHtml() {
  1161. add(HTMLRules, "html-multiline-", /("""|''')/);
  1162. }
  1163. function add(Rules, strPrfx, rgxEnd, rootTokens, closeType) {
  1164. var next = "pop";
  1165. var tokens = rootTokens || [ "start" ];
  1166. if (tokens.length === 0) {
  1167. tokens = null;
  1168. }
  1169. if (/block|multiline/.test(strPrfx)) {
  1170. next = strPrfx + "end";
  1171. rules.$rules[next] = [
  1172. Token("empty", "", "start")
  1173. ];
  1174. }
  1175. rules.embedRules(
  1176. Rules
  1177. , strPrfx
  1178. , [ Token(closeType || token_RPARE, rgxEnd, next) ]
  1179. , tokens
  1180. , tokens == null ? true : false
  1181. );
  1182. }
  1183. this.normalizeRules();
  1184. }
  1185. oop.inherits(MaskHighlightRules, TextRules);
  1186. var Blocks = {
  1187. string: function(str, next){
  1188. var token = Token(
  1189. "string.start"
  1190. , str
  1191. , [
  1192. Token(token_LPARE + "." + token_ITALIC, /~\[/, Blocks.interpolation()),
  1193. Token("string.end", str, "pop"),
  1194. {
  1195. defaultToken: "string"
  1196. }
  1197. ]
  1198. , next
  1199. );
  1200. if (str.length === 1){
  1201. var escaped = Token("string.escape", "\\\\" + str);
  1202. token.push.unshift(escaped);
  1203. }
  1204. return token;
  1205. },
  1206. interpolation: function(){
  1207. return [
  1208. Token(token_UTIL, /\s*\w*\s*:/),
  1209. "js-interpolation-start"
  1210. ];
  1211. },
  1212. tagHead: function (rgx) {
  1213. return Token(token_ATTR, rgx, [
  1214. Token(token_ATTR, /[\w\-_]+/),
  1215. Token(token_LPARE + "." + token_ITALIC, /~\[/, Blocks.interpolation()),
  1216. Blocks.goUp()
  1217. ]);
  1218. },
  1219. tag: function () {
  1220. return {
  1221. token: 'tag',
  1222. onMatch : function(value) {
  1223. if (void 0 !== const_KEYWORDS[value])
  1224. return token_KEYWORD;
  1225. if (void 0 !== const_CONST[value])
  1226. return token_LANG;
  1227. if (void 0 !== const_FUNCTIONS[value])
  1228. return "support.function";
  1229. if (void 0 !== const_TAGS[value.toLowerCase()])
  1230. return token_TAG;
  1231. return token_COMPO;
  1232. },
  1233. regex : /([@\w\-_:+]+)|((^|\s)(?=\s*(\.|#)))/,
  1234. push: [
  1235. Blocks.tagHead(/\./) ,
  1236. Blocks.tagHead(/#/) ,
  1237. Blocks.expression(),
  1238. Blocks.attribute(),
  1239. Token(token_LPARE, /[;>{]/, "pop")
  1240. ]
  1241. };
  1242. },
  1243. syntax: function(rgx, next, type){
  1244. return {
  1245. token: token_LANG,
  1246. regex : rgx,
  1247. push: ({
  1248. "attr": [
  1249. next + "-start",
  1250. Token(token_PUNKT, /;/, "start")
  1251. ],
  1252. "multiline": [
  1253. Blocks.tagHead(/\./) ,
  1254. Blocks.tagHead(/#/) ,
  1255. Blocks.attribute(),
  1256. Blocks.expression(),
  1257. Token(token_LPARE, /[>\{]/),
  1258. Token(token_PUNKT, /;/, "start"),
  1259. Token(token_LPARE, /'''|"""/, [ next + "-start" ])
  1260. ],
  1261. "block": [
  1262. Blocks.tagHead(/\./) ,
  1263. Blocks.tagHead(/#/) ,
  1264. Blocks.attribute(),
  1265. Blocks.expression(),
  1266. Token(token_LPARE, /\{/, [ next + "-start" ])
  1267. ]
  1268. })[type]
  1269. };
  1270. },
  1271. attribute: function(){
  1272. return Token(function(value){
  1273. return /^x\-/.test(value)
  1274. ? token_ATTR + "." + token_BOLD
  1275. : token_ATTR;
  1276. }, /[\w_-]+/, [
  1277. Token(token_PUNKT, /\s*=\s*/, [
  1278. Blocks.string('"'),
  1279. Blocks.string("'"),
  1280. Blocks.word(),
  1281. Blocks.goUp()
  1282. ]),
  1283. Blocks.goUp()
  1284. ]);
  1285. },
  1286. expression: function(){
  1287. return Token(token_LPARE, /\(/, [ "js-statement-start" ]);
  1288. },
  1289. word: function(){
  1290. return Token("string", /[\w-_]+/);
  1291. },
  1292. goUp: function(){
  1293. return Token("text", "", "pop");
  1294. },
  1295. goStart: function(){
  1296. return Token("text", "", "start");
  1297. }
  1298. };
  1299. function Token(token, rgx, mix) {
  1300. var push, next, onMatch;
  1301. if (arguments.length === 4) {
  1302. push = mix;
  1303. next = arguments[3];
  1304. }
  1305. else if (typeof mix === "string") {
  1306. next = mix;
  1307. }
  1308. else {
  1309. push = mix;
  1310. }
  1311. if (typeof token === "function") {
  1312. onMatch = token;
  1313. token = "empty";
  1314. }
  1315. return {
  1316. token: token,
  1317. regex: rgx,
  1318. push: push,
  1319. next: next,
  1320. onMatch: onMatch
  1321. };
  1322. }
  1323. });
  1324. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  1325. "use strict";
  1326. var Range = require("../range").Range;
  1327. var MatchingBraceOutdent = function() {};
  1328. (function() {
  1329. this.checkOutdent = function(line, input) {
  1330. if (! /^\s+$/.test(line))
  1331. return false;
  1332. return /^\s*\}/.test(input);
  1333. };
  1334. this.autoOutdent = function(doc, row) {
  1335. var line = doc.getLine(row);
  1336. var match = line.match(/^(\s*\})/);
  1337. if (!match) return 0;
  1338. var column = match[1].length;
  1339. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  1340. if (!openBracePos || openBracePos.row == row) return 0;
  1341. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  1342. doc.replace(new Range(row, 0, row, column-1), indent);
  1343. };
  1344. this.$getIndent = function(line) {
  1345. return line.match(/^\s*/)[0];
  1346. };
  1347. }).call(MatchingBraceOutdent.prototype);
  1348. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  1349. });
  1350. ace.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) {
  1351. "use strict";
  1352. var oop = require("../../lib/oop");
  1353. var Behaviour = require("../behaviour").Behaviour;
  1354. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1355. var TokenIterator = require("../../token_iterator").TokenIterator;
  1356. var CssBehaviour = function () {
  1357. this.inherit(CstyleBehaviour);
  1358. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1359. if (text === ':') {
  1360. var cursor = editor.getCursorPosition();
  1361. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1362. var token = iterator.getCurrentToken();
  1363. if (token && token.value.match(/\s+/)) {
  1364. token = iterator.stepBackward();
  1365. }
  1366. if (token && token.type === 'support.type') {
  1367. var line = session.doc.getLine(cursor.row);
  1368. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1369. if (rightChar === ':') {
  1370. return {
  1371. text: '',
  1372. selection: [1, 1]
  1373. }
  1374. }
  1375. if (!line.substring(cursor.column).match(/^\s*;/)) {
  1376. return {
  1377. text: ':;',
  1378. selection: [1, 1]
  1379. }
  1380. }
  1381. }
  1382. }
  1383. });
  1384. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1385. var selected = session.doc.getTextRange(range);
  1386. if (!range.isMultiLine() && selected === ':') {
  1387. var cursor = editor.getCursorPosition();
  1388. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1389. var token = iterator.getCurrentToken();
  1390. if (token && token.value.match(/\s+/)) {
  1391. token = iterator.stepBackward();
  1392. }
  1393. if (token && token.type === 'support.type') {
  1394. var line = session.doc.getLine(range.start.row);
  1395. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1396. if (rightChar === ';') {
  1397. range.end.column ++;
  1398. return range;
  1399. }
  1400. }
  1401. }
  1402. });
  1403. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1404. if (text === ';') {
  1405. var cursor = editor.getCursorPosition();
  1406. var line = session.doc.getLine(cursor.row);
  1407. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1408. if (rightChar === ';') {
  1409. return {
  1410. text: '',
  1411. selection: [1, 1]
  1412. }
  1413. }
  1414. }
  1415. });
  1416. }
  1417. oop.inherits(CssBehaviour, CstyleBehaviour);
  1418. exports.CssBehaviour = CssBehaviour;
  1419. });
  1420. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1421. "use strict";
  1422. var oop = require("../../lib/oop");
  1423. var Range = require("../../range").Range;
  1424. var BaseFoldMode = require("./fold_mode").FoldMode;
  1425. var FoldMode = exports.FoldMode = function(commentRegex) {
  1426. if (commentRegex) {
  1427. this.foldingStartMarker = new RegExp(
  1428. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  1429. );
  1430. this.foldingStopMarker = new RegExp(
  1431. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  1432. );
  1433. }
  1434. };
  1435. oop.inherits(FoldMode, BaseFoldMode);
  1436. (function() {
  1437. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  1438. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  1439. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  1440. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1441. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1442. this._getFoldWidgetBase = this.getFoldWidget;
  1443. this.getFoldWidget = function(session, foldStyle, row) {
  1444. var line = session.getLine(row);
  1445. if (this.singleLineBlockCommentRe.test(line)) {
  1446. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1447. return "";
  1448. }
  1449. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1450. if (!fw && this.startRegionRe.test(line))
  1451. return "start"; // lineCommentRegionStart
  1452. return fw;
  1453. };
  1454. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  1455. var line = session.getLine(row);
  1456. if (this.startRegionRe.test(line))
  1457. return this.getCommentRegionBlock(session, line, row);
  1458. var match = line.match(this.foldingStartMarker);
  1459. if (match) {
  1460. var i = match.index;
  1461. if (match[1])
  1462. return this.openingBracketBlock(session, match[1], row, i);
  1463. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1464. if (range && !range.isMultiLine()) {
  1465. if (forceMultiline) {
  1466. range = this.getSectionRange(session, row);
  1467. } else if (foldStyle != "all")
  1468. range = null;
  1469. }
  1470. return range;
  1471. }
  1472. if (foldStyle === "markbegin")
  1473. return;
  1474. var match = line.match(this.foldingStopMarker);
  1475. if (match) {
  1476. var i = match.index + match[0].length;
  1477. if (match[1])
  1478. return this.closingBracketBlock(session, match[1], row, i);
  1479. return session.getCommentFoldRange(row, i, -1);
  1480. }
  1481. };
  1482. this.getSectionRange = function(session, row) {
  1483. var line = session.getLine(row);
  1484. var startIndent = line.search(/\S/);
  1485. var startRow = row;
  1486. var startColumn = line.length;
  1487. row = row + 1;
  1488. var endRow = row;
  1489. var maxRow = session.getLength();
  1490. while (++row < maxRow) {
  1491. line = session.getLine(row);
  1492. var indent = line.search(/\S/);
  1493. if (indent === -1)
  1494. continue;
  1495. if (startIndent > indent)
  1496. break;
  1497. var subRange = this.getFoldWidgetRange(session, "all", row);
  1498. if (subRange) {
  1499. if (subRange.start.row <= startRow) {
  1500. break;
  1501. } else if (subRange.isMultiLine()) {
  1502. row = subRange.end.row;
  1503. } else if (startIndent == indent) {
  1504. break;
  1505. }
  1506. }
  1507. endRow = row;
  1508. }
  1509. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1510. };
  1511. this.getCommentRegionBlock = function(session, line, row) {
  1512. var startColumn = line.search(/\s*$/);
  1513. var maxRow = session.getLength();
  1514. var startRow = row;
  1515. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1516. var depth = 1;
  1517. while (++row < maxRow) {
  1518. line = session.getLine(row);
  1519. var m = re.exec(line);
  1520. if (!m) continue;
  1521. if (m[1]) depth--;
  1522. else depth++;
  1523. if (!depth) break;
  1524. }
  1525. var endRow = row;
  1526. if (endRow > startRow) {
  1527. return new Range(startRow, startColumn, endRow, line.length);
  1528. }
  1529. };
  1530. }).call(FoldMode.prototype);
  1531. });
  1532. ace.define("ace/mode/mask",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mask_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(require, exports, module) {
  1533. "use strict";
  1534. var oop = require("../lib/oop");
  1535. var TextMode = require("./text").Mode;
  1536. var MaskHighlightRules = require("./mask_highlight_rules").MaskHighlightRules;
  1537. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1538. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1539. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1540. var Mode = function() {
  1541. this.HighlightRules = MaskHighlightRules;
  1542. this.$outdent = new MatchingBraceOutdent();
  1543. this.$behaviour = new CssBehaviour();
  1544. this.foldingRules = new CStyleFoldMode();
  1545. };
  1546. oop.inherits(Mode, TextMode);
  1547. (function() {
  1548. this.lineCommentStart = "//";
  1549. this.blockComment = {start: "/*", end: "*/"};
  1550. this.getNextLineIndent = function(state, line, tab) {
  1551. var indent = this.$getIndent(line);
  1552. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1553. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1554. return indent;
  1555. }
  1556. var match = line.match(/^.*\{\s*$/);
  1557. if (match) {
  1558. indent += tab;
  1559. }
  1560. return indent;
  1561. };
  1562. this.checkOutdent = function(state, line, input) {
  1563. return this.$outdent.checkOutdent(line, input);
  1564. };
  1565. this.autoOutdent = function(state, doc, row) {
  1566. this.$outdent.autoOutdent(doc, row);
  1567. };
  1568. this.$id = "ace/mode/mask";
  1569. }).call(Mode.prototype);
  1570. exports.Mode = Mode;
  1571. });