mode-rhtml.js 103 KB

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