mode-mask.js 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808
  1. ace.define("ace/mode/doc_comment_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",[], 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", // hexadecimal, octal and binary
  96. regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  97. }, {
  98. token : "constant.numeric", // decimal integers and floats
  99. regex : /(?:\d\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 : "from(?=\\s*('|\"))"
  151. }, {
  152. token : "keyword",
  153. regex : "(?:" + kwBeforeRe + ")\\b",
  154. next : "start"
  155. }, {
  156. token : ["support.constant"],
  157. regex : /that\b/
  158. }, {
  159. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  160. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  161. }, {
  162. token : keywordMapper,
  163. regex : identifierRe
  164. }, {
  165. token : "punctuation.operator",
  166. regex : /[.](?![.])/,
  167. next : "property"
  168. }, {
  169. token : "storage.type",
  170. regex : /=>/
  171. }, {
  172. token : "keyword.operator",
  173. regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  174. next : "start"
  175. }, {
  176. token : "punctuation.operator",
  177. regex : /[?:,;.]/,
  178. next : "start"
  179. }, {
  180. token : "paren.lparen",
  181. regex : /[\[({]/,
  182. next : "start"
  183. }, {
  184. token : "paren.rparen",
  185. regex : /[\])}]/
  186. }, {
  187. token: "comment",
  188. regex: /^#!.*$/
  189. }
  190. ],
  191. property: [{
  192. token : "text",
  193. regex : "\\s+"
  194. }, {
  195. token : [
  196. "storage.type", "punctuation.operator", "entity.name.function", "text",
  197. "keyword.operator", "text",
  198. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  199. ],
  200. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  201. next: "function_arguments"
  202. }, {
  203. token : "punctuation.operator",
  204. regex : /[.](?![.])/
  205. }, {
  206. token : "support.function",
  207. 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(?=\()/
  208. }, {
  209. token : "support.function.dom",
  210. 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(?=\()/
  211. }, {
  212. token : "support.constant",
  213. 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/
  214. }, {
  215. token : "identifier",
  216. regex : identifierRe
  217. }, {
  218. regex: "",
  219. token: "empty",
  220. next: "no_regex"
  221. }
  222. ],
  223. "start": [
  224. DocCommentHighlightRules.getStartRule("doc-start"),
  225. comments("start"),
  226. {
  227. token: "string.regexp",
  228. regex: "\\/",
  229. next: "regex"
  230. }, {
  231. token : "text",
  232. regex : "\\s+|^$",
  233. next : "start"
  234. }, {
  235. token: "empty",
  236. regex: "",
  237. next: "no_regex"
  238. }
  239. ],
  240. "regex": [
  241. {
  242. token: "regexp.keyword.operator",
  243. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  244. }, {
  245. token: "string.regexp",
  246. regex: "/[sxngimy]*",
  247. next: "no_regex"
  248. }, {
  249. token : "invalid",
  250. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  251. }, {
  252. token : "constant.language.escape",
  253. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  254. }, {
  255. token : "constant.language.delimiter",
  256. regex: /\|/
  257. }, {
  258. token: "constant.language.escape",
  259. regex: /\[\^?/,
  260. next: "regex_character_class"
  261. }, {
  262. token: "empty",
  263. regex: "$",
  264. next: "no_regex"
  265. }, {
  266. defaultToken: "string.regexp"
  267. }
  268. ],
  269. "regex_character_class": [
  270. {
  271. token: "regexp.charclass.keyword.operator",
  272. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  273. }, {
  274. token: "constant.language.escape",
  275. regex: "]",
  276. next: "regex"
  277. }, {
  278. token: "constant.language.escape",
  279. regex: "-"
  280. }, {
  281. token: "empty",
  282. regex: "$",
  283. next: "no_regex"
  284. }, {
  285. defaultToken: "string.regexp.charachterclass"
  286. }
  287. ],
  288. "function_arguments": [
  289. {
  290. token: "variable.parameter",
  291. regex: identifierRe
  292. }, {
  293. token: "punctuation.operator",
  294. regex: "[, ]+"
  295. }, {
  296. token: "punctuation.operator",
  297. regex: "$"
  298. }, {
  299. token: "empty",
  300. regex: "",
  301. next: "no_regex"
  302. }
  303. ],
  304. "qqstring" : [
  305. {
  306. token : "constant.language.escape",
  307. regex : escapedRe
  308. }, {
  309. token : "string",
  310. regex : "\\\\$",
  311. consumeLineEnd : true
  312. }, {
  313. token : "string",
  314. regex : '"|$',
  315. next : "no_regex"
  316. }, {
  317. defaultToken: "string"
  318. }
  319. ],
  320. "qstring" : [
  321. {
  322. token : "constant.language.escape",
  323. regex : escapedRe
  324. }, {
  325. token : "string",
  326. regex : "\\\\$",
  327. consumeLineEnd : true
  328. }, {
  329. token : "string",
  330. regex : "'|$",
  331. next : "no_regex"
  332. }, {
  333. defaultToken: "string"
  334. }
  335. ]
  336. };
  337. if (!options || !options.noES6) {
  338. this.$rules.no_regex.unshift({
  339. regex: "[{}]", onMatch: function(val, state, stack) {
  340. this.next = val == "{" ? this.nextState : "";
  341. if (val == "{" && stack.length) {
  342. stack.unshift("start", state);
  343. }
  344. else if (val == "}" && stack.length) {
  345. stack.shift();
  346. this.next = stack.shift();
  347. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  348. return "paren.quasi.end";
  349. }
  350. return val == "{" ? "paren.lparen" : "paren.rparen";
  351. },
  352. nextState: "start"
  353. }, {
  354. token : "string.quasi.start",
  355. regex : /`/,
  356. push : [{
  357. token : "constant.language.escape",
  358. regex : escapedRe
  359. }, {
  360. token : "paren.quasi.start",
  361. regex : /\${/,
  362. push : "start"
  363. }, {
  364. token : "string.quasi.end",
  365. regex : /`/,
  366. next : "pop"
  367. }, {
  368. defaultToken: "string.quasi"
  369. }]
  370. });
  371. if (!options || options.jsx != false)
  372. JSX.call(this);
  373. }
  374. this.embedRules(DocCommentHighlightRules, "doc-",
  375. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  376. this.normalizeRules();
  377. };
  378. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  379. function JSX() {
  380. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  381. var jsxTag = {
  382. onMatch : function(val, state, stack) {
  383. var offset = val.charAt(1) == "/" ? 2 : 1;
  384. if (offset == 1) {
  385. if (state != this.nextState)
  386. stack.unshift(this.next, this.nextState, 0);
  387. else
  388. stack.unshift(this.next);
  389. stack[2]++;
  390. } else if (offset == 2) {
  391. if (state == this.nextState) {
  392. stack[1]--;
  393. if (!stack[1] || stack[1] < 0) {
  394. stack.shift();
  395. stack.shift();
  396. }
  397. }
  398. }
  399. return [{
  400. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  401. value: val.slice(0, offset)
  402. }, {
  403. type: "meta.tag.tag-name.xml",
  404. value: val.substr(offset)
  405. }];
  406. },
  407. regex : "</?" + tagRegex + "",
  408. next: "jsxAttributes",
  409. nextState: "jsx"
  410. };
  411. this.$rules.start.unshift(jsxTag);
  412. var jsxJsRule = {
  413. regex: "{",
  414. token: "paren.quasi.start",
  415. push: "start"
  416. };
  417. this.$rules.jsx = [
  418. jsxJsRule,
  419. jsxTag,
  420. {include : "reference"},
  421. {defaultToken: "string"}
  422. ];
  423. this.$rules.jsxAttributes = [{
  424. token : "meta.tag.punctuation.tag-close.xml",
  425. regex : "/?>",
  426. onMatch : function(value, currentState, stack) {
  427. if (currentState == stack[0])
  428. stack.shift();
  429. if (value.length == 2) {
  430. if (stack[0] == this.nextState)
  431. stack[1]--;
  432. if (!stack[1] || stack[1] < 0) {
  433. stack.splice(0, 2);
  434. }
  435. }
  436. this.next = stack[0] || "start";
  437. return [{type: this.token, value: value}];
  438. },
  439. nextState: "jsx"
  440. },
  441. jsxJsRule,
  442. comments("jsxAttributes"),
  443. {
  444. token : "entity.other.attribute-name.xml",
  445. regex : tagRegex
  446. }, {
  447. token : "keyword.operator.attribute-equals.xml",
  448. regex : "="
  449. }, {
  450. token : "text.tag-whitespace.xml",
  451. regex : "\\s+"
  452. }, {
  453. token : "string.attribute-value.xml",
  454. regex : "'",
  455. stateName : "jsx_attr_q",
  456. push : [
  457. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  458. {include : "reference"},
  459. {defaultToken : "string.attribute-value.xml"}
  460. ]
  461. }, {
  462. token : "string.attribute-value.xml",
  463. regex : '"',
  464. stateName : "jsx_attr_qq",
  465. push : [
  466. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  467. {include : "reference"},
  468. {defaultToken : "string.attribute-value.xml"}
  469. ]
  470. },
  471. jsxTag
  472. ];
  473. this.$rules.reference = [{
  474. token : "constant.language.escape.reference.xml",
  475. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  476. }];
  477. }
  478. function comments(next) {
  479. return [
  480. {
  481. token : "comment", // multi line comment
  482. regex : /\/\*/,
  483. next: [
  484. DocCommentHighlightRules.getTagRule(),
  485. {token : "comment", regex : "\\*\\/", next : next || "pop"},
  486. {defaultToken : "comment", caseInsensitive: true}
  487. ]
  488. }, {
  489. token : "comment",
  490. regex : "\\/\\/",
  491. next: [
  492. DocCommentHighlightRules.getTagRule(),
  493. {token : "comment", regex : "$|^", next : next || "pop"},
  494. {defaultToken : "comment", caseInsensitive: true}
  495. ]
  496. }
  497. ];
  498. }
  499. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  500. });
  501. ace.define("ace/mode/css_highlight_rules",[], function(require, exports, module) {
  502. "use strict";
  503. var oop = require("../lib/oop");
  504. var lang = require("../lib/lang");
  505. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  506. 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|max-zoom|min-height|min-width|min-zoom|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|user-select|user-zoom|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index";
  507. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  508. 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|zoom";
  509. var supportConstantColor = exports.supportConstantColor = "aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";
  510. 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";
  511. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))";
  512. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  513. 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";
  514. var CssHighlightRules = function() {
  515. var keywordMapper = this.createKeywordMapper({
  516. "support.function": supportFunction,
  517. "support.constant": supportConstant,
  518. "support.type": supportType,
  519. "support.constant.color": supportConstantColor,
  520. "support.constant.fonts": supportConstantFonts
  521. }, "text", true);
  522. this.$rules = {
  523. "start" : [{
  524. include : ["strings", "url", "comments"]
  525. }, {
  526. token: "paren.lparen",
  527. regex: "\\{",
  528. next: "ruleset"
  529. }, {
  530. token: "paren.rparen",
  531. regex: "\\}"
  532. }, {
  533. token: "string",
  534. regex: "@(?!viewport)",
  535. next: "media"
  536. }, {
  537. token: "keyword",
  538. regex: "#[a-z0-9-_]+"
  539. }, {
  540. token: "keyword",
  541. regex: "%"
  542. }, {
  543. token: "variable",
  544. regex: "\\.[a-z0-9-_]+"
  545. }, {
  546. token: "string",
  547. regex: ":[a-z0-9-_]+"
  548. }, {
  549. token : "constant.numeric",
  550. regex : numRe
  551. }, {
  552. token: "constant",
  553. regex: "[a-z0-9-_]+"
  554. }, {
  555. caseInsensitive: true
  556. }],
  557. "media": [{
  558. include : ["strings", "url", "comments"]
  559. }, {
  560. token: "paren.lparen",
  561. regex: "\\{",
  562. next: "start"
  563. }, {
  564. token: "paren.rparen",
  565. regex: "\\}",
  566. next: "start"
  567. }, {
  568. token: "string",
  569. regex: ";",
  570. next: "start"
  571. }, {
  572. token: "keyword",
  573. regex: "(?:media|supports|document|charset|import|namespace|media|supports|document"
  574. + "|page|font|keyframes|viewport|counter-style|font-feature-values"
  575. + "|swash|ornaments|annotation|stylistic|styleset|character-variant)"
  576. }],
  577. "comments" : [{
  578. token: "comment", // multi line comment
  579. regex: "\\/\\*",
  580. push: [{
  581. token : "comment",
  582. regex : "\\*\\/",
  583. next : "pop"
  584. }, {
  585. defaultToken : "comment"
  586. }]
  587. }],
  588. "ruleset" : [{
  589. regex : "-(webkit|ms|moz|o)-",
  590. token : "text"
  591. }, {
  592. token : "punctuation.operator",
  593. regex : "[:;]"
  594. }, {
  595. token : "paren.rparen",
  596. regex : "\\}",
  597. next : "start"
  598. }, {
  599. include : ["strings", "url", "comments"]
  600. }, {
  601. token : ["constant.numeric", "keyword"],
  602. regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vmax|vmin|vm|vw|%)"
  603. }, {
  604. token : "constant.numeric",
  605. regex : numRe
  606. }, {
  607. token : "constant.numeric", // hex6 color
  608. regex : "#[a-f0-9]{6}"
  609. }, {
  610. token : "constant.numeric", // hex3 color
  611. regex : "#[a-f0-9]{3}"
  612. }, {
  613. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  614. regex : pseudoElements
  615. }, {
  616. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  617. regex : pseudoClasses
  618. }, {
  619. include: "url"
  620. }, {
  621. token : keywordMapper,
  622. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  623. }, {
  624. caseInsensitive: true
  625. }],
  626. url: [{
  627. token : "support.function",
  628. regex : "(?:url(:?-prefix)?|domain|regexp)\\(",
  629. push: [{
  630. token : "support.function",
  631. regex : "\\)",
  632. next : "pop"
  633. }, {
  634. defaultToken: "string"
  635. }]
  636. }],
  637. strings: [{
  638. token : "string.start",
  639. regex : "'",
  640. push : [{
  641. token : "string.end",
  642. regex : "'|$",
  643. next: "pop"
  644. }, {
  645. include : "escapes"
  646. }, {
  647. token : "constant.language.escape",
  648. regex : /\\$/,
  649. consumeLineEnd: true
  650. }, {
  651. defaultToken: "string"
  652. }]
  653. }, {
  654. token : "string.start",
  655. regex : '"',
  656. push : [{
  657. token : "string.end",
  658. regex : '"|$',
  659. next: "pop"
  660. }, {
  661. include : "escapes"
  662. }, {
  663. token : "constant.language.escape",
  664. regex : /\\$/,
  665. consumeLineEnd: true
  666. }, {
  667. defaultToken: "string"
  668. }]
  669. }],
  670. escapes: [{
  671. token : "constant.language.escape",
  672. regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/
  673. }]
  674. };
  675. this.normalizeRules();
  676. };
  677. oop.inherits(CssHighlightRules, TextHighlightRules);
  678. exports.CssHighlightRules = CssHighlightRules;
  679. });
  680. ace.define("ace/mode/xml_highlight_rules",[], function(require, exports, module) {
  681. "use strict";
  682. var oop = require("../lib/oop");
  683. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  684. var XmlHighlightRules = function(normalize) {
  685. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  686. this.$rules = {
  687. start : [
  688. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  689. {
  690. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  691. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction"
  692. },
  693. {token : "comment.start.xml", regex : "<\\!--", next : "comment"},
  694. {
  695. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  696. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  697. },
  698. {include : "tag"},
  699. {token : "text.end-tag-open.xml", regex: "</"},
  700. {token : "text.tag-open.xml", regex: "<"},
  701. {include : "reference"},
  702. {defaultToken : "text.xml"}
  703. ],
  704. processing_instruction : [{
  705. token : "entity.other.attribute-name.decl-attribute-name.xml",
  706. regex : tagRegex
  707. }, {
  708. token : "keyword.operator.decl-attribute-equals.xml",
  709. regex : "="
  710. }, {
  711. include: "whitespace"
  712. }, {
  713. include: "string"
  714. }, {
  715. token : "punctuation.xml-decl.xml",
  716. regex : "\\?>",
  717. next : "start"
  718. }],
  719. doctype : [
  720. {include : "whitespace"},
  721. {include : "string"},
  722. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  723. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  724. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  725. ],
  726. int_subset : [{
  727. token : "text.xml",
  728. regex : "\\s+"
  729. }, {
  730. token: "punctuation.int-subset.xml",
  731. regex: "]",
  732. next: "pop"
  733. }, {
  734. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  735. regex : "(<\\!)(" + tagRegex + ")",
  736. push : [{
  737. token : "text",
  738. regex : "\\s+"
  739. },
  740. {
  741. token : "punctuation.markup-decl.xml",
  742. regex : ">",
  743. next : "pop"
  744. },
  745. {include : "string"}]
  746. }],
  747. cdata : [
  748. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  749. {token : "text.xml", regex : "\\s+"},
  750. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  751. ],
  752. comment : [
  753. {token : "comment.end.xml", regex : "-->", next : "start"},
  754. {defaultToken : "comment.xml"}
  755. ],
  756. reference : [{
  757. token : "constant.language.escape.reference.xml",
  758. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  759. }],
  760. attr_reference : [{
  761. token : "constant.language.escape.reference.attribute-value.xml",
  762. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  763. }],
  764. tag : [{
  765. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  766. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  767. next: [
  768. {include : "attributes"},
  769. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  770. ]
  771. }],
  772. tag_whitespace : [
  773. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  774. ],
  775. whitespace : [
  776. {token : "text.whitespace.xml", regex : "\\s+"}
  777. ],
  778. string: [{
  779. token : "string.xml",
  780. regex : "'",
  781. push : [
  782. {token : "string.xml", regex: "'", next: "pop"},
  783. {defaultToken : "string.xml"}
  784. ]
  785. }, {
  786. token : "string.xml",
  787. regex : '"',
  788. push : [
  789. {token : "string.xml", regex: '"', next: "pop"},
  790. {defaultToken : "string.xml"}
  791. ]
  792. }],
  793. attributes: [{
  794. token : "entity.other.attribute-name.xml",
  795. regex : tagRegex
  796. }, {
  797. token : "keyword.operator.attribute-equals.xml",
  798. regex : "="
  799. }, {
  800. include: "tag_whitespace"
  801. }, {
  802. include: "attribute_value"
  803. }],
  804. attribute_value: [{
  805. token : "string.attribute-value.xml",
  806. regex : "'",
  807. push : [
  808. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  809. {include : "attr_reference"},
  810. {defaultToken : "string.attribute-value.xml"}
  811. ]
  812. }, {
  813. token : "string.attribute-value.xml",
  814. regex : '"',
  815. push : [
  816. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  817. {include : "attr_reference"},
  818. {defaultToken : "string.attribute-value.xml"}
  819. ]
  820. }]
  821. };
  822. if (this.constructor === XmlHighlightRules)
  823. this.normalizeRules();
  824. };
  825. (function() {
  826. this.embedTagRules = function(HighlightRules, prefix, tag){
  827. this.$rules.tag.unshift({
  828. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  829. regex : "(<)(" + tag + "(?=\\s|>|$))",
  830. next: [
  831. {include : "attributes"},
  832. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  833. ]
  834. });
  835. this.$rules[tag + "-end"] = [
  836. {include : "attributes"},
  837. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  838. onMatch : function(value, currentState, stack) {
  839. stack.splice(0);
  840. return this.token;
  841. }}
  842. ];
  843. this.embedRules(HighlightRules, prefix, [{
  844. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  845. regex : "(</)(" + tag + "(?=\\s|>|$))",
  846. next: tag + "-end"
  847. }, {
  848. token: "string.cdata.xml",
  849. regex : "<\\!\\[CDATA\\["
  850. }, {
  851. token: "string.cdata.xml",
  852. regex : "\\]\\]>"
  853. }]);
  854. };
  855. }).call(TextHighlightRules.prototype);
  856. oop.inherits(XmlHighlightRules, TextHighlightRules);
  857. exports.XmlHighlightRules = XmlHighlightRules;
  858. });
  859. ace.define("ace/mode/html_highlight_rules",[], function(require, exports, module) {
  860. "use strict";
  861. var oop = require("../lib/oop");
  862. var lang = require("../lib/lang");
  863. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  864. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  865. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  866. var tagMap = lang.createMap({
  867. a : 'anchor',
  868. button : 'form',
  869. form : 'form',
  870. img : 'image',
  871. input : 'form',
  872. label : 'form',
  873. option : 'form',
  874. script : 'script',
  875. select : 'form',
  876. textarea : 'form',
  877. style : 'style',
  878. table : 'table',
  879. tbody : 'table',
  880. td : 'table',
  881. tfoot : 'table',
  882. th : 'table',
  883. tr : 'table'
  884. });
  885. var HtmlHighlightRules = function() {
  886. XmlHighlightRules.call(this);
  887. this.addRules({
  888. attributes: [{
  889. include : "tag_whitespace"
  890. }, {
  891. token : "entity.other.attribute-name.xml",
  892. regex : "[-_a-zA-Z0-9:.]+"
  893. }, {
  894. token : "keyword.operator.attribute-equals.xml",
  895. regex : "=",
  896. push : [{
  897. include: "tag_whitespace"
  898. }, {
  899. token : "string.unquoted.attribute-value.html",
  900. regex : "[^<>='\"`\\s]+",
  901. next : "pop"
  902. }, {
  903. token : "empty",
  904. regex : "",
  905. next : "pop"
  906. }]
  907. }, {
  908. include : "attribute_value"
  909. }],
  910. tag: [{
  911. token : function(start, tag) {
  912. var group = tagMap[tag];
  913. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  914. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  915. },
  916. regex : "(</?)([-_a-zA-Z0-9:.]+)",
  917. next: "tag_stuff"
  918. }],
  919. tag_stuff: [
  920. {include : "attributes"},
  921. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  922. ]
  923. });
  924. this.embedTagRules(CssHighlightRules, "css-", "style");
  925. this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script");
  926. if (this.constructor === HtmlHighlightRules)
  927. this.normalizeRules();
  928. };
  929. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  930. exports.HtmlHighlightRules = HtmlHighlightRules;
  931. });
  932. ace.define("ace/mode/markdown_highlight_rules",[], function(require, exports, module) {
  933. "use strict";
  934. var oop = require("../lib/oop");
  935. var lang = require("../lib/lang");
  936. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  937. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  938. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  939. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  940. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  941. var escaped = function(ch) {
  942. return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
  943. };
  944. function github_embed(tag, prefix) {
  945. return { // Github style block
  946. token : "support.function",
  947. regex : "^\\s*```" + tag + "\\s*$",
  948. push : prefix + "start"
  949. };
  950. }
  951. var MarkdownHighlightRules = function() {
  952. HtmlHighlightRules.call(this);
  953. this.$rules["start"].unshift({
  954. token : "empty_line",
  955. regex : '^$',
  956. next: "allowBlock"
  957. }, { // h1
  958. token: "markup.heading.1",
  959. regex: "^=+(?=\\s*$)"
  960. }, { // h2
  961. token: "markup.heading.2",
  962. regex: "^\\-+(?=\\s*$)"
  963. }, {
  964. token : function(value) {
  965. return "markup.heading." + value.length;
  966. },
  967. regex : /^#{1,6}(?=\s|$)/,
  968. next : "header"
  969. },
  970. github_embed("(?:javascript|js)", "jscode-"),
  971. github_embed("xml", "xmlcode-"),
  972. github_embed("html", "htmlcode-"),
  973. github_embed("css", "csscode-"),
  974. { // Github style block
  975. token : "support.function",
  976. regex : "^\\s*```\\s*\\S*(?:{.*?\\})?\\s*$",
  977. next : "githubblock"
  978. }, { // block quote
  979. token : "string.blockquote",
  980. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  981. next : "blockquote"
  982. }, { // HR * - _
  983. token : "constant",
  984. regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
  985. next: "allowBlock"
  986. }, { // list
  987. token : "markup.list",
  988. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  989. next : "listblock-start"
  990. }, {
  991. include : "basic"
  992. });
  993. this.addRules({
  994. "basic" : [{
  995. token : "constant.language.escape",
  996. regex : /\\[\\`*_{}\[\]()#+\-.!]/
  997. }, { // code span `
  998. token : "support.function",
  999. regex : "(`+)(.*?[^`])(\\1)"
  1000. }, { // reference
  1001. token : ["text", "constant", "text", "url", "string", "text"],
  1002. regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
  1003. }, { // link by reference
  1004. token : ["text", "string", "text", "constant", "text"],
  1005. regex : "(\\[)(" + escaped("]") + ")(\\]\\s*\\[)("+ escaped("]") + ")(\\])"
  1006. }, { // link by url
  1007. token : ["text", "string", "text", "markup.underline", "string", "text"],
  1008. regex : "(\\[)(" + // [
  1009. escaped("]") + // link text
  1010. ")(\\]\\()"+ // ](
  1011. '((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
  1012. '(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
  1013. "(\\))" // )
  1014. }, { // strong ** __
  1015. token : "string.strong",
  1016. regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
  1017. }, { // emphasis * _
  1018. token : "string.emphasis",
  1019. regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
  1020. }, { //
  1021. token : ["text", "url", "text"],
  1022. regex : "(<)("+
  1023. "(?:https?|ftp|dict):[^'\">\\s]+"+
  1024. "|"+
  1025. "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
  1026. ")(>)"
  1027. }],
  1028. "allowBlock": [
  1029. {token : "support.function", regex : "^ {4}.+", next : "allowBlock"},
  1030. {token : "empty_line", regex : '^$', next: "allowBlock"},
  1031. {token : "empty", regex : "", next : "start"}
  1032. ],
  1033. "header" : [{
  1034. regex: "$",
  1035. next : "start"
  1036. }, {
  1037. include: "basic"
  1038. }, {
  1039. defaultToken : "heading"
  1040. } ],
  1041. "listblock-start" : [{
  1042. token : "support.variable",
  1043. regex : /(?:\[[ x]\])?/,
  1044. next : "listblock"
  1045. }],
  1046. "listblock" : [ { // Lists only escape on completely blank lines.
  1047. token : "empty_line",
  1048. regex : "^$",
  1049. next : "start"
  1050. }, { // list
  1051. token : "markup.list",
  1052. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  1053. next : "listblock-start"
  1054. }, {
  1055. include : "basic", noEscape: true
  1056. }, { // Github style block
  1057. token : "support.function",
  1058. regex : "^\\s*```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
  1059. next : "githubblock"
  1060. }, {
  1061. defaultToken : "list" //do not use markup.list to allow stling leading `*` differntly
  1062. } ],
  1063. "blockquote" : [ { // Blockquotes only escape on blank lines.
  1064. token : "empty_line",
  1065. regex : "^\\s*$",
  1066. next : "start"
  1067. }, { // block quote
  1068. token : "string.blockquote",
  1069. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  1070. next : "blockquote"
  1071. }, {
  1072. include : "basic", noEscape: true
  1073. }, {
  1074. defaultToken : "string.blockquote"
  1075. } ],
  1076. "githubblock" : [ {
  1077. token : "support.function",
  1078. regex : "^\\s*```",
  1079. next : "start"
  1080. }, {
  1081. defaultToken : "support.function"
  1082. } ]
  1083. });
  1084. this.embedRules(JavaScriptHighlightRules, "jscode-", [{
  1085. token : "support.function",
  1086. regex : "^\\s*```",
  1087. next : "pop"
  1088. }]);
  1089. this.embedRules(HtmlHighlightRules, "htmlcode-", [{
  1090. token : "support.function",
  1091. regex : "^\\s*```",
  1092. next : "pop"
  1093. }]);
  1094. this.embedRules(CssHighlightRules, "csscode-", [{
  1095. token : "support.function",
  1096. regex : "^\\s*```",
  1097. next : "pop"
  1098. }]);
  1099. this.embedRules(XmlHighlightRules, "xmlcode-", [{
  1100. token : "support.function",
  1101. regex : "^\\s*```",
  1102. next : "pop"
  1103. }]);
  1104. this.normalizeRules();
  1105. };
  1106. oop.inherits(MarkdownHighlightRules, TextHighlightRules);
  1107. exports.MarkdownHighlightRules = MarkdownHighlightRules;
  1108. });
  1109. ace.define("ace/mode/mask_highlight_rules",[], function(require, exports, module) {
  1110. "use strict";
  1111. exports.MaskHighlightRules = MaskHighlightRules;
  1112. var oop = require("../lib/oop");
  1113. var lang = require("../lib/lang");
  1114. var TextRules = require("./text_highlight_rules").TextHighlightRules;
  1115. var JSRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1116. var CssRules = require("./css_highlight_rules").CssHighlightRules;
  1117. var MDRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
  1118. var HTMLRules = require("./html_highlight_rules").HtmlHighlightRules;
  1119. var token_TAG = "keyword.support.constant.language",
  1120. token_COMPO = "support.function.markup.bold",
  1121. token_KEYWORD = "keyword",
  1122. token_LANG = "constant.language",
  1123. token_UTIL = "keyword.control.markup.italic",
  1124. token_ATTR = "support.variable.class",
  1125. token_PUNKT = "keyword.operator",
  1126. token_ITALIC = "markup.italic",
  1127. token_BOLD = "markup.bold",
  1128. token_LPARE = "paren.lparen",
  1129. token_RPARE = "paren.rparen";
  1130. var const_FUNCTIONS,
  1131. const_KEYWORDS,
  1132. const_CONST,
  1133. const_TAGS;
  1134. (function(){
  1135. const_FUNCTIONS = lang.arrayToMap(
  1136. ("log").split("|")
  1137. );
  1138. const_CONST = lang.arrayToMap(
  1139. (":dualbind|:bind|:import|slot|event|style|html|markdown|md").split("|")
  1140. );
  1141. const_KEYWORDS = lang.arrayToMap(
  1142. ("debugger|define|var|if|each|for|of|else|switch|case|with|visible|+if|+each|+for|+switch|+with|+visible|include|import").split("|")
  1143. );
  1144. const_TAGS = lang.arrayToMap(
  1145. ("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
  1146. "big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
  1147. "command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
  1148. "figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
  1149. "header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
  1150. "link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
  1151. "option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
  1152. "small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
  1153. "textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
  1154. );
  1155. }());
  1156. function MaskHighlightRules () {
  1157. this.$rules = {
  1158. "start" : [
  1159. Token("comment", "\\/\\/.*$"),
  1160. Token("comment", "\\/\\*", [
  1161. Token("comment", ".*?\\*\\/", "start"),
  1162. Token("comment", ".+")
  1163. ]),
  1164. Blocks.string("'''"),
  1165. Blocks.string('"""'),
  1166. Blocks.string('"'),
  1167. Blocks.string("'"),
  1168. Blocks.syntax(/(markdown|md)\b/, "md-multiline", "multiline"),
  1169. Blocks.syntax(/html\b/, "html-multiline", "multiline"),
  1170. Blocks.syntax(/(slot|event)\b/, "js-block", "block"),
  1171. Blocks.syntax(/style\b/, "css-block", "block"),
  1172. Blocks.syntax(/var\b/, "js-statement", "attr"),
  1173. Blocks.tag(),
  1174. Token(token_LPARE, "[[({>]"),
  1175. Token(token_RPARE, "[\\])};]", "start"),
  1176. {
  1177. caseInsensitive: true
  1178. }
  1179. ]
  1180. };
  1181. var rules = this;
  1182. addJavaScript("interpolation", /\]/, token_RPARE + "." + token_ITALIC);
  1183. addJavaScript("statement", /\)|}|;/);
  1184. addJavaScript("block", /\}/);
  1185. addCss();
  1186. addMarkdown();
  1187. addHtml();
  1188. function addJavaScript(name, escape, closeType) {
  1189. var prfx = "js-" + name + "-",
  1190. rootTokens = name === "block" ? ["start"] : ["start", "no_regex"];
  1191. add(
  1192. JSRules
  1193. , prfx
  1194. , escape
  1195. , rootTokens
  1196. , closeType
  1197. );
  1198. }
  1199. function addCss() {
  1200. add(CssRules, "css-block-", /\}/);
  1201. }
  1202. function addMarkdown() {
  1203. add(MDRules, "md-multiline-", /("""|''')/, []);
  1204. }
  1205. function addHtml() {
  1206. add(HTMLRules, "html-multiline-", /("""|''')/);
  1207. }
  1208. function add(Rules, strPrfx, rgxEnd, rootTokens, closeType) {
  1209. var next = "pop";
  1210. var tokens = rootTokens || [ "start" ];
  1211. if (tokens.length === 0) {
  1212. tokens = null;
  1213. }
  1214. if (/block|multiline/.test(strPrfx)) {
  1215. next = strPrfx + "end";
  1216. rules.$rules[next] = [
  1217. Token("empty", "", "start")
  1218. ];
  1219. }
  1220. rules.embedRules(
  1221. Rules
  1222. , strPrfx
  1223. , [ Token(closeType || token_RPARE, rgxEnd, next) ]
  1224. , tokens
  1225. , tokens == null ? true : false
  1226. );
  1227. }
  1228. this.normalizeRules();
  1229. }
  1230. oop.inherits(MaskHighlightRules, TextRules);
  1231. var Blocks = {
  1232. string: function(str, next){
  1233. var token = Token(
  1234. "string.start"
  1235. , str
  1236. , [
  1237. Token(token_LPARE + "." + token_ITALIC, /~\[/, Blocks.interpolation()),
  1238. Token("string.end", str, "pop"),
  1239. {
  1240. defaultToken: "string"
  1241. }
  1242. ]
  1243. , next
  1244. );
  1245. if (str.length === 1){
  1246. var escaped = Token("string.escape", "\\\\" + str);
  1247. token.push.unshift(escaped);
  1248. }
  1249. return token;
  1250. },
  1251. interpolation: function(){
  1252. return [
  1253. Token(token_UTIL, /\s*\w*\s*:/),
  1254. "js-interpolation-start"
  1255. ];
  1256. },
  1257. tagHead: function (rgx) {
  1258. return Token(token_ATTR, rgx, [
  1259. Token(token_ATTR, /[\w\-_]+/),
  1260. Token(token_LPARE + "." + token_ITALIC, /~\[/, Blocks.interpolation()),
  1261. Blocks.goUp()
  1262. ]);
  1263. },
  1264. tag: function () {
  1265. return {
  1266. token: 'tag',
  1267. onMatch : function(value) {
  1268. if (void 0 !== const_KEYWORDS[value])
  1269. return token_KEYWORD;
  1270. if (void 0 !== const_CONST[value])
  1271. return token_LANG;
  1272. if (void 0 !== const_FUNCTIONS[value])
  1273. return "support.function";
  1274. if (void 0 !== const_TAGS[value.toLowerCase()])
  1275. return token_TAG;
  1276. return token_COMPO;
  1277. },
  1278. regex : /([@\w\-_:+]+)|((^|\s)(?=\s*(\.|#)))/,
  1279. push: [
  1280. Blocks.tagHead(/\./) ,
  1281. Blocks.tagHead(/#/) ,
  1282. Blocks.expression(),
  1283. Blocks.attribute(),
  1284. Token(token_LPARE, /[;>{]/, "pop")
  1285. ]
  1286. };
  1287. },
  1288. syntax: function(rgx, next, type){
  1289. return {
  1290. token: token_LANG,
  1291. regex : rgx,
  1292. push: ({
  1293. "attr": [
  1294. next + "-start",
  1295. Token(token_PUNKT, /;/, "start")
  1296. ],
  1297. "multiline": [
  1298. Blocks.tagHead(/\./) ,
  1299. Blocks.tagHead(/#/) ,
  1300. Blocks.attribute(),
  1301. Blocks.expression(),
  1302. Token(token_LPARE, /[>\{]/),
  1303. Token(token_PUNKT, /;/, "start"),
  1304. Token(token_LPARE, /'''|"""/, [ next + "-start" ])
  1305. ],
  1306. "block": [
  1307. Blocks.tagHead(/\./) ,
  1308. Blocks.tagHead(/#/) ,
  1309. Blocks.attribute(),
  1310. Blocks.expression(),
  1311. Token(token_LPARE, /\{/, [ next + "-start" ])
  1312. ]
  1313. })[type]
  1314. };
  1315. },
  1316. attribute: function(){
  1317. return Token(function(value){
  1318. return /^x\-/.test(value)
  1319. ? token_ATTR + "." + token_BOLD
  1320. : token_ATTR;
  1321. }, /[\w_-]+/, [
  1322. Token(token_PUNKT, /\s*=\s*/, [
  1323. Blocks.string('"'),
  1324. Blocks.string("'"),
  1325. Blocks.word(),
  1326. Blocks.goUp()
  1327. ]),
  1328. Blocks.goUp()
  1329. ]);
  1330. },
  1331. expression: function(){
  1332. return Token(token_LPARE, /\(/, [ "js-statement-start" ]);
  1333. },
  1334. word: function(){
  1335. return Token("string", /[\w-_]+/);
  1336. },
  1337. goUp: function(){
  1338. return Token("text", "", "pop");
  1339. },
  1340. goStart: function(){
  1341. return Token("text", "", "start");
  1342. }
  1343. };
  1344. function Token(token, rgx, mix) {
  1345. var push, next, onMatch;
  1346. if (arguments.length === 4) {
  1347. push = mix;
  1348. next = arguments[3];
  1349. }
  1350. else if (typeof mix === "string") {
  1351. next = mix;
  1352. }
  1353. else {
  1354. push = mix;
  1355. }
  1356. if (typeof token === "function") {
  1357. onMatch = token;
  1358. token = "empty";
  1359. }
  1360. return {
  1361. token: token,
  1362. regex: rgx,
  1363. push: push,
  1364. next: next,
  1365. onMatch: onMatch
  1366. };
  1367. }
  1368. });
  1369. ace.define("ace/mode/matching_brace_outdent",[], function(require, exports, module) {
  1370. "use strict";
  1371. var Range = require("../range").Range;
  1372. var MatchingBraceOutdent = function() {};
  1373. (function() {
  1374. this.checkOutdent = function(line, input) {
  1375. if (! /^\s+$/.test(line))
  1376. return false;
  1377. return /^\s*\}/.test(input);
  1378. };
  1379. this.autoOutdent = function(doc, row) {
  1380. var line = doc.getLine(row);
  1381. var match = line.match(/^(\s*\})/);
  1382. if (!match) return 0;
  1383. var column = match[1].length;
  1384. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  1385. if (!openBracePos || openBracePos.row == row) return 0;
  1386. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  1387. doc.replace(new Range(row, 0, row, column-1), indent);
  1388. };
  1389. this.$getIndent = function(line) {
  1390. return line.match(/^\s*/)[0];
  1391. };
  1392. }).call(MatchingBraceOutdent.prototype);
  1393. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  1394. });
  1395. ace.define("ace/mode/behaviour/css",[], function(require, exports, module) {
  1396. "use strict";
  1397. var oop = require("../../lib/oop");
  1398. var Behaviour = require("../behaviour").Behaviour;
  1399. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1400. var TokenIterator = require("../../token_iterator").TokenIterator;
  1401. var CssBehaviour = function () {
  1402. this.inherit(CstyleBehaviour);
  1403. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1404. if (text === ':' && editor.selection.isEmpty()) {
  1405. var cursor = editor.getCursorPosition();
  1406. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1407. var token = iterator.getCurrentToken();
  1408. if (token && token.value.match(/\s+/)) {
  1409. token = iterator.stepBackward();
  1410. }
  1411. if (token && token.type === 'support.type') {
  1412. var line = session.doc.getLine(cursor.row);
  1413. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1414. if (rightChar === ':') {
  1415. return {
  1416. text: '',
  1417. selection: [1, 1]
  1418. };
  1419. }
  1420. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  1421. return {
  1422. text: ':;',
  1423. selection: [1, 1]
  1424. };
  1425. }
  1426. }
  1427. }
  1428. });
  1429. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1430. var selected = session.doc.getTextRange(range);
  1431. if (!range.isMultiLine() && selected === ':') {
  1432. var cursor = editor.getCursorPosition();
  1433. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1434. var token = iterator.getCurrentToken();
  1435. if (token && token.value.match(/\s+/)) {
  1436. token = iterator.stepBackward();
  1437. }
  1438. if (token && token.type === 'support.type') {
  1439. var line = session.doc.getLine(range.start.row);
  1440. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1441. if (rightChar === ';') {
  1442. range.end.column ++;
  1443. return range;
  1444. }
  1445. }
  1446. }
  1447. });
  1448. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1449. if (text === ';' && editor.selection.isEmpty()) {
  1450. var cursor = editor.getCursorPosition();
  1451. var line = session.doc.getLine(cursor.row);
  1452. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1453. if (rightChar === ';') {
  1454. return {
  1455. text: '',
  1456. selection: [1, 1]
  1457. };
  1458. }
  1459. }
  1460. });
  1461. this.add("!important", "insertion", function (state, action, editor, session, text) {
  1462. if (text === '!' && editor.selection.isEmpty()) {
  1463. var cursor = editor.getCursorPosition();
  1464. var line = session.doc.getLine(cursor.row);
  1465. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  1466. return {
  1467. text: '!important',
  1468. selection: [10, 10]
  1469. };
  1470. }
  1471. }
  1472. });
  1473. };
  1474. oop.inherits(CssBehaviour, CstyleBehaviour);
  1475. exports.CssBehaviour = CssBehaviour;
  1476. });
  1477. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  1478. "use strict";
  1479. var oop = require("../../lib/oop");
  1480. var Range = require("../../range").Range;
  1481. var BaseFoldMode = require("./fold_mode").FoldMode;
  1482. var FoldMode = exports.FoldMode = function(commentRegex) {
  1483. if (commentRegex) {
  1484. this.foldingStartMarker = new RegExp(
  1485. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  1486. );
  1487. this.foldingStopMarker = new RegExp(
  1488. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  1489. );
  1490. }
  1491. };
  1492. oop.inherits(FoldMode, BaseFoldMode);
  1493. (function() {
  1494. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  1495. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  1496. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  1497. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1498. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1499. this._getFoldWidgetBase = this.getFoldWidget;
  1500. this.getFoldWidget = function(session, foldStyle, row) {
  1501. var line = session.getLine(row);
  1502. if (this.singleLineBlockCommentRe.test(line)) {
  1503. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1504. return "";
  1505. }
  1506. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1507. if (!fw && this.startRegionRe.test(line))
  1508. return "start"; // lineCommentRegionStart
  1509. return fw;
  1510. };
  1511. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  1512. var line = session.getLine(row);
  1513. if (this.startRegionRe.test(line))
  1514. return this.getCommentRegionBlock(session, line, row);
  1515. var match = line.match(this.foldingStartMarker);
  1516. if (match) {
  1517. var i = match.index;
  1518. if (match[1])
  1519. return this.openingBracketBlock(session, match[1], row, i);
  1520. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1521. if (range && !range.isMultiLine()) {
  1522. if (forceMultiline) {
  1523. range = this.getSectionRange(session, row);
  1524. } else if (foldStyle != "all")
  1525. range = null;
  1526. }
  1527. return range;
  1528. }
  1529. if (foldStyle === "markbegin")
  1530. return;
  1531. var match = line.match(this.foldingStopMarker);
  1532. if (match) {
  1533. var i = match.index + match[0].length;
  1534. if (match[1])
  1535. return this.closingBracketBlock(session, match[1], row, i);
  1536. return session.getCommentFoldRange(row, i, -1);
  1537. }
  1538. };
  1539. this.getSectionRange = function(session, row) {
  1540. var line = session.getLine(row);
  1541. var startIndent = line.search(/\S/);
  1542. var startRow = row;
  1543. var startColumn = line.length;
  1544. row = row + 1;
  1545. var endRow = row;
  1546. var maxRow = session.getLength();
  1547. while (++row < maxRow) {
  1548. line = session.getLine(row);
  1549. var indent = line.search(/\S/);
  1550. if (indent === -1)
  1551. continue;
  1552. if (startIndent > indent)
  1553. break;
  1554. var subRange = this.getFoldWidgetRange(session, "all", row);
  1555. if (subRange) {
  1556. if (subRange.start.row <= startRow) {
  1557. break;
  1558. } else if (subRange.isMultiLine()) {
  1559. row = subRange.end.row;
  1560. } else if (startIndent == indent) {
  1561. break;
  1562. }
  1563. }
  1564. endRow = row;
  1565. }
  1566. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1567. };
  1568. this.getCommentRegionBlock = function(session, line, row) {
  1569. var startColumn = line.search(/\s*$/);
  1570. var maxRow = session.getLength();
  1571. var startRow = row;
  1572. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1573. var depth = 1;
  1574. while (++row < maxRow) {
  1575. line = session.getLine(row);
  1576. var m = re.exec(line);
  1577. if (!m) continue;
  1578. if (m[1]) depth--;
  1579. else depth++;
  1580. if (!depth) break;
  1581. }
  1582. var endRow = row;
  1583. if (endRow > startRow) {
  1584. return new Range(startRow, startColumn, endRow, line.length);
  1585. }
  1586. };
  1587. }).call(FoldMode.prototype);
  1588. });
  1589. ace.define("ace/mode/mask",[], function(require, exports, module) {
  1590. "use strict";
  1591. var oop = require("../lib/oop");
  1592. var TextMode = require("./text").Mode;
  1593. var MaskHighlightRules = require("./mask_highlight_rules").MaskHighlightRules;
  1594. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1595. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1596. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1597. var Mode = function() {
  1598. this.HighlightRules = MaskHighlightRules;
  1599. this.$outdent = new MatchingBraceOutdent();
  1600. this.$behaviour = new CssBehaviour();
  1601. this.foldingRules = new CStyleFoldMode();
  1602. };
  1603. oop.inherits(Mode, TextMode);
  1604. (function() {
  1605. this.lineCommentStart = "//";
  1606. this.blockComment = {start: "/*", end: "*/"};
  1607. this.getNextLineIndent = function(state, line, tab) {
  1608. var indent = this.$getIndent(line);
  1609. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1610. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1611. return indent;
  1612. }
  1613. var match = line.match(/^.*\{\s*$/);
  1614. if (match) {
  1615. indent += tab;
  1616. }
  1617. return indent;
  1618. };
  1619. this.checkOutdent = function(state, line, input) {
  1620. return this.$outdent.checkOutdent(line, input);
  1621. };
  1622. this.autoOutdent = function(state, doc, row) {
  1623. this.$outdent.autoOutdent(doc, row);
  1624. };
  1625. this.$id = "ace/mode/mask";
  1626. }).call(Mode.prototype);
  1627. exports.Mode = Mode;
  1628. });
  1629. (function() {
  1630. ace.require(["ace/mode/mask"], function(m) {
  1631. if (typeof module == "object" && typeof exports == "object" && module) {
  1632. module.exports = m;
  1633. }
  1634. });
  1635. })();