mode-html_ruby.js 106 KB

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