mode-markdown.js 101 KB

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