mode-html_ruby.js 114 KB

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