mode-handlebars.js 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424
  1. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. }, {
  11. token : "comment.doc.tag",
  12. regex : "\\bTODO\\b"
  13. }, {
  14. defaultToken : "comment.doc"
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getStartRule = function(start) {
  20. return {
  21. token : "comment.doc", // doc comment
  22. regex : "\\/\\*(?=\\*)",
  23. next : start
  24. };
  25. };
  26. DocCommentHighlightRules.getEndRule = function (start) {
  27. return {
  28. token : "comment.doc", // closing comment
  29. regex : "\\*\\/",
  30. next : start
  31. };
  32. };
  33. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  34. });
  35. ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
  36. "use strict";
  37. var oop = require("../lib/oop");
  38. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  39. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  40. var JavaScriptHighlightRules = function() {
  41. var keywordMapper = this.createKeywordMapper({
  42. "variable.language":
  43. "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  44. "Namespace|QName|XML|XMLList|" + // E4X
  45. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  46. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  47. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  48. "SyntaxError|TypeError|URIError|" +
  49. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  50. "isNaN|parseFloat|parseInt|" +
  51. "JSON|Math|" + // Other
  52. "this|arguments|prototype|window|document" , // Pseudo
  53. "keyword":
  54. "const|yield|import|get|set|" +
  55. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  56. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  57. "__parent__|__count__|escape|unescape|with|__proto__|" +
  58. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  59. "storage.type":
  60. "const|let|var|function",
  61. "constant.language":
  62. "null|Infinity|NaN|undefined",
  63. "support.function":
  64. "alert",
  65. "constant.language.boolean": "true|false"
  66. }, "identifier");
  67. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  68. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  69. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  70. "u[0-9a-fA-F]{4}|" + // unicode
  71. "[0-2][0-7]{0,2}|" + // oct
  72. "3[0-6][0-7]?|" + // oct
  73. "37[0-7]?|" + // oct
  74. "[4-7][0-7]?|" + //oct
  75. ".)";
  76. this.$rules = {
  77. "no_regex" : [
  78. {
  79. token : "comment",
  80. regex : "\\/\\/",
  81. next : "line_comment"
  82. },
  83. DocCommentHighlightRules.getStartRule("doc-start"),
  84. {
  85. token : "comment", // multi line comment
  86. regex : /\/\*/,
  87. next : "comment"
  88. }, {
  89. token : "string",
  90. regex : "'(?=.)",
  91. next : "qstring"
  92. }, {
  93. token : "string",
  94. regex : '"(?=.)',
  95. next : "qqstring"
  96. }, {
  97. token : "constant.numeric", // hex
  98. regex : /0[xX][0-9a-fA-F]+\b/
  99. }, {
  100. token : "constant.numeric", // float
  101. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  102. }, {
  103. token : [
  104. "storage.type", "punctuation.operator", "support.function",
  105. "punctuation.operator", "entity.name.function", "text","keyword.operator"
  106. ],
  107. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  108. next: "function_arguments"
  109. }, {
  110. token : [
  111. "storage.type", "punctuation.operator", "entity.name.function", "text",
  112. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  113. ],
  114. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  115. next: "function_arguments"
  116. }, {
  117. token : [
  118. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  119. "text", "paren.lparen"
  120. ],
  121. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  122. next: "function_arguments"
  123. }, {
  124. token : [
  125. "storage.type", "punctuation.operator", "entity.name.function", "text",
  126. "keyword.operator", "text",
  127. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  128. ],
  129. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  130. next: "function_arguments"
  131. }, {
  132. token : [
  133. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  134. ],
  135. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  136. next: "function_arguments"
  137. }, {
  138. token : [
  139. "entity.name.function", "text", "punctuation.operator",
  140. "text", "storage.type", "text", "paren.lparen"
  141. ],
  142. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  143. next: "function_arguments"
  144. }, {
  145. token : [
  146. "text", "text", "storage.type", "text", "paren.lparen"
  147. ],
  148. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  149. next: "function_arguments"
  150. }, {
  151. token : "keyword",
  152. regex : "(?:" + kwBeforeRe + ")\\b",
  153. next : "start"
  154. }, {
  155. token : ["punctuation.operator", "support.function"],
  156. 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(?=\()/
  157. }, {
  158. token : ["punctuation.operator", "support.function.dom"],
  159. regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  160. }, {
  161. token : ["punctuation.operator", "support.constant"],
  162. 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/
  163. }, {
  164. token : ["support.constant"],
  165. regex : /that\b/
  166. }, {
  167. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  168. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  169. }, {
  170. token : keywordMapper,
  171. regex : identifierRe
  172. }, {
  173. token : "keyword.operator",
  174. regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
  175. next : "start"
  176. }, {
  177. token : "punctuation.operator",
  178. regex : /\?|\:|\,|\;|\./,
  179. next : "start"
  180. }, {
  181. token : "paren.lparen",
  182. regex : /[\[({]/,
  183. next : "start"
  184. }, {
  185. token : "paren.rparen",
  186. regex : /[\])}]/
  187. }, {
  188. token : "keyword.operator",
  189. regex : /\/=?/,
  190. next : "start"
  191. }, {
  192. token: "comment",
  193. regex: /^#!.*$/
  194. }
  195. ],
  196. "start": [
  197. DocCommentHighlightRules.getStartRule("doc-start"),
  198. {
  199. token : "comment", // multi line comment
  200. regex : "\\/\\*",
  201. next : "comment_regex_allowed"
  202. }, {
  203. token : "comment",
  204. regex : "\\/\\/",
  205. next : "line_comment_regex_allowed"
  206. }, {
  207. token: "string.regexp",
  208. regex: "\\/",
  209. next: "regex"
  210. }, {
  211. token : "text",
  212. regex : "\\s+|^$",
  213. next : "start"
  214. }, {
  215. token: "empty",
  216. regex: "",
  217. next: "no_regex"
  218. }
  219. ],
  220. "regex": [
  221. {
  222. token: "regexp.keyword.operator",
  223. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  224. }, {
  225. token: "string.regexp",
  226. regex: "/[sxngimy]*",
  227. next: "no_regex"
  228. }, {
  229. token : "invalid",
  230. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  231. }, {
  232. token : "constant.language.escape",
  233. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  234. }, {
  235. token : "constant.language.delimiter",
  236. regex: /\|/
  237. }, {
  238. token: "constant.language.escape",
  239. regex: /\[\^?/,
  240. next: "regex_character_class"
  241. }, {
  242. token: "empty",
  243. regex: "$",
  244. next: "no_regex"
  245. }, {
  246. defaultToken: "string.regexp"
  247. }
  248. ],
  249. "regex_character_class": [
  250. {
  251. token: "regexp.keyword.operator",
  252. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  253. }, {
  254. token: "constant.language.escape",
  255. regex: "]",
  256. next: "regex"
  257. }, {
  258. token: "constant.language.escape",
  259. regex: "-"
  260. }, {
  261. token: "empty",
  262. regex: "$",
  263. next: "no_regex"
  264. }, {
  265. defaultToken: "string.regexp.charachterclass"
  266. }
  267. ],
  268. "function_arguments": [
  269. {
  270. token: "variable.parameter",
  271. regex: identifierRe
  272. }, {
  273. token: "punctuation.operator",
  274. regex: "[, ]+"
  275. }, {
  276. token: "punctuation.operator",
  277. regex: "$"
  278. }, {
  279. token: "empty",
  280. regex: "",
  281. next: "no_regex"
  282. }
  283. ],
  284. "comment_regex_allowed" : [
  285. {token : "comment", regex : "\\*\\/", next : "start"},
  286. {defaultToken : "comment"}
  287. ],
  288. "comment" : [
  289. {token : "comment", regex : "\\*\\/", next : "no_regex"},
  290. {defaultToken : "comment"}
  291. ],
  292. "line_comment_regex_allowed" : [
  293. {token : "comment", regex : "$|^", next : "start"},
  294. {defaultToken : "comment"}
  295. ],
  296. "line_comment" : [
  297. {token : "comment", regex : "$|^", next : "no_regex"},
  298. {defaultToken : "comment"}
  299. ],
  300. "qqstring" : [
  301. {
  302. token : "constant.language.escape",
  303. regex : escapedRe
  304. }, {
  305. token : "string",
  306. regex : "\\\\$",
  307. next : "qqstring"
  308. }, {
  309. token : "string",
  310. regex : '"|$',
  311. next : "no_regex"
  312. }, {
  313. defaultToken: "string"
  314. }
  315. ],
  316. "qstring" : [
  317. {
  318. token : "constant.language.escape",
  319. regex : escapedRe
  320. }, {
  321. token : "string",
  322. regex : "\\\\$",
  323. next : "qstring"
  324. }, {
  325. token : "string",
  326. regex : "'|$",
  327. next : "no_regex"
  328. }, {
  329. defaultToken: "string"
  330. }
  331. ]
  332. };
  333. this.embedRules(DocCommentHighlightRules, "doc-",
  334. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  335. };
  336. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  337. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  338. });
  339. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  340. "use strict";
  341. var Range = require("../range").Range;
  342. var MatchingBraceOutdent = function() {};
  343. (function() {
  344. this.checkOutdent = function(line, input) {
  345. if (! /^\s+$/.test(line))
  346. return false;
  347. return /^\s*\}/.test(input);
  348. };
  349. this.autoOutdent = function(doc, row) {
  350. var line = doc.getLine(row);
  351. var match = line.match(/^(\s*\})/);
  352. if (!match) return 0;
  353. var column = match[1].length;
  354. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  355. if (!openBracePos || openBracePos.row == row) return 0;
  356. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  357. doc.replace(new Range(row, 0, row, column-1), indent);
  358. };
  359. this.$getIndent = function(line) {
  360. return line.match(/^\s*/)[0];
  361. };
  362. }).call(MatchingBraceOutdent.prototype);
  363. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  364. });
  365. ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  366. "use strict";
  367. var oop = require("../../lib/oop");
  368. var Behaviour = require("../behaviour").Behaviour;
  369. var TokenIterator = require("../../token_iterator").TokenIterator;
  370. var lang = require("../../lib/lang");
  371. var SAFE_INSERT_IN_TOKENS =
  372. ["text", "paren.rparen", "punctuation.operator"];
  373. var SAFE_INSERT_BEFORE_TOKENS =
  374. ["text", "paren.rparen", "punctuation.operator", "comment"];
  375. var context;
  376. var contextCache = {}
  377. var initContext = function(editor) {
  378. var id = -1;
  379. if (editor.multiSelect) {
  380. id = editor.selection.id;
  381. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  382. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  383. }
  384. if (contextCache[id])
  385. return context = contextCache[id];
  386. context = contextCache[id] = {
  387. autoInsertedBrackets: 0,
  388. autoInsertedRow: -1,
  389. autoInsertedLineEnd: "",
  390. maybeInsertedBrackets: 0,
  391. maybeInsertedRow: -1,
  392. maybeInsertedLineStart: "",
  393. maybeInsertedLineEnd: ""
  394. };
  395. };
  396. var CstyleBehaviour = function() {
  397. this.add("braces", "insertion", function(state, action, editor, session, text) {
  398. var cursor = editor.getCursorPosition();
  399. var line = session.doc.getLine(cursor.row);
  400. if (text == '{') {
  401. initContext(editor);
  402. var selection = editor.getSelectionRange();
  403. var selected = session.doc.getTextRange(selection);
  404. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  405. return {
  406. text: '{' + selected + '}',
  407. selection: false
  408. };
  409. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  410. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
  411. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  412. return {
  413. text: '{}',
  414. selection: [1, 1]
  415. };
  416. } else {
  417. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  418. return {
  419. text: '{',
  420. selection: [1, 1]
  421. };
  422. }
  423. }
  424. } else if (text == '}') {
  425. initContext(editor);
  426. var rightChar = line.substring(cursor.column, cursor.column + 1);
  427. if (rightChar == '}') {
  428. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  429. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  430. CstyleBehaviour.popAutoInsertedClosing();
  431. return {
  432. text: '',
  433. selection: [1, 1]
  434. };
  435. }
  436. }
  437. } else if (text == "\n" || text == "\r\n") {
  438. initContext(editor);
  439. var closing = "";
  440. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  441. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  442. CstyleBehaviour.clearMaybeInsertedClosing();
  443. }
  444. var rightChar = line.substring(cursor.column, cursor.column + 1);
  445. if (rightChar === '}') {
  446. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  447. if (!openBracePos)
  448. return null;
  449. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  450. } else if (closing) {
  451. var next_indent = this.$getIndent(line);
  452. } else {
  453. CstyleBehaviour.clearMaybeInsertedClosing();
  454. return;
  455. }
  456. var indent = next_indent + session.getTabString();
  457. return {
  458. text: '\n' + indent + '\n' + next_indent + closing,
  459. selection: [1, indent.length, 1, indent.length]
  460. };
  461. } else {
  462. CstyleBehaviour.clearMaybeInsertedClosing();
  463. }
  464. });
  465. this.add("braces", "deletion", function(state, action, editor, session, range) {
  466. var selected = session.doc.getTextRange(range);
  467. if (!range.isMultiLine() && selected == '{') {
  468. initContext(editor);
  469. var line = session.doc.getLine(range.start.row);
  470. var rightChar = line.substring(range.end.column, range.end.column + 1);
  471. if (rightChar == '}') {
  472. range.end.column++;
  473. return range;
  474. } else {
  475. context.maybeInsertedBrackets--;
  476. }
  477. }
  478. });
  479. this.add("parens", "insertion", function(state, action, editor, session, text) {
  480. if (text == '(') {
  481. initContext(editor);
  482. var selection = editor.getSelectionRange();
  483. var selected = session.doc.getTextRange(selection);
  484. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  485. return {
  486. text: '(' + selected + ')',
  487. selection: false
  488. };
  489. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  490. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  491. return {
  492. text: '()',
  493. selection: [1, 1]
  494. };
  495. }
  496. } else if (text == ')') {
  497. initContext(editor);
  498. var cursor = editor.getCursorPosition();
  499. var line = session.doc.getLine(cursor.row);
  500. var rightChar = line.substring(cursor.column, cursor.column + 1);
  501. if (rightChar == ')') {
  502. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  503. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  504. CstyleBehaviour.popAutoInsertedClosing();
  505. return {
  506. text: '',
  507. selection: [1, 1]
  508. };
  509. }
  510. }
  511. }
  512. });
  513. this.add("parens", "deletion", function(state, action, editor, session, range) {
  514. var selected = session.doc.getTextRange(range);
  515. if (!range.isMultiLine() && selected == '(') {
  516. initContext(editor);
  517. var line = session.doc.getLine(range.start.row);
  518. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  519. if (rightChar == ')') {
  520. range.end.column++;
  521. return range;
  522. }
  523. }
  524. });
  525. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  526. if (text == '[') {
  527. initContext(editor);
  528. var selection = editor.getSelectionRange();
  529. var selected = session.doc.getTextRange(selection);
  530. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  531. return {
  532. text: '[' + selected + ']',
  533. selection: false
  534. };
  535. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  536. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  537. return {
  538. text: '[]',
  539. selection: [1, 1]
  540. };
  541. }
  542. } else if (text == ']') {
  543. initContext(editor);
  544. var cursor = editor.getCursorPosition();
  545. var line = session.doc.getLine(cursor.row);
  546. var rightChar = line.substring(cursor.column, cursor.column + 1);
  547. if (rightChar == ']') {
  548. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  549. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  550. CstyleBehaviour.popAutoInsertedClosing();
  551. return {
  552. text: '',
  553. selection: [1, 1]
  554. };
  555. }
  556. }
  557. }
  558. });
  559. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  560. var selected = session.doc.getTextRange(range);
  561. if (!range.isMultiLine() && selected == '[') {
  562. initContext(editor);
  563. var line = session.doc.getLine(range.start.row);
  564. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  565. if (rightChar == ']') {
  566. range.end.column++;
  567. return range;
  568. }
  569. }
  570. });
  571. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  572. if (text == '"' || text == "'") {
  573. initContext(editor);
  574. var quote = text;
  575. var selection = editor.getSelectionRange();
  576. var selected = session.doc.getTextRange(selection);
  577. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  578. return {
  579. text: quote + selected + quote,
  580. selection: false
  581. };
  582. } else {
  583. var cursor = editor.getCursorPosition();
  584. var line = session.doc.getLine(cursor.row);
  585. var leftChar = line.substring(cursor.column-1, cursor.column);
  586. if (leftChar == '\\') {
  587. return null;
  588. }
  589. var tokens = session.getTokens(selection.start.row);
  590. var col = 0, token;
  591. var quotepos = -1; // Track whether we're inside an open quote.
  592. for (var x = 0; x < tokens.length; x++) {
  593. token = tokens[x];
  594. if (token.type == "string") {
  595. quotepos = -1;
  596. } else if (quotepos < 0) {
  597. quotepos = token.value.indexOf(quote);
  598. }
  599. if ((token.value.length + col) > selection.start.column) {
  600. break;
  601. }
  602. col += tokens[x].value.length;
  603. }
  604. if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
  605. if (!CstyleBehaviour.isSaneInsertion(editor, session))
  606. return;
  607. return {
  608. text: quote + quote,
  609. selection: [1,1]
  610. };
  611. } else if (token && token.type === "string") {
  612. var rightChar = line.substring(cursor.column, cursor.column + 1);
  613. if (rightChar == quote) {
  614. return {
  615. text: '',
  616. selection: [1, 1]
  617. };
  618. }
  619. }
  620. }
  621. }
  622. });
  623. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  624. var selected = session.doc.getTextRange(range);
  625. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  626. initContext(editor);
  627. var line = session.doc.getLine(range.start.row);
  628. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  629. if (rightChar == selected) {
  630. range.end.column++;
  631. return range;
  632. }
  633. }
  634. });
  635. };
  636. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  637. var cursor = editor.getCursorPosition();
  638. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  639. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  640. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  641. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  642. return false;
  643. }
  644. iterator.stepForward();
  645. return iterator.getCurrentTokenRow() !== cursor.row ||
  646. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  647. };
  648. CstyleBehaviour.$matchTokenType = function(token, types) {
  649. return types.indexOf(token.type || token) > -1;
  650. };
  651. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  652. var cursor = editor.getCursorPosition();
  653. var line = session.doc.getLine(cursor.row);
  654. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  655. context.autoInsertedBrackets = 0;
  656. context.autoInsertedRow = cursor.row;
  657. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  658. context.autoInsertedBrackets++;
  659. };
  660. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  661. var cursor = editor.getCursorPosition();
  662. var line = session.doc.getLine(cursor.row);
  663. if (!this.isMaybeInsertedClosing(cursor, line))
  664. context.maybeInsertedBrackets = 0;
  665. context.maybeInsertedRow = cursor.row;
  666. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  667. context.maybeInsertedLineEnd = line.substr(cursor.column);
  668. context.maybeInsertedBrackets++;
  669. };
  670. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  671. return context.autoInsertedBrackets > 0 &&
  672. cursor.row === context.autoInsertedRow &&
  673. bracket === context.autoInsertedLineEnd[0] &&
  674. line.substr(cursor.column) === context.autoInsertedLineEnd;
  675. };
  676. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  677. return context.maybeInsertedBrackets > 0 &&
  678. cursor.row === context.maybeInsertedRow &&
  679. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  680. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  681. };
  682. CstyleBehaviour.popAutoInsertedClosing = function() {
  683. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  684. context.autoInsertedBrackets--;
  685. };
  686. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  687. if (context) {
  688. context.maybeInsertedBrackets = 0;
  689. context.maybeInsertedRow = -1;
  690. }
  691. };
  692. oop.inherits(CstyleBehaviour, Behaviour);
  693. exports.CstyleBehaviour = CstyleBehaviour;
  694. });
  695. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  696. "use strict";
  697. var oop = require("../../lib/oop");
  698. var Range = require("../../range").Range;
  699. var BaseFoldMode = require("./fold_mode").FoldMode;
  700. var FoldMode = exports.FoldMode = function(commentRegex) {
  701. if (commentRegex) {
  702. this.foldingStartMarker = new RegExp(
  703. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  704. );
  705. this.foldingStopMarker = new RegExp(
  706. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  707. );
  708. }
  709. };
  710. oop.inherits(FoldMode, BaseFoldMode);
  711. (function() {
  712. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  713. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  714. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  715. var line = session.getLine(row);
  716. var match = line.match(this.foldingStartMarker);
  717. if (match) {
  718. var i = match.index;
  719. if (match[1])
  720. return this.openingBracketBlock(session, match[1], row, i);
  721. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  722. if (range && !range.isMultiLine()) {
  723. if (forceMultiline) {
  724. range = this.getSectionRange(session, row);
  725. } else if (foldStyle != "all")
  726. range = null;
  727. }
  728. return range;
  729. }
  730. if (foldStyle === "markbegin")
  731. return;
  732. var match = line.match(this.foldingStopMarker);
  733. if (match) {
  734. var i = match.index + match[0].length;
  735. if (match[1])
  736. return this.closingBracketBlock(session, match[1], row, i);
  737. return session.getCommentFoldRange(row, i, -1);
  738. }
  739. };
  740. this.getSectionRange = function(session, row) {
  741. var line = session.getLine(row);
  742. var startIndent = line.search(/\S/);
  743. var startRow = row;
  744. var startColumn = line.length;
  745. row = row + 1;
  746. var endRow = row;
  747. var maxRow = session.getLength();
  748. while (++row < maxRow) {
  749. line = session.getLine(row);
  750. var indent = line.search(/\S/);
  751. if (indent === -1)
  752. continue;
  753. if (startIndent > indent)
  754. break;
  755. var subRange = this.getFoldWidgetRange(session, "all", row);
  756. if (subRange) {
  757. if (subRange.start.row <= startRow) {
  758. break;
  759. } else if (subRange.isMultiLine()) {
  760. row = subRange.end.row;
  761. } else if (startIndent == indent) {
  762. break;
  763. }
  764. }
  765. endRow = row;
  766. }
  767. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  768. };
  769. }).call(FoldMode.prototype);
  770. });
  771. ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
  772. "use strict";
  773. var oop = require("../lib/oop");
  774. var TextMode = require("./text").Mode;
  775. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  776. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  777. var Range = require("../range").Range;
  778. var WorkerClient = require("../worker/worker_client").WorkerClient;
  779. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  780. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  781. var Mode = function() {
  782. this.HighlightRules = JavaScriptHighlightRules;
  783. this.$outdent = new MatchingBraceOutdent();
  784. this.$behaviour = new CstyleBehaviour();
  785. this.foldingRules = new CStyleFoldMode();
  786. };
  787. oop.inherits(Mode, TextMode);
  788. (function() {
  789. this.lineCommentStart = "//";
  790. this.blockComment = {start: "/*", end: "*/"};
  791. this.getNextLineIndent = function(state, line, tab) {
  792. var indent = this.$getIndent(line);
  793. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  794. var tokens = tokenizedLine.tokens;
  795. var endState = tokenizedLine.state;
  796. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  797. return indent;
  798. }
  799. if (state == "start" || state == "no_regex") {
  800. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  801. if (match) {
  802. indent += tab;
  803. }
  804. } else if (state == "doc-start") {
  805. if (endState == "start" || endState == "no_regex") {
  806. return "";
  807. }
  808. var match = line.match(/^\s*(\/?)\*/);
  809. if (match) {
  810. if (match[1]) {
  811. indent += " ";
  812. }
  813. indent += "* ";
  814. }
  815. }
  816. return indent;
  817. };
  818. this.checkOutdent = function(state, line, input) {
  819. return this.$outdent.checkOutdent(line, input);
  820. };
  821. this.autoOutdent = function(state, doc, row) {
  822. this.$outdent.autoOutdent(doc, row);
  823. };
  824. this.createWorker = function(session) {
  825. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  826. worker.attachToDocument(session.getDocument());
  827. worker.on("jslint", function(results) {
  828. session.setAnnotations(results.data);
  829. });
  830. worker.on("terminate", function() {
  831. session.clearAnnotations();
  832. });
  833. return worker;
  834. };
  835. this.$id = "ace/mode/javascript";
  836. }).call(Mode.prototype);
  837. exports.Mode = Mode;
  838. });
  839. ace.define("ace/mode/css_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
  840. "use strict";
  841. var oop = require("../lib/oop");
  842. var lang = require("../lib/lang");
  843. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  844. var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|pointer-events|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
  845. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  846. 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";
  847. var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
  848. var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
  849. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  850. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  851. 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";
  852. var CssHighlightRules = function() {
  853. var keywordMapper = this.createKeywordMapper({
  854. "support.function": supportFunction,
  855. "support.constant": supportConstant,
  856. "support.type": supportType,
  857. "support.constant.color": supportConstantColor,
  858. "support.constant.fonts": supportConstantFonts
  859. }, "text", true);
  860. this.$rules = {
  861. "start" : [{
  862. token : "comment", // multi line comment
  863. regex : "\\/\\*",
  864. push : "comment"
  865. }, {
  866. token: "paren.lparen",
  867. regex: "\\{",
  868. push: "ruleset"
  869. }, {
  870. token: "string",
  871. regex: "@.*?{",
  872. push: "media"
  873. }, {
  874. token: "keyword",
  875. regex: "#[a-z0-9-_]+"
  876. }, {
  877. token: "variable",
  878. regex: "\\.[a-z0-9-_]+"
  879. }, {
  880. token: "string",
  881. regex: ":[a-z0-9-_]+"
  882. }, {
  883. token: "constant",
  884. regex: "[a-z0-9-_]+"
  885. }, {
  886. caseInsensitive: true
  887. }],
  888. "media" : [{
  889. token : "comment", // multi line comment
  890. regex : "\\/\\*",
  891. push : "comment"
  892. }, {
  893. token: "paren.lparen",
  894. regex: "\\{",
  895. push: "ruleset"
  896. }, {
  897. token: "string",
  898. regex: "\\}",
  899. next: "pop"
  900. }, {
  901. token: "keyword",
  902. regex: "#[a-z0-9-_]+"
  903. }, {
  904. token: "variable",
  905. regex: "\\.[a-z0-9-_]+"
  906. }, {
  907. token: "string",
  908. regex: ":[a-z0-9-_]+"
  909. }, {
  910. token: "constant",
  911. regex: "[a-z0-9-_]+"
  912. }, {
  913. caseInsensitive: true
  914. }],
  915. "comment" : [{
  916. token : "comment",
  917. regex : "\\*\\/",
  918. next : "pop"
  919. }, {
  920. defaultToken : "comment"
  921. }],
  922. "ruleset" : [
  923. {
  924. token : "paren.rparen",
  925. regex : "\\}",
  926. next: "pop"
  927. }, {
  928. token : "comment", // multi line comment
  929. regex : "\\/\\*",
  930. push : "comment"
  931. }, {
  932. token : "string", // single line
  933. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  934. }, {
  935. token : "string", // single line
  936. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  937. }, {
  938. token : ["constant.numeric", "keyword"],
  939. regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
  940. }, {
  941. token : "constant.numeric",
  942. regex : numRe
  943. }, {
  944. token : "constant.numeric", // hex6 color
  945. regex : "#[a-f0-9]{6}"
  946. }, {
  947. token : "constant.numeric", // hex3 color
  948. regex : "#[a-f0-9]{3}"
  949. }, {
  950. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  951. regex : pseudoElements
  952. }, {
  953. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  954. regex : pseudoClasses
  955. }, {
  956. token : ["support.function", "string", "support.function"],
  957. regex : "(url\\()(.*)(\\))"
  958. }, {
  959. token : keywordMapper,
  960. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  961. }, {
  962. caseInsensitive: true
  963. }]
  964. };
  965. this.normalizeRules();
  966. };
  967. oop.inherits(CssHighlightRules, TextHighlightRules);
  968. exports.CssHighlightRules = CssHighlightRules;
  969. });
  970. ace.define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(require, exports, module) {
  971. "use strict";
  972. var oop = require("../../lib/oop");
  973. var Behaviour = require("../behaviour").Behaviour;
  974. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  975. var TokenIterator = require("../../token_iterator").TokenIterator;
  976. var CssBehaviour = function () {
  977. this.inherit(CstyleBehaviour);
  978. this.add("colon", "insertion", function (state, action, editor, session, text) {
  979. if (text === ':') {
  980. var cursor = editor.getCursorPosition();
  981. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  982. var token = iterator.getCurrentToken();
  983. if (token && token.value.match(/\s+/)) {
  984. token = iterator.stepBackward();
  985. }
  986. if (token && token.type === 'support.type') {
  987. var line = session.doc.getLine(cursor.row);
  988. var rightChar = line.substring(cursor.column, cursor.column + 1);
  989. if (rightChar === ':') {
  990. return {
  991. text: '',
  992. selection: [1, 1]
  993. }
  994. }
  995. if (!line.substring(cursor.column).match(/^\s*;/)) {
  996. return {
  997. text: ':;',
  998. selection: [1, 1]
  999. }
  1000. }
  1001. }
  1002. }
  1003. });
  1004. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1005. var selected = session.doc.getTextRange(range);
  1006. if (!range.isMultiLine() && selected === ':') {
  1007. var cursor = editor.getCursorPosition();
  1008. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1009. var token = iterator.getCurrentToken();
  1010. if (token && token.value.match(/\s+/)) {
  1011. token = iterator.stepBackward();
  1012. }
  1013. if (token && token.type === 'support.type') {
  1014. var line = session.doc.getLine(range.start.row);
  1015. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1016. if (rightChar === ';') {
  1017. range.end.column ++;
  1018. return range;
  1019. }
  1020. }
  1021. }
  1022. });
  1023. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1024. if (text === ';') {
  1025. var cursor = editor.getCursorPosition();
  1026. var line = session.doc.getLine(cursor.row);
  1027. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1028. if (rightChar === ';') {
  1029. return {
  1030. text: '',
  1031. selection: [1, 1]
  1032. }
  1033. }
  1034. }
  1035. });
  1036. }
  1037. oop.inherits(CssBehaviour, CstyleBehaviour);
  1038. exports.CssBehaviour = CssBehaviour;
  1039. });
  1040. ace.define("ace/mode/css",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/css_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(require, exports, module) {
  1041. "use strict";
  1042. var oop = require("../lib/oop");
  1043. var TextMode = require("./text").Mode;
  1044. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1045. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1046. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1047. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1048. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1049. var Mode = function() {
  1050. this.HighlightRules = CssHighlightRules;
  1051. this.$outdent = new MatchingBraceOutdent();
  1052. this.$behaviour = new CssBehaviour();
  1053. this.foldingRules = new CStyleFoldMode();
  1054. };
  1055. oop.inherits(Mode, TextMode);
  1056. (function() {
  1057. this.foldingRules = "cStyle";
  1058. this.blockComment = {start: "/*", end: "*/"};
  1059. this.getNextLineIndent = function(state, line, tab) {
  1060. var indent = this.$getIndent(line);
  1061. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1062. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1063. return indent;
  1064. }
  1065. var match = line.match(/^.*\{\s*$/);
  1066. if (match) {
  1067. indent += tab;
  1068. }
  1069. return indent;
  1070. };
  1071. this.checkOutdent = function(state, line, input) {
  1072. return this.$outdent.checkOutdent(line, input);
  1073. };
  1074. this.autoOutdent = function(state, doc, row) {
  1075. this.$outdent.autoOutdent(doc, row);
  1076. };
  1077. this.createWorker = function(session) {
  1078. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  1079. worker.attachToDocument(session.getDocument());
  1080. worker.on("csslint", function(e) {
  1081. session.setAnnotations(e.data);
  1082. });
  1083. worker.on("terminate", function() {
  1084. session.clearAnnotations();
  1085. });
  1086. return worker;
  1087. };
  1088. this.$id = "ace/mode/css";
  1089. }).call(Mode.prototype);
  1090. exports.Mode = Mode;
  1091. });
  1092. ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  1093. "use strict";
  1094. var oop = require("../lib/oop");
  1095. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1096. var XmlHighlightRules = function(normalize) {
  1097. this.$rules = {
  1098. start : [
  1099. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  1100. {
  1101. token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
  1102. regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
  1103. },
  1104. {
  1105. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  1106. regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
  1107. },
  1108. {token : "comment.xml", regex : "<\\!--", next : "comment"},
  1109. {
  1110. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  1111. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  1112. },
  1113. {include : "tag"},
  1114. {token : "text.end-tag-open.xml", regex: "</"},
  1115. {token : "text.tag-open.xml", regex: "<"},
  1116. {include : "reference"},
  1117. {defaultToken : "text.xml"}
  1118. ],
  1119. xml_decl : [{
  1120. token : "entity.other.attribute-name.decl-attribute-name.xml",
  1121. regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
  1122. }, {
  1123. token : "keyword.operator.decl-attribute-equals.xml",
  1124. regex : "="
  1125. }, {
  1126. include: "whitespace"
  1127. }, {
  1128. include: "string"
  1129. }, {
  1130. token : "punctuation.xml-decl.xml",
  1131. regex : "\\?>",
  1132. next : "start"
  1133. }],
  1134. processing_instruction : [
  1135. {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
  1136. {defaultToken : "instruction.xml"}
  1137. ],
  1138. doctype : [
  1139. {include : "whitespace"},
  1140. {include : "string"},
  1141. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  1142. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  1143. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  1144. ],
  1145. int_subset : [{
  1146. token : "text.xml",
  1147. regex : "\\s+"
  1148. }, {
  1149. token: "punctuation.int-subset.xml",
  1150. regex: "]",
  1151. next: "pop"
  1152. }, {
  1153. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  1154. regex : "(<\\!)([-_a-zA-Z0-9]+)",
  1155. push : [{
  1156. token : "text",
  1157. regex : "\\s+"
  1158. },
  1159. {
  1160. token : "punctuation.markup-decl.xml",
  1161. regex : ">",
  1162. next : "pop"
  1163. },
  1164. {include : "string"}]
  1165. }],
  1166. cdata : [
  1167. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  1168. {token : "text.xml", regex : "\\s+"},
  1169. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  1170. ],
  1171. comment : [
  1172. {token : "comment.xml", regex : "-->", next : "start"},
  1173. {defaultToken : "comment.xml"}
  1174. ],
  1175. reference : [{
  1176. token : "constant.language.escape.reference.xml",
  1177. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1178. }],
  1179. attr_reference : [{
  1180. token : "constant.language.escape.reference.attribute-value.xml",
  1181. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1182. }],
  1183. tag : [{
  1184. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  1185. regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
  1186. next: [
  1187. {include : "attributes"},
  1188. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1189. ]
  1190. }],
  1191. tag_whitespace : [
  1192. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  1193. ],
  1194. whitespace : [
  1195. {token : "text.whitespace.xml", regex : "\\s+"}
  1196. ],
  1197. string: [{
  1198. token : "string.xml",
  1199. regex : "'",
  1200. push : [
  1201. {token : "string.xml", regex: "'", next: "pop"},
  1202. {defaultToken : "string.xml"}
  1203. ]
  1204. }, {
  1205. token : "string.xml",
  1206. regex : '"',
  1207. push : [
  1208. {token : "string.xml", regex: '"', next: "pop"},
  1209. {defaultToken : "string.xml"}
  1210. ]
  1211. }],
  1212. attributes: [{
  1213. token : "entity.other.attribute-name.xml",
  1214. regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
  1215. }, {
  1216. token : "keyword.operator.attribute-equals.xml",
  1217. regex : "="
  1218. }, {
  1219. include: "tag_whitespace"
  1220. }, {
  1221. include: "attribute_value"
  1222. }],
  1223. attribute_value: [{
  1224. token : "string.attribute-value.xml",
  1225. regex : "'",
  1226. push : [
  1227. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  1228. {include : "attr_reference"},
  1229. {defaultToken : "string.attribute-value.xml"}
  1230. ]
  1231. }, {
  1232. token : "string.attribute-value.xml",
  1233. regex : '"',
  1234. push : [
  1235. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  1236. {include : "attr_reference"},
  1237. {defaultToken : "string.attribute-value.xml"}
  1238. ]
  1239. }]
  1240. };
  1241. if (this.constructor === XmlHighlightRules)
  1242. this.normalizeRules();
  1243. };
  1244. (function() {
  1245. this.embedTagRules = function(HighlightRules, prefix, tag){
  1246. this.$rules.tag.unshift({
  1247. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  1248. regex : "(<)(" + tag + "(?=\\s|>|$))",
  1249. next: [
  1250. {include : "attributes"},
  1251. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  1252. ]
  1253. });
  1254. this.$rules[tag + "-end"] = [
  1255. {include : "attributes"},
  1256. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  1257. onMatch : function(value, currentState, stack) {
  1258. stack.splice(0);
  1259. return this.token;
  1260. }}
  1261. ]
  1262. this.embedRules(HighlightRules, prefix, [{
  1263. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  1264. regex : "(</)(" + tag + "(?=\\s|>|$))",
  1265. next: tag + "-end"
  1266. }, {
  1267. token: "string.cdata.xml",
  1268. regex : "<\\!\\[CDATA\\["
  1269. }, {
  1270. token: "string.cdata.xml",
  1271. regex : "\\]\\]>"
  1272. }]);
  1273. };
  1274. }).call(TextHighlightRules.prototype);
  1275. oop.inherits(XmlHighlightRules, TextHighlightRules);
  1276. exports.XmlHighlightRules = XmlHighlightRules;
  1277. });
  1278. ace.define("ace/mode/html_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/css_highlight_rules","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module) {
  1279. "use strict";
  1280. var oop = require("../lib/oop");
  1281. var lang = require("../lib/lang");
  1282. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1283. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1284. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1285. var tagMap = lang.createMap({
  1286. a : 'anchor',
  1287. button : 'form',
  1288. form : 'form',
  1289. img : 'image',
  1290. input : 'form',
  1291. label : 'form',
  1292. option : 'form',
  1293. script : 'script',
  1294. select : 'form',
  1295. textarea : 'form',
  1296. style : 'style',
  1297. table : 'table',
  1298. tbody : 'table',
  1299. td : 'table',
  1300. tfoot : 'table',
  1301. th : 'table',
  1302. tr : 'table'
  1303. });
  1304. var HtmlHighlightRules = function() {
  1305. XmlHighlightRules.call(this);
  1306. this.addRules({
  1307. attributes: [{
  1308. include : "tag_whitespace"
  1309. }, {
  1310. token : "entity.other.attribute-name.xml",
  1311. regex : "[-_a-zA-Z0-9:]+"
  1312. }, {
  1313. token : "keyword.operator.attribute-equals.xml",
  1314. regex : "=",
  1315. push : [{
  1316. include: "tag_whitespace"
  1317. }, {
  1318. token : "string.unquoted.attribute-value.html",
  1319. regex : "[^<>='\"`\\s]+",
  1320. next : "pop"
  1321. }, {
  1322. token : "empty",
  1323. regex : "",
  1324. next : "pop"
  1325. }]
  1326. }, {
  1327. include : "attribute_value"
  1328. }],
  1329. tag: [{
  1330. token : function(start, tag) {
  1331. var group = tagMap[tag];
  1332. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  1333. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  1334. },
  1335. regex : "(</?)([-_a-zA-Z0-9:]+)",
  1336. next: "tag_stuff"
  1337. }],
  1338. tag_stuff: [
  1339. {include : "attributes"},
  1340. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1341. ],
  1342. });
  1343. this.embedTagRules(CssHighlightRules, "css-", "style");
  1344. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  1345. if (this.constructor === HtmlHighlightRules)
  1346. this.normalizeRules();
  1347. };
  1348. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  1349. exports.HtmlHighlightRules = HtmlHighlightRules;
  1350. });
  1351. ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator"], function(require, exports, module) {
  1352. "use strict";
  1353. var oop = require("../../lib/oop");
  1354. var Behaviour = require("../behaviour").Behaviour;
  1355. var TokenIterator = require("../../token_iterator").TokenIterator;
  1356. function is(token, type) {
  1357. return token.type.lastIndexOf(type + ".xml") > -1;
  1358. }
  1359. var XmlBehaviour = function () {
  1360. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  1361. if (text == '"' || text == "'") {
  1362. var quote = text;
  1363. var selected = session.doc.getTextRange(editor.getSelectionRange());
  1364. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  1365. return {
  1366. text: quote + selected + quote,
  1367. selection: false
  1368. };
  1369. }
  1370. var cursor = editor.getCursorPosition();
  1371. var line = session.doc.getLine(cursor.row);
  1372. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1373. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1374. var token = iterator.getCurrentToken();
  1375. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  1376. return {
  1377. text: "",
  1378. selection: [1, 1]
  1379. };
  1380. }
  1381. if (!token)
  1382. token = iterator.stepBackward();
  1383. if (!token)
  1384. return;
  1385. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  1386. token = iterator.stepBackward();
  1387. }
  1388. var rightSpace = !rightChar || rightChar.match(/\s/);
  1389. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  1390. return {
  1391. text: quote + quote,
  1392. selection: [1, 1]
  1393. };
  1394. }
  1395. }
  1396. });
  1397. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  1398. var selected = session.doc.getTextRange(range);
  1399. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  1400. var line = session.doc.getLine(range.start.row);
  1401. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1402. if (rightChar == selected) {
  1403. range.end.column++;
  1404. return range;
  1405. }
  1406. }
  1407. });
  1408. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  1409. if (text == '>') {
  1410. var position = editor.getCursorPosition();
  1411. var iterator = new TokenIterator(session, position.row, position.column);
  1412. var token = iterator.getCurrentToken() || iterator.stepBackward();
  1413. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  1414. return;
  1415. if (is(token, "reference.attribute-value"))
  1416. return;
  1417. if (is(token, "attribute-value")) {
  1418. var firstChar = token.value.charAt(0);
  1419. if (firstChar == '"' || firstChar == "'") {
  1420. var lastChar = token.value.charAt(token.value.length - 1);
  1421. var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
  1422. if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
  1423. return;
  1424. }
  1425. }
  1426. while (!is(token, "tag-name")) {
  1427. token = iterator.stepBackward();
  1428. }
  1429. var tokenRow = iterator.getCurrentTokenRow();
  1430. var tokenColumn = iterator.getCurrentTokenColumn();
  1431. if (is(iterator.stepBackward(), "end-tag-open"))
  1432. return;
  1433. var element = token.value;
  1434. if (tokenRow == position.row)
  1435. element = element.substring(0, position.column - tokenColumn);
  1436. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  1437. return;
  1438. return {
  1439. text: '>' + '</' + element + '>',
  1440. selection: [1, 1]
  1441. };
  1442. }
  1443. });
  1444. this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
  1445. if (text == "\n") {
  1446. var cursor = editor.getCursorPosition();
  1447. var line = session.getLine(cursor.row);
  1448. var rightChars = line.substring(cursor.column, cursor.column + 2);
  1449. if (rightChars == '</') {
  1450. var next_indent = this.$getIndent(line);
  1451. var indent = next_indent + session.getTabString();
  1452. return {
  1453. text: '\n' + indent + '\n' + next_indent,
  1454. selection: [1, indent.length, 1, indent.length]
  1455. };
  1456. }
  1457. }
  1458. });
  1459. };
  1460. oop.inherits(XmlBehaviour, Behaviour);
  1461. exports.XmlBehaviour = XmlBehaviour;
  1462. });
  1463. ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1464. "use strict";
  1465. var oop = require("../../lib/oop");
  1466. var BaseFoldMode = require("./fold_mode").FoldMode;
  1467. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1468. this.defaultMode = defaultMode;
  1469. this.subModes = subModes;
  1470. };
  1471. oop.inherits(FoldMode, BaseFoldMode);
  1472. (function() {
  1473. this.$getMode = function(state) {
  1474. if (typeof state != "string")
  1475. state = state[0];
  1476. for (var key in this.subModes) {
  1477. if (state.indexOf(key) === 0)
  1478. return this.subModes[key];
  1479. }
  1480. return null;
  1481. };
  1482. this.$tryMode = function(state, session, foldStyle, row) {
  1483. var mode = this.$getMode(state);
  1484. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1485. };
  1486. this.getFoldWidget = function(session, foldStyle, row) {
  1487. return (
  1488. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1489. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1490. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1491. );
  1492. };
  1493. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1494. var mode = this.$getMode(session.getState(row-1));
  1495. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1496. mode = this.$getMode(session.getState(row));
  1497. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1498. mode = this.defaultMode;
  1499. return mode.getFoldWidgetRange(session, foldStyle, row);
  1500. };
  1501. }).call(FoldMode.prototype);
  1502. });
  1503. ace.define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], function(require, exports, module) {
  1504. "use strict";
  1505. var oop = require("../../lib/oop");
  1506. var lang = require("../../lib/lang");
  1507. var Range = require("../../range").Range;
  1508. var BaseFoldMode = require("./fold_mode").FoldMode;
  1509. var TokenIterator = require("../../token_iterator").TokenIterator;
  1510. var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
  1511. BaseFoldMode.call(this);
  1512. this.voidElements = oop.mixin(voidElements || {}, optionalEndTags || {});
  1513. };
  1514. oop.inherits(FoldMode, BaseFoldMode);
  1515. var Tag = function() {
  1516. this.tagName = "";
  1517. this.closing = false;
  1518. this.selfClosing = false;
  1519. this.start = {row: 0, column: 0};
  1520. this.end = {row: 0, column: 0};
  1521. };
  1522. function is(token, type) {
  1523. return token.type.lastIndexOf(type + ".xml") > -1;
  1524. }
  1525. (function() {
  1526. this.getFoldWidget = function(session, foldStyle, row) {
  1527. var tag = this._getFirstTagInLine(session, row);
  1528. if (!tag)
  1529. return "";
  1530. if (tag.closing || (!tag.tagName && tag.selfClosing))
  1531. return foldStyle == "markbeginend" ? "end" : "";
  1532. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  1533. return "";
  1534. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  1535. return "";
  1536. return "start";
  1537. };
  1538. this._getFirstTagInLine = function(session, row) {
  1539. var tokens = session.getTokens(row);
  1540. var tag = new Tag();
  1541. for (var i = 0; i < tokens.length; i++) {
  1542. var token = tokens[i];
  1543. if (is(token, "tag-open")) {
  1544. tag.end.column = tag.start.column + token.value.length;
  1545. tag.closing = is(token, "end-tag-open");
  1546. token = tokens[++i];
  1547. if (!token)
  1548. return null;
  1549. tag.tagName = token.value;
  1550. tag.end.column += token.value.length;
  1551. for (i++; i < tokens.length; i++) {
  1552. token = tokens[i];
  1553. tag.end.column += token.value.length;
  1554. if (is(token, "tag-close")) {
  1555. tag.selfClosing = token.value == '/>';
  1556. break;
  1557. }
  1558. }
  1559. return tag;
  1560. } else if (is(token, "tag-close")) {
  1561. tag.selfClosing = token.value == '/>';
  1562. return tag;
  1563. }
  1564. tag.start.column += token.value.length;
  1565. }
  1566. return null;
  1567. };
  1568. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  1569. var tokens = session.getTokens(row);
  1570. var column = 0;
  1571. for (var i = 0; i < tokens.length; i++) {
  1572. var token = tokens[i];
  1573. column += token.value.length;
  1574. if (column < startColumn)
  1575. continue;
  1576. if (is(token, "end-tag-open")) {
  1577. token = tokens[i + 1];
  1578. if (token && token.value == tagName)
  1579. return true;
  1580. }
  1581. }
  1582. return false;
  1583. };
  1584. this._readTagForward = function(iterator) {
  1585. var token = iterator.getCurrentToken();
  1586. if (!token)
  1587. return null;
  1588. var tag = new Tag();
  1589. do {
  1590. if (is(token, "tag-open")) {
  1591. tag.closing = is(token, "end-tag-open");
  1592. tag.start.row = iterator.getCurrentTokenRow();
  1593. tag.start.column = iterator.getCurrentTokenColumn();
  1594. } else if (is(token, "tag-name")) {
  1595. tag.tagName = token.value;
  1596. } else if (is(token, "tag-close")) {
  1597. tag.selfClosing = token.value == "/>";
  1598. tag.end.row = iterator.getCurrentTokenRow();
  1599. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1600. iterator.stepForward();
  1601. return tag;
  1602. }
  1603. } while(token = iterator.stepForward());
  1604. return null;
  1605. };
  1606. this._readTagBackward = function(iterator) {
  1607. var token = iterator.getCurrentToken();
  1608. if (!token)
  1609. return null;
  1610. var tag = new Tag();
  1611. do {
  1612. if (is(token, "tag-open")) {
  1613. tag.closing = is(token, "end-tag-open");
  1614. tag.start.row = iterator.getCurrentTokenRow();
  1615. tag.start.column = iterator.getCurrentTokenColumn();
  1616. iterator.stepBackward();
  1617. return tag;
  1618. } else if (is(token, "tag-name")) {
  1619. tag.tagName = token.value;
  1620. } else if (is(token, "tag-close")) {
  1621. tag.selfClosing = token.value == "/>";
  1622. tag.end.row = iterator.getCurrentTokenRow();
  1623. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1624. }
  1625. } while(token = iterator.stepBackward());
  1626. return null;
  1627. };
  1628. this._pop = function(stack, tag) {
  1629. while (stack.length) {
  1630. var top = stack[stack.length-1];
  1631. if (!tag || top.tagName == tag.tagName) {
  1632. return stack.pop();
  1633. }
  1634. else if (this.voidElements.hasOwnProperty(tag.tagName)) {
  1635. return;
  1636. }
  1637. else if (this.voidElements.hasOwnProperty(top.tagName)) {
  1638. stack.pop();
  1639. continue;
  1640. } else {
  1641. return null;
  1642. }
  1643. }
  1644. };
  1645. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1646. var firstTag = this._getFirstTagInLine(session, row);
  1647. if (!firstTag)
  1648. return null;
  1649. var isBackward = firstTag.closing || firstTag.selfClosing;
  1650. var stack = [];
  1651. var tag;
  1652. if (!isBackward) {
  1653. var iterator = new TokenIterator(session, row, firstTag.start.column);
  1654. var start = {
  1655. row: row,
  1656. column: firstTag.start.column + firstTag.tagName.length + 2
  1657. };
  1658. while (tag = this._readTagForward(iterator)) {
  1659. if (tag.selfClosing) {
  1660. if (!stack.length) {
  1661. tag.start.column += tag.tagName.length + 2;
  1662. tag.end.column -= 2;
  1663. return Range.fromPoints(tag.start, tag.end);
  1664. } else
  1665. continue;
  1666. }
  1667. if (tag.closing) {
  1668. this._pop(stack, tag);
  1669. if (stack.length == 0)
  1670. return Range.fromPoints(start, tag.start);
  1671. }
  1672. else {
  1673. stack.push(tag);
  1674. }
  1675. }
  1676. }
  1677. else {
  1678. var iterator = new TokenIterator(session, row, firstTag.end.column);
  1679. var end = {
  1680. row: row,
  1681. column: firstTag.start.column
  1682. };
  1683. while (tag = this._readTagBackward(iterator)) {
  1684. if (tag.selfClosing) {
  1685. if (!stack.length) {
  1686. tag.start.column += tag.tagName.length + 2;
  1687. tag.end.column -= 2;
  1688. return Range.fromPoints(tag.start, tag.end);
  1689. } else
  1690. continue;
  1691. }
  1692. if (!tag.closing) {
  1693. this._pop(stack, tag);
  1694. if (stack.length == 0) {
  1695. tag.start.column += tag.tagName.length + 2;
  1696. return Range.fromPoints(tag.start, end);
  1697. }
  1698. }
  1699. else {
  1700. stack.push(tag);
  1701. }
  1702. }
  1703. }
  1704. };
  1705. }).call(FoldMode.prototype);
  1706. });
  1707. ace.define("ace/mode/folding/html",["require","exports","module","ace/lib/oop","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module) {
  1708. "use strict";
  1709. var oop = require("../../lib/oop");
  1710. var MixedFoldMode = require("./mixed").FoldMode;
  1711. var XmlFoldMode = require("./xml").FoldMode;
  1712. var CStyleFoldMode = require("./cstyle").FoldMode;
  1713. var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
  1714. MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
  1715. "js-": new CStyleFoldMode(),
  1716. "css-": new CStyleFoldMode()
  1717. });
  1718. };
  1719. oop.inherits(FoldMode, MixedFoldMode);
  1720. });
  1721. ace.define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) {
  1722. "use strict";
  1723. var TokenIterator = require("../token_iterator").TokenIterator;
  1724. var commonAttributes = [
  1725. "accesskey",
  1726. "class",
  1727. "contenteditable",
  1728. "contextmenu",
  1729. "dir",
  1730. "draggable",
  1731. "dropzone",
  1732. "hidden",
  1733. "id",
  1734. "inert",
  1735. "itemid",
  1736. "itemprop",
  1737. "itemref",
  1738. "itemscope",
  1739. "itemtype",
  1740. "lang",
  1741. "spellcheck",
  1742. "style",
  1743. "tabindex",
  1744. "title",
  1745. "translate"
  1746. ];
  1747. var eventAttributes = [
  1748. "onabort",
  1749. "onblur",
  1750. "oncancel",
  1751. "oncanplay",
  1752. "oncanplaythrough",
  1753. "onchange",
  1754. "onclick",
  1755. "onclose",
  1756. "oncontextmenu",
  1757. "oncuechange",
  1758. "ondblclick",
  1759. "ondrag",
  1760. "ondragend",
  1761. "ondragenter",
  1762. "ondragleave",
  1763. "ondragover",
  1764. "ondragstart",
  1765. "ondrop",
  1766. "ondurationchange",
  1767. "onemptied",
  1768. "onended",
  1769. "onerror",
  1770. "onfocus",
  1771. "oninput",
  1772. "oninvalid",
  1773. "onkeydown",
  1774. "onkeypress",
  1775. "onkeyup",
  1776. "onload",
  1777. "onloadeddata",
  1778. "onloadedmetadata",
  1779. "onloadstart",
  1780. "onmousedown",
  1781. "onmousemove",
  1782. "onmouseout",
  1783. "onmouseover",
  1784. "onmouseup",
  1785. "onmousewheel",
  1786. "onpause",
  1787. "onplay",
  1788. "onplaying",
  1789. "onprogress",
  1790. "onratechange",
  1791. "onreset",
  1792. "onscroll",
  1793. "onseeked",
  1794. "onseeking",
  1795. "onselect",
  1796. "onshow",
  1797. "onstalled",
  1798. "onsubmit",
  1799. "onsuspend",
  1800. "ontimeupdate",
  1801. "onvolumechange",
  1802. "onwaiting"
  1803. ];
  1804. var globalAttributes = commonAttributes.concat(eventAttributes);
  1805. var attributeMap = {
  1806. "html": ["manifest"],
  1807. "head": [],
  1808. "title": [],
  1809. "base": ["href", "target"],
  1810. "link": ["href", "hreflang", "rel", "media", "type", "sizes"],
  1811. "meta": ["http-equiv", "name", "content", "charset"],
  1812. "style": ["type", "media", "scoped"],
  1813. "script": ["charset", "type", "src", "defer", "async"],
  1814. "noscript": ["href"],
  1815. "body": ["onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onmessage", "onoffline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload"],
  1816. "section": [],
  1817. "nav": [],
  1818. "article": ["pubdate"],
  1819. "aside": [],
  1820. "h1": [],
  1821. "h2": [],
  1822. "h3": [],
  1823. "h4": [],
  1824. "h5": [],
  1825. "h6": [],
  1826. "header": [],
  1827. "footer": [],
  1828. "address": [],
  1829. "main": [],
  1830. "p": [],
  1831. "hr": [],
  1832. "pre": [],
  1833. "blockquote": ["cite"],
  1834. "ol": ["start", "reversed"],
  1835. "ul": [],
  1836. "li": ["value"],
  1837. "dl": [],
  1838. "dt": [],
  1839. "dd": [],
  1840. "figure": [],
  1841. "figcaption": [],
  1842. "div": [],
  1843. "a": ["href", "target", "ping", "rel", "media", "hreflang", "type"],
  1844. "em": [],
  1845. "strong": [],
  1846. "small": [],
  1847. "s": [],
  1848. "cite": [],
  1849. "q": ["cite"],
  1850. "dfn": [],
  1851. "abbr": [],
  1852. "data": [],
  1853. "time": ["datetime"],
  1854. "code": [],
  1855. "var": [],
  1856. "samp": [],
  1857. "kbd": [],
  1858. "sub": [],
  1859. "sup": [],
  1860. "i": [],
  1861. "b": [],
  1862. "u": [],
  1863. "mark": [],
  1864. "ruby": [],
  1865. "rt": [],
  1866. "rp": [],
  1867. "bdi": [],
  1868. "bdo": [],
  1869. "span": [],
  1870. "br": [],
  1871. "wbr": [],
  1872. "ins": ["cite", "datetime"],
  1873. "del": ["cite", "datetime"],
  1874. "img": ["alt", "src", "height", "width", "usemap", "ismap"],
  1875. "iframe": ["name", "src", "height", "width", "sandbox", "seamless"],
  1876. "embed": ["src", "height", "width", "type"],
  1877. "object": ["param", "data", "type", "height" , "width", "usemap", "name", "form", "classid"],
  1878. "param": ["name", "value"],
  1879. "video": ["src", "autobuffer", "autoplay", "loop", "controls", "width", "height", "poster"],
  1880. "audio": ["src", "autobuffer", "autoplay", "loop", "controls"],
  1881. "source": ["src", "type", "media"],
  1882. "track": ["kind", "src", "srclang", "label", "default"],
  1883. "canvas": ["width", "height"],
  1884. "map": ["name"],
  1885. "area": ["shape", "coords", "href", "hreflang", "alt", "target", "media", "rel", "ping", "type"],
  1886. "svg": [],
  1887. "math": [],
  1888. "table": ["summary"],
  1889. "caption": [],
  1890. "colgroup": ["span"],
  1891. "col": ["span"],
  1892. "tbody": [],
  1893. "thead": [],
  1894. "tfoot": [],
  1895. "tr": [],
  1896. "td": ["headers", "rowspan", "colspan"],
  1897. "th": ["headers", "rowspan", "colspan", "scope"],
  1898. "form": ["accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"],
  1899. "fieldset": ["disabled", "form", "name"],
  1900. "legend": [],
  1901. "label": ["form", "for"],
  1902. "input": ["type", "accept", "alt", "autocomplete", "checked", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "list", "max", "maxlength", "min", "multiple", "pattern", "placeholder", "readonly", "required", "size", "src", "step", "width", "files", "value"],
  1903. "button": ["autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "value", "type"],
  1904. "select": ["autofocus", "disabled", "form", "multiple", "name", "size"],
  1905. "datalist": [],
  1906. "optgroup": ["disabled", "label"],
  1907. "option": ["disabled", "selected", "label", "value"],
  1908. "textarea": ["autofocus", "disabled", "form", "maxlength", "name", "placeholder", "readonly", "required", "rows", "cols", "wrap"],
  1909. "keygen": ["autofocus", "challenge", "disabled", "form", "keytype", "name"],
  1910. "output": ["for", "form", "name"],
  1911. "progress": ["value", "max"],
  1912. "meter": ["value", "min", "max", "low", "high", "optimum"],
  1913. "details": ["open"],
  1914. "summary": [],
  1915. "command": ["type", "label", "icon", "disabled", "checked", "radiogroup", "command"],
  1916. "menu": ["type", "label"],
  1917. "dialog": ["open"]
  1918. };
  1919. var elements = Object.keys(attributeMap);
  1920. function is(token, type) {
  1921. return token.type.lastIndexOf(type + ".xml") > -1;
  1922. }
  1923. function findTagName(session, pos) {
  1924. var iterator = new TokenIterator(session, pos.row, pos.column);
  1925. var token = iterator.getCurrentToken();
  1926. while (token && !is(token, "tag-name")){
  1927. token = iterator.stepBackward();
  1928. }
  1929. if (token)
  1930. return token.value;
  1931. }
  1932. var HtmlCompletions = function() {
  1933. };
  1934. (function() {
  1935. this.getCompletions = function(state, session, pos, prefix) {
  1936. var token = session.getTokenAt(pos.row, pos.column);
  1937. if (!token)
  1938. return [];
  1939. if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
  1940. return this.getTagCompletions(state, session, pos, prefix);
  1941. if (is(token, "tag-whitespace") || is(token, "attribute-name"))
  1942. return this.getAttributeCompetions(state, session, pos, prefix);
  1943. return [];
  1944. };
  1945. this.getTagCompletions = function(state, session, pos, prefix) {
  1946. return elements.map(function(element){
  1947. return {
  1948. value: element,
  1949. meta: "tag",
  1950. score: Number.MAX_VALUE
  1951. };
  1952. });
  1953. };
  1954. this.getAttributeCompetions = function(state, session, pos, prefix) {
  1955. var tagName = findTagName(session, pos);
  1956. if (!tagName)
  1957. return [];
  1958. var attributes = globalAttributes;
  1959. if (tagName in attributeMap) {
  1960. attributes = attributes.concat(attributeMap[tagName]);
  1961. }
  1962. return attributes.map(function(attribute){
  1963. return {
  1964. caption: attribute,
  1965. snippet: attribute + '="$0"',
  1966. meta: "attribute",
  1967. score: Number.MAX_VALUE
  1968. };
  1969. });
  1970. };
  1971. }).call(HtmlCompletions.prototype);
  1972. exports.HtmlCompletions = HtmlCompletions;
  1973. });
  1974. ace.define("ace/mode/html",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/javascript","ace/mode/css","ace/mode/html_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/html","ace/mode/html_completions","ace/worker/worker_client"], function(require, exports, module) {
  1975. "use strict";
  1976. var oop = require("../lib/oop");
  1977. var lang = require("../lib/lang");
  1978. var TextMode = require("./text").Mode;
  1979. var JavaScriptMode = require("./javascript").Mode;
  1980. var CssMode = require("./css").Mode;
  1981. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  1982. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  1983. var HtmlFoldMode = require("./folding/html").FoldMode;
  1984. var HtmlCompletions = require("./html_completions").HtmlCompletions;
  1985. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1986. var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
  1987. var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
  1988. var Mode = function(options) {
  1989. this.fragmentContext = options && options.fragmentContext;
  1990. this.HighlightRules = HtmlHighlightRules;
  1991. this.$behaviour = new XmlBehaviour();
  1992. this.$completer = new HtmlCompletions();
  1993. this.createModeDelegates({
  1994. "js-": JavaScriptMode,
  1995. "css-": CssMode
  1996. });
  1997. this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
  1998. };
  1999. oop.inherits(Mode, TextMode);
  2000. (function() {
  2001. this.blockComment = {start: "<!--", end: "-->"};
  2002. this.voidElements = lang.arrayToMap(voidElements);
  2003. this.getNextLineIndent = function(state, line, tab) {
  2004. return this.$getIndent(line);
  2005. };
  2006. this.checkOutdent = function(state, line, input) {
  2007. return false;
  2008. };
  2009. this.getCompletions = function(state, session, pos, prefix) {
  2010. return this.$completer.getCompletions(state, session, pos, prefix);
  2011. };
  2012. this.createWorker = function(session) {
  2013. if (this.constructor != Mode)
  2014. return;
  2015. var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
  2016. worker.attachToDocument(session.getDocument());
  2017. if (this.fragmentContext)
  2018. worker.call("setOptions", [{context: this.fragmentContext}]);
  2019. worker.on("error", function(e) {
  2020. session.setAnnotations(e.data);
  2021. });
  2022. worker.on("terminate", function() {
  2023. session.clearAnnotations();
  2024. });
  2025. return worker;
  2026. };
  2027. this.$id = "ace/mode/html";
  2028. }).call(Mode.prototype);
  2029. exports.Mode = Mode;
  2030. });
  2031. ace.define("ace/mode/handlebars_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/html_highlight_rules"], function(require, exports, module) {
  2032. "use strict";
  2033. var oop = require("../lib/oop");
  2034. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2035. function pop2(currentState, stack) {
  2036. stack.splice(0, 3);
  2037. return stack.shift() || "start";
  2038. }
  2039. var HandlebarsHighlightRules = function() {
  2040. HtmlHighlightRules.call(this);
  2041. var hbs = {
  2042. regex : "(?={{)",
  2043. push : "handlebars"
  2044. }
  2045. for (var key in this.$rules) {
  2046. this.$rules[key].unshift(hbs);
  2047. }
  2048. this.$rules.handlebars = [{
  2049. token : "comment.start",
  2050. regex : "{{!--",
  2051. push : [{
  2052. token : "comment.end",
  2053. regex : "--}}",
  2054. next : pop2
  2055. }, {
  2056. defaultToken : "comment"
  2057. }]
  2058. }, {
  2059. token : "comment.start",
  2060. regex : "{{!",
  2061. push : [{
  2062. token : "comment.end",
  2063. regex : "}}",
  2064. next : pop2
  2065. }, {
  2066. defaultToken : "comment"
  2067. }]
  2068. }, {
  2069. token : "storage.type.start", // begin section
  2070. regex : "{{[#\\^/&]?",
  2071. push : [{
  2072. token : "storage.type.end",
  2073. regex : "}}",
  2074. next : pop2
  2075. }, {
  2076. token : "variable.parameter",
  2077. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
  2078. }]
  2079. }, {
  2080. token : "support.function", // unescaped variable
  2081. regex : "{{{",
  2082. push : [{
  2083. token : "support.function",
  2084. regex : "}}}",
  2085. next : pop2
  2086. }, {
  2087. token : "variable.parameter",
  2088. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
  2089. }]
  2090. }];
  2091. this.normalizeRules();
  2092. };
  2093. oop.inherits(HandlebarsHighlightRules, HtmlHighlightRules);
  2094. exports.HandlebarsHighlightRules = HandlebarsHighlightRules;
  2095. });
  2096. ace.define("ace/mode/behaviour/html",["require","exports","module","ace/lib/oop","ace/mode/behaviour/xml"], function(require, exports, module) {
  2097. "use strict";
  2098. var oop = require("../../lib/oop");
  2099. var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
  2100. var HtmlBehaviour = function () {
  2101. XmlBehaviour.call(this);
  2102. };
  2103. oop.inherits(HtmlBehaviour, XmlBehaviour);
  2104. exports.HtmlBehaviour = HtmlBehaviour;
  2105. });
  2106. ace.define("ace/mode/handlebars",["require","exports","module","ace/lib/oop","ace/mode/html","ace/mode/handlebars_highlight_rules","ace/mode/behaviour/html","ace/mode/folding/html"], function(require, exports, module) {
  2107. "use strict";
  2108. var oop = require("../lib/oop");
  2109. var HtmlMode = require("./html").Mode;
  2110. var HandlebarsHighlightRules = require("./handlebars_highlight_rules").HandlebarsHighlightRules;
  2111. var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
  2112. var HtmlFoldMode = require("./folding/html").FoldMode;
  2113. var Mode = function() {
  2114. HtmlMode.call(this);
  2115. this.HighlightRules = HandlebarsHighlightRules;
  2116. this.$behaviour = new HtmlBehaviour();
  2117. this.foldingRules = new HtmlFoldMode();
  2118. };
  2119. oop.inherits(Mode, HtmlMode);
  2120. (function() {
  2121. this.$id = "ace/mode/handlebars";
  2122. }).call(Mode.prototype);
  2123. exports.Mode = Mode;
  2124. });