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

mode-markdown.js 105KB

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