mode-soy_template.js 111 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846
  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/matching_brace_outdent",[], function(require, exports, module) {
  502. "use strict";
  503. var Range = require("../range").Range;
  504. var MatchingBraceOutdent = function() {};
  505. (function() {
  506. this.checkOutdent = function(line, input) {
  507. if (! /^\s+$/.test(line))
  508. return false;
  509. return /^\s*\}/.test(input);
  510. };
  511. this.autoOutdent = function(doc, row) {
  512. var line = doc.getLine(row);
  513. var match = line.match(/^(\s*\})/);
  514. if (!match) return 0;
  515. var column = match[1].length;
  516. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  517. if (!openBracePos || openBracePos.row == row) return 0;
  518. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  519. doc.replace(new Range(row, 0, row, column-1), indent);
  520. };
  521. this.$getIndent = function(line) {
  522. return line.match(/^\s*/)[0];
  523. };
  524. }).call(MatchingBraceOutdent.prototype);
  525. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  526. });
  527. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  528. "use strict";
  529. var oop = require("../../lib/oop");
  530. var Range = require("../../range").Range;
  531. var BaseFoldMode = require("./fold_mode").FoldMode;
  532. var FoldMode = exports.FoldMode = function(commentRegex) {
  533. if (commentRegex) {
  534. this.foldingStartMarker = new RegExp(
  535. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  536. );
  537. this.foldingStopMarker = new RegExp(
  538. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  539. );
  540. }
  541. };
  542. oop.inherits(FoldMode, BaseFoldMode);
  543. (function() {
  544. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  545. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  546. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  547. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  548. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  549. this._getFoldWidgetBase = this.getFoldWidget;
  550. this.getFoldWidget = function(session, foldStyle, row) {
  551. var line = session.getLine(row);
  552. if (this.singleLineBlockCommentRe.test(line)) {
  553. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  554. return "";
  555. }
  556. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  557. if (!fw && this.startRegionRe.test(line))
  558. return "start"; // lineCommentRegionStart
  559. return fw;
  560. };
  561. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  562. var line = session.getLine(row);
  563. if (this.startRegionRe.test(line))
  564. return this.getCommentRegionBlock(session, line, row);
  565. var match = line.match(this.foldingStartMarker);
  566. if (match) {
  567. var i = match.index;
  568. if (match[1])
  569. return this.openingBracketBlock(session, match[1], row, i);
  570. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  571. if (range && !range.isMultiLine()) {
  572. if (forceMultiline) {
  573. range = this.getSectionRange(session, row);
  574. } else if (foldStyle != "all")
  575. range = null;
  576. }
  577. return range;
  578. }
  579. if (foldStyle === "markbegin")
  580. return;
  581. var match = line.match(this.foldingStopMarker);
  582. if (match) {
  583. var i = match.index + match[0].length;
  584. if (match[1])
  585. return this.closingBracketBlock(session, match[1], row, i);
  586. return session.getCommentFoldRange(row, i, -1);
  587. }
  588. };
  589. this.getSectionRange = function(session, row) {
  590. var line = session.getLine(row);
  591. var startIndent = line.search(/\S/);
  592. var startRow = row;
  593. var startColumn = line.length;
  594. row = row + 1;
  595. var endRow = row;
  596. var maxRow = session.getLength();
  597. while (++row < maxRow) {
  598. line = session.getLine(row);
  599. var indent = line.search(/\S/);
  600. if (indent === -1)
  601. continue;
  602. if (startIndent > indent)
  603. break;
  604. var subRange = this.getFoldWidgetRange(session, "all", row);
  605. if (subRange) {
  606. if (subRange.start.row <= startRow) {
  607. break;
  608. } else if (subRange.isMultiLine()) {
  609. row = subRange.end.row;
  610. } else if (startIndent == indent) {
  611. break;
  612. }
  613. }
  614. endRow = row;
  615. }
  616. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  617. };
  618. this.getCommentRegionBlock = function(session, line, row) {
  619. var startColumn = line.search(/\s*$/);
  620. var maxRow = session.getLength();
  621. var startRow = row;
  622. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  623. var depth = 1;
  624. while (++row < maxRow) {
  625. line = session.getLine(row);
  626. var m = re.exec(line);
  627. if (!m) continue;
  628. if (m[1]) depth--;
  629. else depth++;
  630. if (!depth) break;
  631. }
  632. var endRow = row;
  633. if (endRow > startRow) {
  634. return new Range(startRow, startColumn, endRow, line.length);
  635. }
  636. };
  637. }).call(FoldMode.prototype);
  638. });
  639. ace.define("ace/mode/javascript",[], function(require, exports, module) {
  640. "use strict";
  641. var oop = require("../lib/oop");
  642. var TextMode = require("./text").Mode;
  643. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  644. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  645. var WorkerClient = require("../worker/worker_client").WorkerClient;
  646. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  647. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  648. var Mode = function() {
  649. this.HighlightRules = JavaScriptHighlightRules;
  650. this.$outdent = new MatchingBraceOutdent();
  651. this.$behaviour = new CstyleBehaviour();
  652. this.foldingRules = new CStyleFoldMode();
  653. };
  654. oop.inherits(Mode, TextMode);
  655. (function() {
  656. this.lineCommentStart = "//";
  657. this.blockComment = {start: "/*", end: "*/"};
  658. this.$quotes = {'"': '"', "'": "'", "`": "`"};
  659. this.getNextLineIndent = function(state, line, tab) {
  660. var indent = this.$getIndent(line);
  661. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  662. var tokens = tokenizedLine.tokens;
  663. var endState = tokenizedLine.state;
  664. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  665. return indent;
  666. }
  667. if (state == "start" || state == "no_regex") {
  668. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  669. if (match) {
  670. indent += tab;
  671. }
  672. } else if (state == "doc-start") {
  673. if (endState == "start" || endState == "no_regex") {
  674. return "";
  675. }
  676. var match = line.match(/^\s*(\/?)\*/);
  677. if (match) {
  678. if (match[1]) {
  679. indent += " ";
  680. }
  681. indent += "* ";
  682. }
  683. }
  684. return indent;
  685. };
  686. this.checkOutdent = function(state, line, input) {
  687. return this.$outdent.checkOutdent(line, input);
  688. };
  689. this.autoOutdent = function(state, doc, row) {
  690. this.$outdent.autoOutdent(doc, row);
  691. };
  692. this.createWorker = function(session) {
  693. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  694. worker.attachToDocument(session.getDocument());
  695. worker.on("annotate", function(results) {
  696. session.setAnnotations(results.data);
  697. });
  698. worker.on("terminate", function() {
  699. session.clearAnnotations();
  700. });
  701. return worker;
  702. };
  703. this.$id = "ace/mode/javascript";
  704. }).call(Mode.prototype);
  705. exports.Mode = Mode;
  706. });
  707. ace.define("ace/mode/css_highlight_rules",[], function(require, exports, module) {
  708. "use strict";
  709. var oop = require("../lib/oop");
  710. var lang = require("../lib/lang");
  711. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  712. 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";
  713. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  714. 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";
  715. 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";
  716. 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";
  717. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))";
  718. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  719. 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";
  720. var CssHighlightRules = function() {
  721. var keywordMapper = this.createKeywordMapper({
  722. "support.function": supportFunction,
  723. "support.constant": supportConstant,
  724. "support.type": supportType,
  725. "support.constant.color": supportConstantColor,
  726. "support.constant.fonts": supportConstantFonts
  727. }, "text", true);
  728. this.$rules = {
  729. "start" : [{
  730. include : ["strings", "url", "comments"]
  731. }, {
  732. token: "paren.lparen",
  733. regex: "\\{",
  734. next: "ruleset"
  735. }, {
  736. token: "paren.rparen",
  737. regex: "\\}"
  738. }, {
  739. token: "string",
  740. regex: "@(?!viewport)",
  741. next: "media"
  742. }, {
  743. token: "keyword",
  744. regex: "#[a-z0-9-_]+"
  745. }, {
  746. token: "keyword",
  747. regex: "%"
  748. }, {
  749. token: "variable",
  750. regex: "\\.[a-z0-9-_]+"
  751. }, {
  752. token: "string",
  753. regex: ":[a-z0-9-_]+"
  754. }, {
  755. token : "constant.numeric",
  756. regex : numRe
  757. }, {
  758. token: "constant",
  759. regex: "[a-z0-9-_]+"
  760. }, {
  761. caseInsensitive: true
  762. }],
  763. "media": [{
  764. include : ["strings", "url", "comments"]
  765. }, {
  766. token: "paren.lparen",
  767. regex: "\\{",
  768. next: "start"
  769. }, {
  770. token: "paren.rparen",
  771. regex: "\\}",
  772. next: "start"
  773. }, {
  774. token: "string",
  775. regex: ";",
  776. next: "start"
  777. }, {
  778. token: "keyword",
  779. regex: "(?:media|supports|document|charset|import|namespace|media|supports|document"
  780. + "|page|font|keyframes|viewport|counter-style|font-feature-values"
  781. + "|swash|ornaments|annotation|stylistic|styleset|character-variant)"
  782. }],
  783. "comments" : [{
  784. token: "comment", // multi line comment
  785. regex: "\\/\\*",
  786. push: [{
  787. token : "comment",
  788. regex : "\\*\\/",
  789. next : "pop"
  790. }, {
  791. defaultToken : "comment"
  792. }]
  793. }],
  794. "ruleset" : [{
  795. regex : "-(webkit|ms|moz|o)-",
  796. token : "text"
  797. }, {
  798. token : "punctuation.operator",
  799. regex : "[:;]"
  800. }, {
  801. token : "paren.rparen",
  802. regex : "\\}",
  803. next : "start"
  804. }, {
  805. include : ["strings", "url", "comments"]
  806. }, {
  807. token : ["constant.numeric", "keyword"],
  808. 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|%)"
  809. }, {
  810. token : "constant.numeric",
  811. regex : numRe
  812. }, {
  813. token : "constant.numeric", // hex6 color
  814. regex : "#[a-f0-9]{6}"
  815. }, {
  816. token : "constant.numeric", // hex3 color
  817. regex : "#[a-f0-9]{3}"
  818. }, {
  819. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  820. regex : pseudoElements
  821. }, {
  822. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  823. regex : pseudoClasses
  824. }, {
  825. include: "url"
  826. }, {
  827. token : keywordMapper,
  828. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  829. }, {
  830. caseInsensitive: true
  831. }],
  832. url: [{
  833. token : "support.function",
  834. regex : "(?:url(:?-prefix)?|domain|regexp)\\(",
  835. push: [{
  836. token : "support.function",
  837. regex : "\\)",
  838. next : "pop"
  839. }, {
  840. defaultToken: "string"
  841. }]
  842. }],
  843. strings: [{
  844. token : "string.start",
  845. regex : "'",
  846. push : [{
  847. token : "string.end",
  848. regex : "'|$",
  849. next: "pop"
  850. }, {
  851. include : "escapes"
  852. }, {
  853. token : "constant.language.escape",
  854. regex : /\\$/,
  855. consumeLineEnd: true
  856. }, {
  857. defaultToken: "string"
  858. }]
  859. }, {
  860. token : "string.start",
  861. regex : '"',
  862. push : [{
  863. token : "string.end",
  864. regex : '"|$',
  865. next: "pop"
  866. }, {
  867. include : "escapes"
  868. }, {
  869. token : "constant.language.escape",
  870. regex : /\\$/,
  871. consumeLineEnd: true
  872. }, {
  873. defaultToken: "string"
  874. }]
  875. }],
  876. escapes: [{
  877. token : "constant.language.escape",
  878. regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/
  879. }]
  880. };
  881. this.normalizeRules();
  882. };
  883. oop.inherits(CssHighlightRules, TextHighlightRules);
  884. exports.CssHighlightRules = CssHighlightRules;
  885. });
  886. ace.define("ace/mode/css_completions",[], function(require, exports, module) {
  887. "use strict";
  888. var propertyMap = {
  889. "background": {"#$0": 1},
  890. "background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
  891. "background-image": {"url('/$0')": 1},
  892. "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
  893. "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
  894. "background-attachment": {"scroll": 1, "fixed": 1},
  895. "background-size": {"cover": 1, "contain": 1},
  896. "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
  897. "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
  898. "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
  899. "border-color": {"#$0": 1},
  900. "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
  901. "border-collapse": {"collapse": 1, "separate": 1},
  902. "bottom": {"px": 1, "em": 1, "%": 1},
  903. "clear": {"left": 1, "right": 1, "both": 1, "none": 1},
  904. "color": {"#$0": 1, "rgb(#$00,0,0)": 1},
  905. "cursor": {"default": 1, "pointer": 1, "move": 1, "text": 1, "wait": 1, "help": 1, "progress": 1, "n-resize": 1, "ne-resize": 1, "e-resize": 1, "se-resize": 1, "s-resize": 1, "sw-resize": 1, "w-resize": 1, "nw-resize": 1},
  906. "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
  907. "empty-cells": {"show": 1, "hide": 1},
  908. "float": {"left": 1, "right": 1, "none": 1},
  909. "font-family": {"Arial":2,"Comic Sans MS":2,"Consolas":2,"Courier New":2,"Courier":2,"Georgia":2,"Monospace":2,"Sans-Serif":2, "Segoe UI":2,"Tahoma":2,"Times New Roman":2,"Trebuchet MS":2,"Verdana": 1},
  910. "font-size": {"px": 1, "em": 1, "%": 1},
  911. "font-weight": {"bold": 1, "normal": 1},
  912. "font-style": {"italic": 1, "normal": 1},
  913. "font-variant": {"normal": 1, "small-caps": 1},
  914. "height": {"px": 1, "em": 1, "%": 1},
  915. "left": {"px": 1, "em": 1, "%": 1},
  916. "letter-spacing": {"normal": 1},
  917. "line-height": {"normal": 1},
  918. "list-style-type": {"none": 1, "disc": 1, "circle": 1, "square": 1, "decimal": 1, "decimal-leading-zero": 1, "lower-roman": 1, "upper-roman": 1, "lower-greek": 1, "lower-latin": 1, "upper-latin": 1, "georgian": 1, "lower-alpha": 1, "upper-alpha": 1},
  919. "margin": {"px": 1, "em": 1, "%": 1},
  920. "margin-right": {"px": 1, "em": 1, "%": 1},
  921. "margin-left": {"px": 1, "em": 1, "%": 1},
  922. "margin-top": {"px": 1, "em": 1, "%": 1},
  923. "margin-bottom": {"px": 1, "em": 1, "%": 1},
  924. "max-height": {"px": 1, "em": 1, "%": 1},
  925. "max-width": {"px": 1, "em": 1, "%": 1},
  926. "min-height": {"px": 1, "em": 1, "%": 1},
  927. "min-width": {"px": 1, "em": 1, "%": 1},
  928. "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  929. "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  930. "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  931. "padding": {"px": 1, "em": 1, "%": 1},
  932. "padding-top": {"px": 1, "em": 1, "%": 1},
  933. "padding-right": {"px": 1, "em": 1, "%": 1},
  934. "padding-bottom": {"px": 1, "em": 1, "%": 1},
  935. "padding-left": {"px": 1, "em": 1, "%": 1},
  936. "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  937. "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  938. "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
  939. "right": {"px": 1, "em": 1, "%": 1},
  940. "table-layout": {"fixed": 1, "auto": 1},
  941. "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
  942. "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
  943. "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
  944. "top": {"px": 1, "em": 1, "%": 1},
  945. "vertical-align": {"top": 1, "bottom": 1},
  946. "visibility": {"hidden": 1, "visible": 1},
  947. "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
  948. "width": {"px": 1, "em": 1, "%": 1},
  949. "word-spacing": {"normal": 1},
  950. "filter": {"alpha(opacity=$0100)": 1},
  951. "text-shadow": {"$02px 2px 2px #777": 1},
  952. "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
  953. "-moz-border-radius": 1,
  954. "-moz-border-radius-topright": 1,
  955. "-moz-border-radius-bottomright": 1,
  956. "-moz-border-radius-topleft": 1,
  957. "-moz-border-radius-bottomleft": 1,
  958. "-webkit-border-radius": 1,
  959. "-webkit-border-top-right-radius": 1,
  960. "-webkit-border-top-left-radius": 1,
  961. "-webkit-border-bottom-right-radius": 1,
  962. "-webkit-border-bottom-left-radius": 1,
  963. "-moz-box-shadow": 1,
  964. "-webkit-box-shadow": 1,
  965. "transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  966. "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  967. "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
  968. };
  969. var CssCompletions = function() {
  970. };
  971. (function() {
  972. this.completionsDefined = false;
  973. this.defineCompletions = function() {
  974. if (document) {
  975. var style = document.createElement('c').style;
  976. for (var i in style) {
  977. if (typeof style[i] !== 'string')
  978. continue;
  979. var name = i.replace(/[A-Z]/g, function(x) {
  980. return '-' + x.toLowerCase();
  981. });
  982. if (!propertyMap.hasOwnProperty(name))
  983. propertyMap[name] = 1;
  984. }
  985. }
  986. this.completionsDefined = true;
  987. };
  988. this.getCompletions = function(state, session, pos, prefix) {
  989. if (!this.completionsDefined) {
  990. this.defineCompletions();
  991. }
  992. var token = session.getTokenAt(pos.row, pos.column);
  993. if (!token)
  994. return [];
  995. if (state==='ruleset'){
  996. var line = session.getLine(pos.row).substr(0, pos.column);
  997. if (/:[^;]+$/.test(line)) {
  998. /([\w\-]+):[^:]*$/.test(line);
  999. return this.getPropertyValueCompletions(state, session, pos, prefix);
  1000. } else {
  1001. return this.getPropertyCompletions(state, session, pos, prefix);
  1002. }
  1003. }
  1004. return [];
  1005. };
  1006. this.getPropertyCompletions = function(state, session, pos, prefix) {
  1007. var properties = Object.keys(propertyMap);
  1008. return properties.map(function(property){
  1009. return {
  1010. caption: property,
  1011. snippet: property + ': $0;',
  1012. meta: "property",
  1013. score: Number.MAX_VALUE
  1014. };
  1015. });
  1016. };
  1017. this.getPropertyValueCompletions = function(state, session, pos, prefix) {
  1018. var line = session.getLine(pos.row).substr(0, pos.column);
  1019. var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
  1020. if (!property)
  1021. return [];
  1022. var values = [];
  1023. if (property in propertyMap && typeof propertyMap[property] === "object") {
  1024. values = Object.keys(propertyMap[property]);
  1025. }
  1026. return values.map(function(value){
  1027. return {
  1028. caption: value,
  1029. snippet: value,
  1030. meta: "property value",
  1031. score: Number.MAX_VALUE
  1032. };
  1033. });
  1034. };
  1035. }).call(CssCompletions.prototype);
  1036. exports.CssCompletions = CssCompletions;
  1037. });
  1038. ace.define("ace/mode/behaviour/css",[], function(require, exports, module) {
  1039. "use strict";
  1040. var oop = require("../../lib/oop");
  1041. var Behaviour = require("../behaviour").Behaviour;
  1042. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1043. var TokenIterator = require("../../token_iterator").TokenIterator;
  1044. var CssBehaviour = function () {
  1045. this.inherit(CstyleBehaviour);
  1046. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1047. if (text === ':' && editor.selection.isEmpty()) {
  1048. var cursor = editor.getCursorPosition();
  1049. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1050. var token = iterator.getCurrentToken();
  1051. if (token && token.value.match(/\s+/)) {
  1052. token = iterator.stepBackward();
  1053. }
  1054. if (token && token.type === 'support.type') {
  1055. var line = session.doc.getLine(cursor.row);
  1056. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1057. if (rightChar === ':') {
  1058. return {
  1059. text: '',
  1060. selection: [1, 1]
  1061. };
  1062. }
  1063. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  1064. return {
  1065. text: ':;',
  1066. selection: [1, 1]
  1067. };
  1068. }
  1069. }
  1070. }
  1071. });
  1072. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1073. var selected = session.doc.getTextRange(range);
  1074. if (!range.isMultiLine() && selected === ':') {
  1075. var cursor = editor.getCursorPosition();
  1076. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1077. var token = iterator.getCurrentToken();
  1078. if (token && token.value.match(/\s+/)) {
  1079. token = iterator.stepBackward();
  1080. }
  1081. if (token && token.type === 'support.type') {
  1082. var line = session.doc.getLine(range.start.row);
  1083. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1084. if (rightChar === ';') {
  1085. range.end.column ++;
  1086. return range;
  1087. }
  1088. }
  1089. }
  1090. });
  1091. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1092. if (text === ';' && editor.selection.isEmpty()) {
  1093. var cursor = editor.getCursorPosition();
  1094. var line = session.doc.getLine(cursor.row);
  1095. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1096. if (rightChar === ';') {
  1097. return {
  1098. text: '',
  1099. selection: [1, 1]
  1100. };
  1101. }
  1102. }
  1103. });
  1104. this.add("!important", "insertion", function (state, action, editor, session, text) {
  1105. if (text === '!' && editor.selection.isEmpty()) {
  1106. var cursor = editor.getCursorPosition();
  1107. var line = session.doc.getLine(cursor.row);
  1108. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  1109. return {
  1110. text: '!important',
  1111. selection: [10, 10]
  1112. };
  1113. }
  1114. }
  1115. });
  1116. };
  1117. oop.inherits(CssBehaviour, CstyleBehaviour);
  1118. exports.CssBehaviour = CssBehaviour;
  1119. });
  1120. ace.define("ace/mode/css",[], function(require, exports, module) {
  1121. "use strict";
  1122. var oop = require("../lib/oop");
  1123. var TextMode = require("./text").Mode;
  1124. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1125. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1126. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1127. var CssCompletions = require("./css_completions").CssCompletions;
  1128. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1129. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1130. var Mode = function() {
  1131. this.HighlightRules = CssHighlightRules;
  1132. this.$outdent = new MatchingBraceOutdent();
  1133. this.$behaviour = new CssBehaviour();
  1134. this.$completer = new CssCompletions();
  1135. this.foldingRules = new CStyleFoldMode();
  1136. };
  1137. oop.inherits(Mode, TextMode);
  1138. (function() {
  1139. this.foldingRules = "cStyle";
  1140. this.blockComment = {start: "/*", end: "*/"};
  1141. this.getNextLineIndent = function(state, line, tab) {
  1142. var indent = this.$getIndent(line);
  1143. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1144. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1145. return indent;
  1146. }
  1147. var match = line.match(/^.*\{\s*$/);
  1148. if (match) {
  1149. indent += tab;
  1150. }
  1151. return indent;
  1152. };
  1153. this.checkOutdent = function(state, line, input) {
  1154. return this.$outdent.checkOutdent(line, input);
  1155. };
  1156. this.autoOutdent = function(state, doc, row) {
  1157. this.$outdent.autoOutdent(doc, row);
  1158. };
  1159. this.getCompletions = function(state, session, pos, prefix) {
  1160. return this.$completer.getCompletions(state, session, pos, prefix);
  1161. };
  1162. this.createWorker = function(session) {
  1163. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  1164. worker.attachToDocument(session.getDocument());
  1165. worker.on("annotate", function(e) {
  1166. session.setAnnotations(e.data);
  1167. });
  1168. worker.on("terminate", function() {
  1169. session.clearAnnotations();
  1170. });
  1171. return worker;
  1172. };
  1173. this.$id = "ace/mode/css";
  1174. }).call(Mode.prototype);
  1175. exports.Mode = Mode;
  1176. });
  1177. ace.define("ace/mode/xml_highlight_rules",[], function(require, exports, module) {
  1178. "use strict";
  1179. var oop = require("../lib/oop");
  1180. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1181. var XmlHighlightRules = function(normalize) {
  1182. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  1183. this.$rules = {
  1184. start : [
  1185. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  1186. {
  1187. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  1188. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction"
  1189. },
  1190. {token : "comment.start.xml", regex : "<\\!--", next : "comment"},
  1191. {
  1192. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  1193. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  1194. },
  1195. {include : "tag"},
  1196. {token : "text.end-tag-open.xml", regex: "</"},
  1197. {token : "text.tag-open.xml", regex: "<"},
  1198. {include : "reference"},
  1199. {defaultToken : "text.xml"}
  1200. ],
  1201. processing_instruction : [{
  1202. token : "entity.other.attribute-name.decl-attribute-name.xml",
  1203. regex : tagRegex
  1204. }, {
  1205. token : "keyword.operator.decl-attribute-equals.xml",
  1206. regex : "="
  1207. }, {
  1208. include: "whitespace"
  1209. }, {
  1210. include: "string"
  1211. }, {
  1212. token : "punctuation.xml-decl.xml",
  1213. regex : "\\?>",
  1214. next : "start"
  1215. }],
  1216. doctype : [
  1217. {include : "whitespace"},
  1218. {include : "string"},
  1219. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  1220. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  1221. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  1222. ],
  1223. int_subset : [{
  1224. token : "text.xml",
  1225. regex : "\\s+"
  1226. }, {
  1227. token: "punctuation.int-subset.xml",
  1228. regex: "]",
  1229. next: "pop"
  1230. }, {
  1231. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  1232. regex : "(<\\!)(" + tagRegex + ")",
  1233. push : [{
  1234. token : "text",
  1235. regex : "\\s+"
  1236. },
  1237. {
  1238. token : "punctuation.markup-decl.xml",
  1239. regex : ">",
  1240. next : "pop"
  1241. },
  1242. {include : "string"}]
  1243. }],
  1244. cdata : [
  1245. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  1246. {token : "text.xml", regex : "\\s+"},
  1247. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  1248. ],
  1249. comment : [
  1250. {token : "comment.end.xml", regex : "-->", next : "start"},
  1251. {defaultToken : "comment.xml"}
  1252. ],
  1253. reference : [{
  1254. token : "constant.language.escape.reference.xml",
  1255. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1256. }],
  1257. attr_reference : [{
  1258. token : "constant.language.escape.reference.attribute-value.xml",
  1259. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1260. }],
  1261. tag : [{
  1262. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  1263. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  1264. next: [
  1265. {include : "attributes"},
  1266. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1267. ]
  1268. }],
  1269. tag_whitespace : [
  1270. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  1271. ],
  1272. whitespace : [
  1273. {token : "text.whitespace.xml", regex : "\\s+"}
  1274. ],
  1275. string: [{
  1276. token : "string.xml",
  1277. regex : "'",
  1278. push : [
  1279. {token : "string.xml", regex: "'", next: "pop"},
  1280. {defaultToken : "string.xml"}
  1281. ]
  1282. }, {
  1283. token : "string.xml",
  1284. regex : '"',
  1285. push : [
  1286. {token : "string.xml", regex: '"', next: "pop"},
  1287. {defaultToken : "string.xml"}
  1288. ]
  1289. }],
  1290. attributes: [{
  1291. token : "entity.other.attribute-name.xml",
  1292. regex : tagRegex
  1293. }, {
  1294. token : "keyword.operator.attribute-equals.xml",
  1295. regex : "="
  1296. }, {
  1297. include: "tag_whitespace"
  1298. }, {
  1299. include: "attribute_value"
  1300. }],
  1301. attribute_value: [{
  1302. token : "string.attribute-value.xml",
  1303. regex : "'",
  1304. push : [
  1305. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  1306. {include : "attr_reference"},
  1307. {defaultToken : "string.attribute-value.xml"}
  1308. ]
  1309. }, {
  1310. token : "string.attribute-value.xml",
  1311. regex : '"',
  1312. push : [
  1313. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  1314. {include : "attr_reference"},
  1315. {defaultToken : "string.attribute-value.xml"}
  1316. ]
  1317. }]
  1318. };
  1319. if (this.constructor === XmlHighlightRules)
  1320. this.normalizeRules();
  1321. };
  1322. (function() {
  1323. this.embedTagRules = function(HighlightRules, prefix, tag){
  1324. this.$rules.tag.unshift({
  1325. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  1326. regex : "(<)(" + tag + "(?=\\s|>|$))",
  1327. next: [
  1328. {include : "attributes"},
  1329. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  1330. ]
  1331. });
  1332. this.$rules[tag + "-end"] = [
  1333. {include : "attributes"},
  1334. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  1335. onMatch : function(value, currentState, stack) {
  1336. stack.splice(0);
  1337. return this.token;
  1338. }}
  1339. ];
  1340. this.embedRules(HighlightRules, prefix, [{
  1341. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  1342. regex : "(</)(" + tag + "(?=\\s|>|$))",
  1343. next: tag + "-end"
  1344. }, {
  1345. token: "string.cdata.xml",
  1346. regex : "<\\!\\[CDATA\\["
  1347. }, {
  1348. token: "string.cdata.xml",
  1349. regex : "\\]\\]>"
  1350. }]);
  1351. };
  1352. }).call(TextHighlightRules.prototype);
  1353. oop.inherits(XmlHighlightRules, TextHighlightRules);
  1354. exports.XmlHighlightRules = XmlHighlightRules;
  1355. });
  1356. ace.define("ace/mode/html_highlight_rules",[], function(require, exports, module) {
  1357. "use strict";
  1358. var oop = require("../lib/oop");
  1359. var lang = require("../lib/lang");
  1360. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1361. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1362. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1363. var tagMap = lang.createMap({
  1364. a : 'anchor',
  1365. button : 'form',
  1366. form : 'form',
  1367. img : 'image',
  1368. input : 'form',
  1369. label : 'form',
  1370. option : 'form',
  1371. script : 'script',
  1372. select : 'form',
  1373. textarea : 'form',
  1374. style : 'style',
  1375. table : 'table',
  1376. tbody : 'table',
  1377. td : 'table',
  1378. tfoot : 'table',
  1379. th : 'table',
  1380. tr : 'table'
  1381. });
  1382. var HtmlHighlightRules = function() {
  1383. XmlHighlightRules.call(this);
  1384. this.addRules({
  1385. attributes: [{
  1386. include : "tag_whitespace"
  1387. }, {
  1388. token : "entity.other.attribute-name.xml",
  1389. regex : "[-_a-zA-Z0-9:.]+"
  1390. }, {
  1391. token : "keyword.operator.attribute-equals.xml",
  1392. regex : "=",
  1393. push : [{
  1394. include: "tag_whitespace"
  1395. }, {
  1396. token : "string.unquoted.attribute-value.html",
  1397. regex : "[^<>='\"`\\s]+",
  1398. next : "pop"
  1399. }, {
  1400. token : "empty",
  1401. regex : "",
  1402. next : "pop"
  1403. }]
  1404. }, {
  1405. include : "attribute_value"
  1406. }],
  1407. tag: [{
  1408. token : function(start, tag) {
  1409. var group = tagMap[tag];
  1410. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  1411. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  1412. },
  1413. regex : "(</?)([-_a-zA-Z0-9:.]+)",
  1414. next: "tag_stuff"
  1415. }],
  1416. tag_stuff: [
  1417. {include : "attributes"},
  1418. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1419. ]
  1420. });
  1421. this.embedTagRules(CssHighlightRules, "css-", "style");
  1422. this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script");
  1423. if (this.constructor === HtmlHighlightRules)
  1424. this.normalizeRules();
  1425. };
  1426. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  1427. exports.HtmlHighlightRules = HtmlHighlightRules;
  1428. });
  1429. ace.define("ace/mode/behaviour/xml",[], function(require, exports, module) {
  1430. "use strict";
  1431. var oop = require("../../lib/oop");
  1432. var Behaviour = require("../behaviour").Behaviour;
  1433. var TokenIterator = require("../../token_iterator").TokenIterator;
  1434. var lang = require("../../lib/lang");
  1435. function is(token, type) {
  1436. return token && token.type.lastIndexOf(type + ".xml") > -1;
  1437. }
  1438. var XmlBehaviour = function () {
  1439. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  1440. if (text == '"' || text == "'") {
  1441. var quote = text;
  1442. var selected = session.doc.getTextRange(editor.getSelectionRange());
  1443. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  1444. return {
  1445. text: quote + selected + quote,
  1446. selection: false
  1447. };
  1448. }
  1449. var cursor = editor.getCursorPosition();
  1450. var line = session.doc.getLine(cursor.row);
  1451. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1452. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1453. var token = iterator.getCurrentToken();
  1454. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  1455. return {
  1456. text: "",
  1457. selection: [1, 1]
  1458. };
  1459. }
  1460. if (!token)
  1461. token = iterator.stepBackward();
  1462. if (!token)
  1463. return;
  1464. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  1465. token = iterator.stepBackward();
  1466. }
  1467. var rightSpace = !rightChar || rightChar.match(/\s/);
  1468. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  1469. return {
  1470. text: quote + quote,
  1471. selection: [1, 1]
  1472. };
  1473. }
  1474. }
  1475. });
  1476. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  1477. var selected = session.doc.getTextRange(range);
  1478. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  1479. var line = session.doc.getLine(range.start.row);
  1480. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1481. if (rightChar == selected) {
  1482. range.end.column++;
  1483. return range;
  1484. }
  1485. }
  1486. });
  1487. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  1488. if (text == '>') {
  1489. var position = editor.getSelectionRange().start;
  1490. var iterator = new TokenIterator(session, position.row, position.column);
  1491. var token = iterator.getCurrentToken() || iterator.stepBackward();
  1492. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  1493. return;
  1494. if (is(token, "reference.attribute-value"))
  1495. return;
  1496. if (is(token, "attribute-value")) {
  1497. var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
  1498. if (position.column < tokenEndColumn)
  1499. return;
  1500. if (position.column == tokenEndColumn) {
  1501. var nextToken = iterator.stepForward();
  1502. if (nextToken && is(nextToken, "attribute-value"))
  1503. return;
  1504. iterator.stepBackward();
  1505. }
  1506. }
  1507. if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
  1508. return;
  1509. while (!is(token, "tag-name")) {
  1510. token = iterator.stepBackward();
  1511. if (token.value == "<") {
  1512. token = iterator.stepForward();
  1513. break;
  1514. }
  1515. }
  1516. var tokenRow = iterator.getCurrentTokenRow();
  1517. var tokenColumn = iterator.getCurrentTokenColumn();
  1518. if (is(iterator.stepBackward(), "end-tag-open"))
  1519. return;
  1520. var element = token.value;
  1521. if (tokenRow == position.row)
  1522. element = element.substring(0, position.column - tokenColumn);
  1523. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  1524. return;
  1525. return {
  1526. text: ">" + "</" + element + ">",
  1527. selection: [1, 1]
  1528. };
  1529. }
  1530. });
  1531. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  1532. if (text == "\n") {
  1533. var cursor = editor.getCursorPosition();
  1534. var line = session.getLine(cursor.row);
  1535. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1536. var token = iterator.getCurrentToken();
  1537. if (token && token.type.indexOf("tag-close") !== -1) {
  1538. if (token.value == "/>")
  1539. return;
  1540. while (token && token.type.indexOf("tag-name") === -1) {
  1541. token = iterator.stepBackward();
  1542. }
  1543. if (!token) {
  1544. return;
  1545. }
  1546. var tag = token.value;
  1547. var row = iterator.getCurrentTokenRow();
  1548. token = iterator.stepBackward();
  1549. if (!token || token.type.indexOf("end-tag") !== -1) {
  1550. return;
  1551. }
  1552. if (this.voidElements && !this.voidElements[tag]) {
  1553. var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
  1554. var line = session.getLine(row);
  1555. var nextIndent = this.$getIndent(line);
  1556. var indent = nextIndent + session.getTabString();
  1557. if (nextToken && nextToken.value === "</") {
  1558. return {
  1559. text: "\n" + indent + "\n" + nextIndent,
  1560. selection: [1, indent.length, 1, indent.length]
  1561. };
  1562. } else {
  1563. return {
  1564. text: "\n" + indent
  1565. };
  1566. }
  1567. }
  1568. }
  1569. }
  1570. });
  1571. };
  1572. oop.inherits(XmlBehaviour, Behaviour);
  1573. exports.XmlBehaviour = XmlBehaviour;
  1574. });
  1575. ace.define("ace/mode/folding/mixed",[], function(require, exports, module) {
  1576. "use strict";
  1577. var oop = require("../../lib/oop");
  1578. var BaseFoldMode = require("./fold_mode").FoldMode;
  1579. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1580. this.defaultMode = defaultMode;
  1581. this.subModes = subModes;
  1582. };
  1583. oop.inherits(FoldMode, BaseFoldMode);
  1584. (function() {
  1585. this.$getMode = function(state) {
  1586. if (typeof state != "string")
  1587. state = state[0];
  1588. for (var key in this.subModes) {
  1589. if (state.indexOf(key) === 0)
  1590. return this.subModes[key];
  1591. }
  1592. return null;
  1593. };
  1594. this.$tryMode = function(state, session, foldStyle, row) {
  1595. var mode = this.$getMode(state);
  1596. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1597. };
  1598. this.getFoldWidget = function(session, foldStyle, row) {
  1599. return (
  1600. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1601. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1602. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1603. );
  1604. };
  1605. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1606. var mode = this.$getMode(session.getState(row-1));
  1607. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1608. mode = this.$getMode(session.getState(row));
  1609. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1610. mode = this.defaultMode;
  1611. return mode.getFoldWidgetRange(session, foldStyle, row);
  1612. };
  1613. }).call(FoldMode.prototype);
  1614. });
  1615. ace.define("ace/mode/folding/xml",[], function(require, exports, module) {
  1616. "use strict";
  1617. var oop = require("../../lib/oop");
  1618. var lang = require("../../lib/lang");
  1619. var Range = require("../../range").Range;
  1620. var BaseFoldMode = require("./fold_mode").FoldMode;
  1621. var TokenIterator = require("../../token_iterator").TokenIterator;
  1622. var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
  1623. BaseFoldMode.call(this);
  1624. this.voidElements = voidElements || {};
  1625. this.optionalEndTags = oop.mixin({}, this.voidElements);
  1626. if (optionalEndTags)
  1627. oop.mixin(this.optionalEndTags, optionalEndTags);
  1628. };
  1629. oop.inherits(FoldMode, BaseFoldMode);
  1630. var Tag = function() {
  1631. this.tagName = "";
  1632. this.closing = false;
  1633. this.selfClosing = false;
  1634. this.start = {row: 0, column: 0};
  1635. this.end = {row: 0, column: 0};
  1636. };
  1637. function is(token, type) {
  1638. return token.type.lastIndexOf(type + ".xml") > -1;
  1639. }
  1640. (function() {
  1641. this.getFoldWidget = function(session, foldStyle, row) {
  1642. var tag = this._getFirstTagInLine(session, row);
  1643. if (!tag)
  1644. return this.getCommentFoldWidget(session, row);
  1645. if (tag.closing || (!tag.tagName && tag.selfClosing))
  1646. return foldStyle == "markbeginend" ? "end" : "";
  1647. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  1648. return "";
  1649. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  1650. return "";
  1651. return "start";
  1652. };
  1653. this.getCommentFoldWidget = function(session, row) {
  1654. if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
  1655. return "start";
  1656. return "";
  1657. };
  1658. this._getFirstTagInLine = function(session, row) {
  1659. var tokens = session.getTokens(row);
  1660. var tag = new Tag();
  1661. for (var i = 0; i < tokens.length; i++) {
  1662. var token = tokens[i];
  1663. if (is(token, "tag-open")) {
  1664. tag.end.column = tag.start.column + token.value.length;
  1665. tag.closing = is(token, "end-tag-open");
  1666. token = tokens[++i];
  1667. if (!token)
  1668. return null;
  1669. tag.tagName = token.value;
  1670. tag.end.column += token.value.length;
  1671. for (i++; i < tokens.length; i++) {
  1672. token = tokens[i];
  1673. tag.end.column += token.value.length;
  1674. if (is(token, "tag-close")) {
  1675. tag.selfClosing = token.value == '/>';
  1676. break;
  1677. }
  1678. }
  1679. return tag;
  1680. } else if (is(token, "tag-close")) {
  1681. tag.selfClosing = token.value == '/>';
  1682. return tag;
  1683. }
  1684. tag.start.column += token.value.length;
  1685. }
  1686. return null;
  1687. };
  1688. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  1689. var tokens = session.getTokens(row);
  1690. var column = 0;
  1691. for (var i = 0; i < tokens.length; i++) {
  1692. var token = tokens[i];
  1693. column += token.value.length;
  1694. if (column < startColumn)
  1695. continue;
  1696. if (is(token, "end-tag-open")) {
  1697. token = tokens[i + 1];
  1698. if (token && token.value == tagName)
  1699. return true;
  1700. }
  1701. }
  1702. return false;
  1703. };
  1704. this._readTagForward = function(iterator) {
  1705. var token = iterator.getCurrentToken();
  1706. if (!token)
  1707. return null;
  1708. var tag = new Tag();
  1709. do {
  1710. if (is(token, "tag-open")) {
  1711. tag.closing = is(token, "end-tag-open");
  1712. tag.start.row = iterator.getCurrentTokenRow();
  1713. tag.start.column = iterator.getCurrentTokenColumn();
  1714. } else if (is(token, "tag-name")) {
  1715. tag.tagName = token.value;
  1716. } else if (is(token, "tag-close")) {
  1717. tag.selfClosing = token.value == "/>";
  1718. tag.end.row = iterator.getCurrentTokenRow();
  1719. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1720. iterator.stepForward();
  1721. return tag;
  1722. }
  1723. } while(token = iterator.stepForward());
  1724. return null;
  1725. };
  1726. this._readTagBackward = function(iterator) {
  1727. var token = iterator.getCurrentToken();
  1728. if (!token)
  1729. return null;
  1730. var tag = new Tag();
  1731. do {
  1732. if (is(token, "tag-open")) {
  1733. tag.closing = is(token, "end-tag-open");
  1734. tag.start.row = iterator.getCurrentTokenRow();
  1735. tag.start.column = iterator.getCurrentTokenColumn();
  1736. iterator.stepBackward();
  1737. return tag;
  1738. } else if (is(token, "tag-name")) {
  1739. tag.tagName = token.value;
  1740. } else if (is(token, "tag-close")) {
  1741. tag.selfClosing = token.value == "/>";
  1742. tag.end.row = iterator.getCurrentTokenRow();
  1743. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1744. }
  1745. } while(token = iterator.stepBackward());
  1746. return null;
  1747. };
  1748. this._pop = function(stack, tag) {
  1749. while (stack.length) {
  1750. var top = stack[stack.length-1];
  1751. if (!tag || top.tagName == tag.tagName) {
  1752. return stack.pop();
  1753. }
  1754. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  1755. stack.pop();
  1756. continue;
  1757. } else {
  1758. return null;
  1759. }
  1760. }
  1761. };
  1762. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1763. var firstTag = this._getFirstTagInLine(session, row);
  1764. if (!firstTag) {
  1765. return this.getCommentFoldWidget(session, row)
  1766. && session.getCommentFoldRange(row, session.getLine(row).length);
  1767. }
  1768. var isBackward = firstTag.closing || firstTag.selfClosing;
  1769. var stack = [];
  1770. var tag;
  1771. if (!isBackward) {
  1772. var iterator = new TokenIterator(session, row, firstTag.start.column);
  1773. var start = {
  1774. row: row,
  1775. column: firstTag.start.column + firstTag.tagName.length + 2
  1776. };
  1777. if (firstTag.start.row == firstTag.end.row)
  1778. start.column = firstTag.end.column;
  1779. while (tag = this._readTagForward(iterator)) {
  1780. if (tag.selfClosing) {
  1781. if (!stack.length) {
  1782. tag.start.column += tag.tagName.length + 2;
  1783. tag.end.column -= 2;
  1784. return Range.fromPoints(tag.start, tag.end);
  1785. } else
  1786. continue;
  1787. }
  1788. if (tag.closing) {
  1789. this._pop(stack, tag);
  1790. if (stack.length == 0)
  1791. return Range.fromPoints(start, tag.start);
  1792. }
  1793. else {
  1794. stack.push(tag);
  1795. }
  1796. }
  1797. }
  1798. else {
  1799. var iterator = new TokenIterator(session, row, firstTag.end.column);
  1800. var end = {
  1801. row: row,
  1802. column: firstTag.start.column
  1803. };
  1804. while (tag = this._readTagBackward(iterator)) {
  1805. if (tag.selfClosing) {
  1806. if (!stack.length) {
  1807. tag.start.column += tag.tagName.length + 2;
  1808. tag.end.column -= 2;
  1809. return Range.fromPoints(tag.start, tag.end);
  1810. } else
  1811. continue;
  1812. }
  1813. if (!tag.closing) {
  1814. this._pop(stack, tag);
  1815. if (stack.length == 0) {
  1816. tag.start.column += tag.tagName.length + 2;
  1817. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  1818. tag.start.column = tag.end.column;
  1819. return Range.fromPoints(tag.start, end);
  1820. }
  1821. }
  1822. else {
  1823. stack.push(tag);
  1824. }
  1825. }
  1826. }
  1827. };
  1828. }).call(FoldMode.prototype);
  1829. });
  1830. ace.define("ace/mode/folding/html",[], function(require, exports, module) {
  1831. "use strict";
  1832. var oop = require("../../lib/oop");
  1833. var MixedFoldMode = require("./mixed").FoldMode;
  1834. var XmlFoldMode = require("./xml").FoldMode;
  1835. var CStyleFoldMode = require("./cstyle").FoldMode;
  1836. var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
  1837. MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
  1838. "js-": new CStyleFoldMode(),
  1839. "css-": new CStyleFoldMode()
  1840. });
  1841. };
  1842. oop.inherits(FoldMode, MixedFoldMode);
  1843. });
  1844. ace.define("ace/mode/html_completions",[], function(require, exports, module) {
  1845. "use strict";
  1846. var TokenIterator = require("../token_iterator").TokenIterator;
  1847. var commonAttributes = [
  1848. "accesskey",
  1849. "class",
  1850. "contenteditable",
  1851. "contextmenu",
  1852. "dir",
  1853. "draggable",
  1854. "dropzone",
  1855. "hidden",
  1856. "id",
  1857. "inert",
  1858. "itemid",
  1859. "itemprop",
  1860. "itemref",
  1861. "itemscope",
  1862. "itemtype",
  1863. "lang",
  1864. "spellcheck",
  1865. "style",
  1866. "tabindex",
  1867. "title",
  1868. "translate"
  1869. ];
  1870. var eventAttributes = [
  1871. "onabort",
  1872. "onblur",
  1873. "oncancel",
  1874. "oncanplay",
  1875. "oncanplaythrough",
  1876. "onchange",
  1877. "onclick",
  1878. "onclose",
  1879. "oncontextmenu",
  1880. "oncuechange",
  1881. "ondblclick",
  1882. "ondrag",
  1883. "ondragend",
  1884. "ondragenter",
  1885. "ondragleave",
  1886. "ondragover",
  1887. "ondragstart",
  1888. "ondrop",
  1889. "ondurationchange",
  1890. "onemptied",
  1891. "onended",
  1892. "onerror",
  1893. "onfocus",
  1894. "oninput",
  1895. "oninvalid",
  1896. "onkeydown",
  1897. "onkeypress",
  1898. "onkeyup",
  1899. "onload",
  1900. "onloadeddata",
  1901. "onloadedmetadata",
  1902. "onloadstart",
  1903. "onmousedown",
  1904. "onmousemove",
  1905. "onmouseout",
  1906. "onmouseover",
  1907. "onmouseup",
  1908. "onmousewheel",
  1909. "onpause",
  1910. "onplay",
  1911. "onplaying",
  1912. "onprogress",
  1913. "onratechange",
  1914. "onreset",
  1915. "onscroll",
  1916. "onseeked",
  1917. "onseeking",
  1918. "onselect",
  1919. "onshow",
  1920. "onstalled",
  1921. "onsubmit",
  1922. "onsuspend",
  1923. "ontimeupdate",
  1924. "onvolumechange",
  1925. "onwaiting"
  1926. ];
  1927. var globalAttributes = commonAttributes.concat(eventAttributes);
  1928. var attributeMap = {
  1929. "a": {"href": 1, "target": {"_blank": 1, "top": 1}, "ping": 1, "rel": {"nofollow": 1, "alternate": 1, "author": 1, "bookmark": 1, "help": 1, "license": 1, "next": 1, "noreferrer": 1, "prefetch": 1, "prev": 1, "search": 1, "tag": 1}, "media": 1, "hreflang": 1, "type": 1},
  1930. "abbr": {},
  1931. "address": {},
  1932. "area": {"shape": 1, "coords": 1, "href": 1, "hreflang": 1, "alt": 1, "target": 1, "media": 1, "rel": 1, "ping": 1, "type": 1},
  1933. "article": {"pubdate": 1},
  1934. "aside": {},
  1935. "audio": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1 }},
  1936. "b": {},
  1937. "base": {"href": 1, "target": 1},
  1938. "bdi": {},
  1939. "bdo": {},
  1940. "blockquote": {"cite": 1},
  1941. "body": {"onafterprint": 1, "onbeforeprint": 1, "onbeforeunload": 1, "onhashchange": 1, "onmessage": 1, "onoffline": 1, "onpopstate": 1, "onredo": 1, "onresize": 1, "onstorage": 1, "onundo": 1, "onunload": 1},
  1942. "br": {},
  1943. "button": {"autofocus": 1, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": 1, "formmethod": 1, "formnovalidate": 1, "formtarget": 1, "name": 1, "value": 1, "type": {"button": 1, "submit": 1}},
  1944. "canvas": {"width": 1, "height": 1},
  1945. "caption": {},
  1946. "cite": {},
  1947. "code": {},
  1948. "col": {"span": 1},
  1949. "colgroup": {"span": 1},
  1950. "command": {"type": 1, "label": 1, "icon": 1, "disabled": 1, "checked": 1, "radiogroup": 1, "command": 1},
  1951. "data": {},
  1952. "datalist": {},
  1953. "dd": {},
  1954. "del": {"cite": 1, "datetime": 1},
  1955. "details": {"open": 1},
  1956. "dfn": {},
  1957. "dialog": {"open": 1},
  1958. "div": {},
  1959. "dl": {},
  1960. "dt": {},
  1961. "em": {},
  1962. "embed": {"src": 1, "height": 1, "width": 1, "type": 1},
  1963. "fieldset": {"disabled": 1, "form": 1, "name": 1},
  1964. "figcaption": {},
  1965. "figure": {},
  1966. "footer": {},
  1967. "form": {"accept-charset": 1, "action": 1, "autocomplete": 1, "enctype": {"multipart/form-data": 1, "application/x-www-form-urlencoded": 1}, "method": {"get": 1, "post": 1}, "name": 1, "novalidate": 1, "target": {"_blank": 1, "top": 1}},
  1968. "h1": {},
  1969. "h2": {},
  1970. "h3": {},
  1971. "h4": {},
  1972. "h5": {},
  1973. "h6": {},
  1974. "head": {},
  1975. "header": {},
  1976. "hr": {},
  1977. "html": {"manifest": 1},
  1978. "i": {},
  1979. "iframe": {"name": 1, "src": 1, "height": 1, "width": 1, "sandbox": {"allow-same-origin": 1, "allow-top-navigation": 1, "allow-forms": 1, "allow-scripts": 1}, "seamless": {"seamless": 1}},
  1980. "img": {"alt": 1, "src": 1, "height": 1, "width": 1, "usemap": 1, "ismap": 1},
  1981. "input": {
  1982. "type": {"text": 1, "password": 1, "hidden": 1, "checkbox": 1, "submit": 1, "radio": 1, "file": 1, "button": 1, "reset": 1, "image": 31, "color": 1, "date": 1, "datetime": 1, "datetime-local": 1, "email": 1, "month": 1, "number": 1, "range": 1, "search": 1, "tel": 1, "time": 1, "url": 1, "week": 1},
  1983. "accept": 1, "alt": 1, "autocomplete": {"on": 1, "off": 1}, "autofocus": {"autofocus": 1}, "checked": {"checked": 1}, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": {"application/x-www-form-urlencoded": 1, "multipart/form-data": 1, "text/plain": 1}, "formmethod": {"get": 1, "post": 1}, "formnovalidate": {"formnovalidate": 1}, "formtarget": {"_blank": 1, "_self": 1, "_parent": 1, "_top": 1}, "height": 1, "list": 1, "max": 1, "maxlength": 1, "min": 1, "multiple": {"multiple": 1}, "name": 1, "pattern": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "size": 1, "src": 1, "step": 1, "width": 1, "files": 1, "value": 1},
  1984. "ins": {"cite": 1, "datetime": 1},
  1985. "kbd": {},
  1986. "keygen": {"autofocus": 1, "challenge": {"challenge": 1}, "disabled": {"disabled": 1}, "form": 1, "keytype": {"rsa": 1, "dsa": 1, "ec": 1}, "name": 1},
  1987. "label": {"form": 1, "for": 1},
  1988. "legend": {},
  1989. "li": {"value": 1},
  1990. "link": {"href": 1, "hreflang": 1, "rel": {"stylesheet": 1, "icon": 1}, "media": {"all": 1, "screen": 1, "print": 1}, "type": {"text/css": 1, "image/png": 1, "image/jpeg": 1, "image/gif": 1}, "sizes": 1},
  1991. "main": {},
  1992. "map": {"name": 1},
  1993. "mark": {},
  1994. "math": {},
  1995. "menu": {"type": 1, "label": 1},
  1996. "meta": {"http-equiv": {"content-type": 1}, "name": {"description": 1, "keywords": 1}, "content": {"text/html; charset=UTF-8": 1}, "charset": 1},
  1997. "meter": {"value": 1, "min": 1, "max": 1, "low": 1, "high": 1, "optimum": 1},
  1998. "nav": {},
  1999. "noscript": {"href": 1},
  2000. "object": {"param": 1, "data": 1, "type": 1, "height" : 1, "width": 1, "usemap": 1, "name": 1, "form": 1, "classid": 1},
  2001. "ol": {"start": 1, "reversed": 1},
  2002. "optgroup": {"disabled": 1, "label": 1},
  2003. "option": {"disabled": 1, "selected": 1, "label": 1, "value": 1},
  2004. "output": {"for": 1, "form": 1, "name": 1},
  2005. "p": {},
  2006. "param": {"name": 1, "value": 1},
  2007. "pre": {},
  2008. "progress": {"value": 1, "max": 1},
  2009. "q": {"cite": 1},
  2010. "rp": {},
  2011. "rt": {},
  2012. "ruby": {},
  2013. "s": {},
  2014. "samp": {},
  2015. "script": {"charset": 1, "type": {"text/javascript": 1}, "src": 1, "defer": 1, "async": 1},
  2016. "select": {"autofocus": 1, "disabled": 1, "form": 1, "multiple": {"multiple": 1}, "name": 1, "size": 1, "readonly":{"readonly": 1}},
  2017. "small": {},
  2018. "source": {"src": 1, "type": 1, "media": 1},
  2019. "span": {},
  2020. "strong": {},
  2021. "style": {"type": 1, "media": {"all": 1, "screen": 1, "print": 1}, "scoped": 1},
  2022. "sub": {},
  2023. "sup": {},
  2024. "svg": {},
  2025. "table": {"summary": 1},
  2026. "tbody": {},
  2027. "td": {"headers": 1, "rowspan": 1, "colspan": 1},
  2028. "textarea": {"autofocus": {"autofocus": 1}, "disabled": {"disabled": 1}, "form": 1, "maxlength": 1, "name": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "rows": 1, "cols": 1, "wrap": {"on": 1, "off": 1, "hard": 1, "soft": 1}},
  2029. "tfoot": {},
  2030. "th": {"headers": 1, "rowspan": 1, "colspan": 1, "scope": 1},
  2031. "thead": {},
  2032. "time": {"datetime": 1},
  2033. "title": {},
  2034. "tr": {},
  2035. "track": {"kind": 1, "src": 1, "srclang": 1, "label": 1, "default": 1},
  2036. "section": {},
  2037. "summary": {},
  2038. "u": {},
  2039. "ul": {},
  2040. "var": {},
  2041. "video": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "width": 1, "height": 1, "poster": 1, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1}},
  2042. "wbr": {}
  2043. };
  2044. var elements = Object.keys(attributeMap);
  2045. function is(token, type) {
  2046. return token.type.lastIndexOf(type + ".xml") > -1;
  2047. }
  2048. function findTagName(session, pos) {
  2049. var iterator = new TokenIterator(session, pos.row, pos.column);
  2050. var token = iterator.getCurrentToken();
  2051. while (token && !is(token, "tag-name")){
  2052. token = iterator.stepBackward();
  2053. }
  2054. if (token)
  2055. return token.value;
  2056. }
  2057. function findAttributeName(session, pos) {
  2058. var iterator = new TokenIterator(session, pos.row, pos.column);
  2059. var token = iterator.getCurrentToken();
  2060. while (token && !is(token, "attribute-name")){
  2061. token = iterator.stepBackward();
  2062. }
  2063. if (token)
  2064. return token.value;
  2065. }
  2066. var HtmlCompletions = function() {
  2067. };
  2068. (function() {
  2069. this.getCompletions = function(state, session, pos, prefix) {
  2070. var token = session.getTokenAt(pos.row, pos.column);
  2071. if (!token)
  2072. return [];
  2073. if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
  2074. return this.getTagCompletions(state, session, pos, prefix);
  2075. if (is(token, "tag-whitespace") || is(token, "attribute-name"))
  2076. return this.getAttributeCompletions(state, session, pos, prefix);
  2077. if (is(token, "attribute-value"))
  2078. return this.getAttributeValueCompletions(state, session, pos, prefix);
  2079. var line = session.getLine(pos.row).substr(0, pos.column);
  2080. if (/&[a-z]*$/i.test(line))
  2081. return this.getHTMLEntityCompletions(state, session, pos, prefix);
  2082. return [];
  2083. };
  2084. this.getTagCompletions = function(state, session, pos, prefix) {
  2085. return elements.map(function(element){
  2086. return {
  2087. value: element,
  2088. meta: "tag",
  2089. score: Number.MAX_VALUE
  2090. };
  2091. });
  2092. };
  2093. this.getAttributeCompletions = function(state, session, pos, prefix) {
  2094. var tagName = findTagName(session, pos);
  2095. if (!tagName)
  2096. return [];
  2097. var attributes = globalAttributes;
  2098. if (tagName in attributeMap) {
  2099. attributes = attributes.concat(Object.keys(attributeMap[tagName]));
  2100. }
  2101. return attributes.map(function(attribute){
  2102. return {
  2103. caption: attribute,
  2104. snippet: attribute + '="$0"',
  2105. meta: "attribute",
  2106. score: Number.MAX_VALUE
  2107. };
  2108. });
  2109. };
  2110. this.getAttributeValueCompletions = function(state, session, pos, prefix) {
  2111. var tagName = findTagName(session, pos);
  2112. var attributeName = findAttributeName(session, pos);
  2113. if (!tagName)
  2114. return [];
  2115. var values = [];
  2116. if (tagName in attributeMap && attributeName in attributeMap[tagName] && typeof attributeMap[tagName][attributeName] === "object") {
  2117. values = Object.keys(attributeMap[tagName][attributeName]);
  2118. }
  2119. return values.map(function(value){
  2120. return {
  2121. caption: value,
  2122. snippet: value,
  2123. meta: "attribute value",
  2124. score: Number.MAX_VALUE
  2125. };
  2126. });
  2127. };
  2128. this.getHTMLEntityCompletions = function(state, session, pos, prefix) {
  2129. var values = ['Aacute;', 'aacute;', 'Acirc;', 'acirc;', 'acute;', 'AElig;', 'aelig;', 'Agrave;', 'agrave;', 'alefsym;', 'Alpha;', 'alpha;', 'amp;', 'and;', 'ang;', 'Aring;', 'aring;', 'asymp;', 'Atilde;', 'atilde;', 'Auml;', 'auml;', 'bdquo;', 'Beta;', 'beta;', 'brvbar;', 'bull;', 'cap;', 'Ccedil;', 'ccedil;', 'cedil;', 'cent;', 'Chi;', 'chi;', 'circ;', 'clubs;', 'cong;', 'copy;', 'crarr;', 'cup;', 'curren;', 'Dagger;', 'dagger;', 'dArr;', 'darr;', 'deg;', 'Delta;', 'delta;', 'diams;', 'divide;', 'Eacute;', 'eacute;', 'Ecirc;', 'ecirc;', 'Egrave;', 'egrave;', 'empty;', 'emsp;', 'ensp;', 'Epsilon;', 'epsilon;', 'equiv;', 'Eta;', 'eta;', 'ETH;', 'eth;', 'Euml;', 'euml;', 'euro;', 'exist;', 'fnof;', 'forall;', 'frac12;', 'frac14;', 'frac34;', 'frasl;', 'Gamma;', 'gamma;', 'ge;', 'gt;', 'hArr;', 'harr;', 'hearts;', 'hellip;', 'Iacute;', 'iacute;', 'Icirc;', 'icirc;', 'iexcl;', 'Igrave;', 'igrave;', 'image;', 'infin;', 'int;', 'Iota;', 'iota;', 'iquest;', 'isin;', 'Iuml;', 'iuml;', 'Kappa;', 'kappa;', 'Lambda;', 'lambda;', 'lang;', 'laquo;', 'lArr;', 'larr;', 'lceil;', 'ldquo;', 'le;', 'lfloor;', 'lowast;', 'loz;', 'lrm;', 'lsaquo;', 'lsquo;', 'lt;', 'macr;', 'mdash;', 'micro;', 'middot;', 'minus;', 'Mu;', 'mu;', 'nabla;', 'nbsp;', 'ndash;', 'ne;', 'ni;', 'not;', 'notin;', 'nsub;', 'Ntilde;', 'ntilde;', 'Nu;', 'nu;', 'Oacute;', 'oacute;', 'Ocirc;', 'ocirc;', 'OElig;', 'oelig;', 'Ograve;', 'ograve;', 'oline;', 'Omega;', 'omega;', 'Omicron;', 'omicron;', 'oplus;', 'or;', 'ordf;', 'ordm;', 'Oslash;', 'oslash;', 'Otilde;', 'otilde;', 'otimes;', 'Ouml;', 'ouml;', 'para;', 'part;', 'permil;', 'perp;', 'Phi;', 'phi;', 'Pi;', 'pi;', 'piv;', 'plusmn;', 'pound;', 'Prime;', 'prime;', 'prod;', 'prop;', 'Psi;', 'psi;', 'quot;', 'radic;', 'rang;', 'raquo;', 'rArr;', 'rarr;', 'rceil;', 'rdquo;', 'real;', 'reg;', 'rfloor;', 'Rho;', 'rho;', 'rlm;', 'rsaquo;', 'rsquo;', 'sbquo;', 'Scaron;', 'scaron;', 'sdot;', 'sect;', 'shy;', 'Sigma;', 'sigma;', 'sigmaf;', 'sim;', 'spades;', 'sub;', 'sube;', 'sum;', 'sup;', 'sup1;', 'sup2;', 'sup3;', 'supe;', 'szlig;', 'Tau;', 'tau;', 'there4;', 'Theta;', 'theta;', 'thetasym;', 'thinsp;', 'THORN;', 'thorn;', 'tilde;', 'times;', 'trade;', 'Uacute;', 'uacute;', 'uArr;', 'uarr;', 'Ucirc;', 'ucirc;', 'Ugrave;', 'ugrave;', 'uml;', 'upsih;', 'Upsilon;', 'upsilon;', 'Uuml;', 'uuml;', 'weierp;', 'Xi;', 'xi;', 'Yacute;', 'yacute;', 'yen;', 'Yuml;', 'yuml;', 'Zeta;', 'zeta;', 'zwj;', 'zwnj;'];
  2130. return values.map(function(value){
  2131. return {
  2132. caption: value,
  2133. snippet: value,
  2134. meta: "html entity",
  2135. score: Number.MAX_VALUE
  2136. };
  2137. });
  2138. };
  2139. }).call(HtmlCompletions.prototype);
  2140. exports.HtmlCompletions = HtmlCompletions;
  2141. });
  2142. ace.define("ace/mode/html",[], function(require, exports, module) {
  2143. "use strict";
  2144. var oop = require("../lib/oop");
  2145. var lang = require("../lib/lang");
  2146. var TextMode = require("./text").Mode;
  2147. var JavaScriptMode = require("./javascript").Mode;
  2148. var CssMode = require("./css").Mode;
  2149. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2150. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  2151. var HtmlFoldMode = require("./folding/html").FoldMode;
  2152. var HtmlCompletions = require("./html_completions").HtmlCompletions;
  2153. var WorkerClient = require("../worker/worker_client").WorkerClient;
  2154. var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
  2155. var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
  2156. var Mode = function(options) {
  2157. this.fragmentContext = options && options.fragmentContext;
  2158. this.HighlightRules = HtmlHighlightRules;
  2159. this.$behaviour = new XmlBehaviour();
  2160. this.$completer = new HtmlCompletions();
  2161. this.createModeDelegates({
  2162. "js-": JavaScriptMode,
  2163. "css-": CssMode
  2164. });
  2165. this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
  2166. };
  2167. oop.inherits(Mode, TextMode);
  2168. (function() {
  2169. this.blockComment = {start: "<!--", end: "-->"};
  2170. this.voidElements = lang.arrayToMap(voidElements);
  2171. this.getNextLineIndent = function(state, line, tab) {
  2172. return this.$getIndent(line);
  2173. };
  2174. this.checkOutdent = function(state, line, input) {
  2175. return false;
  2176. };
  2177. this.getCompletions = function(state, session, pos, prefix) {
  2178. return this.$completer.getCompletions(state, session, pos, prefix);
  2179. };
  2180. this.createWorker = function(session) {
  2181. if (this.constructor != Mode)
  2182. return;
  2183. var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
  2184. worker.attachToDocument(session.getDocument());
  2185. if (this.fragmentContext)
  2186. worker.call("setOptions", [{context: this.fragmentContext}]);
  2187. worker.on("error", function(e) {
  2188. session.setAnnotations(e.data);
  2189. });
  2190. worker.on("terminate", function() {
  2191. session.clearAnnotations();
  2192. });
  2193. return worker;
  2194. };
  2195. this.$id = "ace/mode/html";
  2196. }).call(Mode.prototype);
  2197. exports.Mode = Mode;
  2198. });
  2199. ace.define("ace/mode/soy_template_highlight_rules",[], function(require, exports, module) {
  2200. "use strict";
  2201. var oop = require("../lib/oop");
  2202. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2203. var SoyTemplateHighlightRules = function() {
  2204. HtmlHighlightRules.call(this);
  2205. var soyRules = { start:
  2206. [ { include: '#template' },
  2207. { include: '#if' },
  2208. { include: '#comment-line' },
  2209. { include: '#comment-block' },
  2210. { include: '#comment-doc' },
  2211. { include: '#call' },
  2212. { include: '#css' },
  2213. { include: '#param' },
  2214. { include: '#print' },
  2215. { include: '#msg' },
  2216. { include: '#for' },
  2217. { include: '#foreach' },
  2218. { include: '#switch' },
  2219. { include: '#tag' },
  2220. { include: 'text.html.basic' } ],
  2221. '#call':
  2222. [ { token:
  2223. [ 'punctuation.definition.tag.begin.soy',
  2224. 'meta.tag.call.soy' ],
  2225. regex: '(\\{/?)(\\s*)(?=call|delcall)',
  2226. push:
  2227. [ { token: 'punctuation.definition.tag.end.soy',
  2228. regex: '\\}',
  2229. next: 'pop' },
  2230. { include: '#string-quoted-single' },
  2231. { include: '#string-quoted-double' },
  2232. { token: ['entity.name.tag.soy', 'variable.parameter.soy'],
  2233. regex: '(call|delcall)(\\s+[\\.\\w]+)'},
  2234. { token:
  2235. [ 'entity.other.attribute-name.soy',
  2236. 'text',
  2237. 'keyword.operator.soy' ],
  2238. regex: '\\b(data)(\\s*)(=)' },
  2239. { defaultToken: 'meta.tag.call.soy' } ] } ],
  2240. '#comment-line':
  2241. [ { token:
  2242. [ 'comment.line.double-slash.soy',
  2243. 'comment.line.double-slash.soy' ],
  2244. regex: '(//)(.*$)' } ],
  2245. '#comment-block':
  2246. [ { token: 'punctuation.definition.comment.begin.soy',
  2247. regex: '/\\*(?!\\*)',
  2248. push:
  2249. [ { token: 'punctuation.definition.comment.end.soy',
  2250. regex: '\\*/',
  2251. next: 'pop' },
  2252. { defaultToken: 'comment.block.soy' } ] } ],
  2253. '#comment-doc':
  2254. [ { token: 'punctuation.definition.comment.begin.soy',
  2255. regex: '/\\*\\*(?!/)',
  2256. push:
  2257. [ { token: 'punctuation.definition.comment.end.soy',
  2258. regex: '\\*/',
  2259. next: 'pop' },
  2260. { token: [ 'support.type.soy', 'text', 'variable.parameter.soy' ],
  2261. regex: '(@param|@param\\?)(\\s+)(\\w+)' },
  2262. { defaultToken: 'comment.block.documentation.soy' } ] } ],
  2263. '#css':
  2264. [ { token:
  2265. [ 'punctuation.definition.tag.begin.soy',
  2266. 'meta.tag.css.soy',
  2267. 'entity.name.tag.soy' ],
  2268. regex: '(\\{/?)(\\s*)(css)\\b',
  2269. push:
  2270. [ { token: 'punctuation.definition.tag.end.soy',
  2271. regex: '\\}',
  2272. next: 'pop' },
  2273. { token: 'support.constant.soy',
  2274. regex: '\\b(?:LITERAL|REFERENCE|BACKEND_SPECIFIC|GOOG)\\b' },
  2275. { defaultToken: 'meta.tag.css.soy' } ] } ],
  2276. '#for':
  2277. [ { token:
  2278. [ 'punctuation.definition.tag.begin.soy',
  2279. 'meta.tag.for.soy',
  2280. 'entity.name.tag.soy' ],
  2281. regex: '(\\{/?)(\\s*)(for)\\b',
  2282. push:
  2283. [ { token: 'punctuation.definition.tag.end.soy',
  2284. regex: '\\}',
  2285. next: 'pop' },
  2286. { token: 'keyword.operator.soy', regex: '\\bin\\b' },
  2287. { token: 'support.function.soy', regex: '\\brange\\b' },
  2288. { include: '#variable' },
  2289. { include: '#number' },
  2290. { include: '#primitive' },
  2291. { defaultToken: 'meta.tag.for.soy' } ] } ],
  2292. '#foreach':
  2293. [ { token:
  2294. [ 'punctuation.definition.tag.begin.soy',
  2295. 'meta.tag.foreach.soy',
  2296. 'entity.name.tag.soy' ],
  2297. regex: '(\\{/?)(\\s*)(foreach)\\b',
  2298. push:
  2299. [ { token: 'punctuation.definition.tag.end.soy',
  2300. regex: '\\}',
  2301. next: 'pop' },
  2302. { token: 'keyword.operator.soy', regex: '\\bin\\b' },
  2303. { include: '#variable' },
  2304. { defaultToken: 'meta.tag.foreach.soy' } ] } ],
  2305. '#function':
  2306. [ { token: 'support.function.soy',
  2307. regex: '\\b(?:isFirst|isLast|index|hasData|length|keys|round|floor|ceiling|min|max|randomInt)\\b' } ],
  2308. '#if':
  2309. [ { token:
  2310. [ 'punctuation.definition.tag.begin.soy',
  2311. 'meta.tag.if.soy',
  2312. 'entity.name.tag.soy' ],
  2313. regex: '(\\{/?)(\\s*)(if|elseif)\\b',
  2314. push:
  2315. [ { token: 'punctuation.definition.tag.end.soy',
  2316. regex: '\\}',
  2317. next: 'pop' },
  2318. { include: '#variable' },
  2319. { include: '#operator' },
  2320. { include: '#function' },
  2321. { include: '#string-quoted-single' },
  2322. { include: '#string-quoted-double' },
  2323. { defaultToken: 'meta.tag.if.soy' } ] } ],
  2324. '#namespace':
  2325. [ { token: [ 'entity.name.tag.soy', 'text', 'variable.parameter.soy' ],
  2326. regex: '(namespace|delpackage)(\\s+)([\\w\\.]+)' } ],
  2327. '#number': [ { token: 'constant.numeric', regex: '[\\d]+' } ],
  2328. '#operator':
  2329. [ { token: 'keyword.operator.soy',
  2330. regex: '==|!=|\\band\\b|\\bor\\b|\\bnot\\b|-|\\+|/|\\?:' } ],
  2331. '#param':
  2332. [ { token:
  2333. [ 'punctuation.definition.tag.begin.soy',
  2334. 'meta.tag.param.soy',
  2335. 'entity.name.tag.soy' ],
  2336. regex: '(\\{/?)(\\s*)(param)',
  2337. push:
  2338. [ { token: 'punctuation.definition.tag.end.soy',
  2339. regex: '\\}',
  2340. next: 'pop' },
  2341. { include: '#variable' },
  2342. { token:
  2343. [ 'entity.other.attribute-name.soy',
  2344. 'text',
  2345. 'keyword.operator.soy' ],
  2346. regex: '\\b([\\w]+)(\\s*)((?::)?)' },
  2347. { defaultToken: 'meta.tag.param.soy' } ] } ],
  2348. '#primitive':
  2349. [ { token: 'constant.language.soy',
  2350. regex: '\\b(?:null|false|true)\\b' } ],
  2351. '#msg':
  2352. [ { token:
  2353. [ 'punctuation.definition.tag.begin.soy',
  2354. 'meta.tag.msg.soy',
  2355. 'entity.name.tag.soy' ],
  2356. regex: '(\\{/?)(\\s*)(msg)\\b',
  2357. push:
  2358. [ { token: 'punctuation.definition.tag.end.soy',
  2359. regex: '\\}',
  2360. next: 'pop' },
  2361. { include: '#string-quoted-single' },
  2362. { include: '#string-quoted-double' },
  2363. { token:
  2364. [ 'entity.other.attribute-name.soy',
  2365. 'text',
  2366. 'keyword.operator.soy' ],
  2367. regex: '\\b(meaning|desc)(\\s*)(=)' },
  2368. { defaultToken: 'meta.tag.msg.soy' } ] } ],
  2369. '#print':
  2370. [ { token:
  2371. [ 'punctuation.definition.tag.begin.soy',
  2372. 'meta.tag.print.soy',
  2373. 'entity.name.tag.soy' ],
  2374. regex: '(\\{/?)(\\s*)(print)\\b',
  2375. push:
  2376. [ { token: 'punctuation.definition.tag.end.soy',
  2377. regex: '\\}',
  2378. next: 'pop' },
  2379. { include: '#variable' },
  2380. { include: '#print-parameter' },
  2381. { include: '#number' },
  2382. { include: '#primitive' },
  2383. { include: '#attribute-lookup' },
  2384. { defaultToken: 'meta.tag.print.soy' } ] } ],
  2385. '#print-parameter':
  2386. [ { token: 'keyword.operator.soy', regex: '\\|' },
  2387. { token: 'variable.parameter.soy',
  2388. regex: 'noAutoescape|id|escapeHtml|escapeJs|insertWorkBreaks|truncate' } ],
  2389. '#special-character':
  2390. [ { token: 'support.constant.soy',
  2391. regex: '\\bsp\\b|\\bnil\\b|\\\\r|\\\\n|\\\\t|\\blb\\b|\\brb\\b' } ],
  2392. '#string-quoted-double': [ { token: 'string.quoted.double', regex: '"[^"]*"' } ],
  2393. '#string-quoted-single': [ { token: 'string.quoted.single', regex: '\'[^\']*\'' } ],
  2394. '#switch':
  2395. [ { token:
  2396. [ 'punctuation.definition.tag.begin.soy',
  2397. 'meta.tag.switch.soy',
  2398. 'entity.name.tag.soy' ],
  2399. regex: '(\\{/?)(\\s*)(switch|case)\\b',
  2400. push:
  2401. [ { token: 'punctuation.definition.tag.end.soy',
  2402. regex: '\\}',
  2403. next: 'pop' },
  2404. { include: '#variable' },
  2405. { include: '#function' },
  2406. { include: '#number' },
  2407. { include: '#string-quoted-single' },
  2408. { include: '#string-quoted-double' },
  2409. { defaultToken: 'meta.tag.switch.soy' } ] } ],
  2410. '#attribute-lookup':
  2411. [ { token: 'punctuation.definition.attribute-lookup.begin.soy',
  2412. regex: '\\[',
  2413. push:
  2414. [ { token: 'punctuation.definition.attribute-lookup.end.soy',
  2415. regex: '\\]',
  2416. next: 'pop' },
  2417. { include: '#variable' },
  2418. { include: '#function' },
  2419. { include: '#operator' },
  2420. { include: '#number' },
  2421. { include: '#primitive' },
  2422. { include: '#string-quoted-single' },
  2423. { include: '#string-quoted-double' } ] } ],
  2424. '#tag':
  2425. [ { token: 'punctuation.definition.tag.begin.soy',
  2426. regex: '\\{',
  2427. push:
  2428. [ { token: 'punctuation.definition.tag.end.soy',
  2429. regex: '\\}',
  2430. next: 'pop' },
  2431. { include: '#namespace' },
  2432. { include: '#variable' },
  2433. { include: '#special-character' },
  2434. { include: '#tag-simple' },
  2435. { include: '#function' },
  2436. { include: '#operator' },
  2437. { include: '#attribute-lookup' },
  2438. { include: '#number' },
  2439. { include: '#primitive' },
  2440. { include: '#print-parameter' } ] } ],
  2441. '#tag-simple':
  2442. [ { token: 'entity.name.tag.soy',
  2443. regex: '{{\\s*(?:literal|else|ifempty|default)\\s*(?=\\})'} ],
  2444. '#template':
  2445. [ { token:
  2446. [ 'punctuation.definition.tag.begin.soy',
  2447. 'meta.tag.template.soy' ],
  2448. regex: '(\\{/?)(\\s*)(?=template|deltemplate)',
  2449. push:
  2450. [ { token: 'punctuation.definition.tag.end.soy',
  2451. regex: '\\}',
  2452. next: 'pop' },
  2453. { token: ['entity.name.tag.soy', 'text', 'entity.name.function.soy' ],
  2454. regex: '(template|deltemplate)(\\s+)([\\.\\w]+)',
  2455. originalRegex: '(?<=template|deltemplate)\\s+([\\.\\w]+)' },
  2456. { token:
  2457. [ 'entity.other.attribute-name.soy',
  2458. 'text',
  2459. 'keyword.operator.soy',
  2460. 'text',
  2461. 'string.quoted.double.soy' ],
  2462. regex: '\\b(private)(\\s*)(=)(\\s*)("true"|"false")' },
  2463. { token:
  2464. [ 'entity.other.attribute-name.soy',
  2465. 'text',
  2466. 'keyword.operator.soy',
  2467. 'text',
  2468. 'string.quoted.single.soy' ],
  2469. regex: '\\b(private)(\\s*)(=)(\\s*)(\'true\'|\'false\')' },
  2470. { token:
  2471. [ 'entity.other.attribute-name.soy',
  2472. 'text',
  2473. 'keyword.operator.soy',
  2474. 'text',
  2475. 'string.quoted.double.soy' ],
  2476. regex: '\\b(autoescape)(\\s*)(=)(\\s*)("true"|"false"|"contextual")' },
  2477. { token:
  2478. [ 'entity.other.attribute-name.soy',
  2479. 'text',
  2480. 'keyword.operator.soy',
  2481. 'text',
  2482. 'string.quoted.single.soy' ],
  2483. regex: '\\b(autoescape)(\\s*)(=)(\\s*)(\'true\'|\'false\'|\'contextual\')' },
  2484. { defaultToken: 'meta.tag.template.soy' } ] } ],
  2485. '#variable': [ { token: 'variable.other.soy', regex: '\\$[\\w\\.]+' } ] };
  2486. for (var i in soyRules) {
  2487. if (this.$rules[i]) {
  2488. this.$rules[i].unshift.apply(this.$rules[i], soyRules[i]);
  2489. } else {
  2490. this.$rules[i] = soyRules[i];
  2491. }
  2492. }
  2493. this.normalizeRules();
  2494. };
  2495. SoyTemplateHighlightRules.metaData = { comment: 'SoyTemplate',
  2496. fileTypes: [ 'soy' ],
  2497. firstLineMatch: '\\{\\s*namespace\\b',
  2498. foldingStartMarker: '\\{\\s*template\\s+[^\\}]*\\}',
  2499. foldingStopMarker: '\\{\\s*/\\s*template\\s*\\}',
  2500. name: 'SoyTemplate',
  2501. scopeName: 'source.soy' };
  2502. oop.inherits(SoyTemplateHighlightRules, HtmlHighlightRules);
  2503. exports.SoyTemplateHighlightRules = SoyTemplateHighlightRules;
  2504. });
  2505. ace.define("ace/mode/soy_template",[], function(require, exports, module) {
  2506. "use strict";
  2507. var oop = require("../lib/oop");
  2508. var HtmlMode = require("./html").Mode;
  2509. var SoyTemplateHighlightRules = require("./soy_template_highlight_rules").SoyTemplateHighlightRules;
  2510. var Mode = function() {
  2511. HtmlMode.call(this);
  2512. this.HighlightRules = SoyTemplateHighlightRules;
  2513. };
  2514. oop.inherits(Mode, HtmlMode);
  2515. (function() {
  2516. this.lineCommentStart = "//";
  2517. this.blockComment = {start: "/*", end: "*/"};
  2518. this.$id = "ace/mode/soy_template";
  2519. }).call(Mode.prototype);
  2520. exports.Mode = Mode;
  2521. });
  2522. (function() {
  2523. ace.require(["ace/mode/soy_template"], function(m) {
  2524. if (typeof module == "object" && typeof exports == "object" && module) {
  2525. module.exports = m;
  2526. }
  2527. });
  2528. })();