Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mode-ejs.js 112KB

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