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|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  64. "__parent__|__count__|escape|unescape|with|__proto__|" +
  65. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  66. "storage.type":
  67. "const|let|var|function",
  68. "constant.language":
  69. "null|Infinity|NaN|undefined",
  70. "support.function":
  71. "alert",
  72. "constant.language.boolean": "true|false"
  73. }, "identifier");
  74. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  75. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  76. "u[0-9a-fA-F]{4}|" + // unicode
  77. "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
  78. "[0-2][0-7]{0,2}|" + // oct
  79. "3[0-7][0-7]?|" + // oct
  80. "[4-7][0-7]?|" + //oct
  81. ".)";
  82. this.$rules = {
  83. "no_regex" : [
  84. DocCommentHighlightRules.getStartRule("doc-start"),
  85. comments("no_regex"),
  86. {
  87. token : "string",
  88. regex : "'(?=.)",
  89. next : "qstring"
  90. }, {
  91. token : "string",
  92. regex : '"(?=.)',
  93. next : "qqstring"
  94. }, {
  95. token : "constant.numeric", // 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/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 WorkerClient = require("../worker/worker_client").WorkerClient;
  640. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  641. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  642. var Mode = function() {
  643. this.HighlightRules = JavaScriptHighlightRules;
  644. this.$outdent = new MatchingBraceOutdent();
  645. this.$behaviour = new CstyleBehaviour();
  646. this.foldingRules = new CStyleFoldMode();
  647. };
  648. oop.inherits(Mode, TextMode);
  649. (function() {
  650. this.lineCommentStart = "//";
  651. this.blockComment = {start: "/*", end: "*/"};
  652. this.getNextLineIndent = function(state, line, tab) {
  653. var indent = this.$getIndent(line);
  654. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  655. var tokens = tokenizedLine.tokens;
  656. var endState = tokenizedLine.state;
  657. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  658. return indent;
  659. }
  660. if (state == "start" || state == "no_regex") {
  661. var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
  662. if (match) {
  663. indent += tab;
  664. }
  665. } else if (state == "doc-start") {
  666. if (endState == "start" || endState == "no_regex") {
  667. return "";
  668. }
  669. var match = line.match(/^\s*(\/?)\*/);
  670. if (match) {
  671. if (match[1]) {
  672. indent += " ";
  673. }
  674. indent += "* ";
  675. }
  676. }
  677. return indent;
  678. };
  679. this.checkOutdent = function(state, line, input) {
  680. return this.$outdent.checkOutdent(line, input);
  681. };
  682. this.autoOutdent = function(state, doc, row) {
  683. this.$outdent.autoOutdent(doc, row);
  684. };
  685. this.createWorker = function(session) {
  686. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  687. worker.attachToDocument(session.getDocument());
  688. worker.on("annotate", function(results) {
  689. session.setAnnotations(results.data);
  690. });
  691. worker.on("terminate", function() {
  692. session.clearAnnotations();
  693. });
  694. return worker;
  695. };
  696. this.$id = "ace/mode/javascript";
  697. }).call(Mode.prototype);
  698. exports.Mode = Mode;
  699. });
  700. ace.define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  701. "use strict";
  702. var oop = require("../lib/oop");
  703. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  704. var XmlHighlightRules = function(normalize) {
  705. var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*";
  706. this.$rules = {
  707. start : [
  708. {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
  709. {
  710. token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
  711. regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
  712. },
  713. {
  714. token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
  715. regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction"
  716. },
  717. {token : "comment.xml", regex : "<\\!--", next : "comment"},
  718. {
  719. token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
  720. regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
  721. },
  722. {include : "tag"},
  723. {token : "text.end-tag-open.xml", regex: "</"},
  724. {token : "text.tag-open.xml", regex: "<"},
  725. {include : "reference"},
  726. {defaultToken : "text.xml"}
  727. ],
  728. xml_decl : [{
  729. token : "entity.other.attribute-name.decl-attribute-name.xml",
  730. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  731. }, {
  732. token : "keyword.operator.decl-attribute-equals.xml",
  733. regex : "="
  734. }, {
  735. include: "whitespace"
  736. }, {
  737. include: "string"
  738. }, {
  739. token : "punctuation.xml-decl.xml",
  740. regex : "\\?>",
  741. next : "start"
  742. }],
  743. processing_instruction : [
  744. {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
  745. {defaultToken : "instruction.xml"}
  746. ],
  747. doctype : [
  748. {include : "whitespace"},
  749. {include : "string"},
  750. {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
  751. {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
  752. {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
  753. ],
  754. int_subset : [{
  755. token : "text.xml",
  756. regex : "\\s+"
  757. }, {
  758. token: "punctuation.int-subset.xml",
  759. regex: "]",
  760. next: "pop"
  761. }, {
  762. token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
  763. regex : "(<\\!)(" + tagRegex + ")",
  764. push : [{
  765. token : "text",
  766. regex : "\\s+"
  767. },
  768. {
  769. token : "punctuation.markup-decl.xml",
  770. regex : ">",
  771. next : "pop"
  772. },
  773. {include : "string"}]
  774. }],
  775. cdata : [
  776. {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
  777. {token : "text.xml", regex : "\\s+"},
  778. {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
  779. ],
  780. comment : [
  781. {token : "comment.xml", regex : "-->", next : "start"},
  782. {defaultToken : "comment.xml"}
  783. ],
  784. reference : [{
  785. token : "constant.language.escape.reference.xml",
  786. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  787. }],
  788. attr_reference : [{
  789. token : "constant.language.escape.reference.attribute-value.xml",
  790. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  791. }],
  792. tag : [{
  793. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
  794. regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
  795. next: [
  796. {include : "attributes"},
  797. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  798. ]
  799. }],
  800. tag_whitespace : [
  801. {token : "text.tag-whitespace.xml", regex : "\\s+"}
  802. ],
  803. whitespace : [
  804. {token : "text.whitespace.xml", regex : "\\s+"}
  805. ],
  806. string: [{
  807. token : "string.xml",
  808. regex : "'",
  809. push : [
  810. {token : "string.xml", regex: "'", next: "pop"},
  811. {defaultToken : "string.xml"}
  812. ]
  813. }, {
  814. token : "string.xml",
  815. regex : '"',
  816. push : [
  817. {token : "string.xml", regex: '"', next: "pop"},
  818. {defaultToken : "string.xml"}
  819. ]
  820. }],
  821. attributes: [{
  822. token : "entity.other.attribute-name.xml",
  823. regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
  824. }, {
  825. token : "keyword.operator.attribute-equals.xml",
  826. regex : "="
  827. }, {
  828. include: "tag_whitespace"
  829. }, {
  830. include: "attribute_value"
  831. }],
  832. attribute_value: [{
  833. token : "string.attribute-value.xml",
  834. regex : "'",
  835. push : [
  836. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  837. {include : "attr_reference"},
  838. {defaultToken : "string.attribute-value.xml"}
  839. ]
  840. }, {
  841. token : "string.attribute-value.xml",
  842. regex : '"',
  843. push : [
  844. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  845. {include : "attr_reference"},
  846. {defaultToken : "string.attribute-value.xml"}
  847. ]
  848. }]
  849. };
  850. if (this.constructor === XmlHighlightRules)
  851. this.normalizeRules();
  852. };
  853. (function() {
  854. this.embedTagRules = function(HighlightRules, prefix, tag){
  855. this.$rules.tag.unshift({
  856. token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  857. regex : "(<)(" + tag + "(?=\\s|>|$))",
  858. next: [
  859. {include : "attributes"},
  860. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
  861. ]
  862. });
  863. this.$rules[tag + "-end"] = [
  864. {include : "attributes"},
  865. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
  866. onMatch : function(value, currentState, stack) {
  867. stack.splice(0);
  868. return this.token;
  869. }}
  870. ]
  871. this.embedRules(HighlightRules, prefix, [{
  872. token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
  873. regex : "(</)(" + tag + "(?=\\s|>|$))",
  874. next: tag + "-end"
  875. }, {
  876. token: "string.cdata.xml",
  877. regex : "<\\!\\[CDATA\\["
  878. }, {
  879. token: "string.cdata.xml",
  880. regex : "\\]\\]>"
  881. }]);
  882. };
  883. }).call(TextHighlightRules.prototype);
  884. oop.inherits(XmlHighlightRules, TextHighlightRules);
  885. exports.XmlHighlightRules = XmlHighlightRules;
  886. });
  887. 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) {
  888. "use strict";
  889. var oop = require("../../lib/oop");
  890. var Behaviour = require("../behaviour").Behaviour;
  891. var TokenIterator = require("../../token_iterator").TokenIterator;
  892. var lang = require("../../lib/lang");
  893. function is(token, type) {
  894. return token.type.lastIndexOf(type + ".xml") > -1;
  895. }
  896. var XmlBehaviour = function () {
  897. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  898. if (text == '"' || text == "'") {
  899. var quote = text;
  900. var selected = session.doc.getTextRange(editor.getSelectionRange());
  901. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  902. return {
  903. text: quote + selected + quote,
  904. selection: false
  905. };
  906. }
  907. var cursor = editor.getCursorPosition();
  908. var line = session.doc.getLine(cursor.row);
  909. var rightChar = line.substring(cursor.column, cursor.column + 1);
  910. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  911. var token = iterator.getCurrentToken();
  912. if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
  913. return {
  914. text: "",
  915. selection: [1, 1]
  916. };
  917. }
  918. if (!token)
  919. token = iterator.stepBackward();
  920. if (!token)
  921. return;
  922. while (is(token, "tag-whitespace") || is(token, "whitespace")) {
  923. token = iterator.stepBackward();
  924. }
  925. var rightSpace = !rightChar || rightChar.match(/\s/);
  926. if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
  927. return {
  928. text: quote + quote,
  929. selection: [1, 1]
  930. };
  931. }
  932. }
  933. });
  934. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  935. var selected = session.doc.getTextRange(range);
  936. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  937. var line = session.doc.getLine(range.start.row);
  938. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  939. if (rightChar == selected) {
  940. range.end.column++;
  941. return range;
  942. }
  943. }
  944. });
  945. this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
  946. if (text == '>') {
  947. var position = editor.getSelectionRange().start;
  948. var iterator = new TokenIterator(session, position.row, position.column);
  949. var token = iterator.getCurrentToken() || iterator.stepBackward();
  950. if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
  951. return;
  952. if (is(token, "reference.attribute-value"))
  953. return;
  954. if (is(token, "attribute-value")) {
  955. var firstChar = token.value.charAt(0);
  956. if (firstChar == '"' || firstChar == "'") {
  957. var lastChar = token.value.charAt(token.value.length - 1);
  958. var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
  959. if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
  960. return;
  961. }
  962. }
  963. while (!is(token, "tag-name")) {
  964. token = iterator.stepBackward();
  965. if (token.value == "<") {
  966. token = iterator.stepForward();
  967. break;
  968. }
  969. }
  970. var tokenRow = iterator.getCurrentTokenRow();
  971. var tokenColumn = iterator.getCurrentTokenColumn();
  972. if (is(iterator.stepBackward(), "end-tag-open"))
  973. return;
  974. var element = token.value;
  975. if (tokenRow == position.row)
  976. element = element.substring(0, position.column - tokenColumn);
  977. if (this.voidElements.hasOwnProperty(element.toLowerCase()))
  978. return;
  979. return {
  980. text: ">" + "</" + element + ">",
  981. selection: [1, 1]
  982. };
  983. }
  984. });
  985. this.add("autoindent", "insertion", function (state, action, editor, session, text) {
  986. if (text == "\n") {
  987. var cursor = editor.getCursorPosition();
  988. var line = session.getLine(cursor.row);
  989. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  990. var token = iterator.getCurrentToken();
  991. if (token && token.type.indexOf("tag-close") !== -1) {
  992. if (token.value == "/>")
  993. return;
  994. while (token && token.type.indexOf("tag-name") === -1) {
  995. token = iterator.stepBackward();
  996. }
  997. if (!token) {
  998. return;
  999. }
  1000. var tag = token.value;
  1001. var row = iterator.getCurrentTokenRow();
  1002. token = iterator.stepBackward();
  1003. if (!token || token.type.indexOf("end-tag") !== -1) {
  1004. return;
  1005. }
  1006. if (this.voidElements && !this.voidElements[tag]) {
  1007. var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
  1008. var line = session.getLine(row);
  1009. var nextIndent = this.$getIndent(line);
  1010. var indent = nextIndent + session.getTabString();
  1011. if (nextToken && nextToken.value === "</") {
  1012. return {
  1013. text: "\n" + indent + "\n" + nextIndent,
  1014. selection: [1, indent.length, 1, indent.length]
  1015. };
  1016. } else {
  1017. return {
  1018. text: "\n" + indent
  1019. };
  1020. }
  1021. }
  1022. }
  1023. }
  1024. });
  1025. };
  1026. oop.inherits(XmlBehaviour, Behaviour);
  1027. exports.XmlBehaviour = XmlBehaviour;
  1028. });
  1029. 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) {
  1030. "use strict";
  1031. var oop = require("../../lib/oop");
  1032. var lang = require("../../lib/lang");
  1033. var Range = require("../../range").Range;
  1034. var BaseFoldMode = require("./fold_mode").FoldMode;
  1035. var TokenIterator = require("../../token_iterator").TokenIterator;
  1036. var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
  1037. BaseFoldMode.call(this);
  1038. this.voidElements = voidElements || {};
  1039. this.optionalEndTags = oop.mixin({}, this.voidElements);
  1040. if (optionalEndTags)
  1041. oop.mixin(this.optionalEndTags, optionalEndTags);
  1042. };
  1043. oop.inherits(FoldMode, BaseFoldMode);
  1044. var Tag = function() {
  1045. this.tagName = "";
  1046. this.closing = false;
  1047. this.selfClosing = false;
  1048. this.start = {row: 0, column: 0};
  1049. this.end = {row: 0, column: 0};
  1050. };
  1051. function is(token, type) {
  1052. return token.type.lastIndexOf(type + ".xml") > -1;
  1053. }
  1054. (function() {
  1055. this.getFoldWidget = function(session, foldStyle, row) {
  1056. var tag = this._getFirstTagInLine(session, row);
  1057. if (!tag)
  1058. return "";
  1059. if (tag.closing || (!tag.tagName && tag.selfClosing))
  1060. return foldStyle == "markbeginend" ? "end" : "";
  1061. if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
  1062. return "";
  1063. if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
  1064. return "";
  1065. return "start";
  1066. };
  1067. this._getFirstTagInLine = function(session, row) {
  1068. var tokens = session.getTokens(row);
  1069. var tag = new Tag();
  1070. for (var i = 0; i < tokens.length; i++) {
  1071. var token = tokens[i];
  1072. if (is(token, "tag-open")) {
  1073. tag.end.column = tag.start.column + token.value.length;
  1074. tag.closing = is(token, "end-tag-open");
  1075. token = tokens[++i];
  1076. if (!token)
  1077. return null;
  1078. tag.tagName = token.value;
  1079. tag.end.column += token.value.length;
  1080. for (i++; i < tokens.length; i++) {
  1081. token = tokens[i];
  1082. tag.end.column += token.value.length;
  1083. if (is(token, "tag-close")) {
  1084. tag.selfClosing = token.value == '/>';
  1085. break;
  1086. }
  1087. }
  1088. return tag;
  1089. } else if (is(token, "tag-close")) {
  1090. tag.selfClosing = token.value == '/>';
  1091. return tag;
  1092. }
  1093. tag.start.column += token.value.length;
  1094. }
  1095. return null;
  1096. };
  1097. this._findEndTagInLine = function(session, row, tagName, startColumn) {
  1098. var tokens = session.getTokens(row);
  1099. var column = 0;
  1100. for (var i = 0; i < tokens.length; i++) {
  1101. var token = tokens[i];
  1102. column += token.value.length;
  1103. if (column < startColumn)
  1104. continue;
  1105. if (is(token, "end-tag-open")) {
  1106. token = tokens[i + 1];
  1107. if (token && token.value == tagName)
  1108. return true;
  1109. }
  1110. }
  1111. return false;
  1112. };
  1113. this._readTagForward = function(iterator) {
  1114. var token = iterator.getCurrentToken();
  1115. if (!token)
  1116. return null;
  1117. var tag = new Tag();
  1118. do {
  1119. if (is(token, "tag-open")) {
  1120. tag.closing = is(token, "end-tag-open");
  1121. tag.start.row = iterator.getCurrentTokenRow();
  1122. tag.start.column = iterator.getCurrentTokenColumn();
  1123. } else if (is(token, "tag-name")) {
  1124. tag.tagName = token.value;
  1125. } else if (is(token, "tag-close")) {
  1126. tag.selfClosing = token.value == "/>";
  1127. tag.end.row = iterator.getCurrentTokenRow();
  1128. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1129. iterator.stepForward();
  1130. return tag;
  1131. }
  1132. } while(token = iterator.stepForward());
  1133. return null;
  1134. };
  1135. this._readTagBackward = function(iterator) {
  1136. var token = iterator.getCurrentToken();
  1137. if (!token)
  1138. return null;
  1139. var tag = new Tag();
  1140. do {
  1141. if (is(token, "tag-open")) {
  1142. tag.closing = is(token, "end-tag-open");
  1143. tag.start.row = iterator.getCurrentTokenRow();
  1144. tag.start.column = iterator.getCurrentTokenColumn();
  1145. iterator.stepBackward();
  1146. return tag;
  1147. } else if (is(token, "tag-name")) {
  1148. tag.tagName = token.value;
  1149. } else if (is(token, "tag-close")) {
  1150. tag.selfClosing = token.value == "/>";
  1151. tag.end.row = iterator.getCurrentTokenRow();
  1152. tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
  1153. }
  1154. } while(token = iterator.stepBackward());
  1155. return null;
  1156. };
  1157. this._pop = function(stack, tag) {
  1158. while (stack.length) {
  1159. var top = stack[stack.length-1];
  1160. if (!tag || top.tagName == tag.tagName) {
  1161. return stack.pop();
  1162. }
  1163. else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
  1164. stack.pop();
  1165. continue;
  1166. } else {
  1167. return null;
  1168. }
  1169. }
  1170. };
  1171. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1172. var firstTag = this._getFirstTagInLine(session, row);
  1173. if (!firstTag)
  1174. return null;
  1175. var isBackward = firstTag.closing || firstTag.selfClosing;
  1176. var stack = [];
  1177. var tag;
  1178. if (!isBackward) {
  1179. var iterator = new TokenIterator(session, row, firstTag.start.column);
  1180. var start = {
  1181. row: row,
  1182. column: firstTag.start.column + firstTag.tagName.length + 2
  1183. };
  1184. if (firstTag.start.row == firstTag.end.row)
  1185. start.column = firstTag.end.column;
  1186. while (tag = this._readTagForward(iterator)) {
  1187. if (tag.selfClosing) {
  1188. if (!stack.length) {
  1189. tag.start.column += tag.tagName.length + 2;
  1190. tag.end.column -= 2;
  1191. return Range.fromPoints(tag.start, tag.end);
  1192. } else
  1193. continue;
  1194. }
  1195. if (tag.closing) {
  1196. this._pop(stack, tag);
  1197. if (stack.length == 0)
  1198. return Range.fromPoints(start, tag.start);
  1199. }
  1200. else {
  1201. stack.push(tag);
  1202. }
  1203. }
  1204. }
  1205. else {
  1206. var iterator = new TokenIterator(session, row, firstTag.end.column);
  1207. var end = {
  1208. row: row,
  1209. column: firstTag.start.column
  1210. };
  1211. while (tag = this._readTagBackward(iterator)) {
  1212. if (tag.selfClosing) {
  1213. if (!stack.length) {
  1214. tag.start.column += tag.tagName.length + 2;
  1215. tag.end.column -= 2;
  1216. return Range.fromPoints(tag.start, tag.end);
  1217. } else
  1218. continue;
  1219. }
  1220. if (!tag.closing) {
  1221. this._pop(stack, tag);
  1222. if (stack.length == 0) {
  1223. tag.start.column += tag.tagName.length + 2;
  1224. if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
  1225. tag.start.column = tag.end.column;
  1226. return Range.fromPoints(tag.start, end);
  1227. }
  1228. }
  1229. else {
  1230. stack.push(tag);
  1231. }
  1232. }
  1233. }
  1234. };
  1235. }).call(FoldMode.prototype);
  1236. });
  1237. 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) {
  1238. "use strict";
  1239. var oop = require("../lib/oop");
  1240. var lang = require("../lib/lang");
  1241. var TextMode = require("./text").Mode;
  1242. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1243. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  1244. var XmlFoldMode = require("./folding/xml").FoldMode;
  1245. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1246. var Mode = function() {
  1247. this.HighlightRules = XmlHighlightRules;
  1248. this.$behaviour = new XmlBehaviour();
  1249. this.foldingRules = new XmlFoldMode();
  1250. };
  1251. oop.inherits(Mode, TextMode);
  1252. (function() {
  1253. this.voidElements = lang.arrayToMap([]);
  1254. this.blockComment = {start: "<!--", end: "-->"};
  1255. this.createWorker = function(session) {
  1256. var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
  1257. worker.attachToDocument(session.getDocument());
  1258. worker.on("error", function(e) {
  1259. session.setAnnotations(e.data);
  1260. });
  1261. worker.on("terminate", function() {
  1262. session.clearAnnotations();
  1263. });
  1264. return worker;
  1265. };
  1266. this.$id = "ace/mode/xml";
  1267. }).call(Mode.prototype);
  1268. exports.Mode = Mode;
  1269. });
  1270. 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) {
  1271. "use strict";
  1272. var oop = require("../lib/oop");
  1273. var lang = require("../lib/lang");
  1274. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1275. 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";
  1276. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  1277. 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";
  1278. var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
  1279. 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";
  1280. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  1281. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  1282. 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";
  1283. var CssHighlightRules = function() {
  1284. var keywordMapper = this.createKeywordMapper({
  1285. "support.function": supportFunction,
  1286. "support.constant": supportConstant,
  1287. "support.type": supportType,
  1288. "support.constant.color": supportConstantColor,
  1289. "support.constant.fonts": supportConstantFonts
  1290. }, "text", true);
  1291. this.$rules = {
  1292. "start" : [{
  1293. token : "comment", // multi line comment
  1294. regex : "\\/\\*",
  1295. push : "comment"
  1296. }, {
  1297. token: "paren.lparen",
  1298. regex: "\\{",
  1299. push: "ruleset"
  1300. }, {
  1301. token: "string",
  1302. regex: "@.*?{",
  1303. push: "media"
  1304. }, {
  1305. token: "keyword",
  1306. regex: "#[a-z0-9-_]+"
  1307. }, {
  1308. token: "variable",
  1309. regex: "\\.[a-z0-9-_]+"
  1310. }, {
  1311. token: "string",
  1312. regex: ":[a-z0-9-_]+"
  1313. }, {
  1314. token: "constant",
  1315. regex: "[a-z0-9-_]+"
  1316. }, {
  1317. caseInsensitive: true
  1318. }],
  1319. "media" : [{
  1320. token : "comment", // multi line comment
  1321. regex : "\\/\\*",
  1322. push : "comment"
  1323. }, {
  1324. token: "paren.lparen",
  1325. regex: "\\{",
  1326. push: "ruleset"
  1327. }, {
  1328. token: "string",
  1329. regex: "\\}",
  1330. next: "pop"
  1331. }, {
  1332. token: "keyword",
  1333. regex: "#[a-z0-9-_]+"
  1334. }, {
  1335. token: "variable",
  1336. regex: "\\.[a-z0-9-_]+"
  1337. }, {
  1338. token: "string",
  1339. regex: ":[a-z0-9-_]+"
  1340. }, {
  1341. token: "constant",
  1342. regex: "[a-z0-9-_]+"
  1343. }, {
  1344. caseInsensitive: true
  1345. }],
  1346. "comment" : [{
  1347. token : "comment",
  1348. regex : "\\*\\/",
  1349. next : "pop"
  1350. }, {
  1351. defaultToken : "comment"
  1352. }],
  1353. "ruleset" : [
  1354. {
  1355. token : "paren.rparen",
  1356. regex : "\\}",
  1357. next: "pop"
  1358. }, {
  1359. token : "comment", // multi line comment
  1360. regex : "\\/\\*",
  1361. push : "comment"
  1362. }, {
  1363. token : "string", // single line
  1364. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1365. }, {
  1366. token : "string", // single line
  1367. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1368. }, {
  1369. token : ["constant.numeric", "keyword"],
  1370. 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|%)"
  1371. }, {
  1372. token : "constant.numeric",
  1373. regex : numRe
  1374. }, {
  1375. token : "constant.numeric", // hex6 color
  1376. regex : "#[a-f0-9]{6}"
  1377. }, {
  1378. token : "constant.numeric", // hex3 color
  1379. regex : "#[a-f0-9]{3}"
  1380. }, {
  1381. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  1382. regex : pseudoElements
  1383. }, {
  1384. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  1385. regex : pseudoClasses
  1386. }, {
  1387. token : ["support.function", "string", "support.function"],
  1388. regex : "(url\\()(.*)(\\))"
  1389. }, {
  1390. token : keywordMapper,
  1391. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  1392. }, {
  1393. caseInsensitive: true
  1394. }]
  1395. };
  1396. this.normalizeRules();
  1397. };
  1398. oop.inherits(CssHighlightRules, TextHighlightRules);
  1399. exports.CssHighlightRules = CssHighlightRules;
  1400. });
  1401. ace.define("ace/mode/css_completions",["require","exports","module"], function(require, exports, module) {
  1402. "use strict";
  1403. var propertyMap = {
  1404. "background": {"#$0": 1},
  1405. "background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
  1406. "background-image": {"url('/$0')": 1},
  1407. "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
  1408. "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
  1409. "background-attachment": {"scroll": 1, "fixed": 1},
  1410. "background-size": {"cover": 1, "contain": 1},
  1411. "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
  1412. "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
  1413. "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
  1414. "border-color": {"#$0": 1},
  1415. "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
  1416. "border-collapse": {"collapse": 1, "separate": 1},
  1417. "bottom": {"px": 1, "em": 1, "%": 1},
  1418. "clear": {"left": 1, "right": 1, "both": 1, "none": 1},
  1419. "color": {"#$0": 1, "rgb(#$00,0,0)": 1},
  1420. "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},
  1421. "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
  1422. "empty-cells": {"show": 1, "hide": 1},
  1423. "float": {"left": 1, "right": 1, "none": 1},
  1424. "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},
  1425. "font-size": {"px": 1, "em": 1, "%": 1},
  1426. "font-weight": {"bold": 1, "normal": 1},
  1427. "font-style": {"italic": 1, "normal": 1},
  1428. "font-variant": {"normal": 1, "small-caps": 1},
  1429. "height": {"px": 1, "em": 1, "%": 1},
  1430. "left": {"px": 1, "em": 1, "%": 1},
  1431. "letter-spacing": {"normal": 1},
  1432. "line-height": {"normal": 1},
  1433. "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},
  1434. "margin": {"px": 1, "em": 1, "%": 1},
  1435. "margin-right": {"px": 1, "em": 1, "%": 1},
  1436. "margin-left": {"px": 1, "em": 1, "%": 1},
  1437. "margin-top": {"px": 1, "em": 1, "%": 1},
  1438. "margin-bottom": {"px": 1, "em": 1, "%": 1},
  1439. "max-height": {"px": 1, "em": 1, "%": 1},
  1440. "max-width": {"px": 1, "em": 1, "%": 1},
  1441. "min-height": {"px": 1, "em": 1, "%": 1},
  1442. "min-width": {"px": 1, "em": 1, "%": 1},
  1443. "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  1444. "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  1445. "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  1446. "padding": {"px": 1, "em": 1, "%": 1},
  1447. "padding-top": {"px": 1, "em": 1, "%": 1},
  1448. "padding-right": {"px": 1, "em": 1, "%": 1},
  1449. "padding-bottom": {"px": 1, "em": 1, "%": 1},
  1450. "padding-left": {"px": 1, "em": 1, "%": 1},
  1451. "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  1452. "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  1453. "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
  1454. "right": {"px": 1, "em": 1, "%": 1},
  1455. "table-layout": {"fixed": 1, "auto": 1},
  1456. "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
  1457. "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
  1458. "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
  1459. "top": {"px": 1, "em": 1, "%": 1},
  1460. "vertical-align": {"top": 1, "bottom": 1},
  1461. "visibility": {"hidden": 1, "visible": 1},
  1462. "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
  1463. "width": {"px": 1, "em": 1, "%": 1},
  1464. "word-spacing": {"normal": 1},
  1465. "filter": {"alpha(opacity=$0100)": 1},
  1466. "text-shadow": {"$02px 2px 2px #777": 1},
  1467. "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
  1468. "-moz-border-radius": 1,
  1469. "-moz-border-radius-topright": 1,
  1470. "-moz-border-radius-bottomright": 1,
  1471. "-moz-border-radius-topleft": 1,
  1472. "-moz-border-radius-bottomleft": 1,
  1473. "-webkit-border-radius": 1,
  1474. "-webkit-border-top-right-radius": 1,
  1475. "-webkit-border-top-left-radius": 1,
  1476. "-webkit-border-bottom-right-radius": 1,
  1477. "-webkit-border-bottom-left-radius": 1,
  1478. "-moz-box-shadow": 1,
  1479. "-webkit-box-shadow": 1,
  1480. "transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  1481. "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  1482. "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
  1483. };
  1484. var CssCompletions = function() {
  1485. };
  1486. (function() {
  1487. this.completionsDefined = false;
  1488. this.defineCompletions = function() {
  1489. if (document) {
  1490. var style = document.createElement('c').style;
  1491. for (var i in style) {
  1492. if (typeof style[i] !== 'string')
  1493. continue;
  1494. var name = i.replace(/[A-Z]/g, function(x) {
  1495. return '-' + x.toLowerCase();
  1496. });
  1497. if (!propertyMap.hasOwnProperty(name))
  1498. propertyMap[name] = 1;
  1499. }
  1500. }
  1501. this.completionsDefined = true;
  1502. }
  1503. this.getCompletions = function(state, session, pos, prefix) {
  1504. if (!this.completionsDefined) {
  1505. this.defineCompletions();
  1506. }
  1507. var token = session.getTokenAt(pos.row, pos.column);
  1508. if (!token)
  1509. return [];
  1510. if (state==='ruleset'){
  1511. var line = session.getLine(pos.row).substr(0, pos.column);
  1512. if (/:[^;]+$/.test(line)) {
  1513. /([\w\-]+):[^:]*$/.test(line);
  1514. return this.getPropertyValueCompletions(state, session, pos, prefix);
  1515. } else {
  1516. return this.getPropertyCompletions(state, session, pos, prefix);
  1517. }
  1518. }
  1519. return [];
  1520. };
  1521. this.getPropertyCompletions = function(state, session, pos, prefix) {
  1522. var properties = Object.keys(propertyMap);
  1523. return properties.map(function(property){
  1524. return {
  1525. caption: property,
  1526. snippet: property + ': $0',
  1527. meta: "property",
  1528. score: Number.MAX_VALUE
  1529. };
  1530. });
  1531. };
  1532. this.getPropertyValueCompletions = function(state, session, pos, prefix) {
  1533. var line = session.getLine(pos.row).substr(0, pos.column);
  1534. var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
  1535. if (!property)
  1536. return [];
  1537. var values = [];
  1538. if (property in propertyMap && typeof propertyMap[property] === "object") {
  1539. values = Object.keys(propertyMap[property]);
  1540. }
  1541. return values.map(function(value){
  1542. return {
  1543. caption: value,
  1544. snippet: value,
  1545. meta: "property value",
  1546. score: Number.MAX_VALUE
  1547. };
  1548. });
  1549. };
  1550. }).call(CssCompletions.prototype);
  1551. exports.CssCompletions = CssCompletions;
  1552. });
  1553. 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) {
  1554. "use strict";
  1555. var oop = require("../../lib/oop");
  1556. var Behaviour = require("../behaviour").Behaviour;
  1557. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  1558. var TokenIterator = require("../../token_iterator").TokenIterator;
  1559. var CssBehaviour = function () {
  1560. this.inherit(CstyleBehaviour);
  1561. this.add("colon", "insertion", function (state, action, editor, session, text) {
  1562. if (text === ':') {
  1563. var cursor = editor.getCursorPosition();
  1564. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1565. var token = iterator.getCurrentToken();
  1566. if (token && token.value.match(/\s+/)) {
  1567. token = iterator.stepBackward();
  1568. }
  1569. if (token && token.type === 'support.type') {
  1570. var line = session.doc.getLine(cursor.row);
  1571. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1572. if (rightChar === ':') {
  1573. return {
  1574. text: '',
  1575. selection: [1, 1]
  1576. }
  1577. }
  1578. if (!line.substring(cursor.column).match(/^\s*;/)) {
  1579. return {
  1580. text: ':;',
  1581. selection: [1, 1]
  1582. }
  1583. }
  1584. }
  1585. }
  1586. });
  1587. this.add("colon", "deletion", function (state, action, editor, session, range) {
  1588. var selected = session.doc.getTextRange(range);
  1589. if (!range.isMultiLine() && selected === ':') {
  1590. var cursor = editor.getCursorPosition();
  1591. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  1592. var token = iterator.getCurrentToken();
  1593. if (token && token.value.match(/\s+/)) {
  1594. token = iterator.stepBackward();
  1595. }
  1596. if (token && token.type === 'support.type') {
  1597. var line = session.doc.getLine(range.start.row);
  1598. var rightChar = line.substring(range.end.column, range.end.column + 1);
  1599. if (rightChar === ';') {
  1600. range.end.column ++;
  1601. return range;
  1602. }
  1603. }
  1604. }
  1605. });
  1606. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  1607. if (text === ';') {
  1608. var cursor = editor.getCursorPosition();
  1609. var line = session.doc.getLine(cursor.row);
  1610. var rightChar = line.substring(cursor.column, cursor.column + 1);
  1611. if (rightChar === ';') {
  1612. return {
  1613. text: '',
  1614. selection: [1, 1]
  1615. }
  1616. }
  1617. }
  1618. });
  1619. }
  1620. oop.inherits(CssBehaviour, CstyleBehaviour);
  1621. exports.CssBehaviour = CssBehaviour;
  1622. });
  1623. 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) {
  1624. "use strict";
  1625. var oop = require("../lib/oop");
  1626. var TextMode = require("./text").Mode;
  1627. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1628. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  1629. var WorkerClient = require("../worker/worker_client").WorkerClient;
  1630. var CssCompletions = require("./css_completions").CssCompletions;
  1631. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  1632. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  1633. var Mode = function() {
  1634. this.HighlightRules = CssHighlightRules;
  1635. this.$outdent = new MatchingBraceOutdent();
  1636. this.$behaviour = new CssBehaviour();
  1637. this.$completer = new CssCompletions();
  1638. this.foldingRules = new CStyleFoldMode();
  1639. };
  1640. oop.inherits(Mode, TextMode);
  1641. (function() {
  1642. this.foldingRules = "cStyle";
  1643. this.blockComment = {start: "/*", end: "*/"};
  1644. this.getNextLineIndent = function(state, line, tab) {
  1645. var indent = this.$getIndent(line);
  1646. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  1647. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  1648. return indent;
  1649. }
  1650. var match = line.match(/^.*\{\s*$/);
  1651. if (match) {
  1652. indent += tab;
  1653. }
  1654. return indent;
  1655. };
  1656. this.checkOutdent = function(state, line, input) {
  1657. return this.$outdent.checkOutdent(line, input);
  1658. };
  1659. this.autoOutdent = function(state, doc, row) {
  1660. this.$outdent.autoOutdent(doc, row);
  1661. };
  1662. this.getCompletions = function(state, session, pos, prefix) {
  1663. return this.$completer.getCompletions(state, session, pos, prefix);
  1664. };
  1665. this.createWorker = function(session) {
  1666. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  1667. worker.attachToDocument(session.getDocument());
  1668. worker.on("annotate", function(e) {
  1669. session.setAnnotations(e.data);
  1670. });
  1671. worker.on("terminate", function() {
  1672. session.clearAnnotations();
  1673. });
  1674. return worker;
  1675. };
  1676. this.$id = "ace/mode/css";
  1677. }).call(Mode.prototype);
  1678. exports.Mode = Mode;
  1679. });
  1680. 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) {
  1681. "use strict";
  1682. var oop = require("../lib/oop");
  1683. var lang = require("../lib/lang");
  1684. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  1685. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  1686. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  1687. var tagMap = lang.createMap({
  1688. a : 'anchor',
  1689. button : 'form',
  1690. form : 'form',
  1691. img : 'image',
  1692. input : 'form',
  1693. label : 'form',
  1694. option : 'form',
  1695. script : 'script',
  1696. select : 'form',
  1697. textarea : 'form',
  1698. style : 'style',
  1699. table : 'table',
  1700. tbody : 'table',
  1701. td : 'table',
  1702. tfoot : 'table',
  1703. th : 'table',
  1704. tr : 'table'
  1705. });
  1706. var HtmlHighlightRules = function() {
  1707. XmlHighlightRules.call(this);
  1708. this.addRules({
  1709. attributes: [{
  1710. include : "tag_whitespace"
  1711. }, {
  1712. token : "entity.other.attribute-name.xml",
  1713. regex : "[-_a-zA-Z0-9:.]+"
  1714. }, {
  1715. token : "keyword.operator.attribute-equals.xml",
  1716. regex : "=",
  1717. push : [{
  1718. include: "tag_whitespace"
  1719. }, {
  1720. token : "string.unquoted.attribute-value.html",
  1721. regex : "[^<>='\"`\\s]+",
  1722. next : "pop"
  1723. }, {
  1724. token : "empty",
  1725. regex : "",
  1726. next : "pop"
  1727. }]
  1728. }, {
  1729. include : "attribute_value"
  1730. }],
  1731. tag: [{
  1732. token : function(start, tag) {
  1733. var group = tagMap[tag];
  1734. return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml",
  1735. "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"];
  1736. },
  1737. regex : "(</?)([-_a-zA-Z0-9:.]+)",
  1738. next: "tag_stuff"
  1739. }],
  1740. tag_stuff: [
  1741. {include : "attributes"},
  1742. {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
  1743. ]
  1744. });
  1745. this.embedTagRules(CssHighlightRules, "css-", "style");
  1746. this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script");
  1747. if (this.constructor === HtmlHighlightRules)
  1748. this.normalizeRules();
  1749. };
  1750. oop.inherits(HtmlHighlightRules, XmlHighlightRules);
  1751. exports.HtmlHighlightRules = HtmlHighlightRules;
  1752. });
  1753. ace.define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
  1754. "use strict";
  1755. var oop = require("../../lib/oop");
  1756. var BaseFoldMode = require("./fold_mode").FoldMode;
  1757. var FoldMode = exports.FoldMode = function(defaultMode, subModes) {
  1758. this.defaultMode = defaultMode;
  1759. this.subModes = subModes;
  1760. };
  1761. oop.inherits(FoldMode, BaseFoldMode);
  1762. (function() {
  1763. this.$getMode = function(state) {
  1764. if (typeof state != "string")
  1765. state = state[0];
  1766. for (var key in this.subModes) {
  1767. if (state.indexOf(key) === 0)
  1768. return this.subModes[key];
  1769. }
  1770. return null;
  1771. };
  1772. this.$tryMode = function(state, session, foldStyle, row) {
  1773. var mode = this.$getMode(state);
  1774. return (mode ? mode.getFoldWidget(session, foldStyle, row) : "");
  1775. };
  1776. this.getFoldWidget = function(session, foldStyle, row) {
  1777. return (
  1778. this.$tryMode(session.getState(row-1), session, foldStyle, row) ||
  1779. this.$tryMode(session.getState(row), session, foldStyle, row) ||
  1780. this.defaultMode.getFoldWidget(session, foldStyle, row)
  1781. );
  1782. };
  1783. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1784. var mode = this.$getMode(session.getState(row-1));
  1785. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1786. mode = this.$getMode(session.getState(row));
  1787. if (!mode || !mode.getFoldWidget(session, foldStyle, row))
  1788. mode = this.defaultMode;
  1789. return mode.getFoldWidgetRange(session, foldStyle, row);
  1790. };
  1791. }).call(FoldMode.prototype);
  1792. });
  1793. 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) {
  1794. "use strict";
  1795. var oop = require("../../lib/oop");
  1796. var MixedFoldMode = require("./mixed").FoldMode;
  1797. var XmlFoldMode = require("./xml").FoldMode;
  1798. var CStyleFoldMode = require("./cstyle").FoldMode;
  1799. var FoldMode = exports.FoldMode = function(voidElements, optionalTags) {
  1800. MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), {
  1801. "js-": new CStyleFoldMode(),
  1802. "css-": new CStyleFoldMode()
  1803. });
  1804. };
  1805. oop.inherits(FoldMode, MixedFoldMode);
  1806. });
  1807. ace.define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) {
  1808. "use strict";
  1809. var TokenIterator = require("../token_iterator").TokenIterator;
  1810. var commonAttributes = [
  1811. "accesskey",
  1812. "class",
  1813. "contenteditable",
  1814. "contextmenu",
  1815. "dir",
  1816. "draggable",
  1817. "dropzone",
  1818. "hidden",
  1819. "id",
  1820. "inert",
  1821. "itemid",
  1822. "itemprop",
  1823. "itemref",
  1824. "itemscope",
  1825. "itemtype",
  1826. "lang",
  1827. "spellcheck",
  1828. "style",
  1829. "tabindex",
  1830. "title",
  1831. "translate"
  1832. ];
  1833. var eventAttributes = [
  1834. "onabort",
  1835. "onblur",
  1836. "oncancel",
  1837. "oncanplay",
  1838. "oncanplaythrough",
  1839. "onchange",
  1840. "onclick",
  1841. "onclose",
  1842. "oncontextmenu",
  1843. "oncuechange",
  1844. "ondblclick",
  1845. "ondrag",
  1846. "ondragend",
  1847. "ondragenter",
  1848. "ondragleave",
  1849. "ondragover",
  1850. "ondragstart",
  1851. "ondrop",
  1852. "ondurationchange",
  1853. "onemptied",
  1854. "onended",
  1855. "onerror",
  1856. "onfocus",
  1857. "oninput",
  1858. "oninvalid",
  1859. "onkeydown",
  1860. "onkeypress",
  1861. "onkeyup",
  1862. "onload",
  1863. "onloadeddata",
  1864. "onloadedmetadata",
  1865. "onloadstart",
  1866. "onmousedown",
  1867. "onmousemove",
  1868. "onmouseout",
  1869. "onmouseover",
  1870. "onmouseup",
  1871. "onmousewheel",
  1872. "onpause",
  1873. "onplay",
  1874. "onplaying",
  1875. "onprogress",
  1876. "onratechange",
  1877. "onreset",
  1878. "onscroll",
  1879. "onseeked",
  1880. "onseeking",
  1881. "onselect",
  1882. "onshow",
  1883. "onstalled",
  1884. "onsubmit",
  1885. "onsuspend",
  1886. "ontimeupdate",
  1887. "onvolumechange",
  1888. "onwaiting"
  1889. ];
  1890. var globalAttributes = commonAttributes.concat(eventAttributes);
  1891. var attributeMap = {
  1892. "html": {"manifest": 1},
  1893. "head": {},
  1894. "title": {},
  1895. "base": {"href": 1, "target": 1},
  1896. "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},
  1897. "meta": {"http-equiv": {"content-type": 1}, "name": {"description": 1, "keywords": 1}, "content": {"text/html; charset=UTF-8": 1}, "charset": 1},
  1898. "style": {"type": 1, "media": {"all": 1, "screen": 1, "print": 1}, "scoped": 1},
  1899. "script": {"charset": 1, "type": {"text/javascript": 1}, "src": 1, "defer": 1, "async": 1},
  1900. "noscript": {"href": 1},
  1901. "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},
  1902. "section": {},
  1903. "nav": {},
  1904. "article": {"pubdate": 1},
  1905. "aside": {},
  1906. "h1": {},
  1907. "h2": {},
  1908. "h3": {},
  1909. "h4": {},
  1910. "h5": {},
  1911. "h6": {},
  1912. "header": {},
  1913. "footer": {},
  1914. "address": {},
  1915. "main": {},
  1916. "p": {},
  1917. "hr": {},
  1918. "pre": {},
  1919. "blockquote": {"cite": 1},
  1920. "ol": {"start": 1, "reversed": 1},
  1921. "ul": {},
  1922. "li": {"value": 1},
  1923. "dl": {},
  1924. "dt": {},
  1925. "dd": {},
  1926. "figure": {},
  1927. "figcaption": {},
  1928. "div": {},
  1929. "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},
  1930. "em": {},
  1931. "strong": {},
  1932. "small": {},
  1933. "s": {},
  1934. "cite": {},
  1935. "q": {"cite": 1},
  1936. "dfn": {},
  1937. "abbr": {},
  1938. "data": {},
  1939. "time": {"datetime": 1},
  1940. "code": {},
  1941. "var": {},
  1942. "samp": {},
  1943. "kbd": {},
  1944. "sub": {},
  1945. "sup": {},
  1946. "i": {},
  1947. "b": {},
  1948. "u": {},
  1949. "mark": {},
  1950. "ruby": {},
  1951. "rt": {},
  1952. "rp": {},
  1953. "bdi": {},
  1954. "bdo": {},
  1955. "span": {},
  1956. "br": {},
  1957. "wbr": {},
  1958. "ins": {"cite": 1, "datetime": 1},
  1959. "del": {"cite": 1, "datetime": 1},
  1960. "img": {"alt": 1, "src": 1, "height": 1, "width": 1, "usemap": 1, "ismap": 1},
  1961. "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}},
  1962. "embed": {"src": 1, "height": 1, "width": 1, "type": 1},
  1963. "object": {"param": 1, "data": 1, "type": 1, "height" : 1, "width": 1, "usemap": 1, "name": 1, "form": 1, "classid": 1},
  1964. "param": {"name": 1, "value": 1},
  1965. "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}},
  1966. "audio": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1 }},
  1967. "source": {"src": 1, "type": 1, "media": 1},
  1968. "track": {"kind": 1, "src": 1, "srclang": 1, "label": 1, "default": 1},
  1969. "canvas": {"width": 1, "height": 1},
  1970. "map": {"name": 1},
  1971. "area": {"shape": 1, "coords": 1, "href": 1, "hreflang": 1, "alt": 1, "target": 1, "media": 1, "rel": 1, "ping": 1, "type": 1},
  1972. "svg": {},
  1973. "math": {},
  1974. "table": {"summary": 1},
  1975. "caption": {},
  1976. "colgroup": {"span": 1},
  1977. "col": {"span": 1},
  1978. "tbody": {},
  1979. "thead": {},
  1980. "tfoot": {},
  1981. "tr": {},
  1982. "td": {"headers": 1, "rowspan": 1, "colspan": 1},
  1983. "th": {"headers": 1, "rowspan": 1, "colspan": 1, "scope": 1},
  1984. "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}},
  1985. "fieldset": {"disabled": 1, "form": 1, "name": 1},
  1986. "legend": {},
  1987. "label": {"form": 1, "for": 1},
  1988. "input": {
  1989. "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},
  1990. "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},
  1991. "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}},
  1992. "select": {"autofocus": 1, "disabled": 1, "form": 1, "multiple": {"multiple": 1}, "name": 1, "size": 1, "readonly":{"readonly": 1}},
  1993. "datalist": {},
  1994. "optgroup": {"disabled": 1, "label": 1},
  1995. "option": {"disabled": 1, "selected": 1, "label": 1, "value": 1},
  1996. "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}},
  1997. "keygen": {"autofocus": 1, "challenge": {"challenge": 1}, "disabled": {"disabled": 1}, "form": 1, "keytype": {"rsa": 1, "dsa": 1, "ec": 1}, "name": 1},
  1998. "output": {"for": 1, "form": 1, "name": 1},
  1999. "progress": {"value": 1, "max": 1},
  2000. "meter": {"value": 1, "min": 1, "max": 1, "low": 1, "high": 1, "optimum": 1},
  2001. "details": {"open": 1},
  2002. "summary": {},
  2003. "command": {"type": 1, "label": 1, "icon": 1, "disabled": 1, "checked": 1, "radiogroup": 1, "command": 1},
  2004. "menu": {"type": 1, "label": 1},
  2005. "dialog": {"open": 1}
  2006. };
  2007. var elements = Object.keys(attributeMap);
  2008. function is(token, type) {
  2009. return token.type.lastIndexOf(type + ".xml") > -1;
  2010. }
  2011. function findTagName(session, pos) {
  2012. var iterator = new TokenIterator(session, pos.row, pos.column);
  2013. var token = iterator.getCurrentToken();
  2014. while (token && !is(token, "tag-name")){
  2015. token = iterator.stepBackward();
  2016. }
  2017. if (token)
  2018. return token.value;
  2019. }
  2020. function findAttributeName(session, pos) {
  2021. var iterator = new TokenIterator(session, pos.row, pos.column);
  2022. var token = iterator.getCurrentToken();
  2023. while (token && !is(token, "attribute-name")){
  2024. token = iterator.stepBackward();
  2025. }
  2026. if (token)
  2027. return token.value;
  2028. }
  2029. var HtmlCompletions = function() {
  2030. };
  2031. (function() {
  2032. this.getCompletions = function(state, session, pos, prefix) {
  2033. var token = session.getTokenAt(pos.row, pos.column);
  2034. if (!token)
  2035. return [];
  2036. if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open"))
  2037. return this.getTagCompletions(state, session, pos, prefix);
  2038. if (is(token, "tag-whitespace") || is(token, "attribute-name"))
  2039. return this.getAttributeCompletions(state, session, pos, prefix);
  2040. if (is(token, "attribute-value"))
  2041. return this.getAttributeValueCompletions(state, session, pos, prefix);
  2042. var line = session.getLine(pos.row).substr(0, pos.column);
  2043. if (/&[a-z]*$/i.test(line))
  2044. return this.getHTMLEntityCompletions(state, session, pos, prefix);
  2045. return [];
  2046. };
  2047. this.getTagCompletions = function(state, session, pos, prefix) {
  2048. return elements.map(function(element){
  2049. return {
  2050. value: element,
  2051. meta: "tag",
  2052. score: Number.MAX_VALUE
  2053. };
  2054. });
  2055. };
  2056. this.getAttributeCompletions = function(state, session, pos, prefix) {
  2057. var tagName = findTagName(session, pos);
  2058. if (!tagName)
  2059. return [];
  2060. var attributes = globalAttributes;
  2061. if (tagName in attributeMap) {
  2062. attributes = attributes.concat(Object.keys(attributeMap[tagName]));
  2063. }
  2064. return attributes.map(function(attribute){
  2065. return {
  2066. caption: attribute,
  2067. snippet: attribute + '="$0"',
  2068. meta: "attribute",
  2069. score: Number.MAX_VALUE
  2070. };
  2071. });
  2072. };
  2073. this.getAttributeValueCompletions = function(state, session, pos, prefix) {
  2074. var tagName = findTagName(session, pos);
  2075. var attributeName = findAttributeName(session, pos);
  2076. if (!tagName)
  2077. return [];
  2078. var values = [];
  2079. if (tagName in attributeMap && attributeName in attributeMap[tagName] && typeof attributeMap[tagName][attributeName] === "object") {
  2080. values = Object.keys(attributeMap[tagName][attributeName]);
  2081. }
  2082. return values.map(function(value){
  2083. return {
  2084. caption: value,
  2085. snippet: value,
  2086. meta: "attribute value",
  2087. score: Number.MAX_VALUE
  2088. };
  2089. });
  2090. };
  2091. this.getHTMLEntityCompletions = function(state, session, pos, prefix) {
  2092. 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;'];
  2093. return values.map(function(value){
  2094. return {
  2095. caption: value,
  2096. snippet: value,
  2097. meta: "html entity",
  2098. score: Number.MAX_VALUE
  2099. };
  2100. });
  2101. };
  2102. }).call(HtmlCompletions.prototype);
  2103. exports.HtmlCompletions = HtmlCompletions;
  2104. });
  2105. 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) {
  2106. "use strict";
  2107. var oop = require("../lib/oop");
  2108. var lang = require("../lib/lang");
  2109. var TextMode = require("./text").Mode;
  2110. var JavaScriptMode = require("./javascript").Mode;
  2111. var CssMode = require("./css").Mode;
  2112. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2113. var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
  2114. var HtmlFoldMode = require("./folding/html").FoldMode;
  2115. var HtmlCompletions = require("./html_completions").HtmlCompletions;
  2116. var WorkerClient = require("../worker/worker_client").WorkerClient;
  2117. var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
  2118. var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
  2119. var Mode = function(options) {
  2120. this.fragmentContext = options && options.fragmentContext;
  2121. this.HighlightRules = HtmlHighlightRules;
  2122. this.$behaviour = new XmlBehaviour();
  2123. this.$completer = new HtmlCompletions();
  2124. this.createModeDelegates({
  2125. "js-": JavaScriptMode,
  2126. "css-": CssMode
  2127. });
  2128. this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags));
  2129. };
  2130. oop.inherits(Mode, TextMode);
  2131. (function() {
  2132. this.blockComment = {start: "<!--", end: "-->"};
  2133. this.voidElements = lang.arrayToMap(voidElements);
  2134. this.getNextLineIndent = function(state, line, tab) {
  2135. return this.$getIndent(line);
  2136. };
  2137. this.checkOutdent = function(state, line, input) {
  2138. return false;
  2139. };
  2140. this.getCompletions = function(state, session, pos, prefix) {
  2141. return this.$completer.getCompletions(state, session, pos, prefix);
  2142. };
  2143. this.createWorker = function(session) {
  2144. if (this.constructor != Mode)
  2145. return;
  2146. var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker");
  2147. worker.attachToDocument(session.getDocument());
  2148. if (this.fragmentContext)
  2149. worker.call("setOptions", [{context: this.fragmentContext}]);
  2150. worker.on("error", function(e) {
  2151. session.setAnnotations(e.data);
  2152. });
  2153. worker.on("terminate", function() {
  2154. session.clearAnnotations();
  2155. });
  2156. return worker;
  2157. };
  2158. this.$id = "ace/mode/html";
  2159. }).call(Mode.prototype);
  2160. exports.Mode = Mode;
  2161. });
  2162. 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) {
  2163. "use strict";
  2164. var oop = require("../lib/oop");
  2165. var lang = require("../lib/lang");
  2166. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  2167. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  2168. var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
  2169. var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
  2170. var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
  2171. var escaped = function(ch) {
  2172. return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
  2173. }
  2174. function github_embed(tag, prefix) {
  2175. return { // Github style block
  2176. token : "support.function",
  2177. regex : "^\\s*```" + tag + "\\s*$",
  2178. push : prefix + "start"
  2179. };
  2180. }
  2181. var MarkdownHighlightRules = function() {
  2182. HtmlHighlightRules.call(this);
  2183. this.$rules["start"].unshift({
  2184. token : "empty_line",
  2185. regex : '^$',
  2186. next: "allowBlock"
  2187. }, { // h1
  2188. token: "markup.heading.1",
  2189. regex: "^=+(?=\\s*$)"
  2190. }, { // h2
  2191. token: "markup.heading.2",
  2192. regex: "^\\-+(?=\\s*$)"
  2193. }, {
  2194. token : function(value) {
  2195. return "markup.heading." + value.length;
  2196. },
  2197. regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
  2198. next : "header"
  2199. },
  2200. github_embed("(?:javascript|js)", "jscode-"),
  2201. github_embed("xml", "xmlcode-"),
  2202. github_embed("html", "htmlcode-"),
  2203. github_embed("css", "csscode-"),
  2204. { // Github style block
  2205. token : "support.function",
  2206. regex : "^\\s*```\\s*\\S*(?:{.*?\\})?\\s*$",
  2207. next : "githubblock"
  2208. }, { // block quote
  2209. token : "string.blockquote",
  2210. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  2211. next : "blockquote"
  2212. }, { // HR * - _
  2213. token : "constant",
  2214. regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
  2215. next: "allowBlock"
  2216. }, { // list
  2217. token : "markup.list",
  2218. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  2219. next : "listblock-start"
  2220. }, {
  2221. include : "basic"
  2222. });
  2223. this.addRules({
  2224. "basic" : [{
  2225. token : "constant.language.escape",
  2226. regex : /\\[\\`*_{}\[\]()#+\-.!]/
  2227. }, { // code span `
  2228. token : "support.function",
  2229. regex : "(`+)(.*?[^`])(\\1)"
  2230. }, { // reference
  2231. token : ["text", "constant", "text", "url", "string", "text"],
  2232. regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
  2233. }, { // link by reference
  2234. token : ["text", "string", "text", "constant", "text"],
  2235. regex : "(\\[)(" + escaped("]") + ")(\\]\\s*\\[)("+ escaped("]") + ")(\\])"
  2236. }, { // link by url
  2237. token : ["text", "string", "text", "markup.underline", "string", "text"],
  2238. regex : "(\\[)(" + // [
  2239. escaped("]") + // link text
  2240. ")(\\]\\()"+ // ](
  2241. '((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
  2242. '(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
  2243. "(\\))" // )
  2244. }, { // strong ** __
  2245. token : "string.strong",
  2246. regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
  2247. }, { // emphasis * _
  2248. token : "string.emphasis",
  2249. regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
  2250. }, { //
  2251. token : ["text", "url", "text"],
  2252. regex : "(<)("+
  2253. "(?:https?|ftp|dict):[^'\">\\s]+"+
  2254. "|"+
  2255. "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
  2256. ")(>)"
  2257. }],
  2258. "allowBlock": [
  2259. {token : "support.function", regex : "^ {4}.+", next : "allowBlock"},
  2260. {token : "empty_line", regex : '^$', next: "allowBlock"},
  2261. {token : "empty", regex : "", next : "start"}
  2262. ],
  2263. "header" : [{
  2264. regex: "$",
  2265. next : "start"
  2266. }, {
  2267. include: "basic"
  2268. }, {
  2269. defaultToken : "heading"
  2270. } ],
  2271. "listblock-start" : [{
  2272. token : "support.variable",
  2273. regex : /(?:\[[ x]\])?/,
  2274. next : "listblock"
  2275. }],
  2276. "listblock" : [ { // Lists only escape on completely blank lines.
  2277. token : "empty_line",
  2278. regex : "^$",
  2279. next : "start"
  2280. }, { // list
  2281. token : "markup.list",
  2282. regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
  2283. next : "listblock-start"
  2284. }, {
  2285. include : "basic", noEscape: true
  2286. }, { // Github style block
  2287. token : "support.function",
  2288. regex : "^\\s*```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
  2289. next : "githubblock"
  2290. }, {
  2291. defaultToken : "list" //do not use markup.list to allow stling leading `*` differntly
  2292. } ],
  2293. "blockquote" : [ { // Blockquotes only escape on blank lines.
  2294. token : "empty_line",
  2295. regex : "^\\s*$",
  2296. next : "start"
  2297. }, { // block quote
  2298. token : "string.blockquote",
  2299. regex : "^\\s*>\\s*(?:[*+-]|\\d+\\.)?\\s+",
  2300. next : "blockquote"
  2301. }, {
  2302. include : "basic", noEscape: true
  2303. }, {
  2304. defaultToken : "string.blockquote"
  2305. } ],
  2306. "githubblock" : [ {
  2307. token : "support.function",
  2308. regex : "^\\s*```",
  2309. next : "start"
  2310. }, {
  2311. token : "support.function",
  2312. regex : ".+"
  2313. } ]
  2314. });
  2315. this.embedRules(JavaScriptHighlightRules, "jscode-", [{
  2316. token : "support.function",
  2317. regex : "^\\s*```",
  2318. next : "pop"
  2319. }]);
  2320. this.embedRules(HtmlHighlightRules, "htmlcode-", [{
  2321. token : "support.function",
  2322. regex : "^\\s*```",
  2323. next : "pop"
  2324. }]);
  2325. this.embedRules(CssHighlightRules, "csscode-", [{
  2326. token : "support.function",
  2327. regex : "^\\s*```",
  2328. next : "pop"
  2329. }]);
  2330. this.embedRules(XmlHighlightRules, "xmlcode-", [{
  2331. token : "support.function",
  2332. regex : "^\\s*```",
  2333. next : "pop"
  2334. }]);
  2335. this.normalizeRules();
  2336. };
  2337. oop.inherits(MarkdownHighlightRules, TextHighlightRules);
  2338. exports.MarkdownHighlightRules = MarkdownHighlightRules;
  2339. });
  2340. ace.define("ace/mode/folding/markdown",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
  2341. "use strict";
  2342. var oop = require("../../lib/oop");
  2343. var BaseFoldMode = require("./fold_mode").FoldMode;
  2344. var Range = require("../../range").Range;
  2345. var FoldMode = exports.FoldMode = function() {};
  2346. oop.inherits(FoldMode, BaseFoldMode);
  2347. (function() {
  2348. this.foldingStartMarker = /^(?:[=-]+\s*$|#{1,6} |`{3})/;
  2349. this.getFoldWidget = function(session, foldStyle, row) {
  2350. var line = session.getLine(row);
  2351. if (!this.foldingStartMarker.test(line))
  2352. return "";
  2353. if (line[0] == "`") {
  2354. if (session.bgTokenizer.getState(row) == "start")
  2355. return "end";
  2356. return "start";
  2357. }
  2358. return "start";
  2359. };
  2360. this.getFoldWidgetRange = function(session, foldStyle, row) {
  2361. var line = session.getLine(row);
  2362. var startColumn = line.length;
  2363. var maxRow = session.getLength();
  2364. var startRow = row;
  2365. var endRow = row;
  2366. if (!line.match(this.foldingStartMarker))
  2367. return;
  2368. if (line[0] == "`") {
  2369. if (session.bgTokenizer.getState(row) !== "start") {
  2370. while (++row < maxRow) {
  2371. line = session.getLine(row);
  2372. if (line[0] == "`" & line.substring(0, 3) == "```")
  2373. break;
  2374. }
  2375. return new Range(startRow, startColumn, row, 0);
  2376. } else {
  2377. while (row -- > 0) {
  2378. line = session.getLine(row);
  2379. if (line[0] == "`" & line.substring(0, 3) == "```")
  2380. break;
  2381. }
  2382. return new Range(row, line.length, startRow, 0);
  2383. }
  2384. }
  2385. var token;
  2386. function isHeading(row) {
  2387. token = session.getTokens(row)[0];
  2388. return token && token.type.lastIndexOf(heading, 0) === 0;
  2389. }
  2390. var heading = "markup.heading";
  2391. function getLevel() {
  2392. var ch = token.value[0];
  2393. if (ch == "=") return 6;
  2394. if (ch == "-") return 5;
  2395. return 7 - token.value.search(/[^#]/);
  2396. }
  2397. if (isHeading(row)) {
  2398. var startHeadingLevel = getLevel();
  2399. while (++row < maxRow) {
  2400. if (!isHeading(row))
  2401. continue;
  2402. var level = getLevel();
  2403. if (level >= startHeadingLevel)
  2404. break;
  2405. }
  2406. endRow = row - (!token || ["=", "-"].indexOf(token.value[0]) == -1 ? 1 : 2);
  2407. if (endRow > startRow) {
  2408. while (endRow > startRow && /^\s*$/.test(session.getLine(endRow)))
  2409. endRow--;
  2410. }
  2411. if (endRow > startRow) {
  2412. var endColumn = session.getLine(endRow).length;
  2413. return new Range(startRow, startColumn, endRow, endColumn);
  2414. }
  2415. }
  2416. };
  2417. }).call(FoldMode.prototype);
  2418. });
  2419. 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) {
  2420. "use strict";
  2421. var oop = require("../lib/oop");
  2422. var TextMode = require("./text").Mode;
  2423. var JavaScriptMode = require("./javascript").Mode;
  2424. var XmlMode = require("./xml").Mode;
  2425. var HtmlMode = require("./html").Mode;
  2426. var MarkdownHighlightRules = require("./markdown_highlight_rules").MarkdownHighlightRules;
  2427. var MarkdownFoldMode = require("./folding/markdown").FoldMode;
  2428. var Mode = function() {
  2429. this.HighlightRules = MarkdownHighlightRules;
  2430. this.createModeDelegates({
  2431. "js-": JavaScriptMode,
  2432. "xml-": XmlMode,
  2433. "html-": HtmlMode
  2434. });
  2435. this.foldingRules = new MarkdownFoldMode();
  2436. this.$behaviour = this.$defaultBehaviour;
  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. });