mode-markdown.js 109 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892
  1. ace.define("ace/mode/doc_comment_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",[], 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 identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
  47. var JavaScriptHighlightRules = function(options) {
  48. var keywordMapper = this.createKeywordMapper({
  49. "variable.language":
  50. "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  51. "Namespace|QName|XML|XMLList|" + // E4X
  52. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  53. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  54. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  55. "SyntaxError|TypeError|URIError|" +
  56. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  57. "isNaN|parseFloat|parseInt|" +
  58. "JSON|Math|" + // Other
  59. "this|arguments|prototype|window|document" , // Pseudo
  60. "keyword":
  61. "const|yield|import|get|set|async|await|" +
  62. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  63. "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  64. "__parent__|__count__|escape|unescape|with|__proto__|" +
  65. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  66. "storage.type":
  67. "const|let|var|function",
  68. "constant.language":
  69. "null|Infinity|NaN|undefined",
  70. "support.function":
  71. "alert",
  72. "constant.language.boolean": "true|false"
  73. }, "identifier");
  74. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  75. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  76. "u[0-9a-fA-F]{4}|" + // unicode
  77. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  78. "[0-2][0-7]{0,2}|" + // oct
  79. "3[0-7][0-7]?|" + // oct
  80. "[4-7][0-7]?|" + //oct
  81. ".)";
  82. this.$rules = {
  83. "no_regex" : [
  84. DocCommentHighlightRules.getStartRule("doc-start"),
  85. comments("no_regex"),
  86. {
  87. token : "string",
  88. regex : "'(?=.)",
  89. next : "qstring"
  90. }, {
  91. token : "string",
  92. regex : '"(?=.)',
  93. next : "qqstring"
  94. }, {
  95. token : "constant.numeric", // hexadecimal, octal and binary
  96. regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
  97. }, {
  98. token : "constant.numeric", // decimal integers and floats
  99. regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
  100. }, {
  101. token : [
  102. "storage.type", "punctuation.operator", "support.function",
  103. "punctuation.operator", "entity.name.function", "text","keyword.operator"
  104. ],
  105. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  106. next: "function_arguments"
  107. }, {
  108. token : [
  109. "storage.type", "punctuation.operator", "entity.name.function", "text",
  110. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  111. ],
  112. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  113. next: "function_arguments"
  114. }, {
  115. token : [
  116. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  117. "text", "paren.lparen"
  118. ],
  119. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  120. next: "function_arguments"
  121. }, {
  122. token : [
  123. "storage.type", "punctuation.operator", "entity.name.function", "text",
  124. "keyword.operator", "text",
  125. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  126. ],
  127. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  128. next: "function_arguments"
  129. }, {
  130. token : [
  131. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  132. ],
  133. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  134. next: "function_arguments"
  135. }, {
  136. token : [
  137. "entity.name.function", "text", "punctuation.operator",
  138. "text", "storage.type", "text", "paren.lparen"
  139. ],
  140. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  141. next: "function_arguments"
  142. }, {
  143. token : [
  144. "text", "text", "storage.type", "text", "paren.lparen"
  145. ],
  146. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  147. next: "function_arguments"
  148. }, {
  149. token : "keyword",
  150. regex : "from(?=\\s*('|\"))"
  151. }, {
  152. token : "keyword",
  153. regex : "(?:" + kwBeforeRe + ")\\b",
  154. next : "start"
  155. }, {
  156. token : ["support.constant"],
  157. regex : /that\b/
  158. }, {
  159. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  160. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  161. }, {
  162. token : keywordMapper,
  163. regex : identifierRe
  164. }, {
  165. token : "punctuation.operator",
  166. regex : /[.](?![.])/,
  167. next : "property"
  168. }, {
  169. token : "storage.type",
  170. regex : /=>/
  171. }, {
  172. token : "keyword.operator",
  173. regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
  174. next : "start"
  175. }, {
  176. token : "punctuation.operator",
  177. regex : /[?:,;.]/,
  178. next : "start"
  179. }, {
  180. token : "paren.lparen",
  181. regex : /[\[({]/,
  182. next : "start"
  183. }, {
  184. token : "paren.rparen",
  185. regex : /[\])}]/
  186. }, {
  187. token: "comment",
  188. regex: /^#!.*$/
  189. }
  190. ],
  191. property: [{
  192. token : "text",
  193. regex : "\\s+"
  194. }, {
  195. token : [
  196. "storage.type", "punctuation.operator", "entity.name.function", "text",
  197. "keyword.operator", "text",
  198. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  199. ],
  200. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  201. next: "function_arguments"
  202. }, {
  203. token : "punctuation.operator",
  204. regex : /[.](?![.])/
  205. }, {
  206. token : "support.function",
  207. 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(?=\()/
  208. }, {
  209. token : "support.function.dom",
  210. regex : /(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  211. }, {
  212. token : "support.constant",
  213. 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/
  214. }, {
  215. token : "identifier",
  216. regex : identifierRe
  217. }, {
  218. regex: "",
  219. token: "empty",
  220. next: "no_regex"
  221. }
  222. ],
  223. "start": [
  224. DocCommentHighlightRules.getStartRule("doc-start"),
  225. comments("start"),
  226. {
  227. token: "string.regexp",
  228. regex: "\\/",
  229. next: "regex"
  230. }, {
  231. token : "text",
  232. regex : "\\s+|^$",
  233. next : "start"
  234. }, {
  235. token: "empty",
  236. regex: "",
  237. next: "no_regex"
  238. }
  239. ],
  240. "regex": [
  241. {
  242. token: "regexp.keyword.operator",
  243. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  244. }, {
  245. token: "string.regexp",
  246. regex: "/[sxngimy]*",
  247. next: "no_regex"
  248. }, {
  249. token : "invalid",
  250. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  251. }, {
  252. token : "constant.language.escape",
  253. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  254. }, {
  255. token : "constant.language.delimiter",
  256. regex: /\|/
  257. }, {
  258. token: "constant.language.escape",
  259. regex: /\[\^?/,
  260. next: "regex_character_class"
  261. }, {
  262. token: "empty",
  263. regex: "$",
  264. next: "no_regex"
  265. }, {
  266. defaultToken: "string.regexp"
  267. }
  268. ],
  269. "regex_character_class": [
  270. {
  271. token: "regexp.charclass.keyword.operator",
  272. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  273. }, {
  274. token: "constant.language.escape",
  275. regex: "]",
  276. next: "regex"
  277. }, {
  278. token: "constant.language.escape",
  279. regex: "-"
  280. }, {
  281. token: "empty",
  282. regex: "$",
  283. next: "no_regex"
  284. }, {
  285. defaultToken: "string.regexp.charachterclass"
  286. }
  287. ],
  288. "function_arguments": [
  289. {
  290. token: "variable.parameter",
  291. regex: identifierRe
  292. }, {
  293. token: "punctuation.operator",
  294. regex: "[, ]+"
  295. }, {
  296. token: "punctuation.operator",
  297. regex: "$"
  298. }, {
  299. token: "empty",
  300. regex: "",
  301. next: "no_regex"
  302. }
  303. ],
  304. "qqstring" : [
  305. {
  306. token : "constant.language.escape",
  307. regex : escapedRe
  308. }, {
  309. token : "string",
  310. regex : "\\\\$",
  311. consumeLineEnd : true
  312. }, {
  313. token : "string",
  314. regex : '"|$',
  315. next : "no_regex"
  316. }, {
  317. defaultToken: "string"
  318. }
  319. ],
  320. "qstring" : [
  321. {
  322. token : "constant.language.escape",
  323. regex : escapedRe
  324. }, {
  325. token : "string",
  326. regex : "\\\\$",
  327. consumeLineEnd : true
  328. }, {
  329. token : "string",
  330. regex : "'|$",
  331. next : "no_regex"
  332. }, {
  333. defaultToken: "string"
  334. }
  335. ]
  336. };
  337. if (!options || !options.noES6) {
  338. this.$rules.no_regex.unshift({
  339. regex: "[{}]", onMatch: function(val, state, stack) {
  340. this.next = val == "{" ? this.nextState : "";
  341. if (val == "{" && stack.length) {
  342. stack.unshift("start", state);
  343. }
  344. else if (val == "}" && stack.length) {
  345. stack.shift();
  346. this.next = stack.shift();
  347. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  348. return "paren.quasi.end";
  349. }
  350. return val == "{" ? "paren.lparen" : "paren.rparen";
  351. },
  352. nextState: "start"
  353. }, {
  354. token : "string.quasi.start",
  355. regex : /`/,
  356. push : [{
  357. token : "constant.language.escape",
  358. regex : escapedRe
  359. }, {
  360. token : "paren.quasi.start",
  361. regex : /\${/,
  362. push : "start"
  363. }, {
  364. token : "string.quasi.end",
  365. regex : /`/,
  366. next : "pop"
  367. }, {
  368. defaultToken: "string.quasi"
  369. }]
  370. });
  371. if (!options || options.jsx != false)
  372. JSX.call(this);
  373. }
  374. this.embedRules(DocCommentHighlightRules, "doc-",
  375. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  376. this.normalizeRules();
  377. };
  378. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  379. function JSX() {
  380. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  381. var jsxTag = {
  382. onMatch : function(val, state, stack) {
  383. var offset = val.charAt(1) == "/" ? 2 : 1;
  384. if (offset == 1) {
  385. if (state != this.nextState)
  386. stack.unshift(this.next, this.nextState, 0);
  387. else
  388. stack.unshift(this.next);
  389. stack[2]++;
  390. } else if (offset == 2) {
  391. if (state == this.nextState) {
  392. stack[1]--;
  393. if (!stack[1] || stack[1] < 0) {
  394. stack.shift();
  395. stack.shift();
  396. }
  397. }
  398. }
  399. return [{
  400. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  401. value: val.slice(0, offset)
  402. }, {
  403. type: "meta.tag.tag-name.xml",
  404. value: val.substr(offset)
  405. }];
  406. },
  407. regex : "</?" + tagRegex + "",
  408. next: "jsxAttributes",
  409. nextState: "jsx"
  410. };
  411. this.$rules.start.unshift(jsxTag);
  412. var jsxJsRule = {
  413. regex: "{",
  414. token: "paren.quasi.start",
  415. push: "start"
  416. };
  417. this.$rules.jsx = [
  418. jsxJsRule,
  419. jsxTag,
  420. {include : "reference"},
  421. {defaultToken: "string"}
  422. ];
  423. this.$rules.jsxAttributes = [{
  424. token : "meta.tag.punctuation.tag-close.xml",
  425. regex : "/?>",
  426. onMatch : function(value, currentState, stack) {
  427. if (currentState == stack[0])
  428. stack.shift();
  429. if (value.length == 2) {
  430. if (stack[0] == this.nextState)
  431. stack[1]--;
  432. if (!stack[1] || stack[1] < 0) {
  433. stack.splice(0, 2);
  434. }
  435. }
  436. this.next = stack[0] || "start";
  437. return [{type: this.token, value: value}];
  438. },
  439. nextState: "jsx"
  440. },
  441. jsxJsRule,
  442. comments("jsxAttributes"),
  443. {
  444. token : "entity.other.attribute-name.xml",
  445. regex : tagRegex
  446. }, {
  447. token : "keyword.operator.attribute-equals.xml",
  448. regex : "="
  449. }, {
  450. token : "text.tag-whitespace.xml",
  451. regex : "\\s+"
  452. }, {
  453. token : "string.attribute-value.xml",
  454. regex : "'",
  455. stateName : "jsx_attr_q",
  456. push : [
  457. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  458. {include : "reference"},
  459. {defaultToken : "string.attribute-value.xml"}
  460. ]
  461. }, {
  462. token : "string.attribute-value.xml",
  463. regex : '"',
  464. stateName : "jsx_attr_qq",
  465. push : [
  466. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  467. {include : "reference"},
  468. {defaultToken : "string.attribute-value.xml"}
  469. ]
  470. },
  471. jsxTag
  472. ];
  473. this.$rules.reference = [{
  474. token : "constant.language.escape.reference.xml",
  475. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  476. }];
  477. }
  478. function comments(next) {
  479. return [
  480. {
  481. token : "comment", // multi line comment
  482. regex : /\/\*/,
  483. next: [
  484. DocCommentHighlightRules.getTagRule(),
  485. {token : "comment", regex : "\\*\\/", next : next || "pop"},
  486. {defaultToken : "comment", caseInsensitive: true}
  487. ]
  488. }, {
  489. token : "comment",
  490. regex : "\\/\\/",
  491. next: [
  492. DocCommentHighlightRules.getTagRule(),
  493. {token : "comment", regex : "$|^", next : next || "pop"},
  494. {defaultToken : "comment", caseInsensitive: true}
  495. ]
  496. }
  497. ];
  498. }
  499. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  500. });
  501. ace.define("ace/mode/matching_brace_outdent",[], function(require, exports, module) {
  502. "use strict";
  503. var Range = require("../range").Range;
  504. var MatchingBraceOutdent = function() {};
  505. (function() {
  506. this.checkOutdent = function(line, input) {
  507. if (! /^\s+$/.test(line))
  508. return false;
  509. return /^\s*\}/.test(input);
  510. };
  511. this.autoOutdent = function(doc, row) {
  512. var line = doc.getLine(row);
  513. var match = line.match(/^(\s*\})/);
  514. if (!match) return 0;
  515. var column = match[1].length;
  516. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  517. if (!openBracePos || openBracePos.row == row) return 0;
  518. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  519. doc.replace(new Range(row, 0, row, column-1), indent);
  520. };
  521. this.$getIndent = function(line) {
  522. return line.match(/^\s*/)[0];
  523. };
  524. }).call(MatchingBraceOutdent.prototype);
  525. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  526. });
  527. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  528. "use strict";
  529. var oop = require("../../lib/oop");
  530. var Range = require("../../range").Range;
  531. var BaseFoldMode = require("./fold_mode").FoldMode;
  532. var FoldMode = exports.FoldMode = function(commentRegex) {
  533. if (commentRegex) {
  534. this.foldingStartMarker = new RegExp(
  535. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  536. );
  537. this.foldingStopMarker = new RegExp(
  538. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  539. );
  540. }
  541. };
  542. oop.inherits(FoldMode, BaseFoldMode);
  543. (function() {
  544. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  545. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  546. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  547. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  548. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  549. this._getFoldWidgetBase = this.getFoldWidget;
  550. this.getFoldWidget = function(session, foldStyle, row) {
  551. var line = session.getLine(row);
  552. if (this.singleLineBlockCommentRe.test(line)) {
  553. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  554. return "";
  555. }
  556. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  557. if (!fw && this.startRegionRe.test(line))
  558. return "start"; // lineCommentRegionStart
  559. return fw;
  560. };
  561. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  562. var line = session.getLine(row);
  563. if (this.startRegionRe.test(line))
  564. return this.getCommentRegionBlock(session, line, row);
  565. var match = line.match(this.foldingStartMarker);
  566. if (match) {
  567. var i = match.index;
  568. if (match[1])
  569. return this.openingBracketBlock(session, match[1], row, i);
  570. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  571. if (range && !range.isMultiLine()) {
  572. if (forceMultiline) {
  573. range = this.getSectionRange(session, row);
  574. } else if (foldStyle != "all")
  575. range = null;
  576. }
  577. return range;
  578. }
  579. if (foldStyle === "markbegin")
  580. return;
  581. var match = line.match(this.foldingStopMarker);
  582. if (match) {
  583. var i = match.index + match[0].length;
  584. if (match[1])
  585. return this.closingBracketBlock(session, match[1], row, i);
  586. return session.getCommentFoldRange(row, i, -1);
  587. }
  588. };
  589. this.getSectionRange = function(session, row) {
  590. var line = session.getLine(row);
  591. var startIndent = line.search(/\S/);
  592. var startRow = row;
  593. var startColumn = line.length;
  594. row = row + 1;
  595. var endRow = row;
  596. var maxRow = session.getLength();
  597. while (++row < maxRow) {
  598. line = session.getLine(row);
  599. var indent = line.search(/\S/);
  600. if (indent === -1)
  601. continue;
  602. if (startIndent > indent)
  603. break;
  604. var subRange = this.getFoldWidgetRange(session, "all", row);
  605. if (subRange) {
  606. if (subRange.start.row <= startRow) {
  607. break;
  608. } else if (subRange.isMultiLine()) {
  609. row = subRange.end.row;
  610. } else if (startIndent == indent) {
  611. break;
  612. }
  613. }
  614. endRow = row;
  615. }
  616. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  617. };
  618. this.getCommentRegionBlock = function(session, line, row) {
  619. var startColumn = line.search(/\s*$/);
  620. var maxRow = session.getLength();
  621. var startRow = row;
  622. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  623. var depth = 1;
  624. while (++row < maxRow) {
  625. line = session.getLine(row);
  626. var m = re.exec(line);
  627. if (!m) continue;
  628. if (m[1]) depth--;
  629. else depth++;
  630. if (!depth) break;
  631. }
  632. var endRow = row;
  633. if (endRow > startRow) {
  634. return new Range(startRow, startColumn, endRow, line.length);
  635. }
  636. };
  637. }).call(FoldMode.prototype);
  638. });
  639. ace.define("ace/mode/javascript",[], function(require, exports, module) {
  640. "use strict";
  641. var oop = require("../lib/oop");
  642. var TextMode = require("./text").Mode;
  643. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  644. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  645. var WorkerClient = require("../worker/worker_client").WorkerClient;
  646. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  647. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  648. var Mode = function() {
  649. this.HighlightRules = JavaScriptHighlightRules;
  650. this.$outdent = new MatchingBraceOutdent();
  651. this.$behaviour = new CstyleBehaviour();
  652. this.foldingRules = new CStyleFoldMode();
  653. };
  654. oop.inherits(Mode, TextMode);
  655. (function() {
  656. this.lineCommentStart = "//";
  657. this.blockComment = {start: "/*", end: "*/"};
  658. this.$quotes = {'"': '"', "'": "'", "`": "`"};
  659. this.getNextLineIndent = function(state, line, tab) {
  660. var indent = this.$getIndent(line);
  661. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  662. var tokens = tokenizedLine.tokens;
  663. var endState = tokenizedLine.state;
  664. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  665. return indent;
  666. }
  667. if (state == "start" || state == "no_regex") {
  668. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  669. if (match) {
  670. indent += tab;
  671. }
  672. } else if (state == "doc-start") {
  673. if (endState == "start" || endState == "no_regex") {
  674. return "";
  675. }
  676. var match = line.match(/^\s*(\/?)\*/);
  677. if (match) {
  678. if (match[1]) {
  679. indent += " ";
  680. }
  681. indent += "* ";
  682. }
  683. }
  684. return indent;
  685. };
  686. this.checkOutdent = function(state, line, input) {
  687. return this.$outdent.checkOutdent(line, input);
  688. };
  689. this.autoOutdent = function(state, doc, row) {
  690. this.$outdent.autoOutdent(doc, row);
  691. };
  692. this.createWorker = function(session) {
  693. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  694. worker.attachToDocument(session.getDocument());
  695. worker.on("annotate", function(results) {
  696. session.setAnnotations(results.data);
  697. });
  698. worker.on("terminate", function() {
  699. session.clearAnnotations();
  700. });
  701. return worker;
  702. };
  703. this.$id = "ace/mode/javascript";
  704. }).call(Mode.prototype);
  705. exports.Mode = Mode;
  706. });
  707. ace.define("ace/mode/xml_highlight_rules",[], function(require, exports, module) {
  708. "use strict";
  709. var oop = require("../lib/oop");
  710. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  711. var XmlHighlightRules = function(normalize) {
  712. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  713. this.$rules = {
  714. start : [
  715. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  716. {
  717. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  718. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction"
  719. },
  720. {token : "comment.start.xml", regex : "<\\!--", next : "comment"},
  721. {
  722. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  723. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  724. },
  725. {include : "tag"},
  726. {token : "text.end-tag-open.xml", regex: "</"},
  727. {token : "text.tag-open.xml", regex: "<"},
  728. {include : "reference"},
  729. {defaultToken : "text.xml"}
  730. ],
  731. processing_instruction : [{
  732. token : "entity.other.attribute-name.decl-attribute-name.xml",
  733. regex : tagRegex
  734. }, {
  735. token : "keyword.operator.decl-attribute-equals.xml",
  736. regex : "="
  737. }, {
  738. include: "whitespace"
  739. }, {
  740. include: "string"
  741. }, {
  742. token : "punctuation.xml-decl.xml",
  743. regex : "\\?>",
  744. next : "start"
  745. }],
  746. doctype : [
  747. {include : "whitespace"},
  748. {include : "string"},
  749. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  750. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  751. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  752. ],
  753. int_subset : [{
  754. token : "text.xml",
  755. regex : "\\s+"
  756. }, {
  757. token: "punctuation.int-subset.xml",
  758. regex: "]",
  759. next: "pop"
  760. }, {
  761. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  762. regex : "(<\\!)(" + tagRegex + ")",
  763. push : [{
  764. token : "text",
  765. regex : "\\s+"
  766. },
  767. {
  768. token : "punctuation.markup-decl.xml",
  769. regex : ">",
  770. next : "pop"
  771. },
  772. {include : "string"}]
  773. }],
  774. cdata : [
  775. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  776. {token : "text.xml", regex : "\\s+"},
  777. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  778. ],
  779. comment : [
  780. {token : "comment.end.xml", regex : "-->", next : "start"},
  781. {defaultToken : "comment.xml"}
  782. ],
  783. reference : [{
  784. token : "constant.language.escape.reference.xml",
  785. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  786. }],
  787. attr_reference : [{
  788. token : "constant.language.escape.reference.attribute-value.xml",
  789. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  790. }],
  791. tag : [{
  792. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  793. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  794. next: [
  795. {include : "attributes"},
  796. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  797. ]
  798. }],
  799. tag_whitespace : [
  800. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  801. ],
  802. whitespace : [
  803. {token : "text.whitespace.xml", regex : "\\s+"}
  804. ],
  805. string: [{
  806. token : "string.xml",
  807. regex : "'",
  808. push : [
  809. {token : "string.xml", regex: "'", next: "pop"},
  810. {defaultToken : "string.xml"}
  811. ]
  812. }, {
  813. token : "string.xml",
  814. regex : '"',
  815. push : [
  816. {token : "string.xml", regex: '"', next: "pop"},
  817. {defaultToken : "string.xml"}
  818. ]
  819. }],
  820. attributes: [{
  821. token : "entity.other.attribute-name.xml",
  822. regex : tagRegex
  823. }, {
  824. token : "keyword.operator.attribute-equals.xml",
  825. regex : "="
  826. }, {
  827. include: "tag_whitespace"
  828. }, {
  829. include: "attribute_value"
  830. }],
  831. attribute_value: [{
  832. token : "string.attribute-value.xml",
  833. regex : "'",
  834. push : [
  835. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  836. {include : "attr_reference"},
  837. {defaultToken : "string.attribute-value.xml"}
  838. ]
  839. }, {
  840. token : "string.attribute-value.xml",
  841. regex : '"',
  842. push : [
  843. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  844. {include : "attr_reference"},
  845. {defaultToken : "string.attribute-value.xml"}
  846. ]
  847. }]
  848. };
  849. if (this.constructor === XmlHighlightRules)
  850. this.normalizeRules();
  851. };
  852. (function() {
  853. this.embedTagRules = function(HighlightRules, prefix, tag){
  854. this.$rules.tag.unshift({
  855. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  856. regex : "(<)(" + tag + "(?=\\s|>|$))",
  857. next: [
  858. {include : "attributes"},
  859. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  860. ]
  861. });
  862. this.$rules[tag + "-end"] = [
  863. {include : "attributes"},
  864. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  865. onMatch : function(value, currentState, stack) {
  866. stack.splice(0);
  867. return this.token;
  868. }}
  869. ];
  870. this.embedRules(HighlightRules, prefix, [{
  871. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  872. regex : "(</)(" + tag + "(?=\\s|>|$))",
  873. next: tag + "-end"
  874. }, {
  875. token: "string.cdata.xml",
  876. regex : "<\\!\\[CDATA\\["
  877. }, {
  878. token: "string.cdata.xml",
  879. regex : "\\]\\]>"
  880. }]);
  881. };
  882. }).call(TextHighlightRules.prototype);
  883. oop.inherits(XmlHighlightRules, TextHighlightRules);
  884. exports.XmlHighlightRules = XmlHighlightRules;
  885. });
  886. ace.define("ace/mode/behaviour/xml",[], function(require, exports, module) {
  887. "use strict";
  888. var oop = require("../../lib/oop");
  889. var Behaviour = require("../behaviour").Behaviour;
  890. var TokenIterator = require("../../token_iterator").TokenIterator;
  891. var lang = require("../../lib/lang");
  892. function is(token, type) {
  893. return token && token.type.lastIndexOf(type + ".xml") > -1;
  894. }
  895. var XmlBehaviour = function () {
  896. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  897. if (text == '"' || text == "'") {
  898. var quote = text;
  899. var selected = session.doc.getTextRange(editor.getSelectionRange());
  900. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  901. return {
  902. text: quote + selected + quote,
  903. selection: false
  904. };
  905. }
  906. var cursor = editor.getCursorPosition();
  907. var line = session.doc.getLine(cursor.row);
  908. var rightChar = line.substring(cursor.column, cursor.column + 1);
  909. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  910. var token = iterator.getCurrentToken();
  911. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  912. return {
  913. text: "",
  914. selection: [1, 1]
  915. };
  916. }
  917. if (!token)
  918. token = iterator.stepBackward();
  919. if (!token)
  920. return;
  921. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  922. token = iterator.stepBackward();
  923. }
  924. var rightSpace = !rightChar || rightChar.match(/\s/);
  925. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  926. return {
  927. text: quote + quote,
  928. selection: [1, 1]
  929. };
  930. }
  931. }
  932. });
  933. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  934. var selected = session.doc.getTextRange(range);
  935. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  936. var line = session.doc.getLine(range.start.row);
  937. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  938. if (rightChar == selected) {
  939. range.end.column++;
  940. return range;
  941. }
  942. }
  943. });
  944. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  945. if (text == '>') {
  946. var position = editor.getSelectionRange().start;
  947. var iterator = new TokenIterator(session, position.row, position.column);
  948. var token = iterator.getCurrentToken() || iterator.stepBackward();
  949. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  950. return;
  951. if (is(token, "reference.attribute-value"))
  952. return;
  953. if (is(token, "attribute-value")) {
  954. var tokenEndColumn = iterator.getCurrentTokenColumn() + token.value.length;
  955. if (position.column < tokenEndColumn)
  956. return;
  957. if (position.column == tokenEndColumn) {
  958. var nextToken = iterator.stepForward();
  959. if (nextToken && is(nextToken, "attribute-value"))
  960. return;
  961. iterator.stepBackward();
  962. }
  963. }
  964. if (/^\s*>/.test(session.getLine(position.row).slice(position.column)))
  965. return;
  966. while (!is(token, "tag-name")) {
  967. token = iterator.stepBackward();
  968. if (token.value == "<") {
  969. token = iterator.stepForward();
  970. break;
  971. }
  972. }
  973. var tokenRow = iterator.getCurrentTokenRow();
  974. var tokenColumn = iterator.getCurrentTokenColumn();
  975. if (is(iterator.stepBackward(), "end-tag-open"))
  976. return;
  977. var element = token.value;
  978. if (tokenRow == position.row)
  979. element = element.substring(0, position.column - tokenColumn);
  980. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  981. return;
  982. return {
  983. text: ">" + "</" + element + ">",
  984. selection: [1, 1]
  985. };
  986. }
  987. });
  988. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  989. if (text == "\n") {
  990. var cursor = editor.getCursorPosition();
  991. var line = session.getLine(cursor.row);
  992. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  993. var token = iterator.getCurrentToken();
  994. if (token && token.type.indexOf("tag-close") !== -1) {
  995. if (token.value == "/>")
  996. return;
  997. while (token && token.type.indexOf("tag-name") === -1) {
  998. token = iterator.stepBackward();
  999. }
  1000. if (!token) {
  1001. return;
  1002. }
  1003. var tag = token.value;
  1004. var row = iterator.getCurrentTokenRow();
  1005. token = iterator.stepBackward();
  1006. if (!token || token.type.indexOf("end-tag") !== -1) {
  1007. return;
  1008. }
  1009. if (this.voidElements && !this.voidElements[tag]) {
  1010. var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
  1011. var line = session.getLine(row);
  1012. var nextIndent = this.$getIndent(line);
  1013. var indent = nextIndent + session.getTabString();
  1014. if (nextToken && nextToken.value === "</") {
  1015. return {
  1016. text: "\n" + indent + "\n" + nextIndent,
  1017. selection: [1, indent.length, 1, indent.length]
  1018. };
  1019. } else {
  1020. return {
  1021. text: "\n" + indent
  1022. };
  1023. }
  1024. }
  1025. }
  1026. }
  1027. });
  1028. };
  1029. oop.inherits(XmlBehaviour, Behaviour);
  1030. exports.XmlBehaviour = XmlBehaviour;
  1031. });
  1032. ace.define("ace/mode/folding/xml",[], function(require, exports, module) {
  1033. "use strict";
  1034. var oop = require("../../lib/oop");
  1035. var lang = require("../../lib/lang");
  1036. var Range = require("../../range").Range;
  1037. var BaseFoldMode = require("./fold_mode").FoldMode;
  1038. var TokenIterator = require("../../token_iterator").TokenIterator;
  1039. var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
  1040. BaseFoldMode.call(this);
  1041. this.voidElements = voidElements || {};
  1042. this.optionalEndTags = oop.mixin({}, this.voidElements);
  1043. if (optionalEndTags)
  1044. oop.mixin(this.optionalEndTags, optionalEndTags);
  1045. };
  1046. oop.inherits(FoldMode, BaseFoldMode);
  1047. var Tag = function() {
  1048. this.tagName = "";
  1049. this.closing = false;
  1050. this.selfClosing = false;
  1051. this.start = {row: 0, column: 0};
  1052. this.end = {row: 0, column: 0};
  1053. };
  1054. function is(token, type) {
  1055. return token.type.lastIndexOf(type + ".xml") > -1;
  1056. }
  1057. (function() {
  1058. this.getFoldWidget = function(session, foldStyle, row) {
  1059. var tag = this._getFirstTagInLine(session, row);
  1060. if (!tag)
  1061. return this.getCommentFoldWidget(session, row);
  1062. if (tag.closing || (!tag.tagName && tag.selfClosing))
  1063. return foldStyle == "markbeginend" ? "end" : "";
  1064. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  1065. return "";
  1066. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  1067. return "";
  1068. return "start";
  1069. };
  1070. this.getCommentFoldWidget = function(session, row) {
  1071. if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row)))
  1072. return "start";
  1073. return "";
  1074. };
  1075. this._getFirstTagInLine = function(session, row) {
  1076. var tokens = session.getTokens(row);
  1077. var tag = new Tag();
  1078. for (var i = 0; i < tokens.length; i++) {
  1079. var token = tokens[i];
  1080. if (is(token, "tag-open")) {
  1081. tag.end.column = tag.start.column + token.value.length;
  1082. tag.closing = is(token, "end-tag-open");
  1083. token = tokens[++i];
  1084. if (!token)
  1085. return null;
  1086. tag.tagName = token.value;
  1087. tag.end.column += token.value.length;
  1088. for (i++; i < tokens.length; i++) {
  1089. token = tokens[i];
  1090. tag.end.column += token.value.length;
  1091. if (is(token, "tag-close")) {
  1092. tag.selfClosing = token.value == '/>';
  1093. break;
  1094. }
  1095. }
  1096. return tag;
  1097. } else if (is(token, "tag-close")) {
  1098. tag.selfClosing = token.value == '/>';
  1099. return tag;
  1100. }
  1101. tag.start.column += token.value.length;
  1102. }
  1103. return null;
  1104. };
  1105. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  1106. var tokens = session.getTokens(row);
  1107. var column = 0;
  1108. for (var i = 0; i < tokens.length; i++) {
  1109. var token = tokens[i];
  1110. column += token.value.length;
  1111. if (column < startColumn)
  1112. continue;
  1113. if (is(token, "end-tag-open")) {
  1114. token = tokens[i + 1];
  1115. if (token && token.value == tagName)
  1116. return true;
  1117. }
  1118. }
  1119. return false;
  1120. };
  1121. this._readTagForward = function(iterator) {
  1122. var token = iterator.getCurrentToken();
  1123. if (!token)
  1124. return null;
  1125. var tag = new Tag();
  1126. do {
  1127. if (is(token, "tag-open")) {
  1128. tag.closing = is(token, "end-tag-open");
  1129. tag.start.row = iterator.getCurrentTokenRow();
  1130. tag.start.column = iterator.getCurrentTokenColumn();
  1131. } else if (is(token, "tag-name")) {
  1132. tag.tagName = token.value;
  1133. } else if (is(token, "tag-close")) {
  1134. tag.selfClosing = token.value == "/>";
  1135. tag.end.row = iterator.getCurrentTokenRow();
  1136. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1137. iterator.stepForward();
  1138. return tag;
  1139. }
  1140. } while(token = iterator.stepForward());
  1141. return null;
  1142. };
  1143. this._readTagBackward = function(iterator) {
  1144. var token = iterator.getCurrentToken();
  1145. if (!token)
  1146. return null;
  1147. var tag = new Tag();
  1148. do {
  1149. if (is(token, "tag-open")) {
  1150. tag.closing = is(token, "end-tag-open");
  1151. tag.start.row = iterator.getCurrentTokenRow();
  1152. tag.start.column = iterator.getCurrentTokenColumn();
  1153. iterator.stepBackward();
  1154. return tag;
  1155. } else if (is(token, "tag-name")) {
  1156. tag.tagName = token.value;
  1157. } else if (is(token, "tag-close")) {
  1158. tag.selfClosing = token.value == "/>";
  1159. tag.end.row = iterator.getCurrentTokenRow();
  1160. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1161. }
  1162. } while(token = iterator.stepBackward());
  1163. return null;
  1164. };
  1165. this._pop = function(stack, tag) {
  1166. while (stack.length) {
  1167. var top = stack[stack.length-1];
  1168. if (!tag || top.tagName == tag.tagName) {
  1169. return stack.pop();
  1170. }
  1171. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  1172. stack.pop();
  1173. continue;
  1174. } else {
  1175. return null;
  1176. }
  1177. }
  1178. };
  1179. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1180. var firstTag = this._getFirstTagInLine(session, row);
  1181. if (!firstTag) {
  1182. return this.getCommentFoldWidget(session, row)
  1183. && session.getCommentFoldRange(row, session.getLine(row).length);
  1184. }
  1185. var isBackward = firstTag.closing || firstTag.selfClosing;
  1186. var stack = [];
  1187. var tag;
  1188. if (!isBackward) {
  1189. var iterator = new TokenIterator(session, row, firstTag.start.column);
  1190. var start = {
  1191. row: row,
  1192. column: firstTag.start.column + firstTag.tagName.length + 2
  1193. };
  1194. if (firstTag.start.row == firstTag.end.row)
  1195. start.column = firstTag.end.column;
  1196. while (tag = this._readTagForward(iterator)) {
  1197. if (tag.selfClosing) {
  1198. if (!stack.length) {
  1199. tag.start.column += tag.tagName.length + 2;
  1200. tag.end.column -= 2;
  1201. return Range.fromPoints(tag.start, tag.end);
  1202. } else
  1203. continue;
  1204. }
  1205. if (tag.closing) {
  1206. this._pop(stack, tag);
  1207. if (stack.length == 0)
  1208. return Range.fromPoints(start, tag.start);
  1209. }
  1210. else {
  1211. stack.push(tag);
  1212. }
  1213. }
  1214. }
  1215. else {
  1216. var iterator = new TokenIterator(session, row, firstTag.end.column);
  1217. var end = {
  1218. row: row,
  1219. column: firstTag.start.column
  1220. };
  1221. while (tag = this._readTagBackward(iterator)) {
  1222. if (tag.selfClosing) {
  1223. if (!stack.length) {
  1224. tag.start.column += tag.tagName.length + 2;
  1225. tag.end.column -= 2;
  1226. return Range.fromPoints(tag.start, tag.end);
  1227. } else
  1228. continue;
  1229. }
  1230. if (!tag.closing) {
  1231. this._pop(stack, tag);
  1232. if (stack.length == 0) {
  1233. tag.start.column += tag.tagName.length + 2;
  1234. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  1235. tag.start.column = tag.end.column;
  1236. return Range.fromPoints(tag.start, end);
  1237. }
  1238. }
  1239. else {
  1240. stack.push(tag);
  1241. }
  1242. }
  1243. }
  1244. };
  1245. }).call(FoldMode.prototype);
  1246. });
  1247. ace.define("ace/mode/xml",[], function(require, exports, module) {
  1248. "use strict";
  1249. var oop = require("../lib/oop");
  1250. var lang = require("../lib/lang");
  1251. var TextMode = require("./text").Mode;
  1252. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1253. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  1254. var XmlFoldMode = require("./folding/xml").FoldMode;
  1255. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1256. var Mode = function() {
  1257. this.HighlightRules = XmlHighlightRules;
  1258. this.$behaviour = new XmlBehaviour();
  1259. this.foldingRules = new XmlFoldMode();
  1260. };
  1261. oop.inherits(Mode, TextMode);
  1262. (function() {
  1263. this.voidElements = lang.arrayToMap([]);
  1264. this.blockComment = {start: "<!--", end: "-->"};
  1265. this.createWorker = function(session) {
  1266. var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
  1267. worker.attachToDocument(session.getDocument());
  1268. worker.on("error", function(e) {
  1269. session.setAnnotations(e.data);
  1270. });
  1271. worker.on("terminate", function() {
  1272. session.clearAnnotations();
  1273. });
  1274. return worker;
  1275. };
  1276. this.$id = "ace/mode/xml";
  1277. }).call(Mode.prototype);
  1278. exports.Mode = Mode;
  1279. });
  1280. ace.define("ace/mode/css_highlight_rules",[], function(require, exports, module) {
  1281. "use strict";
  1282. var oop = require("../lib/oop");
  1283. var lang = require("../lib/lang");
  1284. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1285. var supportType = exports.supportType = "align-content|align-items|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|border|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|bottom|box-shadow|box-sizing|caption-side|clear|clip|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|cursor|direction|display|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|font|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|hanging-punctuation|height|justify-content|left|letter-spacing|line-height|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|max-height|max-width|max-zoom|min-height|min-width|min-zoom|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|order|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page-break-after|page-break-before|page-break-inside|perspective|perspective-origin|position|quotes|resize|right|tab-size|table-layout|text-align|text-align-last|text-decoration|text-decoration-color|text-decoration-line|text-decoration-style|text-indent|text-justify|text-overflow|text-shadow|text-transform|top|transform|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|user-select|user-zoom|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index";
  1286. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  1287. 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|zoom";
  1288. var supportConstantColor = exports.supportConstantColor = "aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";
  1289. var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
  1290. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))";
  1291. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  1292. 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";
  1293. var CssHighlightRules = function() {
  1294. var keywordMapper = this.createKeywordMapper({
  1295. "support.function": supportFunction,
  1296. "support.constant": supportConstant,
  1297. "support.type": supportType,
  1298. "support.constant.color": supportConstantColor,
  1299. "support.constant.fonts": supportConstantFonts
  1300. }, "text", true);
  1301. this.$rules = {
  1302. "start" : [{
  1303. include : ["strings", "url", "comments"]
  1304. }, {
  1305. token: "paren.lparen",
  1306. regex: "\\{",
  1307. next: "ruleset"
  1308. }, {
  1309. token: "paren.rparen",
  1310. regex: "\\}"
  1311. }, {
  1312. token: "string",
  1313. regex: "@(?!viewport)",
  1314. next: "media"
  1315. }, {
  1316. token: "keyword",
  1317. regex: "#[a-z0-9-_]+"
  1318. }, {
  1319. token: "keyword",
  1320. regex: "%"
  1321. }, {
  1322. token: "variable",
  1323. regex: "\\.[a-z0-9-_]+"
  1324. }, {
  1325. token: "string",
  1326. regex: ":[a-z0-9-_]+"
  1327. }, {
  1328. token : "constant.numeric",
  1329. regex : numRe
  1330. }, {
  1331. token: "constant",
  1332. regex: "[a-z0-9-_]+"
  1333. }, {
  1334. caseInsensitive: true
  1335. }],
  1336. "media": [{
  1337. include : ["strings", "url", "comments"]
  1338. }, {
  1339. token: "paren.lparen",
  1340. regex: "\\{",
  1341. next: "start"
  1342. }, {
  1343. token: "paren.rparen",
  1344. regex: "\\}",
  1345. next: "start"
  1346. }, {
  1347. token: "string",
  1348. regex: ";",
  1349. next: "start"
  1350. }, {
  1351. token: "keyword",
  1352. regex: "(?:media|supports|document|charset|import|namespace|media|supports|document"
  1353. + "|page|font|keyframes|viewport|counter-style|font-feature-values"
  1354. + "|swash|ornaments|annotation|stylistic|styleset|character-variant)"
  1355. }],
  1356. "comments" : [{
  1357. token: "comment", // multi line comment
  1358. regex: "\\/\\*",
  1359. push: [{
  1360. token : "comment",
  1361. regex : "\\*\\/",
  1362. next : "pop"
  1363. }, {
  1364. defaultToken : "comment"
  1365. }]
  1366. }],
  1367. "ruleset" : [{
  1368. regex : "-(webkit|ms|moz|o)-",
  1369. token : "text"
  1370. }, {
  1371. token : "punctuation.operator",
  1372. regex : "[:;]"
  1373. }, {
  1374. token : "paren.rparen",
  1375. regex : "\\}",
  1376. next : "start"
  1377. }, {
  1378. include : ["strings", "url", "comments"]
  1379. }, {
  1380. token : ["constant.numeric", "keyword"],
  1381. regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vmax|vmin|vm|vw|%)"
  1382. }, {
  1383. token : "constant.numeric",
  1384. regex : numRe
  1385. }, {
  1386. token : "constant.numeric", // hex6 color
  1387. regex : "#[a-f0-9]{6}"
  1388. }, {
  1389. token : "constant.numeric", // hex3 color
  1390. regex : "#[a-f0-9]{3}"
  1391. }, {
  1392. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  1393. regex : pseudoElements
  1394. }, {
  1395. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  1396. regex : pseudoClasses
  1397. }, {
  1398. include: "url"
  1399. }, {
  1400. token : keywordMapper,
  1401. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  1402. }, {
  1403. caseInsensitive: true
  1404. }],
  1405. url: [{
  1406. token : "support.function",
  1407. regex : "(?:url(:?-prefix)?|domain|regexp)\\(",
  1408. push: [{
  1409. token : "support.function",
  1410. regex : "\\)",
  1411. next : "pop"
  1412. }, {
  1413. defaultToken: "string"
  1414. }]
  1415. }],
  1416. strings: [{
  1417. token : "string.start",
  1418. regex : "'",
  1419. push : [{
  1420. token : "string.end",
  1421. regex : "'|$",
  1422. next: "pop"
  1423. }, {
  1424. include : "escapes"
  1425. }, {
  1426. token : "constant.language.escape",
  1427. regex : /\\$/,
  1428. consumeLineEnd: true
  1429. }, {
  1430. defaultToken: "string"
  1431. }]
  1432. }, {
  1433. token : "string.start",
  1434. regex : '"',
  1435. push : [{
  1436. token : "string.end",
  1437. regex : '"|$',
  1438. next: "pop"
  1439. }, {
  1440. include : "escapes"
  1441. }, {
  1442. token : "constant.language.escape",
  1443. regex : /\\$/,
  1444. consumeLineEnd: true
  1445. }, {
  1446. defaultToken: "string"
  1447. }]
  1448. }],
  1449. escapes: [{
  1450. token : "constant.language.escape",
  1451. regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/
  1452. }]
  1453. };
  1454. this.normalizeRules();
  1455. };
  1456. oop.inherits(CssHighlightRules, TextHighlightRules);
  1457. exports.CssHighlightRules = CssHighlightRules;
  1458. });
  1459. ace.define("ace/mode/css_completions",[], function(require, exports, module) {
  1460. "use strict";
  1461. var propertyMap = {
  1462. "background": {"#$0": 1},
  1463. "background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
  1464. "background-image": {"url('/$0')": 1},
  1465. "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
  1466. "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
  1467. "background-attachment": {"scroll": 1, "fixed": 1},
  1468. "background-size": {"cover": 1, "contain": 1},
  1469. "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
  1470. "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
  1471. "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
  1472. "border-color": {"#$0": 1},
  1473. "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
  1474. "border-collapse": {"collapse": 1, "separate": 1},
  1475. "bottom": {"px": 1, "em": 1, "%": 1},
  1476. "clear": {"left": 1, "right": 1, "both": 1, "none": 1},
  1477. "color": {"#$0": 1, "rgb(#$00,0,0)": 1},
  1478. "cursor": {"default": 1, "pointer": 1, "move": 1, "text": 1, "wait": 1, "help": 1, "progress": 1, "n-resize": 1, "ne-resize": 1, "e-resize": 1, "se-resize": 1, "s-resize": 1, "sw-resize": 1, "w-resize": 1, "nw-resize": 1},
  1479. "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
  1480. "empty-cells": {"show": 1, "hide": 1},
  1481. "float": {"left": 1, "right": 1, "none": 1},
  1482. "font-family": {"Arial":2,"Comic Sans MS":2,"Consolas":2,"Courier New":2,"Courier":2,"Georgia":2,"Monospace":2,"Sans-Serif":2, "Segoe UI":2,"Tahoma":2,"Times New Roman":2,"Trebuchet MS":2,"Verdana": 1},
  1483. "font-size": {"px": 1, "em": 1, "%": 1},
  1484. "font-weight": {"bold": 1, "normal": 1},
  1485. "font-style": {"italic": 1, "normal": 1},
  1486. "font-variant": {"normal": 1, "small-caps": 1},
  1487. "height": {"px": 1, "em": 1, "%": 1},
  1488. "left": {"px": 1, "em": 1, "%": 1},
  1489. "letter-spacing": {"normal": 1},
  1490. "line-height": {"normal": 1},
  1491. "list-style-type": {"none": 1, "disc": 1, "circle": 1, "square": 1, "decimal": 1, "decimal-leading-zero": 1, "lower-roman": 1, "upper-roman": 1, "lower-greek": 1, "lower-latin": 1, "upper-latin": 1, "georgian": 1, "lower-alpha": 1, "upper-alpha": 1},
  1492. "margin": {"px": 1, "em": 1, "%": 1},
  1493. "margin-right": {"px": 1, "em": 1, "%": 1},
  1494. "margin-left": {"px": 1, "em": 1, "%": 1},
  1495. "margin-top": {"px": 1, "em": 1, "%": 1},
  1496. "margin-bottom": {"px": 1, "em": 1, "%": 1},
  1497. "max-height": {"px": 1, "em": 1, "%": 1},
  1498. "max-width": {"px": 1, "em": 1, "%": 1},
  1499. "min-height": {"px": 1, "em": 1, "%": 1},
  1500. "min-width": {"px": 1, "em": 1, "%": 1},
  1501. "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  1502. "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  1503. "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  1504. "padding": {"px": 1, "em": 1, "%": 1},
  1505. "padding-top": {"px": 1, "em": 1, "%": 1},
  1506. "padding-right": {"px": 1, "em": 1, "%": 1},
  1507. "padding-bottom": {"px": 1, "em": 1, "%": 1},
  1508. "padding-left": {"px": 1, "em": 1, "%": 1},
  1509. "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  1510. "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  1511. "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
  1512. "right": {"px": 1, "em": 1, "%": 1},
  1513. "table-layout": {"fixed": 1, "auto": 1},
  1514. "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
  1515. "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
  1516. "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
  1517. "top": {"px": 1, "em": 1, "%": 1},
  1518. "vertical-align": {"top": 1, "bottom": 1},
  1519. "visibility": {"hidden": 1, "visible": 1},
  1520. "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
  1521. "width": {"px": 1, "em": 1, "%": 1},
  1522. "word-spacing": {"normal": 1},
  1523. "filter": {"alpha(opacity=$0100)": 1},
  1524. "text-shadow": {"$02px 2px 2px #777": 1},
  1525. "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
  1526. "-moz-border-radius": 1,
  1527. "-moz-border-radius-topright": 1,
  1528. "-moz-border-radius-bottomright": 1,
  1529. "-moz-border-radius-topleft": 1,
  1530. "-moz-border-radius-bottomleft": 1,
  1531. "-webkit-border-radius": 1,
  1532. "-webkit-border-top-right-radius": 1,
  1533. "-webkit-border-top-left-radius": 1,
  1534. "-webkit-border-bottom-right-radius": 1,
  1535. "-webkit-border-bottom-left-radius": 1,
  1536. "-moz-box-shadow": 1,
  1537. "-webkit-box-shadow": 1,
  1538. "transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  1539. "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  1540. "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
  1541. };
  1542. var CssCompletions = function() {
  1543. };
  1544. (function() {
  1545. this.completionsDefined = false;
  1546. this.defineCompletions = function() {
  1547. if (document) {
  1548. var style = document.createElement('c').style;
  1549. for (var i in style) {
  1550. if (typeof style[i] !== 'string')
  1551. continue;
  1552. var name = i.replace(/[A-Z]/g, function(x) {
  1553. return '-' + x.toLowerCase();
  1554. });
  1555. if (!propertyMap.hasOwnProperty(name))
  1556. propertyMap[name] = 1;
  1557. }
  1558. }
  1559. this.completionsDefined = true;
  1560. };
  1561. this.getCompletions = function(state, session, pos, prefix) {
  1562. if (!this.completionsDefined) {
  1563. this.defineCompletions();
  1564. }
  1565. var token = session.getTokenAt(pos.row, pos.column);
  1566. if (!token)
  1567. return [];
  1568. if (state==='ruleset'){
  1569. var line = session.getLine(pos.row).substr(0, pos.column);
  1570. if (/:[^;]+$/.test(line)) {
  1571. /([\w\-]+):[^:]*$/.test(line);
  1572. return this.getPropertyValueCompletions(state, session, pos, prefix);
  1573. } else {
  1574. return this.getPropertyCompletions(state, session, pos, prefix);
  1575. }
  1576. }
  1577. return [];
  1578. };
  1579. this.getPropertyCompletions = function(state, session, pos, prefix) {
  1580. var properties = Object.keys(propertyMap);
  1581. return properties.map(function(property){
  1582. return {
  1583. caption: property,
  1584. snippet: property + ': $0;',
  1585. meta: "property",
  1586. score: Number.MAX_VALUE
  1587. };
  1588. });
  1589. };
  1590. this.getPropertyValueCompletions = function(state, session, pos, prefix) {
  1591. var line = session.getLine(pos.row).substr(0, pos.column);
  1592. var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
  1593. if (!property)
  1594. return [];
  1595. var values = [];
  1596. if (property in propertyMap && typeof propertyMap[property] === "object") {
  1597. values = Object.keys(propertyMap[property]);
  1598. }
  1599. return values.map(function(value){
  1600. return {
  1601. caption: value,
  1602. snippet: value,
  1603. meta: "property value",
  1604. score: Number.MAX_VALUE
  1605. };
  1606. });
  1607. };
  1608. }).call(CssCompletions.prototype);
  1609. exports.CssCompletions = CssCompletions;
  1610. });
  1611. ace.define("ace/mode/behaviour/css",[], function(require, exports, module) {
  1612. "use strict";
  1613. var oop = require("../../lib/oop");
  1614. var Behaviour = require("../behaviour").Behaviour;
  1615. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1616. var TokenIterator = require("../../token_iterator").TokenIterator;
  1617. var CssBehaviour = function () {
  1618. this.inherit(CstyleBehaviour);
  1619. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1620. if (text === ':' && editor.selection.isEmpty()) {
  1621. var cursor = editor.getCursorPosition();
  1622. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1623. var token = iterator.getCurrentToken();
  1624. if (token && token.value.match(/\s+/)) {
  1625. token = iterator.stepBackward();
  1626. }
  1627. if (token && token.type === 'support.type') {
  1628. var line = session.doc.getLine(cursor.row);
  1629. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1630. if (rightChar === ':') {
  1631. return {
  1632. text: '',
  1633. selection: [1, 1]
  1634. };
  1635. }
  1636. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  1637. return {
  1638. text: ':;',
  1639. selection: [1, 1]
  1640. };
  1641. }
  1642. }
  1643. }
  1644. });
  1645. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1646. var selected = session.doc.getTextRange(range);
  1647. if (!range.isMultiLine() && selected === ':') {
  1648. var cursor = editor.getCursorPosition();
  1649. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1650. var token = iterator.getCurrentToken();
  1651. if (token && token.value.match(/\s+/)) {
  1652. token = iterator.stepBackward();
  1653. }
  1654. if (token && token.type === 'support.type') {
  1655. var line = session.doc.getLine(range.start.row);
  1656. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1657. if (rightChar === ';') {
  1658. range.end.column ++;
  1659. return range;
  1660. }
  1661. }
  1662. }
  1663. });
  1664. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1665. if (text === ';' && editor.selection.isEmpty()) {
  1666. var cursor = editor.getCursorPosition();
  1667. var line = session.doc.getLine(cursor.row);
  1668. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1669. if (rightChar === ';') {
  1670. return {
  1671. text: '',
  1672. selection: [1, 1]
  1673. };
  1674. }
  1675. }
  1676. });
  1677. this.add("!important", "insertion", function (state, action, editor, session, text) {
  1678. if (text === '!' && editor.selection.isEmpty()) {
  1679. var cursor = editor.getCursorPosition();
  1680. var line = session.doc.getLine(cursor.row);
  1681. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  1682. return {
  1683. text: '!important',
  1684. selection: [10, 10]
  1685. };
  1686. }
  1687. }
  1688. });
  1689. };
  1690. oop.inherits(CssBehaviour, CstyleBehaviour);
  1691. exports.CssBehaviour = CssBehaviour;
  1692. });
  1693. ace.define("ace/mode/css",[], function(require, exports, module) {
  1694. "use strict";
  1695. var oop = require("../lib/oop");
  1696. var TextMode = require("./text").Mode;
  1697. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1698. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1699. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1700. var CssCompletions = require("./css_completions").CssCompletions;
  1701. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1702. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1703. var Mode = function() {
  1704. this.HighlightRules = CssHighlightRules;
  1705. this.$outdent = new MatchingBraceOutdent();
  1706. this.$behaviour = new CssBehaviour();
  1707. this.$completer = new CssCompletions();
  1708. this.foldingRules = new CStyleFoldMode();
  1709. };
  1710. oop.inherits(Mode, TextMode);
  1711. (function() {
  1712. this.foldingRules = "cStyle";
  1713. this.blockComment = {start: "/*", end: "*/"};
  1714. this.getNextLineIndent = function(state, line, tab) {
  1715. var indent = this.$getIndent(line);
  1716. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1717. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1718. return indent;
  1719. }
  1720. var match = line.match(/^.*\{\s*$/);
  1721. if (match) {
  1722. indent += tab;
  1723. }
  1724. return indent;
  1725. };
  1726. this.checkOutdent = function(state, line, input) {
  1727. return this.$outdent.checkOutdent(line, input);
  1728. };
  1729. this.autoOutdent = function(state, doc, row) {
  1730. this.$outdent.autoOutdent(doc, row);
  1731. };
  1732. this.getCompletions = function(state, session, pos, prefix) {
  1733. return this.$completer.getCompletions(state, session, pos, prefix);
  1734. };
  1735. this.createWorker = function(session) {
  1736. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  1737. worker.attachToDocument(session.getDocument());
  1738. worker.on("annotate", function(e) {
  1739. session.setAnnotations(e.data);
  1740. });
  1741. worker.on("terminate", function() {
  1742. session.clearAnnotations();
  1743. });
  1744. return worker;
  1745. };
  1746. this.$id = "ace/mode/css";
  1747. }).call(Mode.prototype);
  1748. exports.Mode = Mode;
  1749. });
  1750. ace.define("ace/mode/html_highlight_rules",[], function(require, exports, module) {
  1751. "use strict";
  1752. var oop = require("../lib/oop");
  1753. var lang = require("../lib/lang");
  1754. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1755. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1756. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1757. var tagMap = lang.createMap({
  1758. a : 'anchor',
  1759. button : 'form',
  1760. form : 'form',
  1761. img : 'image',
  1762. input : 'form',
  1763. label : 'form',
  1764. option : 'form',
  1765. script : 'script',
  1766. select : 'form',
  1767. textarea : 'form',
  1768. style : 'style',
  1769. table : 'table',
  1770. tbody : 'table',
  1771. td : 'table',
  1772. tfoot : 'table',
  1773. th : 'table',
  1774. tr : 'table'
  1775. });
  1776. var HtmlHighlightRules = function() {
  1777. XmlHighlightRules.call(this);
  1778. this.addRules({
  1779. attributes: [{
  1780. include : "tag_whitespace"
  1781. }, {
  1782. token : "entity.other.attribute-name.xml",
  1783. regex : "[-_a-zA-Z0-9:.]+"
  1784. }, {
  1785. token : "keyword.operator.attribute-equals.xml",
  1786. regex : "=",
  1787. push : [{
  1788. include: "tag_whitespace"
  1789. }, {
  1790. token : "string.unquoted.attribute-value.html",
  1791. regex : "[^<>='\"`\\s]+",
  1792. next : "pop"
  1793. }, {
  1794. token : "empty",
  1795. regex : "",
  1796. next : "pop"
  1797. }]
  1798. }, {
  1799. include : "attribute_value"
  1800. }],
  1801. tag: [{
  1802. token : function(start, tag) {
  1803. var group = tagMap[tag];
  1804. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  1805. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  1806. },
  1807. regex : "(</?)([-_a-zA-Z0-9:.]+)",
  1808. next: "tag_stuff"
  1809. }],
  1810. tag_stuff: [
  1811. {include : "attributes"},
  1812. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1813. ]
  1814. });
  1815. this.embedTagRules(CssHighlightRules, "css-", "style");
  1816. this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script");
  1817. if (this.constructor === HtmlHighlightRules)
  1818. this.normalizeRules();
  1819. };
  1820. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  1821. exports.HtmlHighlightRules = HtmlHighlightRules;
  1822. });
  1823. ace.define("ace/mode/folding/mixed",[], function(require, exports, module) {
  1824. "use strict";
  1825. var oop = require("../../lib/oop");
  1826. var BaseFoldMode = require("./fold_mode").FoldMode;
  1827. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1828. this.defaultMode = defaultMode;
  1829. this.subModes = subModes;
  1830. };
  1831. oop.inherits(FoldMode, BaseFoldMode);
  1832. (function() {
  1833. this.$getMode = function(state) {
  1834. if (typeof state != "string")
  1835. state = state[0];
  1836. for (var key in this.subModes) {
  1837. if (state.indexOf(key) === 0)
  1838. return this.subModes[key];
  1839. }
  1840. return null;
  1841. };
  1842. this.$tryMode = function(state, session, foldStyle, row) {
  1843. var mode = this.$getMode(state);
  1844. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1845. };
  1846. this.getFoldWidget = function(session, foldStyle, row) {
  1847. return (
  1848. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1849. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1850. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1851. );
  1852. };
  1853. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1854. var mode = this.$getMode(session.getState(row-1));
  1855. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1856. mode = this.$getMode(session.getState(row));
  1857. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1858. mode = this.defaultMode;
  1859. return mode.getFoldWidgetRange(session, foldStyle, row);
  1860. };
  1861. }).call(FoldMode.prototype);
  1862. });
  1863. ace.define("ace/mode/folding/html",[], function(require, exports, module) {
  1864. "use strict";
  1865. var oop = require("../../lib/oop");
  1866. var MixedFoldMode = require("./mixed").FoldMode;
  1867. var XmlFoldMode = require("./xml").FoldMode;
  1868. var CStyleFoldMode = require("./cstyle").FoldMode;
  1869. var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
  1870. MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
  1871. "js-": new CStyleFoldMode(),
  1872. "css-": new CStyleFoldMode()
  1873. });
  1874. };
  1875. oop.inherits(FoldMode, MixedFoldMode);
  1876. });
  1877. ace.define("ace/mode/html_completions",[], function(require, exports, module) {
  1878. "use strict";
  1879. var TokenIterator = require("../token_iterator").TokenIterator;
  1880. var commonAttributes = [
  1881. "accesskey",
  1882. "class",
  1883. "contenteditable",
  1884. "contextmenu",
  1885. "dir",
  1886. "draggable",
  1887. "dropzone",
  1888. "hidden",
  1889. "id",
  1890. "inert",
  1891. "itemid",
  1892. "itemprop",
  1893. "itemref",
  1894. "itemscope",
  1895. "itemtype",
  1896. "lang",
  1897. "spellcheck",
  1898. "style",
  1899. "tabindex",
  1900. "title",
  1901. "translate"
  1902. ];
  1903. var eventAttributes = [
  1904. "onabort",
  1905. "onblur",
  1906. "oncancel",
  1907. "oncanplay",
  1908. "oncanplaythrough",
  1909. "onchange",
  1910. "onclick",
  1911. "onclose",
  1912. "oncontextmenu",
  1913. "oncuechange",
  1914. "ondblclick",
  1915. "ondrag",
  1916. "ondragend",
  1917. "ondragenter",
  1918. "ondragleave",
  1919. "ondragover",
  1920. "ondragstart",
  1921. "ondrop",
  1922. "ondurationchange",
  1923. "onemptied",
  1924. "onended",
  1925. "onerror",
  1926. "onfocus",
  1927. "oninput",
  1928. "oninvalid",
  1929. "onkeydown",
  1930. "onkeypress",
  1931. "onkeyup",
  1932. "onload",
  1933. "onloadeddata",
  1934. "onloadedmetadata",
  1935. "onloadstart",
  1936. "onmousedown",
  1937. "onmousemove",
  1938. "onmouseout",
  1939. "onmouseover",
  1940. "onmouseup",
  1941. "onmousewheel",
  1942. "onpause",
  1943. "onplay",
  1944. "onplaying",
  1945. "onprogress",
  1946. "onratechange",
  1947. "onreset",
  1948. "onscroll",
  1949. "onseeked",
  1950. "onseeking",
  1951. "onselect",
  1952. "onshow",
  1953. "onstalled",
  1954. "onsubmit",
  1955. "onsuspend",
  1956. "ontimeupdate",
  1957. "onvolumechange",
  1958. "onwaiting"
  1959. ];
  1960. var globalAttributes = commonAttributes.concat(eventAttributes);
  1961. var attributeMap = {
  1962. "a": {"href": 1, "target": {"_blank": 1, "top": 1}, "ping": 1, "rel": {"nofollow": 1, "alternate": 1, "author": 1, "bookmark": 1, "help": 1, "license": 1, "next": 1, "noreferrer": 1, "prefetch": 1, "prev": 1, "search": 1, "tag": 1}, "media": 1, "hreflang": 1, "type": 1},
  1963. "abbr": {},
  1964. "address": {},
  1965. "area": {"shape": 1, "coords": 1, "href": 1, "hreflang": 1, "alt": 1, "target": 1, "media": 1, "rel": 1, "ping": 1, "type": 1},
  1966. "article": {"pubdate": 1},
  1967. "aside": {},
  1968. "audio": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1 }},
  1969. "b": {},
  1970. "base": {"href": 1, "target": 1},
  1971. "bdi": {},
  1972. "bdo": {},
  1973. "blockquote": {"cite": 1},
  1974. "body": {"onafterprint": 1, "onbeforeprint": 1, "onbeforeunload": 1, "onhashchange": 1, "onmessage": 1, "onoffline": 1, "onpopstate": 1, "onredo": 1, "onresize": 1, "onstorage": 1, "onundo": 1, "onunload": 1},
  1975. "br": {},
  1976. "button": {"autofocus": 1, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": 1, "formmethod": 1, "formnovalidate": 1, "formtarget": 1, "name": 1, "value": 1, "type": {"button": 1, "submit": 1}},
  1977. "canvas": {"width": 1, "height": 1},
  1978. "caption": {},
  1979. "cite": {},
  1980. "code": {},
  1981. "col": {"span": 1},
  1982. "colgroup": {"span": 1},
  1983. "command": {"type": 1, "label": 1, "icon": 1, "disabled": 1, "checked": 1, "radiogroup": 1, "command": 1},
  1984. "data": {},
  1985. "datalist": {},
  1986. "dd": {},
  1987. "del": {"cite": 1, "datetime": 1},
  1988. "details": {"open": 1},
  1989. "dfn": {},
  1990. "dialog": {"open": 1},
  1991. "div": {},
  1992. "dl": {},
  1993. "dt": {},
  1994. "em": {},
  1995. "embed": {"src": 1, "height": 1, "width": 1, "type": 1},
  1996. "fieldset": {"disabled": 1, "form": 1, "name": 1},
  1997. "figcaption": {},
  1998. "figure": {},
  1999. "footer": {},
  2000. "form": {"accept-charset": 1, "action": 1, "autocomplete": 1, "enctype": {"multipart/form-data": 1, "application/x-www-form-urlencoded": 1}, "method": {"get": 1, "post": 1}, "name": 1, "novalidate": 1, "target": {"_blank": 1, "top": 1}},
  2001. "h1": {},
  2002. "h2": {},
  2003. "h3": {},
  2004. "h4": {},
  2005. "h5": {},
  2006. "h6": {},
  2007. "head": {},
  2008. "header": {},
  2009. "hr": {},
  2010. "html": {"manifest": 1},
  2011. "i": {},
  2012. "iframe": {"name": 1, "src": 1, "height": 1, "width": 1, "sandbox": {"allow-same-origin": 1, "allow-top-navigation": 1, "allow-forms": 1, "allow-scripts": 1}, "seamless": {"seamless": 1}},
  2013. "img": {"alt": 1, "src": 1, "height": 1, "width": 1, "usemap": 1, "ismap": 1},
  2014. "input": {
  2015. "type": {"text": 1, "password": 1, "hidden": 1, "checkbox": 1, "submit": 1, "radio": 1, "file": 1, "button": 1, "reset": 1, "image": 31, "color": 1, "date": 1, "datetime": 1, "datetime-local": 1, "email": 1, "month": 1, "number": 1, "range": 1, "search": 1, "tel": 1, "time": 1, "url": 1, "week": 1},
  2016. "accept": 1, "alt": 1, "autocomplete": {"on": 1, "off": 1}, "autofocus": {"autofocus": 1}, "checked": {"checked": 1}, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": {"application/x-www-form-urlencoded": 1, "multipart/form-data": 1, "text/plain": 1}, "formmethod": {"get": 1, "post": 1}, "formnovalidate": {"formnovalidate": 1}, "formtarget": {"_blank": 1, "_self": 1, "_parent": 1, "_top": 1}, "height": 1, "list": 1, "max": 1, "maxlength": 1, "min": 1, "multiple": {"multiple": 1}, "name": 1, "pattern": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "size": 1, "src": 1, "step": 1, "width": 1, "files": 1, "value": 1},
  2017. "ins": {"cite": 1, "datetime": 1},
  2018. "kbd": {},
  2019. "keygen": {"autofocus": 1, "challenge": {"challenge": 1}, "disabled": {"disabled": 1}, "form": 1, "keytype": {"rsa": 1, "dsa": 1, "ec": 1}, "name": 1},
  2020. "label": {"form": 1, "for": 1},
  2021. "legend": {},
  2022. "li": {"value": 1},
  2023. "link": {"href": 1, "hreflang": 1, "rel": {"stylesheet": 1, "icon": 1}, "media": {"all": 1, "screen": 1, "print": 1}, "type": {"text/css": 1, "image/png": 1, "image/jpeg": 1, "image/gif": 1}, "sizes": 1},
  2024. "main": {},
  2025. "map": {"name": 1},
  2026. "mark": {},
  2027. "math": {},
  2028. "menu": {"type": 1, "label": 1},
  2029. "meta": {"http-equiv": {"content-type": 1}, "name": {"description": 1, "keywords": 1}, "content": {"text/html; charset=UTF-8": 1}, "charset": 1},
  2030. "meter": {"value": 1, "min": 1, "max": 1, "low": 1, "high": 1, "optimum": 1},
  2031. "nav": {},
  2032. "noscript": {"href": 1},
  2033. "object": {"param": 1, "data": 1, "type": 1, "height" : 1, "width": 1, "usemap": 1, "name": 1, "form": 1, "classid": 1},
  2034. "ol": {"start": 1, "reversed": 1},
  2035. "optgroup": {"disabled": 1, "label": 1},
  2036. "option": {"disabled": 1, "selected": 1, "label": 1, "value": 1},
  2037. "output": {"for": 1, "form": 1, "name": 1},
  2038. "p": {},
  2039. "param": {"name": 1, "value": 1},
  2040. "pre": {},
  2041. "progress": {"value": 1, "max": 1},
  2042. "q": {"cite": 1},
  2043. "rp": {},
  2044. "rt": {},
  2045. "ruby": {},
  2046. "s": {},
  2047. "samp": {},
  2048. "script": {"charset": 1, "type": {"text/javascript": 1}, "src": 1, "defer": 1, "async": 1},
  2049. "select": {"autofocus": 1, "disabled": 1, "form": 1, "multiple": {"multiple": 1}, "name": 1, "size": 1, "readonly":{"readonly": 1}},
  2050. "small": {},
  2051. "source": {"src": 1, "type": 1, "media": 1},
  2052. "span": {},
  2053. "strong": {},
  2054. "style": {"type": 1, "media": {"all": 1, "screen": 1, "print": 1}, "scoped": 1},
  2055. "sub": {},
  2056. "sup": {},
  2057. "svg": {},
  2058. "table": {"summary": 1},
  2059. "tbody": {},
  2060. "td": {"headers": 1, "rowspan": 1, "colspan": 1},
  2061. "textarea": {"autofocus": {"autofocus": 1}, "disabled": {"disabled": 1}, "form": 1, "maxlength": 1, "name": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "rows": 1, "cols": 1, "wrap": {"on": 1, "off": 1, "hard": 1, "soft": 1}},
  2062. "tfoot": {},
  2063. "th": {"headers": 1, "rowspan": 1, "colspan": 1, "scope": 1},
  2064. "thead": {},
  2065. "time": {"datetime": 1},
  2066. "title": {},
  2067. "tr": {},
  2068. "track": {"kind": 1, "src": 1, "srclang": 1, "label": 1, "default": 1},
  2069. "section": {},
  2070. "summary": {},
  2071. "u": {},
  2072. "ul": {},
  2073. "var": {},
  2074. "video": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "width": 1, "height": 1, "poster": 1, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1}},
  2075. "wbr": {}
  2076. };
  2077. var elements = Object.keys(attributeMap);
  2078. function is(token, type) {
  2079. return token.type.lastIndexOf(type + ".xml") > -1;
  2080. }
  2081. function findTagName(session, pos) {
  2082. var iterator = new TokenIterator(session, pos.row, pos.column);
  2083. var token = iterator.getCurrentToken();
  2084. while (token && !is(token, "tag-name")){
  2085. token = iterator.stepBackward();
  2086. }
  2087. if (token)
  2088. return token.value;
  2089. }
  2090. function findAttributeName(session, pos) {
  2091. var iterator = new TokenIterator(session, pos.row, pos.column);
  2092. var token = iterator.getCurrentToken();
  2093. while (token && !is(token, "attribute-name")){
  2094. token = iterator.stepBackward();
  2095. }
  2096. if (token)
  2097. return token.value;
  2098. }
  2099. var HtmlCompletions = function() {
  2100. };
  2101. (function() {
  2102. this.getCompletions = function(state, session, pos, prefix) {
  2103. var token = session.getTokenAt(pos.row, pos.column);
  2104. if (!token)
  2105. return [];
  2106. if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
  2107. return this.getTagCompletions(state, session, pos, prefix);
  2108. if (is(token, "tag-whitespace") || is(token, "attribute-name"))
  2109. return this.getAttributeCompletions(state, session, pos, prefix);
  2110. if (is(token, "attribute-value"))
  2111. return this.getAttributeValueCompletions(state, session, pos, prefix);
  2112. var line = session.getLine(pos.row).substr(0, pos.column);
  2113. if (/&[a-z]*$/i.test(line))
  2114. return this.getHTMLEntityCompletions(state, session, pos, prefix);
  2115. return [];
  2116. };
  2117. this.getTagCompletions = function(state, session, pos, prefix) {
  2118. return elements.map(function(element){
  2119. return {
  2120. value: element,
  2121. meta: "tag",
  2122. score: Number.MAX_VALUE
  2123. };
  2124. });
  2125. };
  2126. this.getAttributeCompletions = function(state, session, pos, prefix) {
  2127. var tagName = findTagName(session, pos);
  2128. if (!tagName)
  2129. return [];
  2130. var attributes = globalAttributes;
  2131. if (tagName in attributeMap) {
  2132. attributes = attributes.concat(Object.keys(attributeMap[tagName]));
  2133. }
  2134. return attributes.map(function(attribute){
  2135. return {
  2136. caption: attribute,
  2137. snippet: attribute + '="$0"',
  2138. meta: "attribute",
  2139. score: Number.MAX_VALUE
  2140. };
  2141. });
  2142. };
  2143. this.getAttributeValueCompletions = function(state, session, pos, prefix) {
  2144. var tagName = findTagName(session, pos);
  2145. var attributeName = findAttributeName(session, pos);
  2146. if (!tagName)
  2147. return [];
  2148. var values = [];
  2149. if (tagName in attributeMap && attributeName in attributeMap[tagName] && typeof attributeMap[tagName][attributeName] === "object") {
  2150. values = Object.keys(attributeMap[tagName][attributeName]);
  2151. }
  2152. return values.map(function(value){
  2153. return {
  2154. caption: value,
  2155. snippet: value,
  2156. meta: "attribute value",
  2157. score: Number.MAX_VALUE
  2158. };
  2159. });
  2160. };
  2161. this.getHTMLEntityCompletions = function(state, session, pos, prefix) {
  2162. var values = ['Aacute;', 'aacute;', 'Acirc;', 'acirc;', 'acute;', 'AElig;', 'aelig;', 'Agrave;', 'agrave;', 'alefsym;', 'Alpha;', 'alpha;', 'amp;', 'and;', 'ang;', 'Aring;', 'aring;', 'asymp;', 'Atilde;', 'atilde;', 'Auml;', 'auml;', 'bdquo;', 'Beta;', 'beta;', 'brvbar;', 'bull;', 'cap;', 'Ccedil;', 'ccedil;', 'cedil;', 'cent;', 'Chi;', 'chi;', 'circ;', 'clubs;', 'cong;', 'copy;', 'crarr;', 'cup;', 'curren;', 'Dagger;', 'dagger;', 'dArr;', 'darr;', 'deg;', 'Delta;', 'delta;', 'diams;', 'divide;', 'Eacute;', 'eacute;', 'Ecirc;', 'ecirc;', 'Egrave;', 'egrave;', 'empty;', 'emsp;', 'ensp;', 'Epsilon;', 'epsilon;', 'equiv;', 'Eta;', 'eta;', 'ETH;', 'eth;', 'Euml;', 'euml;', 'euro;', 'exist;', 'fnof;', 'forall;', 'frac12;', 'frac14;', 'frac34;', 'frasl;', 'Gamma;', 'gamma;', 'ge;', 'gt;', 'hArr;', 'harr;', 'hearts;', 'hellip;', 'Iacute;', 'iacute;', 'Icirc;', 'icirc;', 'iexcl;', 'Igrave;', 'igrave;', 'image;', 'infin;', 'int;', 'Iota;', 'iota;', 'iquest;', 'isin;', 'Iuml;', 'iuml;', 'Kappa;', 'kappa;', 'Lambda;', 'lambda;', 'lang;', 'laquo;', 'lArr;', 'larr;', 'lceil;', 'ldquo;', 'le;', 'lfloor;', 'lowast;', 'loz;', 'lrm;', 'lsaquo;', 'lsquo;', 'lt;', 'macr;', 'mdash;', 'micro;', 'middot;', 'minus;', 'Mu;', 'mu;', 'nabla;', 'nbsp;', 'ndash;', 'ne;', 'ni;', 'not;', 'notin;', 'nsub;', 'Ntilde;', 'ntilde;', 'Nu;', 'nu;', 'Oacute;', 'oacute;', 'Ocirc;', 'ocirc;', 'OElig;', 'oelig;', 'Ograve;', 'ograve;', 'oline;', 'Omega;', 'omega;', 'Omicron;', 'omicron;', 'oplus;', 'or;', 'ordf;', 'ordm;', 'Oslash;', 'oslash;', 'Otilde;', 'otilde;', 'otimes;', 'Ouml;', 'ouml;', 'para;', 'part;', 'permil;', 'perp;', 'Phi;', 'phi;', 'Pi;', 'pi;', 'piv;', 'plusmn;', 'pound;', 'Prime;', 'prime;', 'prod;', 'prop;', 'Psi;', 'psi;', 'quot;', 'radic;', 'rang;', 'raquo;', 'rArr;', 'rarr;', 'rceil;', 'rdquo;', 'real;', 'reg;', 'rfloor;', 'Rho;', 'rho;', 'rlm;', 'rsaquo;', 'rsquo;', 'sbquo;', 'Scaron;', 'scaron;', 'sdot;', 'sect;', 'shy;', 'Sigma;', 'sigma;', 'sigmaf;', 'sim;', 'spades;', 'sub;', 'sube;', 'sum;', 'sup;', 'sup1;', 'sup2;', 'sup3;', 'supe;', 'szlig;', 'Tau;', 'tau;', 'there4;', 'Theta;', 'theta;', 'thetasym;', 'thinsp;', 'THORN;', 'thorn;', 'tilde;', 'times;', 'trade;', 'Uacute;', 'uacute;', 'uArr;', 'uarr;', 'Ucirc;', 'ucirc;', 'Ugrave;', 'ugrave;', 'uml;', 'upsih;', 'Upsilon;', 'upsilon;', 'Uuml;', 'uuml;', 'weierp;', 'Xi;', 'xi;', 'Yacute;', 'yacute;', 'yen;', 'Yuml;', 'yuml;', 'Zeta;', 'zeta;', 'zwj;', 'zwnj;'];
  2163. return values.map(function(value){
  2164. return {
  2165. caption: value,
  2166. snippet: value,
  2167. meta: "html entity",
  2168. score: Number.MAX_VALUE
  2169. };
  2170. });
  2171. };
  2172. }).call(HtmlCompletions.prototype);
  2173. exports.HtmlCompletions = HtmlCompletions;
  2174. });
  2175. ace.define("ace/mode/html",[], function(require, exports, module) {
  2176. "use strict";
  2177. var oop = require("../lib/oop");
  2178. var lang = require("../lib/lang");
  2179. var TextMode = require("./text").Mode;
  2180. var JavaScriptMode = require("./javascript").Mode;
  2181. var CssMode = require("./css").Mode;
  2182. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2183. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  2184. var HtmlFoldMode = require("./folding/html").FoldMode;
  2185. var HtmlCompletions = require("./html_completions").HtmlCompletions;
  2186. var WorkerClient = require("../worker/worker_client").WorkerClient;
  2187. var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
  2188. var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
  2189. var Mode = function(options) {
  2190. this.fragmentContext = options && options.fragmentContext;
  2191. this.HighlightRules = HtmlHighlightRules;
  2192. this.$behaviour = new XmlBehaviour();
  2193. this.$completer = new HtmlCompletions();
  2194. this.createModeDelegates({
  2195. "js-": JavaScriptMode,
  2196. "css-": CssMode
  2197. });
  2198. this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
  2199. };
  2200. oop.inherits(Mode, TextMode);
  2201. (function() {
  2202. this.blockComment = {start: "<!--", end: "-->"};
  2203. this.voidElements = lang.arrayToMap(voidElements);
  2204. this.getNextLineIndent = function(state, line, tab) {
  2205. return this.$getIndent(line);
  2206. };
  2207. this.checkOutdent = function(state, line, input) {
  2208. return false;
  2209. };
  2210. this.getCompletions = function(state, session, pos, prefix) {
  2211. return this.$completer.getCompletions(state, session, pos, prefix);
  2212. };
  2213. this.createWorker = function(session) {
  2214. if (this.constructor != Mode)
  2215. return;
  2216. var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
  2217. worker.attachToDocument(session.getDocument());
  2218. if (this.fragmentContext)
  2219. worker.call("setOptions", [{context: this.fragmentContext}]);
  2220. worker.on("error", function(e) {
  2221. session.setAnnotations(e.data);
  2222. });
  2223. worker.on("terminate", function() {
  2224. session.clearAnnotations();
  2225. });
  2226. return worker;
  2227. };
  2228. this.$id = "ace/mode/html";
  2229. }).call(Mode.prototype);
  2230. exports.Mode = Mode;
  2231. });
  2232. ace.define("ace/mode/markdown_highlight_rules",[], function(require, exports, module) {
  2233. "use strict";
  2234. var oop = require("../lib/oop");
  2235. var lang = require("../lib/lang");
  2236. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  2237. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  2238. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  2239. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2240. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  2241. var escaped = function(ch) {
  2242. return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
  2243. };
  2244. function github_embed(tag, prefix) {
  2245. return { // Github style block
  2246. token : "support.function",
  2247. regex : "^\\s*```" + tag + "\\s*$",
  2248. push : prefix + "start"
  2249. };
  2250. }
  2251. var MarkdownHighlightRules = function() {
  2252. HtmlHighlightRules.call(this);
  2253. this.$rules["start"].unshift({
  2254. token : "empty_line",
  2255. regex : '^$',
  2256. next: "allowBlock"
  2257. }, { // h1
  2258. token: "markup.heading.1",
  2259. regex: "^=+(?=\\s*$)"
  2260. }, { // h2
  2261. token: "markup.heading.2",
  2262. regex: "^\\-+(?=\\s*$)"
  2263. }, {
  2264. token : function(value) {
  2265. return "markup.heading." + value.length;
  2266. },
  2267. regex : /^#{1,6}(?=\s|$)/,
  2268. next : "header"
  2269. },
  2270. github_embed("(?:javascript|js)", "jscode-"),
  2271. github_embed("xml", "xmlcode-"),
  2272. github_embed("html", "htmlcode-"),
  2273. github_embed("css", "csscode-"),
  2274. { // Github style block
  2275. token : "support.function",
  2276. regex : "^\\s*```\\s*\\S*(?:{.*?\\})?\\s*$",
  2277. next : "githubblock"
  2278. }, { // block quote
  2279. token : "string.blockquote",
  2280. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  2281. next : "blockquote"
  2282. }, { // HR * - _
  2283. token : "constant",
  2284. regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
  2285. next: "allowBlock"
  2286. }, { // list
  2287. token : "markup.list",
  2288. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  2289. next : "listblock-start"
  2290. }, {
  2291. include : "basic"
  2292. });
  2293. this.addRules({
  2294. "basic" : [{
  2295. token : "constant.language.escape",
  2296. regex : /\\[\\`*_{}\[\]()#+\-.!]/
  2297. }, { // code span `
  2298. token : "support.function",
  2299. regex : "(`+)(.*?[^`])(\\1)"
  2300. }, { // reference
  2301. token : ["text", "constant", "text", "url", "string", "text"],
  2302. regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
  2303. }, { // link by reference
  2304. token : ["text", "string", "text", "constant", "text"],
  2305. regex : "(\\[)(" + escaped("]") + ")(\\]\\s*\\[)("+ escaped("]") + ")(\\])"
  2306. }, { // link by url
  2307. token : ["text", "string", "text", "markup.underline", "string", "text"],
  2308. regex : "(\\[)(" + // [
  2309. escaped("]") + // link text
  2310. ")(\\]\\()"+ // ](
  2311. '((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
  2312. '(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
  2313. "(\\))" // )
  2314. }, { // strong ** __
  2315. token : "string.strong",
  2316. regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
  2317. }, { // emphasis * _
  2318. token : "string.emphasis",
  2319. regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
  2320. }, { //
  2321. token : ["text", "url", "text"],
  2322. regex : "(<)("+
  2323. "(?:https?|ftp|dict):[^'\">\\s]+"+
  2324. "|"+
  2325. "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
  2326. ")(>)"
  2327. }],
  2328. "allowBlock": [
  2329. {token : "support.function", regex : "^ {4}.+", next : "allowBlock"},
  2330. {token : "empty_line", regex : '^$', next: "allowBlock"},
  2331. {token : "empty", regex : "", next : "start"}
  2332. ],
  2333. "header" : [{
  2334. regex: "$",
  2335. next : "start"
  2336. }, {
  2337. include: "basic"
  2338. }, {
  2339. defaultToken : "heading"
  2340. } ],
  2341. "listblock-start" : [{
  2342. token : "support.variable",
  2343. regex : /(?:\[[ x]\])?/,
  2344. next : "listblock"
  2345. }],
  2346. "listblock" : [ { // Lists only escape on completely blank lines.
  2347. token : "empty_line",
  2348. regex : "^$",
  2349. next : "start"
  2350. }, { // list
  2351. token : "markup.list",
  2352. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  2353. next : "listblock-start"
  2354. }, {
  2355. include : "basic", noEscape: true
  2356. }, { // Github style block
  2357. token : "support.function",
  2358. regex : "^\\s*```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
  2359. next : "githubblock"
  2360. }, {
  2361. defaultToken : "list" //do not use markup.list to allow stling leading `*` differntly
  2362. } ],
  2363. "blockquote" : [ { // Blockquotes only escape on blank lines.
  2364. token : "empty_line",
  2365. regex : "^\\s*$",
  2366. next : "start"
  2367. }, { // block quote
  2368. token : "string.blockquote",
  2369. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  2370. next : "blockquote"
  2371. }, {
  2372. include : "basic", noEscape: true
  2373. }, {
  2374. defaultToken : "string.blockquote"
  2375. } ],
  2376. "githubblock" : [ {
  2377. token : "support.function",
  2378. regex : "^\\s*```",
  2379. next : "start"
  2380. }, {
  2381. defaultToken : "support.function"
  2382. } ]
  2383. });
  2384. this.embedRules(JavaScriptHighlightRules, "jscode-", [{
  2385. token : "support.function",
  2386. regex : "^\\s*```",
  2387. next : "pop"
  2388. }]);
  2389. this.embedRules(HtmlHighlightRules, "htmlcode-", [{
  2390. token : "support.function",
  2391. regex : "^\\s*```",
  2392. next : "pop"
  2393. }]);
  2394. this.embedRules(CssHighlightRules, "csscode-", [{
  2395. token : "support.function",
  2396. regex : "^\\s*```",
  2397. next : "pop"
  2398. }]);
  2399. this.embedRules(XmlHighlightRules, "xmlcode-", [{
  2400. token : "support.function",
  2401. regex : "^\\s*```",
  2402. next : "pop"
  2403. }]);
  2404. this.normalizeRules();
  2405. };
  2406. oop.inherits(MarkdownHighlightRules, TextHighlightRules);
  2407. exports.MarkdownHighlightRules = MarkdownHighlightRules;
  2408. });
  2409. ace.define("ace/mode/folding/markdown",[], function(require, exports, module) {
  2410. "use strict";
  2411. var oop = require("../../lib/oop");
  2412. var BaseFoldMode = require("./fold_mode").FoldMode;
  2413. var Range = require("../../range").Range;
  2414. var FoldMode = exports.FoldMode = function() {};
  2415. oop.inherits(FoldMode, BaseFoldMode);
  2416. (function() {
  2417. this.foldingStartMarker = /^(?:[=-]+\s*$|#{1,6} |`{3})/;
  2418. this.getFoldWidget = function(session, foldStyle, row) {
  2419. var line = session.getLine(row);
  2420. if (!this.foldingStartMarker.test(line))
  2421. return "";
  2422. if (line[0] == "`") {
  2423. if (session.bgTokenizer.getState(row) == "start")
  2424. return "end";
  2425. return "start";
  2426. }
  2427. return "start";
  2428. };
  2429. this.getFoldWidgetRange = function(session, foldStyle, row) {
  2430. var line = session.getLine(row);
  2431. var startColumn = line.length;
  2432. var maxRow = session.getLength();
  2433. var startRow = row;
  2434. var endRow = row;
  2435. if (!line.match(this.foldingStartMarker))
  2436. return;
  2437. if (line[0] == "`") {
  2438. if (session.bgTokenizer.getState(row) !== "start") {
  2439. while (++row < maxRow) {
  2440. line = session.getLine(row);
  2441. if (line[0] == "`" & line.substring(0, 3) == "```")
  2442. break;
  2443. }
  2444. return new Range(startRow, startColumn, row, 0);
  2445. } else {
  2446. while (row -- > 0) {
  2447. line = session.getLine(row);
  2448. if (line[0] == "`" & line.substring(0, 3) == "```")
  2449. break;
  2450. }
  2451. return new Range(row, line.length, startRow, 0);
  2452. }
  2453. }
  2454. var token;
  2455. function isHeading(row) {
  2456. token = session.getTokens(row)[0];
  2457. return token && token.type.lastIndexOf(heading, 0) === 0;
  2458. }
  2459. var heading = "markup.heading";
  2460. function getLevel() {
  2461. var ch = token.value[0];
  2462. if (ch == "=") return 6;
  2463. if (ch == "-") return 5;
  2464. return 7 - token.value.search(/[^#]/);
  2465. }
  2466. if (isHeading(row)) {
  2467. var startHeadingLevel = getLevel();
  2468. while (++row < maxRow) {
  2469. if (!isHeading(row))
  2470. continue;
  2471. var level = getLevel();
  2472. if (level >= startHeadingLevel)
  2473. break;
  2474. }
  2475. endRow = row - (!token || ["=", "-"].indexOf(token.value[0]) == -1 ? 1 : 2);
  2476. if (endRow > startRow) {
  2477. while (endRow > startRow && /^\s*$/.test(session.getLine(endRow)))
  2478. endRow--;
  2479. }
  2480. if (endRow > startRow) {
  2481. var endColumn = session.getLine(endRow).length;
  2482. return new Range(startRow, startColumn, endRow, endColumn);
  2483. }
  2484. }
  2485. };
  2486. }).call(FoldMode.prototype);
  2487. });
  2488. ace.define("ace/mode/markdown",[], function(require, exports, module) {
  2489. "use strict";
  2490. var oop = require("../lib/oop");
  2491. var TextMode = require("./text").Mode;
  2492. var JavaScriptMode = require("./javascript").Mode;
  2493. var XmlMode = require("./xml").Mode;
  2494. var HtmlMode = require("./html").Mode;
  2495. var MarkdownHighlightRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
  2496. var MarkdownFoldMode = require("./folding/markdown").FoldMode;
  2497. var Mode = function() {
  2498. this.HighlightRules = MarkdownHighlightRules;
  2499. this.createModeDelegates({
  2500. "js-": JavaScriptMode,
  2501. "xml-": XmlMode,
  2502. "html-": HtmlMode
  2503. });
  2504. this.foldingRules = new MarkdownFoldMode();
  2505. this.$behaviour = this.$defaultBehaviour;
  2506. };
  2507. oop.inherits(Mode, TextMode);
  2508. (function() {
  2509. this.type = "text";
  2510. this.blockComment = {start: "<!--", end: "-->"};
  2511. this.getNextLineIndent = function(state, line, tab) {
  2512. if (state == "listblock") {
  2513. var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
  2514. if (!match)
  2515. return "";
  2516. var marker = match[2];
  2517. if (!marker)
  2518. marker = parseInt(match[3], 10) + 1 + ".";
  2519. return match[1] + marker + match[4];
  2520. } else {
  2521. return this.$getIndent(line);
  2522. }
  2523. };
  2524. this.$id = "ace/mode/markdown";
  2525. }).call(Mode.prototype);
  2526. exports.Mode = Mode;
  2527. });
  2528. (function() {
  2529. ace.require(["ace/mode/markdown"], function(m) {
  2530. if (typeof module == "object" && typeof exports == "object" && module) {
  2531. module.exports = m;
  2532. }
  2533. });
  2534. })();