mode-markdown.js 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821
  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/.test(token.type);
  635. var stringAfter = !rightToken || /string/.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/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  915. "use strict";
  916. var oop = require("../lib/oop");
  917. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  918. var XmlHighlightRules = function(normalize) {
  919. var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
  920. this.$rules = {
  921. start : [
  922. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  923. {
  924. token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
  925. regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
  926. },
  927. {
  928. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  929. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
  930. },
  931. {token : "comment.xml", regex : "<\\!--", next : "comment"},
  932. {
  933. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  934. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  935. },
  936. {include : "tag"},
  937. {token : "text.end-tag-open.xml", regex: "</"},
  938. {token : "text.tag-open.xml", regex: "<"},
  939. {include : "reference"},
  940. {defaultToken : "text.xml"}
  941. ],
  942. xml_decl : [{
  943. token : "entity.other.attribute-name.decl-attribute-name.xml",
  944. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  945. }, {
  946. token : "keyword.operator.decl-attribute-equals.xml",
  947. regex : "="
  948. }, {
  949. include: "whitespace"
  950. }, {
  951. include: "string"
  952. }, {
  953. token : "punctuation.xml-decl.xml",
  954. regex : "\\?>",
  955. next : "start"
  956. }],
  957. processing_instruction : [
  958. {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
  959. {defaultToken : "instruction.xml"}
  960. ],
  961. doctype : [
  962. {include : "whitespace"},
  963. {include : "string"},
  964. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  965. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  966. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  967. ],
  968. int_subset : [{
  969. token : "text.xml",
  970. regex : "\\s+"
  971. }, {
  972. token: "punctuation.int-subset.xml",
  973. regex: "]",
  974. next: "pop"
  975. }, {
  976. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  977. regex : "(<\\!)(" + tagRegex + ")",
  978. push : [{
  979. token : "text",
  980. regex : "\\s+"
  981. },
  982. {
  983. token : "punctuation.markup-decl.xml",
  984. regex : ">",
  985. next : "pop"
  986. },
  987. {include : "string"}]
  988. }],
  989. cdata : [
  990. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  991. {token : "text.xml", regex : "\\s+"},
  992. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  993. ],
  994. comment : [
  995. {token : "comment.xml", regex : "-->", next : "start"},
  996. {defaultToken : "comment.xml"}
  997. ],
  998. reference : [{
  999. token : "constant.language.escape.reference.xml",
  1000. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1001. }],
  1002. attr_reference : [{
  1003. token : "constant.language.escape.reference.attribute-value.xml",
  1004. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  1005. }],
  1006. tag : [{
  1007. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  1008. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  1009. next: [
  1010. {include : "attributes"},
  1011. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1012. ]
  1013. }],
  1014. tag_whitespace : [
  1015. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  1016. ],
  1017. whitespace : [
  1018. {token : "text.whitespace.xml", regex : "\\s+"}
  1019. ],
  1020. string: [{
  1021. token : "string.xml",
  1022. regex : "'",
  1023. push : [
  1024. {token : "string.xml", regex: "'", next: "pop"},
  1025. {defaultToken : "string.xml"}
  1026. ]
  1027. }, {
  1028. token : "string.xml",
  1029. regex : '"',
  1030. push : [
  1031. {token : "string.xml", regex: '"', next: "pop"},
  1032. {defaultToken : "string.xml"}
  1033. ]
  1034. }],
  1035. attributes: [{
  1036. token : "entity.other.attribute-name.xml",
  1037. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  1038. }, {
  1039. token : "keyword.operator.attribute-equals.xml",
  1040. regex : "="
  1041. }, {
  1042. include: "tag_whitespace"
  1043. }, {
  1044. include: "attribute_value"
  1045. }],
  1046. attribute_value: [{
  1047. token : "string.attribute-value.xml",
  1048. regex : "'",
  1049. push : [
  1050. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  1051. {include : "attr_reference"},
  1052. {defaultToken : "string.attribute-value.xml"}
  1053. ]
  1054. }, {
  1055. token : "string.attribute-value.xml",
  1056. regex : '"',
  1057. push : [
  1058. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  1059. {include : "attr_reference"},
  1060. {defaultToken : "string.attribute-value.xml"}
  1061. ]
  1062. }]
  1063. };
  1064. if (this.constructor === XmlHighlightRules)
  1065. this.normalizeRules();
  1066. };
  1067. (function() {
  1068. this.embedTagRules = function(HighlightRules, prefix, tag){
  1069. this.$rules.tag.unshift({
  1070. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  1071. regex : "(<)(" + tag + "(?=\\s|>|$))",
  1072. next: [
  1073. {include : "attributes"},
  1074. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  1075. ]
  1076. });
  1077. this.$rules[tag + "-end"] = [
  1078. {include : "attributes"},
  1079. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  1080. onMatch : function(value, currentState, stack) {
  1081. stack.splice(0);
  1082. return this.token;
  1083. }}
  1084. ]
  1085. this.embedRules(HighlightRules, prefix, [{
  1086. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  1087. regex : "(</)(" + tag + "(?=\\s|>|$))",
  1088. next: tag + "-end"
  1089. }, {
  1090. token: "string.cdata.xml",
  1091. regex : "<\\!\\[CDATA\\["
  1092. }, {
  1093. token: "string.cdata.xml",
  1094. regex : "\\]\\]>"
  1095. }]);
  1096. };
  1097. }).call(TextHighlightRules.prototype);
  1098. oop.inherits(XmlHighlightRules, TextHighlightRules);
  1099. exports.XmlHighlightRules = XmlHighlightRules;
  1100. });
  1101. 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) {
  1102. "use strict";
  1103. var oop = require("../../lib/oop");
  1104. var Behaviour = require("../behaviour").Behaviour;
  1105. var TokenIterator = require("../../token_iterator").TokenIterator;
  1106. var lang = require("../../lib/lang");
  1107. function is(token, type) {
  1108. return token.type.lastIndexOf(type + ".xml") > -1;
  1109. }
  1110. var XmlBehaviour = function () {
  1111. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  1112. if (text == '"' || text == "'") {
  1113. var quote = text;
  1114. var selected = session.doc.getTextRange(editor.getSelectionRange());
  1115. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  1116. return {
  1117. text: quote + selected + quote,
  1118. selection: false
  1119. };
  1120. }
  1121. var cursor = editor.getCursorPosition();
  1122. var line = session.doc.getLine(cursor.row);
  1123. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1124. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1125. var token = iterator.getCurrentToken();
  1126. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  1127. return {
  1128. text: "",
  1129. selection: [1, 1]
  1130. };
  1131. }
  1132. if (!token)
  1133. token = iterator.stepBackward();
  1134. if (!token)
  1135. return;
  1136. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  1137. token = iterator.stepBackward();
  1138. }
  1139. var rightSpace = !rightChar || rightChar.match(/\s/);
  1140. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  1141. return {
  1142. text: quote + quote,
  1143. selection: [1, 1]
  1144. };
  1145. }
  1146. }
  1147. });
  1148. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  1149. var selected = session.doc.getTextRange(range);
  1150. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  1151. var line = session.doc.getLine(range.start.row);
  1152. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  1153. if (rightChar == selected) {
  1154. range.end.column++;
  1155. return range;
  1156. }
  1157. }
  1158. });
  1159. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  1160. if (text == '>') {
  1161. var position = editor.getCursorPosition();
  1162. var iterator = new TokenIterator(session, position.row, position.column);
  1163. var token = iterator.getCurrentToken() || iterator.stepBackward();
  1164. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  1165. return;
  1166. if (is(token, "reference.attribute-value"))
  1167. return;
  1168. if (is(token, "attribute-value")) {
  1169. var firstChar = token.value.charAt(0);
  1170. if (firstChar == '"' || firstChar == "'") {
  1171. var lastChar = token.value.charAt(token.value.length - 1);
  1172. var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
  1173. if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
  1174. return;
  1175. }
  1176. }
  1177. while (!is(token, "tag-name")) {
  1178. token = iterator.stepBackward();
  1179. }
  1180. var tokenRow = iterator.getCurrentTokenRow();
  1181. var tokenColumn = iterator.getCurrentTokenColumn();
  1182. if (is(iterator.stepBackward(), "end-tag-open"))
  1183. return;
  1184. var element = token.value;
  1185. if (tokenRow == position.row)
  1186. element = element.substring(0, position.column - tokenColumn);
  1187. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  1188. return;
  1189. return {
  1190. text: ">" + "</" + element + ">",
  1191. selection: [1, 1]
  1192. };
  1193. }
  1194. });
  1195. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  1196. if (text == "\n") {
  1197. var cursor = editor.getCursorPosition();
  1198. var line = session.getLine(cursor.row);
  1199. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1200. var token = iterator.getCurrentToken();
  1201. if (token && token.type.indexOf("tag-close") !== -1) {
  1202. if (token.value == "/>")
  1203. return;
  1204. while (token && token.type.indexOf("tag-name") === -1) {
  1205. token = iterator.stepBackward();
  1206. }
  1207. if (!token) {
  1208. return;
  1209. }
  1210. var tag = token.value;
  1211. var row = iterator.getCurrentTokenRow();
  1212. token = iterator.stepBackward();
  1213. if (!token || token.type.indexOf("end-tag") !== -1) {
  1214. return;
  1215. }
  1216. if (this.voidElements && !this.voidElements[tag]) {
  1217. var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
  1218. var line = session.getLine(row);
  1219. var nextIndent = this.$getIndent(line);
  1220. var indent = nextIndent + session.getTabString();
  1221. if (nextToken && nextToken.value === "</") {
  1222. return {
  1223. text: "\n" + indent + "\n" + nextIndent,
  1224. selection: [1, indent.length, 1, indent.length]
  1225. };
  1226. } else {
  1227. return {
  1228. text: "\n" + indent
  1229. };
  1230. }
  1231. }
  1232. }
  1233. }
  1234. });
  1235. };
  1236. oop.inherits(XmlBehaviour, Behaviour);
  1237. exports.XmlBehaviour = XmlBehaviour;
  1238. });
  1239. 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) {
  1240. "use strict";
  1241. var oop = require("../../lib/oop");
  1242. var lang = require("../../lib/lang");
  1243. var Range = require("../../range").Range;
  1244. var BaseFoldMode = require("./fold_mode").FoldMode;
  1245. var TokenIterator = require("../../token_iterator").TokenIterator;
  1246. var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
  1247. BaseFoldMode.call(this);
  1248. this.voidElements = voidElements || {};
  1249. this.optionalEndTags = oop.mixin({}, this.voidElements);
  1250. if (optionalEndTags)
  1251. oop.mixin(this.optionalEndTags, optionalEndTags);
  1252. };
  1253. oop.inherits(FoldMode, BaseFoldMode);
  1254. var Tag = function() {
  1255. this.tagName = "";
  1256. this.closing = false;
  1257. this.selfClosing = false;
  1258. this.start = {row: 0, column: 0};
  1259. this.end = {row: 0, column: 0};
  1260. };
  1261. function is(token, type) {
  1262. return token.type.lastIndexOf(type + ".xml") > -1;
  1263. }
  1264. (function() {
  1265. this.getFoldWidget = function(session, foldStyle, row) {
  1266. var tag = this._getFirstTagInLine(session, row);
  1267. if (!tag)
  1268. return "";
  1269. if (tag.closing || (!tag.tagName && tag.selfClosing))
  1270. return foldStyle == "markbeginend" ? "end" : "";
  1271. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  1272. return "";
  1273. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  1274. return "";
  1275. return "start";
  1276. };
  1277. this._getFirstTagInLine = function(session, row) {
  1278. var tokens = session.getTokens(row);
  1279. var tag = new Tag();
  1280. for (var i = 0; i < tokens.length; i++) {
  1281. var token = tokens[i];
  1282. if (is(token, "tag-open")) {
  1283. tag.end.column = tag.start.column + token.value.length;
  1284. tag.closing = is(token, "end-tag-open");
  1285. token = tokens[++i];
  1286. if (!token)
  1287. return null;
  1288. tag.tagName = token.value;
  1289. tag.end.column += token.value.length;
  1290. for (i++; i < tokens.length; i++) {
  1291. token = tokens[i];
  1292. tag.end.column += token.value.length;
  1293. if (is(token, "tag-close")) {
  1294. tag.selfClosing = token.value == '/>';
  1295. break;
  1296. }
  1297. }
  1298. return tag;
  1299. } else if (is(token, "tag-close")) {
  1300. tag.selfClosing = token.value == '/>';
  1301. return tag;
  1302. }
  1303. tag.start.column += token.value.length;
  1304. }
  1305. return null;
  1306. };
  1307. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  1308. var tokens = session.getTokens(row);
  1309. var column = 0;
  1310. for (var i = 0; i < tokens.length; i++) {
  1311. var token = tokens[i];
  1312. column += token.value.length;
  1313. if (column < startColumn)
  1314. continue;
  1315. if (is(token, "end-tag-open")) {
  1316. token = tokens[i + 1];
  1317. if (token && token.value == tagName)
  1318. return true;
  1319. }
  1320. }
  1321. return false;
  1322. };
  1323. this._readTagForward = function(iterator) {
  1324. var token = iterator.getCurrentToken();
  1325. if (!token)
  1326. return null;
  1327. var tag = new Tag();
  1328. do {
  1329. if (is(token, "tag-open")) {
  1330. tag.closing = is(token, "end-tag-open");
  1331. tag.start.row = iterator.getCurrentTokenRow();
  1332. tag.start.column = iterator.getCurrentTokenColumn();
  1333. } else if (is(token, "tag-name")) {
  1334. tag.tagName = token.value;
  1335. } else if (is(token, "tag-close")) {
  1336. tag.selfClosing = token.value == "/>";
  1337. tag.end.row = iterator.getCurrentTokenRow();
  1338. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1339. iterator.stepForward();
  1340. return tag;
  1341. }
  1342. } while(token = iterator.stepForward());
  1343. return null;
  1344. };
  1345. this._readTagBackward = function(iterator) {
  1346. var token = iterator.getCurrentToken();
  1347. if (!token)
  1348. return null;
  1349. var tag = new Tag();
  1350. do {
  1351. if (is(token, "tag-open")) {
  1352. tag.closing = is(token, "end-tag-open");
  1353. tag.start.row = iterator.getCurrentTokenRow();
  1354. tag.start.column = iterator.getCurrentTokenColumn();
  1355. iterator.stepBackward();
  1356. return tag;
  1357. } else if (is(token, "tag-name")) {
  1358. tag.tagName = token.value;
  1359. } else if (is(token, "tag-close")) {
  1360. tag.selfClosing = token.value == "/>";
  1361. tag.end.row = iterator.getCurrentTokenRow();
  1362. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1363. }
  1364. } while(token = iterator.stepBackward());
  1365. return null;
  1366. };
  1367. this._pop = function(stack, tag) {
  1368. while (stack.length) {
  1369. var top = stack[stack.length-1];
  1370. if (!tag || top.tagName == tag.tagName) {
  1371. return stack.pop();
  1372. }
  1373. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  1374. stack.pop();
  1375. continue;
  1376. } else {
  1377. return null;
  1378. }
  1379. }
  1380. };
  1381. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1382. var firstTag = this._getFirstTagInLine(session, row);
  1383. if (!firstTag)
  1384. return null;
  1385. var isBackward = firstTag.closing || firstTag.selfClosing;
  1386. var stack = [];
  1387. var tag;
  1388. if (!isBackward) {
  1389. var iterator = new TokenIterator(session, row, firstTag.start.column);
  1390. var start = {
  1391. row: row,
  1392. column: firstTag.start.column + firstTag.tagName.length + 2
  1393. };
  1394. if (firstTag.start.row == firstTag.end.row)
  1395. start.column = firstTag.end.column;
  1396. while (tag = this._readTagForward(iterator)) {
  1397. if (tag.selfClosing) {
  1398. if (!stack.length) {
  1399. tag.start.column += tag.tagName.length + 2;
  1400. tag.end.column -= 2;
  1401. return Range.fromPoints(tag.start, tag.end);
  1402. } else
  1403. continue;
  1404. }
  1405. if (tag.closing) {
  1406. this._pop(stack, tag);
  1407. if (stack.length == 0)
  1408. return Range.fromPoints(start, tag.start);
  1409. }
  1410. else {
  1411. stack.push(tag);
  1412. }
  1413. }
  1414. }
  1415. else {
  1416. var iterator = new TokenIterator(session, row, firstTag.end.column);
  1417. var end = {
  1418. row: row,
  1419. column: firstTag.start.column
  1420. };
  1421. while (tag = this._readTagBackward(iterator)) {
  1422. if (tag.selfClosing) {
  1423. if (!stack.length) {
  1424. tag.start.column += tag.tagName.length + 2;
  1425. tag.end.column -= 2;
  1426. return Range.fromPoints(tag.start, tag.end);
  1427. } else
  1428. continue;
  1429. }
  1430. if (!tag.closing) {
  1431. this._pop(stack, tag);
  1432. if (stack.length == 0) {
  1433. tag.start.column += tag.tagName.length + 2;
  1434. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  1435. tag.start.column = tag.end.column;
  1436. return Range.fromPoints(tag.start, end);
  1437. }
  1438. }
  1439. else {
  1440. stack.push(tag);
  1441. }
  1442. }
  1443. }
  1444. };
  1445. }).call(FoldMode.prototype);
  1446. });
  1447. ace.define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml","ace/worker/worker_client"], function(require, exports, module) {
  1448. "use strict";
  1449. var oop = require("../lib/oop");
  1450. var lang = require("../lib/lang");
  1451. var TextMode = require("./text").Mode;
  1452. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1453. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  1454. var XmlFoldMode = require("./folding/xml").FoldMode;
  1455. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1456. var Mode = function() {
  1457. this.HighlightRules = XmlHighlightRules;
  1458. this.$behaviour = new XmlBehaviour();
  1459. this.foldingRules = new XmlFoldMode();
  1460. };
  1461. oop.inherits(Mode, TextMode);
  1462. (function() {
  1463. this.voidElements = lang.arrayToMap([]);
  1464. this.blockComment = {start: "<!--", end: "-->"};
  1465. this.createWorker = function(session) {
  1466. var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
  1467. worker.attachToDocument(session.getDocument());
  1468. worker.on("error", function(e) {
  1469. session.setAnnotations(e.data);
  1470. });
  1471. worker.on("terminate", function() {
  1472. session.clearAnnotations();
  1473. });
  1474. return worker;
  1475. };
  1476. this.$id = "ace/mode/xml";
  1477. }).call(Mode.prototype);
  1478. exports.Mode = Mode;
  1479. });
  1480. 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) {
  1481. "use strict";
  1482. var oop = require("../lib/oop");
  1483. var lang = require("../lib/lang");
  1484. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1485. 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";
  1486. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  1487. 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";
  1488. var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
  1489. 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";
  1490. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  1491. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  1492. 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";
  1493. var CssHighlightRules = function() {
  1494. var keywordMapper = this.createKeywordMapper({
  1495. "support.function": supportFunction,
  1496. "support.constant": supportConstant,
  1497. "support.type": supportType,
  1498. "support.constant.color": supportConstantColor,
  1499. "support.constant.fonts": supportConstantFonts
  1500. }, "text", true);
  1501. this.$rules = {
  1502. "start" : [{
  1503. token : "comment", // multi line comment
  1504. regex : "\\/\\*",
  1505. push : "comment"
  1506. }, {
  1507. token: "paren.lparen",
  1508. regex: "\\{",
  1509. push: "ruleset"
  1510. }, {
  1511. token: "string",
  1512. regex: "@.*?{",
  1513. push: "media"
  1514. }, {
  1515. token: "keyword",
  1516. regex: "#[a-z0-9-_]+"
  1517. }, {
  1518. token: "variable",
  1519. regex: "\\.[a-z0-9-_]+"
  1520. }, {
  1521. token: "string",
  1522. regex: ":[a-z0-9-_]+"
  1523. }, {
  1524. token: "constant",
  1525. regex: "[a-z0-9-_]+"
  1526. }, {
  1527. caseInsensitive: true
  1528. }],
  1529. "media" : [{
  1530. token : "comment", // multi line comment
  1531. regex : "\\/\\*",
  1532. push : "comment"
  1533. }, {
  1534. token: "paren.lparen",
  1535. regex: "\\{",
  1536. push: "ruleset"
  1537. }, {
  1538. token: "string",
  1539. regex: "\\}",
  1540. next: "pop"
  1541. }, {
  1542. token: "keyword",
  1543. regex: "#[a-z0-9-_]+"
  1544. }, {
  1545. token: "variable",
  1546. regex: "\\.[a-z0-9-_]+"
  1547. }, {
  1548. token: "string",
  1549. regex: ":[a-z0-9-_]+"
  1550. }, {
  1551. token: "constant",
  1552. regex: "[a-z0-9-_]+"
  1553. }, {
  1554. caseInsensitive: true
  1555. }],
  1556. "comment" : [{
  1557. token : "comment",
  1558. regex : "\\*\\/",
  1559. next : "pop"
  1560. }, {
  1561. defaultToken : "comment"
  1562. }],
  1563. "ruleset" : [
  1564. {
  1565. token : "paren.rparen",
  1566. regex : "\\}",
  1567. next: "pop"
  1568. }, {
  1569. token : "comment", // multi line comment
  1570. regex : "\\/\\*",
  1571. push : "comment"
  1572. }, {
  1573. token : "string", // single line
  1574. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1575. }, {
  1576. token : "string", // single line
  1577. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1578. }, {
  1579. token : ["constant.numeric", "keyword"],
  1580. 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|%)"
  1581. }, {
  1582. token : "constant.numeric",
  1583. regex : numRe
  1584. }, {
  1585. token : "constant.numeric", // hex6 color
  1586. regex : "#[a-f0-9]{6}"
  1587. }, {
  1588. token : "constant.numeric", // hex3 color
  1589. regex : "#[a-f0-9]{3}"
  1590. }, {
  1591. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  1592. regex : pseudoElements
  1593. }, {
  1594. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  1595. regex : pseudoClasses
  1596. }, {
  1597. token : ["support.function", "string", "support.function"],
  1598. regex : "(url\\()(.*)(\\))"
  1599. }, {
  1600. token : keywordMapper,
  1601. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  1602. }, {
  1603. caseInsensitive: true
  1604. }]
  1605. };
  1606. this.normalizeRules();
  1607. };
  1608. oop.inherits(CssHighlightRules, TextHighlightRules);
  1609. exports.CssHighlightRules = CssHighlightRules;
  1610. });
  1611. 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) {
  1612. "use strict";
  1613. var oop = require("../../lib/oop");
  1614. var Behaviour = require("../behaviour").Behaviour;
  1615. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1616. var TokenIterator = require("../../token_iterator").TokenIterator;
  1617. var CssBehaviour = function () {
  1618. this.inherit(CstyleBehaviour);
  1619. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1620. if (text === ':') {
  1621. var cursor = editor.getCursorPosition();
  1622. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1623. var token = iterator.getCurrentToken();
  1624. if (token && token.value.match(/\s+/)) {
  1625. token = iterator.stepBackward();
  1626. }
  1627. if (token && token.type === 'support.type') {
  1628. var line = session.doc.getLine(cursor.row);
  1629. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1630. if (rightChar === ':') {
  1631. return {
  1632. text: '',
  1633. selection: [1, 1]
  1634. }
  1635. }
  1636. if (!line.substring(cursor.column).match(/^\s*;/)) {
  1637. return {
  1638. text: ':;',
  1639. selection: [1, 1]
  1640. }
  1641. }
  1642. }
  1643. }
  1644. });
  1645. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1646. var selected = session.doc.getTextRange(range);
  1647. if (!range.isMultiLine() && selected === ':') {
  1648. var cursor = editor.getCursorPosition();
  1649. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1650. var token = iterator.getCurrentToken();
  1651. if (token && token.value.match(/\s+/)) {
  1652. token = iterator.stepBackward();
  1653. }
  1654. if (token && token.type === 'support.type') {
  1655. var line = session.doc.getLine(range.start.row);
  1656. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1657. if (rightChar === ';') {
  1658. range.end.column ++;
  1659. return range;
  1660. }
  1661. }
  1662. }
  1663. });
  1664. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1665. if (text === ';') {
  1666. var cursor = editor.getCursorPosition();
  1667. var line = session.doc.getLine(cursor.row);
  1668. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1669. if (rightChar === ';') {
  1670. return {
  1671. text: '',
  1672. selection: [1, 1]
  1673. }
  1674. }
  1675. }
  1676. });
  1677. }
  1678. oop.inherits(CssBehaviour, CstyleBehaviour);
  1679. exports.CssBehaviour = CssBehaviour;
  1680. });
  1681. 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) {
  1682. "use strict";
  1683. var oop = require("../lib/oop");
  1684. var TextMode = require("./text").Mode;
  1685. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1686. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1687. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1688. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1689. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1690. var Mode = function() {
  1691. this.HighlightRules = CssHighlightRules;
  1692. this.$outdent = new MatchingBraceOutdent();
  1693. this.$behaviour = new CssBehaviour();
  1694. this.foldingRules = new CStyleFoldMode();
  1695. };
  1696. oop.inherits(Mode, TextMode);
  1697. (function() {
  1698. this.foldingRules = "cStyle";
  1699. this.blockComment = {start: "/*", end: "*/"};
  1700. this.getNextLineIndent = function(state, line, tab) {
  1701. var indent = this.$getIndent(line);
  1702. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1703. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1704. return indent;
  1705. }
  1706. var match = line.match(/^.*\{\s*$/);
  1707. if (match) {
  1708. indent += tab;
  1709. }
  1710. return indent;
  1711. };
  1712. this.checkOutdent = function(state, line, input) {
  1713. return this.$outdent.checkOutdent(line, input);
  1714. };
  1715. this.autoOutdent = function(state, doc, row) {
  1716. this.$outdent.autoOutdent(doc, row);
  1717. };
  1718. this.createWorker = function(session) {
  1719. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  1720. worker.attachToDocument(session.getDocument());
  1721. worker.on("annotate", function(e) {
  1722. session.setAnnotations(e.data);
  1723. });
  1724. worker.on("terminate", function() {
  1725. session.clearAnnotations();
  1726. });
  1727. return worker;
  1728. };
  1729. this.$id = "ace/mode/css";
  1730. }).call(Mode.prototype);
  1731. exports.Mode = Mode;
  1732. });
  1733. 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) {
  1734. "use strict";
  1735. var oop = require("../lib/oop");
  1736. var lang = require("../lib/lang");
  1737. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1738. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1739. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1740. var tagMap = lang.createMap({
  1741. a : 'anchor',
  1742. button : 'form',
  1743. form : 'form',
  1744. img : 'image',
  1745. input : 'form',
  1746. label : 'form',
  1747. option : 'form',
  1748. script : 'script',
  1749. select : 'form',
  1750. textarea : 'form',
  1751. style : 'style',
  1752. table : 'table',
  1753. tbody : 'table',
  1754. td : 'table',
  1755. tfoot : 'table',
  1756. th : 'table',
  1757. tr : 'table'
  1758. });
  1759. var HtmlHighlightRules = function() {
  1760. XmlHighlightRules.call(this);
  1761. this.addRules({
  1762. attributes: [{
  1763. include : "tag_whitespace"
  1764. }, {
  1765. token : "entity.other.attribute-name.xml",
  1766. regex : "[-_a-zA-Z0-9:]+"
  1767. }, {
  1768. token : "keyword.operator.attribute-equals.xml",
  1769. regex : "=",
  1770. push : [{
  1771. include: "tag_whitespace"
  1772. }, {
  1773. token : "string.unquoted.attribute-value.html",
  1774. regex : "[^<>='\"`\\s]+",
  1775. next : "pop"
  1776. }, {
  1777. token : "empty",
  1778. regex : "",
  1779. next : "pop"
  1780. }]
  1781. }, {
  1782. include : "attribute_value"
  1783. }],
  1784. tag: [{
  1785. token : function(start, tag) {
  1786. var group = tagMap[tag];
  1787. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  1788. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  1789. },
  1790. regex : "(</?)([-_a-zA-Z0-9:]+)",
  1791. next: "tag_stuff"
  1792. }],
  1793. tag_stuff: [
  1794. {include : "attributes"},
  1795. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1796. ],
  1797. });
  1798. this.embedTagRules(CssHighlightRules, "css-", "style");
  1799. this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
  1800. if (this.constructor === HtmlHighlightRules)
  1801. this.normalizeRules();
  1802. };
  1803. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  1804. exports.HtmlHighlightRules = HtmlHighlightRules;
  1805. });
  1806. ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1807. "use strict";
  1808. var oop = require("../../lib/oop");
  1809. var BaseFoldMode = require("./fold_mode").FoldMode;
  1810. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1811. this.defaultMode = defaultMode;
  1812. this.subModes = subModes;
  1813. };
  1814. oop.inherits(FoldMode, BaseFoldMode);
  1815. (function() {
  1816. this.$getMode = function(state) {
  1817. if (typeof state != "string")
  1818. state = state[0];
  1819. for (var key in this.subModes) {
  1820. if (state.indexOf(key) === 0)
  1821. return this.subModes[key];
  1822. }
  1823. return null;
  1824. };
  1825. this.$tryMode = function(state, session, foldStyle, row) {
  1826. var mode = this.$getMode(state);
  1827. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1828. };
  1829. this.getFoldWidget = function(session, foldStyle, row) {
  1830. return (
  1831. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1832. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1833. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1834. );
  1835. };
  1836. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1837. var mode = this.$getMode(session.getState(row-1));
  1838. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1839. mode = this.$getMode(session.getState(row));
  1840. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1841. mode = this.defaultMode;
  1842. return mode.getFoldWidgetRange(session, foldStyle, row);
  1843. };
  1844. }).call(FoldMode.prototype);
  1845. });
  1846. 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) {
  1847. "use strict";
  1848. var oop = require("../../lib/oop");
  1849. var MixedFoldMode = require("./mixed").FoldMode;
  1850. var XmlFoldMode = require("./xml").FoldMode;
  1851. var CStyleFoldMode = require("./cstyle").FoldMode;
  1852. var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
  1853. MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
  1854. "js-": new CStyleFoldMode(),
  1855. "css-": new CStyleFoldMode()
  1856. });
  1857. };
  1858. oop.inherits(FoldMode, MixedFoldMode);
  1859. });
  1860. ace.define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) {
  1861. "use strict";
  1862. var TokenIterator = require("../token_iterator").TokenIterator;
  1863. var commonAttributes = [
  1864. "accesskey",
  1865. "class",
  1866. "contenteditable",
  1867. "contextmenu",
  1868. "dir",
  1869. "draggable",
  1870. "dropzone",
  1871. "hidden",
  1872. "id",
  1873. "inert",
  1874. "itemid",
  1875. "itemprop",
  1876. "itemref",
  1877. "itemscope",
  1878. "itemtype",
  1879. "lang",
  1880. "spellcheck",
  1881. "style",
  1882. "tabindex",
  1883. "title",
  1884. "translate"
  1885. ];
  1886. var eventAttributes = [
  1887. "onabort",
  1888. "onblur",
  1889. "oncancel",
  1890. "oncanplay",
  1891. "oncanplaythrough",
  1892. "onchange",
  1893. "onclick",
  1894. "onclose",
  1895. "oncontextmenu",
  1896. "oncuechange",
  1897. "ondblclick",
  1898. "ondrag",
  1899. "ondragend",
  1900. "ondragenter",
  1901. "ondragleave",
  1902. "ondragover",
  1903. "ondragstart",
  1904. "ondrop",
  1905. "ondurationchange",
  1906. "onemptied",
  1907. "onended",
  1908. "onerror",
  1909. "onfocus",
  1910. "oninput",
  1911. "oninvalid",
  1912. "onkeydown",
  1913. "onkeypress",
  1914. "onkeyup",
  1915. "onload",
  1916. "onloadeddata",
  1917. "onloadedmetadata",
  1918. "onloadstart",
  1919. "onmousedown",
  1920. "onmousemove",
  1921. "onmouseout",
  1922. "onmouseover",
  1923. "onmouseup",
  1924. "onmousewheel",
  1925. "onpause",
  1926. "onplay",
  1927. "onplaying",
  1928. "onprogress",
  1929. "onratechange",
  1930. "onreset",
  1931. "onscroll",
  1932. "onseeked",
  1933. "onseeking",
  1934. "onselect",
  1935. "onshow",
  1936. "onstalled",
  1937. "onsubmit",
  1938. "onsuspend",
  1939. "ontimeupdate",
  1940. "onvolumechange",
  1941. "onwaiting"
  1942. ];
  1943. var globalAttributes = commonAttributes.concat(eventAttributes);
  1944. var attributeMap = {
  1945. "html": ["manifest"],
  1946. "head": [],
  1947. "title": [],
  1948. "base": ["href", "target"],
  1949. "link": ["href", "hreflang", "rel", "media", "type", "sizes"],
  1950. "meta": ["http-equiv", "name", "content", "charset"],
  1951. "style": ["type", "media", "scoped"],
  1952. "script": ["charset", "type", "src", "defer", "async"],
  1953. "noscript": ["href"],
  1954. "body": ["onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onmessage", "onoffline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload"],
  1955. "section": [],
  1956. "nav": [],
  1957. "article": ["pubdate"],
  1958. "aside": [],
  1959. "h1": [],
  1960. "h2": [],
  1961. "h3": [],
  1962. "h4": [],
  1963. "h5": [],
  1964. "h6": [],
  1965. "header": [],
  1966. "footer": [],
  1967. "address": [],
  1968. "main": [],
  1969. "p": [],
  1970. "hr": [],
  1971. "pre": [],
  1972. "blockquote": ["cite"],
  1973. "ol": ["start", "reversed"],
  1974. "ul": [],
  1975. "li": ["value"],
  1976. "dl": [],
  1977. "dt": [],
  1978. "dd": [],
  1979. "figure": [],
  1980. "figcaption": [],
  1981. "div": [],
  1982. "a": ["href", "target", "ping", "rel", "media", "hreflang", "type"],
  1983. "em": [],
  1984. "strong": [],
  1985. "small": [],
  1986. "s": [],
  1987. "cite": [],
  1988. "q": ["cite"],
  1989. "dfn": [],
  1990. "abbr": [],
  1991. "data": [],
  1992. "time": ["datetime"],
  1993. "code": [],
  1994. "var": [],
  1995. "samp": [],
  1996. "kbd": [],
  1997. "sub": [],
  1998. "sup": [],
  1999. "i": [],
  2000. "b": [],
  2001. "u": [],
  2002. "mark": [],
  2003. "ruby": [],
  2004. "rt": [],
  2005. "rp": [],
  2006. "bdi": [],
  2007. "bdo": [],
  2008. "span": [],
  2009. "br": [],
  2010. "wbr": [],
  2011. "ins": ["cite", "datetime"],
  2012. "del": ["cite", "datetime"],
  2013. "img": ["alt", "src", "height", "width", "usemap", "ismap"],
  2014. "iframe": ["name", "src", "height", "width", "sandbox", "seamless"],
  2015. "embed": ["src", "height", "width", "type"],
  2016. "object": ["param", "data", "type", "height" , "width", "usemap", "name", "form", "classid"],
  2017. "param": ["name", "value"],
  2018. "video": ["src", "autobuffer", "autoplay", "loop", "controls", "width", "height", "poster"],
  2019. "audio": ["src", "autobuffer", "autoplay", "loop", "controls"],
  2020. "source": ["src", "type", "media"],
  2021. "track": ["kind", "src", "srclang", "label", "default"],
  2022. "canvas": ["width", "height"],
  2023. "map": ["name"],
  2024. "area": ["shape", "coords", "href", "hreflang", "alt", "target", "media", "rel", "ping", "type"],
  2025. "svg": [],
  2026. "math": [],
  2027. "table": ["summary"],
  2028. "caption": [],
  2029. "colgroup": ["span"],
  2030. "col": ["span"],
  2031. "tbody": [],
  2032. "thead": [],
  2033. "tfoot": [],
  2034. "tr": [],
  2035. "td": ["headers", "rowspan", "colspan"],
  2036. "th": ["headers", "rowspan", "colspan", "scope"],
  2037. "form": ["accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"],
  2038. "fieldset": ["disabled", "form", "name"],
  2039. "legend": [],
  2040. "label": ["form", "for"],
  2041. "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"],
  2042. "button": ["autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "value", "type"],
  2043. "select": ["autofocus", "disabled", "form", "multiple", "name", "size"],
  2044. "datalist": [],
  2045. "optgroup": ["disabled", "label"],
  2046. "option": ["disabled", "selected", "label", "value"],
  2047. "textarea": ["autofocus", "disabled", "form", "maxlength", "name", "placeholder", "readonly", "required", "rows", "cols", "wrap"],
  2048. "keygen": ["autofocus", "challenge", "disabled", "form", "keytype", "name"],
  2049. "output": ["for", "form", "name"],
  2050. "progress": ["value", "max"],
  2051. "meter": ["value", "min", "max", "low", "high", "optimum"],
  2052. "details": ["open"],
  2053. "summary": [],
  2054. "command": ["type", "label", "icon", "disabled", "checked", "radiogroup", "command"],
  2055. "menu": ["type", "label"],
  2056. "dialog": ["open"]
  2057. };
  2058. var elements = Object.keys(attributeMap);
  2059. function is(token, type) {
  2060. return token.type.lastIndexOf(type + ".xml") > -1;
  2061. }
  2062. function findTagName(session, pos) {
  2063. var iterator = new TokenIterator(session, pos.row, pos.column);
  2064. var token = iterator.getCurrentToken();
  2065. while (token && !is(token, "tag-name")){
  2066. token = iterator.stepBackward();
  2067. }
  2068. if (token)
  2069. return token.value;
  2070. }
  2071. var HtmlCompletions = function() {
  2072. };
  2073. (function() {
  2074. this.getCompletions = function(state, session, pos, prefix) {
  2075. var token = session.getTokenAt(pos.row, pos.column);
  2076. if (!token)
  2077. return [];
  2078. if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
  2079. return this.getTagCompletions(state, session, pos, prefix);
  2080. if (is(token, "tag-whitespace") || is(token, "attribute-name"))
  2081. return this.getAttributeCompetions(state, session, pos, prefix);
  2082. return [];
  2083. };
  2084. this.getTagCompletions = function(state, session, pos, prefix) {
  2085. return elements.map(function(element){
  2086. return {
  2087. value: element,
  2088. meta: "tag",
  2089. score: Number.MAX_VALUE
  2090. };
  2091. });
  2092. };
  2093. this.getAttributeCompetions = function(state, session, pos, prefix) {
  2094. var tagName = findTagName(session, pos);
  2095. if (!tagName)
  2096. return [];
  2097. var attributes = globalAttributes;
  2098. if (tagName in attributeMap) {
  2099. attributes = attributes.concat(attributeMap[tagName]);
  2100. }
  2101. return attributes.map(function(attribute){
  2102. return {
  2103. caption: attribute,
  2104. snippet: attribute + '="$0"',
  2105. meta: "attribute",
  2106. score: Number.MAX_VALUE
  2107. };
  2108. });
  2109. };
  2110. }).call(HtmlCompletions.prototype);
  2111. exports.HtmlCompletions = HtmlCompletions;
  2112. });
  2113. 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) {
  2114. "use strict";
  2115. var oop = require("../lib/oop");
  2116. var lang = require("../lib/lang");
  2117. var TextMode = require("./text").Mode;
  2118. var JavaScriptMode = require("./javascript").Mode;
  2119. var CssMode = require("./css").Mode;
  2120. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2121. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  2122. var HtmlFoldMode = require("./folding/html").FoldMode;
  2123. var HtmlCompletions = require("./html_completions").HtmlCompletions;
  2124. var WorkerClient = require("../worker/worker_client").WorkerClient;
  2125. var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
  2126. var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
  2127. var Mode = function(options) {
  2128. this.fragmentContext = options && options.fragmentContext;
  2129. this.HighlightRules = HtmlHighlightRules;
  2130. this.$behaviour = new XmlBehaviour();
  2131. this.$completer = new HtmlCompletions();
  2132. this.createModeDelegates({
  2133. "js-": JavaScriptMode,
  2134. "css-": CssMode
  2135. });
  2136. this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
  2137. };
  2138. oop.inherits(Mode, TextMode);
  2139. (function() {
  2140. this.blockComment = {start: "<!--", end: "-->"};
  2141. this.voidElements = lang.arrayToMap(voidElements);
  2142. this.getNextLineIndent = function(state, line, tab) {
  2143. return this.$getIndent(line);
  2144. };
  2145. this.checkOutdent = function(state, line, input) {
  2146. return false;
  2147. };
  2148. this.getCompletions = function(state, session, pos, prefix) {
  2149. return this.$completer.getCompletions(state, session, pos, prefix);
  2150. };
  2151. this.createWorker = function(session) {
  2152. if (this.constructor != Mode)
  2153. return;
  2154. var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
  2155. worker.attachToDocument(session.getDocument());
  2156. if (this.fragmentContext)
  2157. worker.call("setOptions", [{context: this.fragmentContext}]);
  2158. worker.on("error", function(e) {
  2159. session.setAnnotations(e.data);
  2160. });
  2161. worker.on("terminate", function() {
  2162. session.clearAnnotations();
  2163. });
  2164. return worker;
  2165. };
  2166. this.$id = "ace/mode/html";
  2167. }).call(Mode.prototype);
  2168. exports.Mode = Mode;
  2169. });
  2170. ace.define("ace/mode/markdown_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules","ace/mode/html_highlight_rules","ace/mode/css_highlight_rules"], function(require, exports, module) {
  2171. "use strict";
  2172. var oop = require("../lib/oop");
  2173. var lang = require("../lib/lang");
  2174. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  2175. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  2176. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  2177. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2178. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  2179. var escaped = function(ch) {
  2180. return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
  2181. }
  2182. function github_embed(tag, prefix) {
  2183. return { // Github style block
  2184. token : "support.function",
  2185. regex : "^\\s*```" + tag + "\\s*$",
  2186. push : prefix + "start"
  2187. };
  2188. }
  2189. var MarkdownHighlightRules = function() {
  2190. HtmlHighlightRules.call(this);
  2191. this.$rules["start"].unshift({
  2192. token : "empty_line",
  2193. regex : '^$',
  2194. next: "allowBlock"
  2195. }, { // h1
  2196. token: "markup.heading.1",
  2197. regex: "^=+(?=\\s*$)"
  2198. }, { // h2
  2199. token: "markup.heading.2",
  2200. regex: "^\\-+(?=\\s*$)"
  2201. }, {
  2202. token : function(value) {
  2203. return "markup.heading." + value.length;
  2204. },
  2205. regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
  2206. next : "header"
  2207. },
  2208. github_embed("(?:javascript|js)", "jscode-"),
  2209. github_embed("xml", "xmlcode-"),
  2210. github_embed("html", "htmlcode-"),
  2211. github_embed("css", "csscode-"),
  2212. { // Github style block
  2213. token : "support.function",
  2214. regex : "^\\s*```\\s*\\S*(?:{.*?\\})?\\s*$",
  2215. next : "githubblock"
  2216. }, { // block quote
  2217. token : "string.blockquote",
  2218. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  2219. next : "blockquote"
  2220. }, { // HR * - _
  2221. token : "constant",
  2222. regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
  2223. next: "allowBlock"
  2224. }, { // list
  2225. token : "markup.list",
  2226. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  2227. next : "listblock-start"
  2228. }, {
  2229. include : "basic"
  2230. });
  2231. this.addRules({
  2232. "basic" : [{
  2233. token : "constant.language.escape",
  2234. regex : /\\[\\`*_{}\[\]()#+\-.!]/
  2235. }, { // code span `
  2236. token : "support.function",
  2237. regex : "(`+)(.*?[^`])(\\1)"
  2238. }, { // reference
  2239. token : ["text", "constant", "text", "url", "string", "text"],
  2240. regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
  2241. }, { // link by reference
  2242. token : ["text", "string", "text", "constant", "text"],
  2243. regex : "(\\[)(" + escaped("]") + ")(\\]\s*\\[)("+ escaped("]") + ")(\\])"
  2244. }, { // link by url
  2245. token : ["text", "string", "text", "markup.underline", "string", "text"],
  2246. regex : "(\\[)(" + // [
  2247. escaped("]") + // link text
  2248. ")(\\]\\()"+ // ](
  2249. '((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
  2250. '(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
  2251. "(\\))" // )
  2252. }, { // strong ** __
  2253. token : "string.strong",
  2254. regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
  2255. }, { // emphasis * _
  2256. token : "string.emphasis",
  2257. regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
  2258. }, { //
  2259. token : ["text", "url", "text"],
  2260. regex : "(<)("+
  2261. "(?:https?|ftp|dict):[^'\">\\s]+"+
  2262. "|"+
  2263. "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
  2264. ")(>)"
  2265. }],
  2266. "allowBlock": [
  2267. {token : "support.function", regex : "^ {4}.+", next : "allowBlock"},
  2268. {token : "empty", regex : "", next : "start"}
  2269. ],
  2270. "header" : [{
  2271. regex: "$",
  2272. next : "start"
  2273. }, {
  2274. include: "basic"
  2275. }, {
  2276. defaultToken : "heading"
  2277. } ],
  2278. "listblock-start" : [{
  2279. token : "support.variable",
  2280. regex : /(?:\[[ x]\])?/,
  2281. next : "listblock"
  2282. }],
  2283. "listblock" : [ { // Lists only escape on completely blank lines.
  2284. token : "empty_line",
  2285. regex : "^$",
  2286. next : "start"
  2287. }, { // list
  2288. token : "markup.list",
  2289. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  2290. next : "listblock-start"
  2291. }, {
  2292. include : "basic", noEscape: true
  2293. }, { // Github style block
  2294. token : "support.function",
  2295. regex : "^\\s*```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
  2296. next : "githubblock"
  2297. }, {
  2298. defaultToken : "list" //do not use markup.list to allow stling leading `*` differntly
  2299. } ],
  2300. "blockquote" : [ { // Blockquotes only escape on blank lines.
  2301. token : "empty_line",
  2302. regex : "^\\s*$",
  2303. next : "start"
  2304. }, { // block quote
  2305. token : "string.blockquote",
  2306. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  2307. next : "blockquote"
  2308. }, {
  2309. include : "basic", noEscape: true
  2310. }, {
  2311. defaultToken : "string.blockquote"
  2312. } ],
  2313. "githubblock" : [ {
  2314. token : "support.function",
  2315. regex : "^\\s*```",
  2316. next : "start"
  2317. }, {
  2318. token : "support.function",
  2319. regex : ".+"
  2320. } ]
  2321. });
  2322. this.embedRules(JavaScriptHighlightRules, "jscode-", [{
  2323. token : "support.function",
  2324. regex : "^\\s*```",
  2325. next : "pop"
  2326. }]);
  2327. this.embedRules(HtmlHighlightRules, "htmlcode-", [{
  2328. token : "support.function",
  2329. regex : "^\\s*```",
  2330. next : "pop"
  2331. }]);
  2332. this.embedRules(CssHighlightRules, "csscode-", [{
  2333. token : "support.function",
  2334. regex : "^\\s*```",
  2335. next : "pop"
  2336. }]);
  2337. this.embedRules(XmlHighlightRules, "xmlcode-", [{
  2338. token : "support.function",
  2339. regex : "^\\s*```",
  2340. next : "pop"
  2341. }]);
  2342. this.normalizeRules();
  2343. };
  2344. oop.inherits(MarkdownHighlightRules, TextHighlightRules);
  2345. exports.MarkdownHighlightRules = MarkdownHighlightRules;
  2346. });
  2347. ace.define("ace/mode/folding/markdown",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
  2348. "use strict";
  2349. var oop = require("../../lib/oop");
  2350. var BaseFoldMode = require("./fold_mode").FoldMode;
  2351. var Range = require("../../range").Range;
  2352. var FoldMode = exports.FoldMode = function() {};
  2353. oop.inherits(FoldMode, BaseFoldMode);
  2354. (function() {
  2355. this.foldingStartMarker = /^(?:[=-]+\s*$|#{1,6} |`{3})/;
  2356. this.getFoldWidget = function(session, foldStyle, row) {
  2357. var line = session.getLine(row);
  2358. if (!this.foldingStartMarker.test(line))
  2359. return "";
  2360. if (line[0] == "`") {
  2361. if (session.bgTokenizer.getState(row) == "start")
  2362. return "end";
  2363. return "start";
  2364. }
  2365. return "start";
  2366. };
  2367. this.getFoldWidgetRange = function(session, foldStyle, row) {
  2368. var line = session.getLine(row);
  2369. var startColumn = line.length;
  2370. var maxRow = session.getLength();
  2371. var startRow = row;
  2372. var endRow = row;
  2373. if (!line.match(this.foldingStartMarker))
  2374. return;
  2375. if (line[0] == "`") {
  2376. if (session.bgTokenizer.getState(row) !== "start") {
  2377. while (++row < maxRow) {
  2378. line = session.getLine(row);
  2379. if (line[0] == "`" & line.substring(0, 3) == "```")
  2380. break;
  2381. }
  2382. return new Range(startRow, startColumn, row, 0);
  2383. } else {
  2384. while (row -- > 0) {
  2385. line = session.getLine(row);
  2386. if (line[0] == "`" & line.substring(0, 3) == "```")
  2387. break;
  2388. }
  2389. return new Range(row, line.length, startRow, 0);
  2390. }
  2391. }
  2392. var token;
  2393. function isHeading(row) {
  2394. token = session.getTokens(row)[0];
  2395. return token && token.type.lastIndexOf(heading, 0) === 0;
  2396. }
  2397. var heading = "markup.heading";
  2398. function getLevel() {
  2399. var ch = token.value[0];
  2400. if (ch == "=") return 6;
  2401. if (ch == "-") return 5;
  2402. return 7 - token.value.search(/[^#]/);
  2403. }
  2404. if (isHeading(row)) {
  2405. var startHeadingLevel = getLevel();
  2406. while (++row < maxRow) {
  2407. if (!isHeading(row))
  2408. continue;
  2409. var level = getLevel();
  2410. if (level >= startHeadingLevel)
  2411. break;
  2412. }
  2413. endRow = row - (!token || ["=", "-"].indexOf(token.value[0]) == -1 ? 1 : 2);
  2414. if (endRow > startRow) {
  2415. while (endRow > startRow && /^\s*$/.test(session.getLine(endRow)))
  2416. endRow--;
  2417. }
  2418. if (endRow > startRow) {
  2419. var endColumn = session.getLine(endRow).length;
  2420. return new Range(startRow, startColumn, endRow, endColumn);
  2421. }
  2422. }
  2423. };
  2424. }).call(FoldMode.prototype);
  2425. });
  2426. ace.define("ace/mode/markdown",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript","ace/mode/xml","ace/mode/html","ace/mode/markdown_highlight_rules","ace/mode/folding/markdown"], function(require, exports, module) {
  2427. "use strict";
  2428. var oop = require("../lib/oop");
  2429. var TextMode = require("./text").Mode;
  2430. var JavaScriptMode = require("./javascript").Mode;
  2431. var XmlMode = require("./xml").Mode;
  2432. var HtmlMode = require("./html").Mode;
  2433. var MarkdownHighlightRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
  2434. var MarkdownFoldMode = require("./folding/markdown").FoldMode;
  2435. var Mode = function() {
  2436. this.HighlightRules = MarkdownHighlightRules;
  2437. this.createModeDelegates({
  2438. "js-": JavaScriptMode,
  2439. "xml-": XmlMode,
  2440. "html-": HtmlMode
  2441. });
  2442. this.foldingRules = new MarkdownFoldMode();
  2443. };
  2444. oop.inherits(Mode, TextMode);
  2445. (function() {
  2446. this.type = "text";
  2447. this.blockComment = {start: "<!--", end: "-->"};
  2448. this.getNextLineIndent = function(state, line, tab) {
  2449. if (state == "listblock") {
  2450. var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
  2451. if (!match)
  2452. return "";
  2453. var marker = match[2];
  2454. if (!marker)
  2455. marker = parseInt(match[3], 10) + 1 + ".";
  2456. return match[1] + marker + match[4];
  2457. } else {
  2458. return this.$getIndent(line);
  2459. }
  2460. };
  2461. this.$id = "ace/mode/markdown";
  2462. }).call(Mode.prototype);
  2463. exports.Mode = Mode;
  2464. });