mode-ejs.js 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961
  1. 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) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var lang = require("../lib/lang");
  5. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  6. 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";
  7. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  8. 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";
  9. var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
  10. var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
  11. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  12. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  13. 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";
  14. var CssHighlightRules = function() {
  15. var keywordMapper = this.createKeywordMapper({
  16. "support.function": supportFunction,
  17. "support.constant": supportConstant,
  18. "support.type": supportType,
  19. "support.constant.color": supportConstantColor,
  20. "support.constant.fonts": supportConstantFonts
  21. }, "text", true);
  22. this.$rules = {
  23. "start" : [{
  24. token : "comment", // multi line comment
  25. regex : "\\/\\*",
  26. push : "comment"
  27. }, {
  28. token: "paren.lparen",
  29. regex: "\\{",
  30. push: "ruleset"
  31. }, {
  32. token: "string",
  33. regex: "@.*?{",
  34. push: "media"
  35. }, {
  36. token: "keyword",
  37. regex: "#[a-z0-9-_]+"
  38. }, {
  39. token: "variable",
  40. regex: "\\.[a-z0-9-_]+"
  41. }, {
  42. token: "string",
  43. regex: ":[a-z0-9-_]+"
  44. }, {
  45. token: "constant",
  46. regex: "[a-z0-9-_]+"
  47. }, {
  48. caseInsensitive: true
  49. }],
  50. "media" : [{
  51. token : "comment", // multi line comment
  52. regex : "\\/\\*",
  53. push : "comment"
  54. }, {
  55. token: "paren.lparen",
  56. regex: "\\{",
  57. push: "ruleset"
  58. }, {
  59. token: "string",
  60. regex: "\\}",
  61. next: "pop"
  62. }, {
  63. token: "keyword",
  64. regex: "#[a-z0-9-_]+"
  65. }, {
  66. token: "variable",
  67. regex: "\\.[a-z0-9-_]+"
  68. }, {
  69. token: "string",
  70. regex: ":[a-z0-9-_]+"
  71. }, {
  72. token: "constant",
  73. regex: "[a-z0-9-_]+"
  74. }, {
  75. caseInsensitive: true
  76. }],
  77. "comment" : [{
  78. token : "comment",
  79. regex : "\\*\\/",
  80. next : "pop"
  81. }, {
  82. defaultToken : "comment"
  83. }],
  84. "ruleset" : [
  85. {
  86. token : "paren.rparen",
  87. regex : "\\}",
  88. next: "pop"
  89. }, {
  90. token : "comment", // multi line comment
  91. regex : "\\/\\*",
  92. push : "comment"
  93. }, {
  94. token : "string", // single line
  95. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  96. }, {
  97. token : "string", // single line
  98. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  99. }, {
  100. token : ["constant.numeric", "keyword"],
  101. 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|%)"
  102. }, {
  103. token : "constant.numeric",
  104. regex : numRe
  105. }, {
  106. token : "constant.numeric", // hex6 color
  107. regex : "#[a-f0-9]{6}"
  108. }, {
  109. token : "constant.numeric", // hex3 color
  110. regex : "#[a-f0-9]{3}"
  111. }, {
  112. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  113. regex : pseudoElements
  114. }, {
  115. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  116. regex : pseudoClasses
  117. }, {
  118. token : ["support.function", "string", "support.function"],
  119. regex : "(url\\()(.*)(\\))"
  120. }, {
  121. token : keywordMapper,
  122. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  123. }, {
  124. caseInsensitive: true
  125. }]
  126. };
  127. this.normalizeRules();
  128. };
  129. oop.inherits(CssHighlightRules, TextHighlightRules);
  130. exports.CssHighlightRules = CssHighlightRules;
  131. });
  132. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  133. "use strict";
  134. var oop = require("../lib/oop");
  135. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  136. var DocCommentHighlightRules = function() {
  137. this.$rules = {
  138. "start" : [ {
  139. token : "comment.doc.tag",
  140. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  141. },
  142. DocCommentHighlightRules.getTagRule(),
  143. {
  144. defaultToken : "comment.doc",
  145. caseInsensitive: true
  146. }]
  147. };
  148. };
  149. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  150. DocCommentHighlightRules.getTagRule = function(start) {
  151. return {
  152. token : "comment.doc.tag.storage.type",
  153. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  154. };
  155. }
  156. DocCommentHighlightRules.getStartRule = function(start) {
  157. return {
  158. token : "comment.doc", // doc comment
  159. regex : "\\/\\*(?=\\*)",
  160. next : start
  161. };
  162. };
  163. DocCommentHighlightRules.getEndRule = function (start) {
  164. return {
  165. token : "comment.doc", // closing comment
  166. regex : "\\*\\/",
  167. next : start
  168. };
  169. };
  170. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  171. });
  172. 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) {
  173. "use strict";
  174. var oop = require("../lib/oop");
  175. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  176. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  177. var JavaScriptHighlightRules = function(options) {
  178. var keywordMapper = this.createKeywordMapper({
  179. "variable.language":
  180. "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  181. "Namespace|QName|XML|XMLList|" + // E4X
  182. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  183. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  184. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  185. "SyntaxError|TypeError|URIError|" +
  186. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  187. "isNaN|parseFloat|parseInt|" +
  188. "JSON|Math|" + // Other
  189. "this|arguments|prototype|window|document" , // Pseudo
  190. "keyword":
  191. "const|yield|import|get|set|" +
  192. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  193. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  194. "__parent__|__count__|escape|unescape|with|__proto__|" +
  195. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  196. "storage.type":
  197. "const|let|var|function",
  198. "constant.language":
  199. "null|Infinity|NaN|undefined",
  200. "support.function":
  201. "alert",
  202. "constant.language.boolean": "true|false"
  203. }, "identifier");
  204. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  205. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  206. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  207. "u[0-9a-fA-F]{4}|" + // unicode
  208. "[0-2][0-7]{0,2}|" + // oct
  209. "3[0-6][0-7]?|" + // oct
  210. "37[0-7]?|" + // oct
  211. "[4-7][0-7]?|" + //oct
  212. ".)";
  213. this.$rules = {
  214. "no_regex" : [
  215. {
  216. token : "comment",
  217. regex : "\\/\\/",
  218. next : "line_comment"
  219. },
  220. DocCommentHighlightRules.getStartRule("doc-start"),
  221. {
  222. token : "comment", // multi line comment
  223. regex : /\/\*/,
  224. next : "comment"
  225. }, {
  226. token : "string",
  227. regex : "'(?=.)",
  228. next : "qstring"
  229. }, {
  230. token : "string",
  231. regex : '"(?=.)',
  232. next : "qqstring"
  233. }, {
  234. token : "constant.numeric", // hex
  235. regex : /0[xX][0-9a-fA-F]+\b/
  236. }, {
  237. token : "constant.numeric", // float
  238. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  239. }, {
  240. token : [
  241. "storage.type", "punctuation.operator", "support.function",
  242. "punctuation.operator", "entity.name.function", "text","keyword.operator"
  243. ],
  244. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  245. next: "function_arguments"
  246. }, {
  247. token : [
  248. "storage.type", "punctuation.operator", "entity.name.function", "text",
  249. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  250. ],
  251. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  252. next: "function_arguments"
  253. }, {
  254. token : [
  255. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  256. "text", "paren.lparen"
  257. ],
  258. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  259. next: "function_arguments"
  260. }, {
  261. token : [
  262. "storage.type", "punctuation.operator", "entity.name.function", "text",
  263. "keyword.operator", "text",
  264. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  265. ],
  266. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  267. next: "function_arguments"
  268. }, {
  269. token : [
  270. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  271. ],
  272. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  273. next: "function_arguments"
  274. }, {
  275. token : [
  276. "entity.name.function", "text", "punctuation.operator",
  277. "text", "storage.type", "text", "paren.lparen"
  278. ],
  279. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  280. next: "function_arguments"
  281. }, {
  282. token : [
  283. "text", "text", "storage.type", "text", "paren.lparen"
  284. ],
  285. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  286. next: "function_arguments"
  287. }, {
  288. token : "keyword",
  289. regex : "(?:" + kwBeforeRe + ")\\b",
  290. next : "start"
  291. }, {
  292. token : ["punctuation.operator", "support.function"],
  293. 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(?=\()/
  294. }, {
  295. token : ["punctuation.operator", "support.function.dom"],
  296. regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  297. }, {
  298. token : ["punctuation.operator", "support.constant"],
  299. 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/
  300. }, {
  301. token : ["support.constant"],
  302. regex : /that\b/
  303. }, {
  304. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  305. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  306. }, {
  307. token : keywordMapper,
  308. regex : identifierRe
  309. }, {
  310. token : "keyword.operator",
  311. regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
  312. next : "start"
  313. }, {
  314. token : "punctuation.operator",
  315. regex : /[?:,;.]/,
  316. next : "start"
  317. }, {
  318. token : "paren.lparen",
  319. regex : /[\[({]/,
  320. next : "start"
  321. }, {
  322. token : "paren.rparen",
  323. regex : /[\])}]/
  324. }, {
  325. token: "comment",
  326. regex: /^#!.*$/
  327. }
  328. ],
  329. "start": [
  330. DocCommentHighlightRules.getStartRule("doc-start"),
  331. {
  332. token : "comment", // multi line comment
  333. regex : "\\/\\*",
  334. next : "comment_regex_allowed"
  335. }, {
  336. token : "comment",
  337. regex : "\\/\\/",
  338. next : "line_comment_regex_allowed"
  339. }, {
  340. token: "string.regexp",
  341. regex: "\\/",
  342. next: "regex"
  343. }, {
  344. token : "text",
  345. regex : "\\s+|^$",
  346. next : "start"
  347. }, {
  348. token: "empty",
  349. regex: "",
  350. next: "no_regex"
  351. }
  352. ],
  353. "regex": [
  354. {
  355. token: "regexp.keyword.operator",
  356. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  357. }, {
  358. token: "string.regexp",
  359. regex: "/[sxngimy]*",
  360. next: "no_regex"
  361. }, {
  362. token : "invalid",
  363. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  364. }, {
  365. token : "constant.language.escape",
  366. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  367. }, {
  368. token : "constant.language.delimiter",
  369. regex: /\|/
  370. }, {
  371. token: "constant.language.escape",
  372. regex: /\[\^?/,
  373. next: "regex_character_class"
  374. }, {
  375. token: "empty",
  376. regex: "$",
  377. next: "no_regex"
  378. }, {
  379. defaultToken: "string.regexp"
  380. }
  381. ],
  382. "regex_character_class": [
  383. {
  384. token: "regexp.charclass.keyword.operator",
  385. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  386. }, {
  387. token: "constant.language.escape",
  388. regex: "]",
  389. next: "regex"
  390. }, {
  391. token: "constant.language.escape",
  392. regex: "-"
  393. }, {
  394. token: "empty",
  395. regex: "$",
  396. next: "no_regex"
  397. }, {
  398. defaultToken: "string.regexp.charachterclass"
  399. }
  400. ],
  401. "function_arguments": [
  402. {
  403. token: "variable.parameter",
  404. regex: identifierRe
  405. }, {
  406. token: "punctuation.operator",
  407. regex: "[, ]+"
  408. }, {
  409. token: "punctuation.operator",
  410. regex: "$"
  411. }, {
  412. token: "empty",
  413. regex: "",
  414. next: "no_regex"
  415. }
  416. ],
  417. "comment_regex_allowed" : [
  418. DocCommentHighlightRules.getTagRule(),
  419. {token : "comment", regex : "\\*\\/", next : "start"},
  420. {defaultToken : "comment", caseInsensitive: true}
  421. ],
  422. "comment" : [
  423. DocCommentHighlightRules.getTagRule(),
  424. {token : "comment", regex : "\\*\\/", next : "no_regex"},
  425. {defaultToken : "comment", caseInsensitive: true}
  426. ],
  427. "line_comment_regex_allowed" : [
  428. DocCommentHighlightRules.getTagRule(),
  429. {token : "comment", regex : "$|^", next : "start"},
  430. {defaultToken : "comment", caseInsensitive: true}
  431. ],
  432. "line_comment" : [
  433. DocCommentHighlightRules.getTagRule(),
  434. {token : "comment", regex : "$|^", next : "no_regex"},
  435. {defaultToken : "comment", caseInsensitive: true}
  436. ],
  437. "qqstring" : [
  438. {
  439. token : "constant.language.escape",
  440. regex : escapedRe
  441. }, {
  442. token : "string",
  443. regex : "\\\\$",
  444. next : "qqstring"
  445. }, {
  446. token : "string",
  447. regex : '"|$',
  448. next : "no_regex"
  449. }, {
  450. defaultToken: "string"
  451. }
  452. ],
  453. "qstring" : [
  454. {
  455. token : "constant.language.escape",
  456. regex : escapedRe
  457. }, {
  458. token : "string",
  459. regex : "\\\\$",
  460. next : "qstring"
  461. }, {
  462. token : "string",
  463. regex : "'|$",
  464. next : "no_regex"
  465. }, {
  466. defaultToken: "string"
  467. }
  468. ]
  469. };
  470. if (!options || !options.noES6) {
  471. this.$rules.no_regex.unshift({
  472. regex: "[{}]", onMatch: function(val, state, stack) {
  473. this.next = val == "{" ? this.nextState : "";
  474. if (val == "{" && stack.length) {
  475. stack.unshift("start", state);
  476. return "paren";
  477. }
  478. if (val == "}" && stack.length) {
  479. stack.shift();
  480. this.next = stack.shift();
  481. if (this.next.indexOf("string") != -1)
  482. return "paren.quasi.end";
  483. }
  484. return val == "{" ? "paren.lparen" : "paren.rparen";
  485. },
  486. nextState: "start"
  487. }, {
  488. token : "string.quasi.start",
  489. regex : /`/,
  490. push : [{
  491. token : "constant.language.escape",
  492. regex : escapedRe
  493. }, {
  494. token : "paren.quasi.start",
  495. regex : /\${/,
  496. push : "start"
  497. }, {
  498. token : "string.quasi.end",
  499. regex : /`/,
  500. next : "pop"
  501. }, {
  502. defaultToken: "string.quasi"
  503. }]
  504. });
  505. }
  506. this.embedRules(DocCommentHighlightRules, "doc-",
  507. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  508. this.normalizeRules();
  509. };
  510. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  511. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  512. });
  513. ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  514. "use strict";
  515. var oop = require("../lib/oop");
  516. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  517. var XmlHighlightRules = function(normalize) {
  518. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  519. this.$rules = {
  520. start : [
  521. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  522. {
  523. token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
  524. regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
  525. },
  526. {
  527. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  528. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
  529. },
  530. {token : "comment.xml", regex : "<\\!--", next : "comment"},
  531. {
  532. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  533. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  534. },
  535. {include : "tag"},
  536. {token : "text.end-tag-open.xml", regex: "</"},
  537. {token : "text.tag-open.xml", regex: "<"},
  538. {include : "reference"},
  539. {defaultToken : "text.xml"}
  540. ],
  541. xml_decl : [{
  542. token : "entity.other.attribute-name.decl-attribute-name.xml",
  543. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  544. }, {
  545. token : "keyword.operator.decl-attribute-equals.xml",
  546. regex : "="
  547. }, {
  548. include: "whitespace"
  549. }, {
  550. include: "string"
  551. }, {
  552. token : "punctuation.xml-decl.xml",
  553. regex : "\\?>",
  554. next : "start"
  555. }],
  556. processing_instruction : [
  557. {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
  558. {defaultToken : "instruction.xml"}
  559. ],
  560. doctype : [
  561. {include : "whitespace"},
  562. {include : "string"},
  563. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  564. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  565. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  566. ],
  567. int_subset : [{
  568. token : "text.xml",
  569. regex : "\\s+"
  570. }, {
  571. token: "punctuation.int-subset.xml",
  572. regex: "]",
  573. next: "pop"
  574. }, {
  575. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  576. regex : "(<\\!)(" + tagRegex + ")",
  577. push : [{
  578. token : "text",
  579. regex : "\\s+"
  580. },
  581. {
  582. token : "punctuation.markup-decl.xml",
  583. regex : ">",
  584. next : "pop"
  585. },
  586. {include : "string"}]
  587. }],
  588. cdata : [
  589. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  590. {token : "text.xml", regex : "\\s+"},
  591. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  592. ],
  593. comment : [
  594. {token : "comment.xml", regex : "-->", next : "start"},
  595. {defaultToken : "comment.xml"}
  596. ],
  597. reference : [{
  598. token : "constant.language.escape.reference.xml",
  599. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  600. }],
  601. attr_reference : [{
  602. token : "constant.language.escape.reference.attribute-value.xml",
  603. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  604. }],
  605. tag : [{
  606. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  607. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  608. next: [
  609. {include : "attributes"},
  610. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  611. ]
  612. }],
  613. tag_whitespace : [
  614. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  615. ],
  616. whitespace : [
  617. {token : "text.whitespace.xml", regex : "\\s+"}
  618. ],
  619. string: [{
  620. token : "string.xml",
  621. regex : "'",
  622. push : [
  623. {token : "string.xml", regex: "'", next: "pop"},
  624. {defaultToken : "string.xml"}
  625. ]
  626. }, {
  627. token : "string.xml",
  628. regex : '"',
  629. push : [
  630. {token : "string.xml", regex: '"', next: "pop"},
  631. {defaultToken : "string.xml"}
  632. ]
  633. }],
  634. attributes: [{
  635. token : "entity.other.attribute-name.xml",
  636. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  637. }, {
  638. token : "keyword.operator.attribute-equals.xml",
  639. regex : "="
  640. }, {
  641. include: "tag_whitespace"
  642. }, {
  643. include: "attribute_value"
  644. }],
  645. attribute_value: [{
  646. token : "string.attribute-value.xml",
  647. regex : "'",
  648. push : [
  649. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  650. {include : "attr_reference"},
  651. {defaultToken : "string.attribute-value.xml"}
  652. ]
  653. }, {
  654. token : "string.attribute-value.xml",
  655. regex : '"',
  656. push : [
  657. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  658. {include : "attr_reference"},
  659. {defaultToken : "string.attribute-value.xml"}
  660. ]
  661. }]
  662. };
  663. if (this.constructor === XmlHighlightRules)
  664. this.normalizeRules();
  665. };
  666. (function() {
  667. this.embedTagRules = function(HighlightRules, prefix, tag){
  668. this.$rules.tag.unshift({
  669. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  670. regex : "(<)(" + tag + "(?=\\s|>|$))",
  671. next: [
  672. {include : "attributes"},
  673. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  674. ]
  675. });
  676. this.$rules[tag + "-end"] = [
  677. {include : "attributes"},
  678. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  679. onMatch : function(value, currentState, stack) {
  680. stack.splice(0);
  681. return this.token;
  682. }}
  683. ]
  684. this.embedRules(HighlightRules, prefix, [{
  685. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  686. regex : "(</)(" + tag + "(?=\\s|>|$))",
  687. next: tag + "-end"
  688. }, {
  689. token: "string.cdata.xml",
  690. regex : "<\\!\\[CDATA\\["
  691. }, {
  692. token: "string.cdata.xml",
  693. regex : "\\]\\]>"
  694. }]);
  695. };
  696. }).call(TextHighlightRules.prototype);
  697. oop.inherits(XmlHighlightRules, TextHighlightRules);
  698. exports.XmlHighlightRules = XmlHighlightRules;
  699. });
  700. 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) {
  701. "use strict";
  702. var oop = require("../lib/oop");
  703. var lang = require("../lib/lang");
  704. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  705. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  706. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  707. var tagMap = lang.createMap({
  708. a : 'anchor',
  709. button : 'form',
  710. form : 'form',
  711. img : 'image',
  712. input : 'form',
  713. label : 'form',
  714. option : 'form',
  715. script : 'script',
  716. select : 'form',
  717. textarea : 'form',
  718. style : 'style',
  719. table : 'table',
  720. tbody : 'table',
  721. td : 'table',
  722. tfoot : 'table',
  723. th : 'table',
  724. tr : 'table'
  725. });
  726. var HtmlHighlightRules = function() {
  727. XmlHighlightRules.call(this);
  728. this.addRules({
  729. attributes: [{
  730. include : "tag_whitespace"
  731. }, {
  732. token : "entity.other.attribute-name.xml",
  733. regex : "[-_a-zA-Z0-9:.]+"
  734. }, {
  735. token : "keyword.operator.attribute-equals.xml",
  736. regex : "=",
  737. push : [{
  738. include: "tag_whitespace"
  739. }, {
  740. token : "string.unquoted.attribute-value.html",
  741. regex : "[^<>='\"`\\s]+",
  742. next : "pop"
  743. }, {
  744. token : "empty",
  745. regex : "",
  746. next : "pop"
  747. }]
  748. }, {
  749. include : "attribute_value"
  750. }],
  751. tag: [{
  752. token : function(start, tag) {
  753. var group = tagMap[tag];
  754. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  755. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  756. },
  757. regex : "(</?)([-_a-zA-Z0-9:.]+)",
  758. next: "tag_stuff"
  759. }],
  760. tag_stuff: [
  761. {include : "attributes"},
  762. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  763. ],
  764. });
  765. this.embedTagRules(CssHighlightRules, "css-", "style");
  766. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  767. if (this.constructor === HtmlHighlightRules)
  768. this.normalizeRules();
  769. };
  770. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  771. exports.HtmlHighlightRules = HtmlHighlightRules;
  772. });
  773. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  774. "use strict";
  775. var Range = require("../range").Range;
  776. var MatchingBraceOutdent = function() {};
  777. (function() {
  778. this.checkOutdent = function(line, input) {
  779. if (! /^\s+$/.test(line))
  780. return false;
  781. return /^\s*\}/.test(input);
  782. };
  783. this.autoOutdent = function(doc, row) {
  784. var line = doc.getLine(row);
  785. var match = line.match(/^(\s*\})/);
  786. if (!match) return 0;
  787. var column = match[1].length;
  788. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  789. if (!openBracePos || openBracePos.row == row) return 0;
  790. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  791. doc.replace(new Range(row, 0, row, column-1), indent);
  792. };
  793. this.$getIndent = function(line) {
  794. return line.match(/^\s*/)[0];
  795. };
  796. }).call(MatchingBraceOutdent.prototype);
  797. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  798. });
  799. 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) {
  800. "use strict";
  801. var oop = require("../../lib/oop");
  802. var Behaviour = require("../behaviour").Behaviour;
  803. var TokenIterator = require("../../token_iterator").TokenIterator;
  804. var lang = require("../../lib/lang");
  805. var SAFE_INSERT_IN_TOKENS =
  806. ["text", "paren.rparen", "punctuation.operator"];
  807. var SAFE_INSERT_BEFORE_TOKENS =
  808. ["text", "paren.rparen", "punctuation.operator", "comment"];
  809. var context;
  810. var contextCache = {};
  811. var initContext = function(editor) {
  812. var id = -1;
  813. if (editor.multiSelect) {
  814. id = editor.selection.index;
  815. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  816. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  817. }
  818. if (contextCache[id])
  819. return context = contextCache[id];
  820. context = contextCache[id] = {
  821. autoInsertedBrackets: 0,
  822. autoInsertedRow: -1,
  823. autoInsertedLineEnd: "",
  824. maybeInsertedBrackets: 0,
  825. maybeInsertedRow: -1,
  826. maybeInsertedLineStart: "",
  827. maybeInsertedLineEnd: ""
  828. };
  829. };
  830. var getWrapped = function(selection, selected, opening, closing) {
  831. var rowDiff = selection.end.row - selection.start.row;
  832. return {
  833. text: opening + selected + closing,
  834. selection: [
  835. 0,
  836. selection.start.column + 1,
  837. rowDiff,
  838. selection.end.column + (rowDiff ? 0 : 1)
  839. ]
  840. };
  841. };
  842. var CstyleBehaviour = function() {
  843. this.add("braces", "insertion", function(state, action, editor, session, text) {
  844. var cursor = editor.getCursorPosition();
  845. var line = session.doc.getLine(cursor.row);
  846. if (text == '{') {
  847. initContext(editor);
  848. var selection = editor.getSelectionRange();
  849. var selected = session.doc.getTextRange(selection);
  850. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  851. return getWrapped(selection, selected, '{', '}');
  852. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  853. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
  854. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  855. return {
  856. text: '{}',
  857. selection: [1, 1]
  858. };
  859. } else {
  860. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  861. return {
  862. text: '{',
  863. selection: [1, 1]
  864. };
  865. }
  866. }
  867. } else if (text == '}') {
  868. initContext(editor);
  869. var rightChar = line.substring(cursor.column, cursor.column + 1);
  870. if (rightChar == '}') {
  871. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  872. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  873. CstyleBehaviour.popAutoInsertedClosing();
  874. return {
  875. text: '',
  876. selection: [1, 1]
  877. };
  878. }
  879. }
  880. } else if (text == "\n" || text == "\r\n") {
  881. initContext(editor);
  882. var closing = "";
  883. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  884. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  885. CstyleBehaviour.clearMaybeInsertedClosing();
  886. }
  887. var rightChar = line.substring(cursor.column, cursor.column + 1);
  888. if (rightChar === '}') {
  889. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  890. if (!openBracePos)
  891. return null;
  892. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  893. } else if (closing) {
  894. var next_indent = this.$getIndent(line);
  895. } else {
  896. CstyleBehaviour.clearMaybeInsertedClosing();
  897. return;
  898. }
  899. var indent = next_indent + session.getTabString();
  900. return {
  901. text: '\n' + indent + '\n' + next_indent + closing,
  902. selection: [1, indent.length, 1, indent.length]
  903. };
  904. } else {
  905. CstyleBehaviour.clearMaybeInsertedClosing();
  906. }
  907. });
  908. this.add("braces", "deletion", function(state, action, editor, session, range) {
  909. var selected = session.doc.getTextRange(range);
  910. if (!range.isMultiLine() && selected == '{') {
  911. initContext(editor);
  912. var line = session.doc.getLine(range.start.row);
  913. var rightChar = line.substring(range.end.column, range.end.column + 1);
  914. if (rightChar == '}') {
  915. range.end.column++;
  916. return range;
  917. } else {
  918. context.maybeInsertedBrackets--;
  919. }
  920. }
  921. });
  922. this.add("parens", "insertion", function(state, action, editor, session, text) {
  923. if (text == '(') {
  924. initContext(editor);
  925. var selection = editor.getSelectionRange();
  926. var selected = session.doc.getTextRange(selection);
  927. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  928. return getWrapped(selection, selected, '(', ')');
  929. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  930. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  931. return {
  932. text: '()',
  933. selection: [1, 1]
  934. };
  935. }
  936. } else if (text == ')') {
  937. initContext(editor);
  938. var cursor = editor.getCursorPosition();
  939. var line = session.doc.getLine(cursor.row);
  940. var rightChar = line.substring(cursor.column, cursor.column + 1);
  941. if (rightChar == ')') {
  942. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  943. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  944. CstyleBehaviour.popAutoInsertedClosing();
  945. return {
  946. text: '',
  947. selection: [1, 1]
  948. };
  949. }
  950. }
  951. }
  952. });
  953. this.add("parens", "deletion", function(state, action, editor, session, range) {
  954. var selected = session.doc.getTextRange(range);
  955. if (!range.isMultiLine() && selected == '(') {
  956. initContext(editor);
  957. var line = session.doc.getLine(range.start.row);
  958. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  959. if (rightChar == ')') {
  960. range.end.column++;
  961. return range;
  962. }
  963. }
  964. });
  965. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  966. if (text == '[') {
  967. initContext(editor);
  968. var selection = editor.getSelectionRange();
  969. var selected = session.doc.getTextRange(selection);
  970. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  971. return getWrapped(selection, selected, '[', ']');
  972. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  973. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  974. return {
  975. text: '[]',
  976. selection: [1, 1]
  977. };
  978. }
  979. } else if (text == ']') {
  980. initContext(editor);
  981. var cursor = editor.getCursorPosition();
  982. var line = session.doc.getLine(cursor.row);
  983. var rightChar = line.substring(cursor.column, cursor.column + 1);
  984. if (rightChar == ']') {
  985. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  986. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  987. CstyleBehaviour.popAutoInsertedClosing();
  988. return {
  989. text: '',
  990. selection: [1, 1]
  991. };
  992. }
  993. }
  994. }
  995. });
  996. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  997. var selected = session.doc.getTextRange(range);
  998. if (!range.isMultiLine() && selected == '[') {
  999. initContext(editor);
  1000. var line = session.doc.getLine(range.start.row);
  1001. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1002. if (rightChar == ']') {
  1003. range.end.column++;
  1004. return range;
  1005. }
  1006. }
  1007. });
  1008. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  1009. if (text == '"' || text == "'") {
  1010. initContext(editor);
  1011. var quote = text;
  1012. var selection = editor.getSelectionRange();
  1013. var selected = session.doc.getTextRange(selection);
  1014. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  1015. return getWrapped(selection, selected, quote, quote);
  1016. } else if (!selected) {
  1017. var cursor = editor.getCursorPosition();
  1018. var line = session.doc.getLine(cursor.row);
  1019. var leftChar = line.substring(cursor.column-1, cursor.column);
  1020. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1021. var token = session.getTokenAt(cursor.row, cursor.column);
  1022. var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
  1023. if (leftChar == "\\" && token && /escape/.test(token.type))
  1024. return null;
  1025. var stringBefore = token && /string|escape/.test(token.type);
  1026. var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
  1027. var pair;
  1028. if (rightChar == quote) {
  1029. pair = stringBefore !== stringAfter;
  1030. } else {
  1031. if (stringBefore && !stringAfter)
  1032. return null; // wrap string with different quote
  1033. if (stringBefore && stringAfter)
  1034. return null; // do not pair quotes inside strings
  1035. var wordRe = session.$mode.tokenRe;
  1036. wordRe.lastIndex = 0;
  1037. var isWordBefore = wordRe.test(leftChar);
  1038. wordRe.lastIndex = 0;
  1039. var isWordAfter = wordRe.test(leftChar);
  1040. if (isWordBefore || isWordAfter)
  1041. return null; // before or after alphanumeric
  1042. if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
  1043. return null; // there is rightChar and it isn't closing
  1044. pair = true;
  1045. }
  1046. return {
  1047. text: pair ? quote + quote : "",
  1048. selection: [1,1]
  1049. };
  1050. }
  1051. }
  1052. });
  1053. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  1054. var selected = session.doc.getTextRange(range);
  1055. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  1056. initContext(editor);
  1057. var line = session.doc.getLine(range.start.row);
  1058. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1059. if (rightChar == selected) {
  1060. range.end.column++;
  1061. return range;
  1062. }
  1063. }
  1064. });
  1065. };
  1066. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  1067. var cursor = editor.getCursorPosition();
  1068. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1069. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  1070. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  1071. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  1072. return false;
  1073. }
  1074. iterator.stepForward();
  1075. return iterator.getCurrentTokenRow() !== cursor.row ||
  1076. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  1077. };
  1078. CstyleBehaviour.$matchTokenType = function(token, types) {
  1079. return types.indexOf(token.type || token) > -1;
  1080. };
  1081. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  1082. var cursor = editor.getCursorPosition();
  1083. var line = session.doc.getLine(cursor.row);
  1084. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  1085. context.autoInsertedBrackets = 0;
  1086. context.autoInsertedRow = cursor.row;
  1087. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  1088. context.autoInsertedBrackets++;
  1089. };
  1090. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  1091. var cursor = editor.getCursorPosition();
  1092. var line = session.doc.getLine(cursor.row);
  1093. if (!this.isMaybeInsertedClosing(cursor, line))
  1094. context.maybeInsertedBrackets = 0;
  1095. context.maybeInsertedRow = cursor.row;
  1096. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  1097. context.maybeInsertedLineEnd = line.substr(cursor.column);
  1098. context.maybeInsertedBrackets++;
  1099. };
  1100. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  1101. return context.autoInsertedBrackets > 0 &&
  1102. cursor.row === context.autoInsertedRow &&
  1103. bracket === context.autoInsertedLineEnd[0] &&
  1104. line.substr(cursor.column) === context.autoInsertedLineEnd;
  1105. };
  1106. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  1107. return context.maybeInsertedBrackets > 0 &&
  1108. cursor.row === context.maybeInsertedRow &&
  1109. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  1110. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  1111. };
  1112. CstyleBehaviour.popAutoInsertedClosing = function() {
  1113. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  1114. context.autoInsertedBrackets--;
  1115. };
  1116. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  1117. if (context) {
  1118. context.maybeInsertedBrackets = 0;
  1119. context.maybeInsertedRow = -1;
  1120. }
  1121. };
  1122. oop.inherits(CstyleBehaviour, Behaviour);
  1123. exports.CstyleBehaviour = CstyleBehaviour;
  1124. });
  1125. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1126. "use strict";
  1127. var oop = require("../../lib/oop");
  1128. var Range = require("../../range").Range;
  1129. var BaseFoldMode = require("./fold_mode").FoldMode;
  1130. var FoldMode = exports.FoldMode = function(commentRegex) {
  1131. if (commentRegex) {
  1132. this.foldingStartMarker = new RegExp(
  1133. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  1134. );
  1135. this.foldingStopMarker = new RegExp(
  1136. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  1137. );
  1138. }
  1139. };
  1140. oop.inherits(FoldMode, BaseFoldMode);
  1141. (function() {
  1142. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  1143. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  1144. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  1145. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  1146. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  1147. this._getFoldWidgetBase = this.getFoldWidget;
  1148. this.getFoldWidget = function(session, foldStyle, row) {
  1149. var line = session.getLine(row);
  1150. if (this.singleLineBlockCommentRe.test(line)) {
  1151. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  1152. return "";
  1153. }
  1154. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  1155. if (!fw && this.startRegionRe.test(line))
  1156. return "start"; // lineCommentRegionStart
  1157. return fw;
  1158. };
  1159. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  1160. var line = session.getLine(row);
  1161. if (this.startRegionRe.test(line))
  1162. return this.getCommentRegionBlock(session, line, row);
  1163. var match = line.match(this.foldingStartMarker);
  1164. if (match) {
  1165. var i = match.index;
  1166. if (match[1])
  1167. return this.openingBracketBlock(session, match[1], row, i);
  1168. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  1169. if (range && !range.isMultiLine()) {
  1170. if (forceMultiline) {
  1171. range = this.getSectionRange(session, row);
  1172. } else if (foldStyle != "all")
  1173. range = null;
  1174. }
  1175. return range;
  1176. }
  1177. if (foldStyle === "markbegin")
  1178. return;
  1179. var match = line.match(this.foldingStopMarker);
  1180. if (match) {
  1181. var i = match.index + match[0].length;
  1182. if (match[1])
  1183. return this.closingBracketBlock(session, match[1], row, i);
  1184. return session.getCommentFoldRange(row, i, -1);
  1185. }
  1186. };
  1187. this.getSectionRange = function(session, row) {
  1188. var line = session.getLine(row);
  1189. var startIndent = line.search(/\S/);
  1190. var startRow = row;
  1191. var startColumn = line.length;
  1192. row = row + 1;
  1193. var endRow = row;
  1194. var maxRow = session.getLength();
  1195. while (++row < maxRow) {
  1196. line = session.getLine(row);
  1197. var indent = line.search(/\S/);
  1198. if (indent === -1)
  1199. continue;
  1200. if (startIndent > indent)
  1201. break;
  1202. var subRange = this.getFoldWidgetRange(session, "all", row);
  1203. if (subRange) {
  1204. if (subRange.start.row <= startRow) {
  1205. break;
  1206. } else if (subRange.isMultiLine()) {
  1207. row = subRange.end.row;
  1208. } else if (startIndent == indent) {
  1209. break;
  1210. }
  1211. }
  1212. endRow = row;
  1213. }
  1214. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  1215. };
  1216. this.getCommentRegionBlock = function(session, line, row) {
  1217. var startColumn = line.search(/\s*$/);
  1218. var maxRow = session.getLength();
  1219. var startRow = row;
  1220. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  1221. var depth = 1;
  1222. while (++row < maxRow) {
  1223. line = session.getLine(row);
  1224. var m = re.exec(line);
  1225. if (!m) continue;
  1226. if (m[1]) depth--;
  1227. else depth++;
  1228. if (!depth) break;
  1229. }
  1230. var endRow = row;
  1231. if (endRow > startRow) {
  1232. return new Range(startRow, startColumn, endRow, line.length);
  1233. }
  1234. };
  1235. }).call(FoldMode.prototype);
  1236. });
  1237. 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) {
  1238. "use strict";
  1239. var oop = require("../lib/oop");
  1240. var TextMode = require("./text").Mode;
  1241. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1242. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1243. var Range = require("../range").Range;
  1244. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1245. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  1246. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1247. var Mode = function() {
  1248. this.HighlightRules = JavaScriptHighlightRules;
  1249. this.$outdent = new MatchingBraceOutdent();
  1250. this.$behaviour = new CstyleBehaviour();
  1251. this.foldingRules = new CStyleFoldMode();
  1252. };
  1253. oop.inherits(Mode, TextMode);
  1254. (function() {
  1255. this.lineCommentStart = "//";
  1256. this.blockComment = {start: "/*", end: "*/"};
  1257. this.getNextLineIndent = function(state, line, tab) {
  1258. var indent = this.$getIndent(line);
  1259. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  1260. var tokens = tokenizedLine.tokens;
  1261. var endState = tokenizedLine.state;
  1262. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1263. return indent;
  1264. }
  1265. if (state == "start" || state == "no_regex") {
  1266. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  1267. if (match) {
  1268. indent += tab;
  1269. }
  1270. } else if (state == "doc-start") {
  1271. if (endState == "start" || endState == "no_regex") {
  1272. return "";
  1273. }
  1274. var match = line.match(/^\s*(\/?)\*/);
  1275. if (match) {
  1276. if (match[1]) {
  1277. indent += " ";
  1278. }
  1279. indent += "* ";
  1280. }
  1281. }
  1282. return indent;
  1283. };
  1284. this.checkOutdent = function(state, line, input) {
  1285. return this.$outdent.checkOutdent(line, input);
  1286. };
  1287. this.autoOutdent = function(state, doc, row) {
  1288. this.$outdent.autoOutdent(doc, row);
  1289. };
  1290. this.createWorker = function(session) {
  1291. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1292. worker.attachToDocument(session.getDocument());
  1293. worker.on("annotate", function(results) {
  1294. session.setAnnotations(results.data);
  1295. });
  1296. worker.on("terminate", function() {
  1297. session.clearAnnotations();
  1298. });
  1299. return worker;
  1300. };
  1301. this.$id = "ace/mode/javascript";
  1302. }).call(Mode.prototype);
  1303. exports.Mode = Mode;
  1304. });
  1305. 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) {
  1306. "use strict";
  1307. var oop = require("../../lib/oop");
  1308. var Behaviour = require("../behaviour").Behaviour;
  1309. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1310. var TokenIterator = require("../../token_iterator").TokenIterator;
  1311. var CssBehaviour = function () {
  1312. this.inherit(CstyleBehaviour);
  1313. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1314. if (text === ':') {
  1315. var cursor = editor.getCursorPosition();
  1316. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1317. var token = iterator.getCurrentToken();
  1318. if (token && token.value.match(/\s+/)) {
  1319. token = iterator.stepBackward();
  1320. }
  1321. if (token && token.type === 'support.type') {
  1322. var line = session.doc.getLine(cursor.row);
  1323. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1324. if (rightChar === ':') {
  1325. return {
  1326. text: '',
  1327. selection: [1, 1]
  1328. }
  1329. }
  1330. if (!line.substring(cursor.column).match(/^\s*;/)) {
  1331. return {
  1332. text: ':;',
  1333. selection: [1, 1]
  1334. }
  1335. }
  1336. }
  1337. }
  1338. });
  1339. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1340. var selected = session.doc.getTextRange(range);
  1341. if (!range.isMultiLine() && selected === ':') {
  1342. var cursor = editor.getCursorPosition();
  1343. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1344. var token = iterator.getCurrentToken();
  1345. if (token && token.value.match(/\s+/)) {
  1346. token = iterator.stepBackward();
  1347. }
  1348. if (token && token.type === 'support.type') {
  1349. var line = session.doc.getLine(range.start.row);
  1350. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1351. if (rightChar === ';') {
  1352. range.end.column ++;
  1353. return range;
  1354. }
  1355. }
  1356. }
  1357. });
  1358. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1359. if (text === ';') {
  1360. var cursor = editor.getCursorPosition();
  1361. var line = session.doc.getLine(cursor.row);
  1362. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1363. if (rightChar === ';') {
  1364. return {
  1365. text: '',
  1366. selection: [1, 1]
  1367. }
  1368. }
  1369. }
  1370. });
  1371. }
  1372. oop.inherits(CssBehaviour, CstyleBehaviour);
  1373. exports.CssBehaviour = CssBehaviour;
  1374. });
  1375. 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) {
  1376. "use strict";
  1377. var oop = require("../lib/oop");
  1378. var TextMode = require("./text").Mode;
  1379. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1380. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1381. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1382. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1383. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1384. var Mode = function() {
  1385. this.HighlightRules = CssHighlightRules;
  1386. this.$outdent = new MatchingBraceOutdent();
  1387. this.$behaviour = new CssBehaviour();
  1388. this.foldingRules = new CStyleFoldMode();
  1389. };
  1390. oop.inherits(Mode, TextMode);
  1391. (function() {
  1392. this.foldingRules = "cStyle";
  1393. this.blockComment = {start: "/*", end: "*/"};
  1394. this.getNextLineIndent = function(state, line, tab) {
  1395. var indent = this.$getIndent(line);
  1396. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1397. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1398. return indent;
  1399. }
  1400. var match = line.match(/^.*\{\s*$/);
  1401. if (match) {
  1402. indent += tab;
  1403. }
  1404. return indent;
  1405. };
  1406. this.checkOutdent = function(state, line, input) {
  1407. return this.$outdent.checkOutdent(line, input);
  1408. };
  1409. this.autoOutdent = function(state, doc, row) {
  1410. this.$outdent.autoOutdent(doc, row);
  1411. };
  1412. this.createWorker = function(session) {
  1413. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  1414. worker.attachToDocument(session.getDocument());
  1415. worker.on("annotate", function(e) {
  1416. session.setAnnotations(e.data);
  1417. });
  1418. worker.on("terminate", function() {
  1419. session.clearAnnotations();
  1420. });
  1421. return worker;
  1422. };
  1423. this.$id = "ace/mode/css";
  1424. }).call(Mode.prototype);
  1425. exports.Mode = Mode;
  1426. });
  1427. ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  1428. "use strict";
  1429. var oop = require("../../lib/oop");
  1430. var Behaviour = require("../behaviour").Behaviour;
  1431. var TokenIterator = require("../../token_iterator").TokenIterator;
  1432. var lang = require("../../lib/lang");
  1433. function is(token, type) {
  1434. return token.type.lastIndexOf(type + ".xml") > -1;
  1435. }
  1436. var XmlBehaviour = function () {
  1437. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  1438. if (text == '"' || text == "'") {
  1439. var quote = text;
  1440. var selected = session.doc.getTextRange(editor.getSelectionRange());
  1441. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  1442. return {
  1443. text: quote + selected + quote,
  1444. selection: false
  1445. };
  1446. }
  1447. var cursor = editor.getCursorPosition();
  1448. var line = session.doc.getLine(cursor.row);
  1449. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1450. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1451. var token = iterator.getCurrentToken();
  1452. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  1453. return {
  1454. text: "",
  1455. selection: [1, 1]
  1456. };
  1457. }
  1458. if (!token)
  1459. token = iterator.stepBackward();
  1460. if (!token)
  1461. return;
  1462. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  1463. token = iterator.stepBackward();
  1464. }
  1465. var rightSpace = !rightChar || rightChar.match(/\s/);
  1466. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  1467. return {
  1468. text: quote + quote,
  1469. selection: [1, 1]
  1470. };
  1471. }
  1472. }
  1473. });
  1474. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  1475. var selected = session.doc.getTextRange(range);
  1476. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  1477. var line = session.doc.getLine(range.start.row);
  1478. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1479. if (rightChar == selected) {
  1480. range.end.column++;
  1481. return range;
  1482. }
  1483. }
  1484. });
  1485. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  1486. if (text == '>') {
  1487. var position = editor.getCursorPosition();
  1488. var iterator = new TokenIterator(session, position.row, position.column);
  1489. var token = iterator.getCurrentToken() || iterator.stepBackward();
  1490. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  1491. return;
  1492. if (is(token, "reference.attribute-value"))
  1493. return;
  1494. if (is(token, "attribute-value")) {
  1495. var firstChar = token.value.charAt(0);
  1496. if (firstChar == '"' || firstChar == "'") {
  1497. var lastChar = token.value.charAt(token.value.length - 1);
  1498. var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
  1499. if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
  1500. return;
  1501. }
  1502. }
  1503. while (!is(token, "tag-name")) {
  1504. token = iterator.stepBackward();
  1505. }
  1506. var tokenRow = iterator.getCurrentTokenRow();
  1507. var tokenColumn = iterator.getCurrentTokenColumn();
  1508. if (is(iterator.stepBackward(), "end-tag-open"))
  1509. return;
  1510. var element = token.value;
  1511. if (tokenRow == position.row)
  1512. element = element.substring(0, position.column - tokenColumn);
  1513. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  1514. return;
  1515. return {
  1516. text: ">" + "</" + element + ">",
  1517. selection: [1, 1]
  1518. };
  1519. }
  1520. });
  1521. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  1522. if (text == "\n") {
  1523. var cursor = editor.getCursorPosition();
  1524. var line = session.getLine(cursor.row);
  1525. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1526. var token = iterator.getCurrentToken();
  1527. if (token && token.type.indexOf("tag-close") !== -1) {
  1528. if (token.value == "/>")
  1529. return;
  1530. while (token && token.type.indexOf("tag-name") === -1) {
  1531. token = iterator.stepBackward();
  1532. }
  1533. if (!token) {
  1534. return;
  1535. }
  1536. var tag = token.value;
  1537. var row = iterator.getCurrentTokenRow();
  1538. token = iterator.stepBackward();
  1539. if (!token || token.type.indexOf("end-tag") !== -1) {
  1540. return;
  1541. }
  1542. if (this.voidElements && !this.voidElements[tag]) {
  1543. var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
  1544. var line = session.getLine(row);
  1545. var nextIndent = this.$getIndent(line);
  1546. var indent = nextIndent + session.getTabString();
  1547. if (nextToken && nextToken.value === "</") {
  1548. return {
  1549. text: "\n" + indent + "\n" + nextIndent,
  1550. selection: [1, indent.length, 1, indent.length]
  1551. };
  1552. } else {
  1553. return {
  1554. text: "\n" + indent
  1555. };
  1556. }
  1557. }
  1558. }
  1559. }
  1560. });
  1561. };
  1562. oop.inherits(XmlBehaviour, Behaviour);
  1563. exports.XmlBehaviour = XmlBehaviour;
  1564. });
  1565. ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1566. "use strict";
  1567. var oop = require("../../lib/oop");
  1568. var BaseFoldMode = require("./fold_mode").FoldMode;
  1569. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1570. this.defaultMode = defaultMode;
  1571. this.subModes = subModes;
  1572. };
  1573. oop.inherits(FoldMode, BaseFoldMode);
  1574. (function() {
  1575. this.$getMode = function(state) {
  1576. if (typeof state != "string")
  1577. state = state[0];
  1578. for (var key in this.subModes) {
  1579. if (state.indexOf(key) === 0)
  1580. return this.subModes[key];
  1581. }
  1582. return null;
  1583. };
  1584. this.$tryMode = function(state, session, foldStyle, row) {
  1585. var mode = this.$getMode(state);
  1586. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1587. };
  1588. this.getFoldWidget = function(session, foldStyle, row) {
  1589. return (
  1590. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1591. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1592. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1593. );
  1594. };
  1595. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1596. var mode = this.$getMode(session.getState(row-1));
  1597. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1598. mode = this.$getMode(session.getState(row));
  1599. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1600. mode = this.defaultMode;
  1601. return mode.getFoldWidgetRange(session, foldStyle, row);
  1602. };
  1603. }).call(FoldMode.prototype);
  1604. });
  1605. 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) {
  1606. "use strict";
  1607. var oop = require("../../lib/oop");
  1608. var lang = require("../../lib/lang");
  1609. var Range = require("../../range").Range;
  1610. var BaseFoldMode = require("./fold_mode").FoldMode;
  1611. var TokenIterator = require("../../token_iterator").TokenIterator;
  1612. var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
  1613. BaseFoldMode.call(this);
  1614. this.voidElements = voidElements || {};
  1615. this.optionalEndTags = oop.mixin({}, this.voidElements);
  1616. if (optionalEndTags)
  1617. oop.mixin(this.optionalEndTags, optionalEndTags);
  1618. };
  1619. oop.inherits(FoldMode, BaseFoldMode);
  1620. var Tag = function() {
  1621. this.tagName = "";
  1622. this.closing = false;
  1623. this.selfClosing = false;
  1624. this.start = {row: 0, column: 0};
  1625. this.end = {row: 0, column: 0};
  1626. };
  1627. function is(token, type) {
  1628. return token.type.lastIndexOf(type + ".xml") > -1;
  1629. }
  1630. (function() {
  1631. this.getFoldWidget = function(session, foldStyle, row) {
  1632. var tag = this._getFirstTagInLine(session, row);
  1633. if (!tag)
  1634. return "";
  1635. if (tag.closing || (!tag.tagName && tag.selfClosing))
  1636. return foldStyle == "markbeginend" ? "end" : "";
  1637. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  1638. return "";
  1639. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  1640. return "";
  1641. return "start";
  1642. };
  1643. this._getFirstTagInLine = function(session, row) {
  1644. var tokens = session.getTokens(row);
  1645. var tag = new Tag();
  1646. for (var i = 0; i < tokens.length; i++) {
  1647. var token = tokens[i];
  1648. if (is(token, "tag-open")) {
  1649. tag.end.column = tag.start.column + token.value.length;
  1650. tag.closing = is(token, "end-tag-open");
  1651. token = tokens[++i];
  1652. if (!token)
  1653. return null;
  1654. tag.tagName = token.value;
  1655. tag.end.column += token.value.length;
  1656. for (i++; i < tokens.length; i++) {
  1657. token = tokens[i];
  1658. tag.end.column += token.value.length;
  1659. if (is(token, "tag-close")) {
  1660. tag.selfClosing = token.value == '/>';
  1661. break;
  1662. }
  1663. }
  1664. return tag;
  1665. } else if (is(token, "tag-close")) {
  1666. tag.selfClosing = token.value == '/>';
  1667. return tag;
  1668. }
  1669. tag.start.column += token.value.length;
  1670. }
  1671. return null;
  1672. };
  1673. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  1674. var tokens = session.getTokens(row);
  1675. var column = 0;
  1676. for (var i = 0; i < tokens.length; i++) {
  1677. var token = tokens[i];
  1678. column += token.value.length;
  1679. if (column < startColumn)
  1680. continue;
  1681. if (is(token, "end-tag-open")) {
  1682. token = tokens[i + 1];
  1683. if (token && token.value == tagName)
  1684. return true;
  1685. }
  1686. }
  1687. return false;
  1688. };
  1689. this._readTagForward = function(iterator) {
  1690. var token = iterator.getCurrentToken();
  1691. if (!token)
  1692. return null;
  1693. var tag = new Tag();
  1694. do {
  1695. if (is(token, "tag-open")) {
  1696. tag.closing = is(token, "end-tag-open");
  1697. tag.start.row = iterator.getCurrentTokenRow();
  1698. tag.start.column = iterator.getCurrentTokenColumn();
  1699. } else if (is(token, "tag-name")) {
  1700. tag.tagName = token.value;
  1701. } else if (is(token, "tag-close")) {
  1702. tag.selfClosing = token.value == "/>";
  1703. tag.end.row = iterator.getCurrentTokenRow();
  1704. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1705. iterator.stepForward();
  1706. return tag;
  1707. }
  1708. } while(token = iterator.stepForward());
  1709. return null;
  1710. };
  1711. this._readTagBackward = function(iterator) {
  1712. var token = iterator.getCurrentToken();
  1713. if (!token)
  1714. return null;
  1715. var tag = new Tag();
  1716. do {
  1717. if (is(token, "tag-open")) {
  1718. tag.closing = is(token, "end-tag-open");
  1719. tag.start.row = iterator.getCurrentTokenRow();
  1720. tag.start.column = iterator.getCurrentTokenColumn();
  1721. iterator.stepBackward();
  1722. return tag;
  1723. } else if (is(token, "tag-name")) {
  1724. tag.tagName = token.value;
  1725. } else if (is(token, "tag-close")) {
  1726. tag.selfClosing = token.value == "/>";
  1727. tag.end.row = iterator.getCurrentTokenRow();
  1728. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1729. }
  1730. } while(token = iterator.stepBackward());
  1731. return null;
  1732. };
  1733. this._pop = function(stack, tag) {
  1734. while (stack.length) {
  1735. var top = stack[stack.length-1];
  1736. if (!tag || top.tagName == tag.tagName) {
  1737. return stack.pop();
  1738. }
  1739. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  1740. stack.pop();
  1741. continue;
  1742. } else {
  1743. return null;
  1744. }
  1745. }
  1746. };
  1747. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1748. var firstTag = this._getFirstTagInLine(session, row);
  1749. if (!firstTag)
  1750. return null;
  1751. var isBackward = firstTag.closing || firstTag.selfClosing;
  1752. var stack = [];
  1753. var tag;
  1754. if (!isBackward) {
  1755. var iterator = new TokenIterator(session, row, firstTag.start.column);
  1756. var start = {
  1757. row: row,
  1758. column: firstTag.start.column + firstTag.tagName.length + 2
  1759. };
  1760. if (firstTag.start.row == firstTag.end.row)
  1761. start.column = firstTag.end.column;
  1762. while (tag = this._readTagForward(iterator)) {
  1763. if (tag.selfClosing) {
  1764. if (!stack.length) {
  1765. tag.start.column += tag.tagName.length + 2;
  1766. tag.end.column -= 2;
  1767. return Range.fromPoints(tag.start, tag.end);
  1768. } else
  1769. continue;
  1770. }
  1771. if (tag.closing) {
  1772. this._pop(stack, tag);
  1773. if (stack.length == 0)
  1774. return Range.fromPoints(start, tag.start);
  1775. }
  1776. else {
  1777. stack.push(tag);
  1778. }
  1779. }
  1780. }
  1781. else {
  1782. var iterator = new TokenIterator(session, row, firstTag.end.column);
  1783. var end = {
  1784. row: row,
  1785. column: firstTag.start.column
  1786. };
  1787. while (tag = this._readTagBackward(iterator)) {
  1788. if (tag.selfClosing) {
  1789. if (!stack.length) {
  1790. tag.start.column += tag.tagName.length + 2;
  1791. tag.end.column -= 2;
  1792. return Range.fromPoints(tag.start, tag.end);
  1793. } else
  1794. continue;
  1795. }
  1796. if (!tag.closing) {
  1797. this._pop(stack, tag);
  1798. if (stack.length == 0) {
  1799. tag.start.column += tag.tagName.length + 2;
  1800. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  1801. tag.start.column = tag.end.column;
  1802. return Range.fromPoints(tag.start, end);
  1803. }
  1804. }
  1805. else {
  1806. stack.push(tag);
  1807. }
  1808. }
  1809. }
  1810. };
  1811. }).call(FoldMode.prototype);
  1812. });
  1813. 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) {
  1814. "use strict";
  1815. var oop = require("../../lib/oop");
  1816. var MixedFoldMode = require("./mixed").FoldMode;
  1817. var XmlFoldMode = require("./xml").FoldMode;
  1818. var CStyleFoldMode = require("./cstyle").FoldMode;
  1819. var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
  1820. MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
  1821. "js-": new CStyleFoldMode(),
  1822. "css-": new CStyleFoldMode()
  1823. });
  1824. };
  1825. oop.inherits(FoldMode, MixedFoldMode);
  1826. });
  1827. ace.define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) {
  1828. "use strict";
  1829. var TokenIterator = require("../token_iterator").TokenIterator;
  1830. var commonAttributes = [
  1831. "accesskey",
  1832. "class",
  1833. "contenteditable",
  1834. "contextmenu",
  1835. "dir",
  1836. "draggable",
  1837. "dropzone",
  1838. "hidden",
  1839. "id",
  1840. "inert",
  1841. "itemid",
  1842. "itemprop",
  1843. "itemref",
  1844. "itemscope",
  1845. "itemtype",
  1846. "lang",
  1847. "spellcheck",
  1848. "style",
  1849. "tabindex",
  1850. "title",
  1851. "translate"
  1852. ];
  1853. var eventAttributes = [
  1854. "onabort",
  1855. "onblur",
  1856. "oncancel",
  1857. "oncanplay",
  1858. "oncanplaythrough",
  1859. "onchange",
  1860. "onclick",
  1861. "onclose",
  1862. "oncontextmenu",
  1863. "oncuechange",
  1864. "ondblclick",
  1865. "ondrag",
  1866. "ondragend",
  1867. "ondragenter",
  1868. "ondragleave",
  1869. "ondragover",
  1870. "ondragstart",
  1871. "ondrop",
  1872. "ondurationchange",
  1873. "onemptied",
  1874. "onended",
  1875. "onerror",
  1876. "onfocus",
  1877. "oninput",
  1878. "oninvalid",
  1879. "onkeydown",
  1880. "onkeypress",
  1881. "onkeyup",
  1882. "onload",
  1883. "onloadeddata",
  1884. "onloadedmetadata",
  1885. "onloadstart",
  1886. "onmousedown",
  1887. "onmousemove",
  1888. "onmouseout",
  1889. "onmouseover",
  1890. "onmouseup",
  1891. "onmousewheel",
  1892. "onpause",
  1893. "onplay",
  1894. "onplaying",
  1895. "onprogress",
  1896. "onratechange",
  1897. "onreset",
  1898. "onscroll",
  1899. "onseeked",
  1900. "onseeking",
  1901. "onselect",
  1902. "onshow",
  1903. "onstalled",
  1904. "onsubmit",
  1905. "onsuspend",
  1906. "ontimeupdate",
  1907. "onvolumechange",
  1908. "onwaiting"
  1909. ];
  1910. var globalAttributes = commonAttributes.concat(eventAttributes);
  1911. var attributeMap = {
  1912. "html": ["manifest"],
  1913. "head": [],
  1914. "title": [],
  1915. "base": ["href", "target"],
  1916. "link": ["href", "hreflang", "rel", "media", "type", "sizes"],
  1917. "meta": ["http-equiv", "name", "content", "charset"],
  1918. "style": ["type", "media", "scoped"],
  1919. "script": ["charset", "type", "src", "defer", "async"],
  1920. "noscript": ["href"],
  1921. "body": ["onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onmessage", "onoffline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload"],
  1922. "section": [],
  1923. "nav": [],
  1924. "article": ["pubdate"],
  1925. "aside": [],
  1926. "h1": [],
  1927. "h2": [],
  1928. "h3": [],
  1929. "h4": [],
  1930. "h5": [],
  1931. "h6": [],
  1932. "header": [],
  1933. "footer": [],
  1934. "address": [],
  1935. "main": [],
  1936. "p": [],
  1937. "hr": [],
  1938. "pre": [],
  1939. "blockquote": ["cite"],
  1940. "ol": ["start", "reversed"],
  1941. "ul": [],
  1942. "li": ["value"],
  1943. "dl": [],
  1944. "dt": [],
  1945. "dd": [],
  1946. "figure": [],
  1947. "figcaption": [],
  1948. "div": [],
  1949. "a": ["href", "target", "ping", "rel", "media", "hreflang", "type"],
  1950. "em": [],
  1951. "strong": [],
  1952. "small": [],
  1953. "s": [],
  1954. "cite": [],
  1955. "q": ["cite"],
  1956. "dfn": [],
  1957. "abbr": [],
  1958. "data": [],
  1959. "time": ["datetime"],
  1960. "code": [],
  1961. "var": [],
  1962. "samp": [],
  1963. "kbd": [],
  1964. "sub": [],
  1965. "sup": [],
  1966. "i": [],
  1967. "b": [],
  1968. "u": [],
  1969. "mark": [],
  1970. "ruby": [],
  1971. "rt": [],
  1972. "rp": [],
  1973. "bdi": [],
  1974. "bdo": [],
  1975. "span": [],
  1976. "br": [],
  1977. "wbr": [],
  1978. "ins": ["cite", "datetime"],
  1979. "del": ["cite", "datetime"],
  1980. "img": ["alt", "src", "height", "width", "usemap", "ismap"],
  1981. "iframe": ["name", "src", "height", "width", "sandbox", "seamless"],
  1982. "embed": ["src", "height", "width", "type"],
  1983. "object": ["param", "data", "type", "height" , "width", "usemap", "name", "form", "classid"],
  1984. "param": ["name", "value"],
  1985. "video": ["src", "autobuffer", "autoplay", "loop", "controls", "width", "height", "poster"],
  1986. "audio": ["src", "autobuffer", "autoplay", "loop", "controls"],
  1987. "source": ["src", "type", "media"],
  1988. "track": ["kind", "src", "srclang", "label", "default"],
  1989. "canvas": ["width", "height"],
  1990. "map": ["name"],
  1991. "area": ["shape", "coords", "href", "hreflang", "alt", "target", "media", "rel", "ping", "type"],
  1992. "svg": [],
  1993. "math": [],
  1994. "table": ["summary"],
  1995. "caption": [],
  1996. "colgroup": ["span"],
  1997. "col": ["span"],
  1998. "tbody": [],
  1999. "thead": [],
  2000. "tfoot": [],
  2001. "tr": [],
  2002. "td": ["headers", "rowspan", "colspan"],
  2003. "th": ["headers", "rowspan", "colspan", "scope"],
  2004. "form": ["accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"],
  2005. "fieldset": ["disabled", "form", "name"],
  2006. "legend": [],
  2007. "label": ["form", "for"],
  2008. "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"],
  2009. "button": ["autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "value", "type"],
  2010. "select": ["autofocus", "disabled", "form", "multiple", "name", "size"],
  2011. "datalist": [],
  2012. "optgroup": ["disabled", "label"],
  2013. "option": ["disabled", "selected", "label", "value"],
  2014. "textarea": ["autofocus", "disabled", "form", "maxlength", "name", "placeholder", "readonly", "required", "rows", "cols", "wrap"],
  2015. "keygen": ["autofocus", "challenge", "disabled", "form", "keytype", "name"],
  2016. "output": ["for", "form", "name"],
  2017. "progress": ["value", "max"],
  2018. "meter": ["value", "min", "max", "low", "high", "optimum"],
  2019. "details": ["open"],
  2020. "summary": [],
  2021. "command": ["type", "label", "icon", "disabled", "checked", "radiogroup", "command"],
  2022. "menu": ["type", "label"],
  2023. "dialog": ["open"]
  2024. };
  2025. var elements = Object.keys(attributeMap);
  2026. function is(token, type) {
  2027. return token.type.lastIndexOf(type + ".xml") > -1;
  2028. }
  2029. function findTagName(session, pos) {
  2030. var iterator = new TokenIterator(session, pos.row, pos.column);
  2031. var token = iterator.getCurrentToken();
  2032. while (token && !is(token, "tag-name")){
  2033. token = iterator.stepBackward();
  2034. }
  2035. if (token)
  2036. return token.value;
  2037. }
  2038. var HtmlCompletions = function() {
  2039. };
  2040. (function() {
  2041. this.getCompletions = function(state, session, pos, prefix) {
  2042. var token = session.getTokenAt(pos.row, pos.column);
  2043. if (!token)
  2044. return [];
  2045. if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
  2046. return this.getTagCompletions(state, session, pos, prefix);
  2047. if (is(token, "tag-whitespace") || is(token, "attribute-name"))
  2048. return this.getAttributeCompetions(state, session, pos, prefix);
  2049. return [];
  2050. };
  2051. this.getTagCompletions = function(state, session, pos, prefix) {
  2052. return elements.map(function(element){
  2053. return {
  2054. value: element,
  2055. meta: "tag",
  2056. score: Number.MAX_VALUE
  2057. };
  2058. });
  2059. };
  2060. this.getAttributeCompetions = function(state, session, pos, prefix) {
  2061. var tagName = findTagName(session, pos);
  2062. if (!tagName)
  2063. return [];
  2064. var attributes = globalAttributes;
  2065. if (tagName in attributeMap) {
  2066. attributes = attributes.concat(attributeMap[tagName]);
  2067. }
  2068. return attributes.map(function(attribute){
  2069. return {
  2070. caption: attribute,
  2071. snippet: attribute + '="$0"',
  2072. meta: "attribute",
  2073. score: Number.MAX_VALUE
  2074. };
  2075. });
  2076. };
  2077. }).call(HtmlCompletions.prototype);
  2078. exports.HtmlCompletions = HtmlCompletions;
  2079. });
  2080. 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) {
  2081. "use strict";
  2082. var oop = require("../lib/oop");
  2083. var lang = require("../lib/lang");
  2084. var TextMode = require("./text").Mode;
  2085. var JavaScriptMode = require("./javascript").Mode;
  2086. var CssMode = require("./css").Mode;
  2087. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2088. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  2089. var HtmlFoldMode = require("./folding/html").FoldMode;
  2090. var HtmlCompletions = require("./html_completions").HtmlCompletions;
  2091. var WorkerClient = require("../worker/worker_client").WorkerClient;
  2092. var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
  2093. var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
  2094. var Mode = function(options) {
  2095. this.fragmentContext = options && options.fragmentContext;
  2096. this.HighlightRules = HtmlHighlightRules;
  2097. this.$behaviour = new XmlBehaviour();
  2098. this.$completer = new HtmlCompletions();
  2099. this.createModeDelegates({
  2100. "js-": JavaScriptMode,
  2101. "css-": CssMode
  2102. });
  2103. this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
  2104. };
  2105. oop.inherits(Mode, TextMode);
  2106. (function() {
  2107. this.blockComment = {start: "<!--", end: "-->"};
  2108. this.voidElements = lang.arrayToMap(voidElements);
  2109. this.getNextLineIndent = function(state, line, tab) {
  2110. return this.$getIndent(line);
  2111. };
  2112. this.checkOutdent = function(state, line, input) {
  2113. return false;
  2114. };
  2115. this.getCompletions = function(state, session, pos, prefix) {
  2116. return this.$completer.getCompletions(state, session, pos, prefix);
  2117. };
  2118. this.createWorker = function(session) {
  2119. if (this.constructor != Mode)
  2120. return;
  2121. var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
  2122. worker.attachToDocument(session.getDocument());
  2123. if (this.fragmentContext)
  2124. worker.call("setOptions", [{context: this.fragmentContext}]);
  2125. worker.on("error", function(e) {
  2126. session.setAnnotations(e.data);
  2127. });
  2128. worker.on("terminate", function() {
  2129. session.clearAnnotations();
  2130. });
  2131. return worker;
  2132. };
  2133. this.$id = "ace/mode/html";
  2134. }).call(Mode.prototype);
  2135. exports.Mode = Mode;
  2136. });
  2137. ace.define("ace/mode/ruby_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2138. "use strict";
  2139. var oop = require("../lib/oop");
  2140. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  2141. var constantOtherSymbol = exports.constantOtherSymbol = {
  2142. token : "constant.other.symbol.ruby", // symbol
  2143. regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
  2144. };
  2145. var qString = exports.qString = {
  2146. token : "string", // single line
  2147. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  2148. };
  2149. var qqString = exports.qqString = {
  2150. token : "string", // single line
  2151. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  2152. };
  2153. var tString = exports.tString = {
  2154. token : "string", // backtick string
  2155. regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
  2156. };
  2157. var constantNumericHex = exports.constantNumericHex = {
  2158. token : "constant.numeric", // hex
  2159. regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
  2160. };
  2161. var constantNumericFloat = exports.constantNumericFloat = {
  2162. token : "constant.numeric", // float
  2163. regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
  2164. };
  2165. var RubyHighlightRules = function() {
  2166. var builtinFunctions = (
  2167. "abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" +
  2168. "assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" +
  2169. "assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" +
  2170. "assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" +
  2171. "assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" +
  2172. "assert_select_email|assert_select_rjs|assert_select_encoded|css_select|at_exit|" +
  2173. "attr|attr_writer|attr_reader|attr_accessor|attr_accessible|autoload|binding|block_given?|callcc|" +
  2174. "caller|catch|chomp|chomp!|chop|chop!|defined?|delete_via_redirect|eval|exec|exit|" +
  2175. "exit!|fail|Float|flunk|follow_redirect!|fork|form_for|form_tag|format|gets|global_variables|gsub|" +
  2176. "gsub!|get_via_redirect|host!|https?|https!|include|Integer|lambda|link_to|" +
  2177. "link_to_unless_current|link_to_function|link_to_remote|load|local_variables|loop|open|open_session|" +
  2178. "p|print|printf|proc|putc|puts|post_via_redirect|put_via_redirect|raise|rand|" +
  2179. "raw|readline|readlines|redirect?|request_via_redirect|require|scan|select|" +
  2180. "set_trace_func|sleep|split|sprintf|srand|String|stylesheet_link_tag|syscall|system|sub|sub!|test|" +
  2181. "throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan|" +
  2182. "render|javascript_include_tag|csrf_meta_tag|label_tag|text_field_tag|submit_tag|check_box_tag|" +
  2183. "content_tag|radio_button_tag|text_area_tag|password_field_tag|hidden_field_tag|" +
  2184. "fields_for|select_tag|options_for_select|options_from_collection_for_select|collection_select|" +
  2185. "time_zone_select|select_date|select_time|select_datetime|date_select|time_select|datetime_select|" +
  2186. "select_year|select_month|select_day|select_hour|select_minute|select_second|file_field_tag|" +
  2187. "file_field|respond_to|skip_before_filter|around_filter|after_filter|verify|" +
  2188. "protect_from_forgery|rescue_from|helper_method|redirect_to|before_filter|" +
  2189. "send_data|send_file|validates_presence_of|validates_uniqueness_of|validates_length_of|" +
  2190. "validates_format_of|validates_acceptance_of|validates_associated|validates_exclusion_of|" +
  2191. "validates_inclusion_of|validates_numericality_of|validates_with|validates_each|" +
  2192. "authenticate_or_request_with_http_basic|authenticate_or_request_with_http_digest|" +
  2193. "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" +
  2194. "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" +
  2195. "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" +
  2196. "has_many|has_one|belongs_to|has_and_belongs_to_many"
  2197. );
  2198. var keywords = (
  2199. "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" +
  2200. "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" +
  2201. "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield"
  2202. );
  2203. var buildinConstants = (
  2204. "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" +
  2205. "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING"
  2206. );
  2207. var builtinVariables = (
  2208. "\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" +
  2209. "$!|root_url|flash|session|cookies|params|request|response|logger|self"
  2210. );
  2211. var keywordMapper = this.$keywords = this.createKeywordMapper({
  2212. "keyword": keywords,
  2213. "constant.language": buildinConstants,
  2214. "variable.language": builtinVariables,
  2215. "support.function": builtinFunctions,
  2216. "invalid.deprecated": "debugger" // TODO is this a remnant from js mode?
  2217. }, "identifier");
  2218. this.$rules = {
  2219. "start" : [
  2220. {
  2221. token : "comment",
  2222. regex : "#.*$"
  2223. }, {
  2224. token : "comment", // multi line comment
  2225. regex : "^=begin(?:$|\\s.*$)",
  2226. next : "comment"
  2227. }, {
  2228. token : "string.regexp",
  2229. regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  2230. },
  2231. [{
  2232. regex: "[{}]", onMatch: function(val, state, stack) {
  2233. this.next = val == "{" ? this.nextState : "";
  2234. if (val == "{" && stack.length) {
  2235. stack.unshift("start", state);
  2236. return "paren.lparen";
  2237. }
  2238. if (val == "}" && stack.length) {
  2239. stack.shift();
  2240. this.next = stack.shift();
  2241. if (this.next.indexOf("string") != -1)
  2242. return "paren.end";
  2243. }
  2244. return val == "{" ? "paren.lparen" : "paren.rparen";
  2245. },
  2246. nextState: "start"
  2247. }, {
  2248. token : "string.start",
  2249. regex : /"/,
  2250. push : [{
  2251. token : "constant.language.escape",
  2252. regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
  2253. }, {
  2254. token : "paren.start",
  2255. regex : /\#{/,
  2256. push : "start"
  2257. }, {
  2258. token : "string.end",
  2259. regex : /"/,
  2260. next : "pop"
  2261. }, {
  2262. defaultToken: "string"
  2263. }]
  2264. }, {
  2265. token : "string.start",
  2266. regex : /`/,
  2267. push : [{
  2268. token : "constant.language.escape",
  2269. regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
  2270. }, {
  2271. token : "paren.start",
  2272. regex : /\#{/,
  2273. push : "start"
  2274. }, {
  2275. token : "string.end",
  2276. regex : /`/,
  2277. next : "pop"
  2278. }, {
  2279. defaultToken: "string"
  2280. }]
  2281. }, {
  2282. token : "string.start",
  2283. regex : /'/,
  2284. push : [{
  2285. token : "constant.language.escape",
  2286. regex : /\\['\\]/
  2287. }, {
  2288. token : "string.end",
  2289. regex : /'/,
  2290. next : "pop"
  2291. }, {
  2292. defaultToken: "string"
  2293. }]
  2294. }],
  2295. {
  2296. token : "text", // namespaces aren't symbols
  2297. regex : "::"
  2298. }, {
  2299. token : "variable.instance", // instance variable
  2300. regex : "@{1,2}[a-zA-Z_\\d]+"
  2301. }, {
  2302. token : "support.class", // class name
  2303. regex : "[A-Z][a-zA-Z_\\d]+"
  2304. },
  2305. constantOtherSymbol,
  2306. constantNumericHex,
  2307. constantNumericFloat,
  2308. {
  2309. token : "constant.language.boolean",
  2310. regex : "(?:true|false)\\b"
  2311. }, {
  2312. token : keywordMapper,
  2313. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  2314. }, {
  2315. token : "punctuation.separator.key-value",
  2316. regex : "=>"
  2317. }, {
  2318. stateName: "heredoc",
  2319. onMatch : function(value, currentState, stack) {
  2320. var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
  2321. var tokens = value.split(this.splitRegex);
  2322. stack.push(next, tokens[3]);
  2323. return [
  2324. {type:"constant", value: tokens[1]},
  2325. {type:"string", value: tokens[2]},
  2326. {type:"support.class", value: tokens[3]},
  2327. {type:"string", value: tokens[4]}
  2328. ];
  2329. },
  2330. regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)",
  2331. rules: {
  2332. heredoc: [{
  2333. onMatch: function(value, currentState, stack) {
  2334. if (value === stack[1]) {
  2335. stack.shift();
  2336. stack.shift();
  2337. this.next = stack[0] || "start";
  2338. return "support.class";
  2339. }
  2340. this.next = "";
  2341. return "string";
  2342. },
  2343. regex: ".*$",
  2344. next: "start"
  2345. }],
  2346. indentedHeredoc: [{
  2347. token: "string",
  2348. regex: "^ +"
  2349. }, {
  2350. onMatch: function(value, currentState, stack) {
  2351. if (value === stack[1]) {
  2352. stack.shift();
  2353. stack.shift();
  2354. this.next = stack[0] || "start";
  2355. return "support.class";
  2356. }
  2357. this.next = "";
  2358. return "string";
  2359. },
  2360. regex: ".*$",
  2361. next: "start"
  2362. }]
  2363. }
  2364. }, {
  2365. regex : "$",
  2366. token : "empty",
  2367. next : function(currentState, stack) {
  2368. if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
  2369. return stack[0];
  2370. return currentState;
  2371. }
  2372. }, {
  2373. token : "string.character",
  2374. regex : "\\B\\?."
  2375. }, {
  2376. token : "keyword.operator",
  2377. regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  2378. }, {
  2379. token : "paren.lparen",
  2380. regex : "[[({]"
  2381. }, {
  2382. token : "paren.rparen",
  2383. regex : "[\\])}]"
  2384. }, {
  2385. token : "text",
  2386. regex : "\\s+"
  2387. }
  2388. ],
  2389. "comment" : [
  2390. {
  2391. token : "comment", // closing comment
  2392. regex : "^=end(?:$|\\s.*$)",
  2393. next : "start"
  2394. }, {
  2395. token : "comment", // comment spanning whole line
  2396. regex : ".+"
  2397. }
  2398. ]
  2399. };
  2400. this.normalizeRules();
  2401. };
  2402. oop.inherits(RubyHighlightRules, TextHighlightRules);
  2403. exports.RubyHighlightRules = RubyHighlightRules;
  2404. });
  2405. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
  2406. "use strict";
  2407. var oop = require("../../lib/oop");
  2408. var BaseFoldMode = require("./fold_mode").FoldMode;
  2409. var Range = require("../../range").Range;
  2410. var FoldMode = exports.FoldMode = function() {};
  2411. oop.inherits(FoldMode, BaseFoldMode);
  2412. (function() {
  2413. this.getFoldWidgetRange = function(session, foldStyle, row) {
  2414. var range = this.indentationBlock(session, row);
  2415. if (range)
  2416. return range;
  2417. var re = /\S/;
  2418. var line = session.getLine(row);
  2419. var startLevel = line.search(re);
  2420. if (startLevel == -1 || line[startLevel] != "#")
  2421. return;
  2422. var startColumn = line.length;
  2423. var maxRow = session.getLength();
  2424. var startRow = row;
  2425. var endRow = row;
  2426. while (++row < maxRow) {
  2427. line = session.getLine(row);
  2428. var level = line.search(re);
  2429. if (level == -1)
  2430. continue;
  2431. if (line[level] != "#")
  2432. break;
  2433. endRow = row;
  2434. }
  2435. if (endRow > startRow) {
  2436. var endColumn = session.getLine(endRow).length;
  2437. return new Range(startRow, startColumn, endRow, endColumn);
  2438. }
  2439. };
  2440. this.getFoldWidget = function(session, foldStyle, row) {
  2441. var line = session.getLine(row);
  2442. var indent = line.search(/\S/);
  2443. var next = session.getLine(row + 1);
  2444. var prev = session.getLine(row - 1);
  2445. var prevIndent = prev.search(/\S/);
  2446. var nextIndent = next.search(/\S/);
  2447. if (indent == -1) {
  2448. session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
  2449. return "";
  2450. }
  2451. if (prevIndent == -1) {
  2452. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  2453. session.foldWidgets[row - 1] = "";
  2454. session.foldWidgets[row + 1] = "";
  2455. return "start";
  2456. }
  2457. } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  2458. if (session.getLine(row - 2).search(/\S/) == -1) {
  2459. session.foldWidgets[row - 1] = "start";
  2460. session.foldWidgets[row + 1] = "";
  2461. return "";
  2462. }
  2463. }
  2464. if (prevIndent!= -1 && prevIndent < indent)
  2465. session.foldWidgets[row - 1] = "start";
  2466. else
  2467. session.foldWidgets[row - 1] = "";
  2468. if (indent < nextIndent)
  2469. return "start";
  2470. else
  2471. return "";
  2472. };
  2473. }).call(FoldMode.prototype);
  2474. });
  2475. ace.define("ace/mode/ruby",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ruby_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) {
  2476. "use strict";
  2477. var oop = require("../lib/oop");
  2478. var TextMode = require("./text").Mode;
  2479. var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
  2480. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  2481. var Range = require("../range").Range;
  2482. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  2483. var FoldMode = require("./folding/coffee").FoldMode;
  2484. var Mode = function() {
  2485. this.HighlightRules = RubyHighlightRules;
  2486. this.$outdent = new MatchingBraceOutdent();
  2487. this.$behaviour = new CstyleBehaviour();
  2488. this.foldingRules = new FoldMode();
  2489. };
  2490. oop.inherits(Mode, TextMode);
  2491. (function() {
  2492. this.lineCommentStart = "#";
  2493. this.getNextLineIndent = function(state, line, tab) {
  2494. var indent = this.$getIndent(line);
  2495. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  2496. var tokens = tokenizedLine.tokens;
  2497. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  2498. return indent;
  2499. }
  2500. if (state == "start") {
  2501. var match = line.match(/^.*[\{\(\[]\s*$/);
  2502. var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/);
  2503. var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/);
  2504. var startingConditional = line.match(/^\s*(if|else)\s*/)
  2505. if (match || startingClassOrMethod || startingDoBlock || startingConditional) {
  2506. indent += tab;
  2507. }
  2508. }
  2509. return indent;
  2510. };
  2511. this.checkOutdent = function(state, line, input) {
  2512. return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input);
  2513. };
  2514. this.autoOutdent = function(state, session, row) {
  2515. var line = session.getLine(row);
  2516. if (/}/.test(line))
  2517. return this.$outdent.autoOutdent(session, row);
  2518. var indent = this.$getIndent(line);
  2519. var prevLine = session.getLine(row - 1);
  2520. var prevIndent = this.$getIndent(prevLine);
  2521. var tab = session.getTabString();
  2522. if (prevIndent.length <= indent.length) {
  2523. if (indent.slice(-tab.length) == tab)
  2524. session.remove(new Range(row, indent.length-tab.length, row, indent.length));
  2525. }
  2526. };
  2527. this.$id = "ace/mode/ruby";
  2528. }).call(Mode.prototype);
  2529. exports.Mode = Mode;
  2530. });
  2531. ace.define("ace/mode/ejs",["require","exports","module","ace/lib/oop","ace/mode/html_highlight_rules","ace/mode/javascript_highlight_rules","ace/lib/oop","ace/mode/html","ace/mode/javascript","ace/mode/css","ace/mode/ruby"], function(require, exports, module) {
  2532. "use strict";
  2533. var oop = require("../lib/oop");
  2534. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2535. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  2536. var EjsHighlightRules = function(start, end) {
  2537. HtmlHighlightRules.call(this);
  2538. if (!start)
  2539. start = "(?:<%|<\\?|{{)";
  2540. if (!end)
  2541. end = "(?:%>|\\?>|}})";
  2542. for (var i in this.$rules) {
  2543. this.$rules[i].unshift({
  2544. token : "markup.list.meta.tag",
  2545. regex : start + "(?![>}])[-=]?",
  2546. push : "ejs-start"
  2547. });
  2548. }
  2549. this.embedRules(JavaScriptHighlightRules, "ejs-");
  2550. this.$rules["ejs-start"].unshift({
  2551. token : "markup.list.meta.tag",
  2552. regex : "-?" + end,
  2553. next : "pop"
  2554. }, {
  2555. token: "comment",
  2556. regex: "//.*?" + end,
  2557. next: "pop"
  2558. });
  2559. this.$rules["ejs-no_regex"].unshift({
  2560. token : "markup.list.meta.tag",
  2561. regex : "-?" + end,
  2562. next : "pop"
  2563. }, {
  2564. token: "comment",
  2565. regex: "//.*?" + end,
  2566. next: "pop"
  2567. });
  2568. this.normalizeRules();
  2569. };
  2570. oop.inherits(EjsHighlightRules, HtmlHighlightRules);
  2571. exports.EjsHighlightRules = EjsHighlightRules;
  2572. var oop = require("../lib/oop");
  2573. var HtmlMode = require("./html").Mode;
  2574. var JavaScriptMode = require("./javascript").Mode;
  2575. var CssMode = require("./css").Mode;
  2576. var RubyMode = require("./ruby").Mode;
  2577. var Mode = function() {
  2578. HtmlMode.call(this);
  2579. this.HighlightRules = EjsHighlightRules;
  2580. this.createModeDelegates({
  2581. "js-": JavaScriptMode,
  2582. "css-": CssMode,
  2583. "ejs-": JavaScriptMode
  2584. });
  2585. };
  2586. oop.inherits(Mode, HtmlMode);
  2587. (function() {
  2588. this.$id = "ace/mode/ejs";
  2589. }).call(Mode.prototype);
  2590. exports.Mode = Mode;
  2591. });