mode-markdown.js 108 KB

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