Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

mode-html_ruby.js 113KB

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