tinymce_plugins_codesample.js 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338
  1. import {
  2. __commonJS,
  3. init_define_APP_INFO
  4. } from "./chunk-XY75H3MP.js";
  5. // node_modules/tinymce/plugins/codesample/plugin.js
  6. var require_plugin = __commonJS({
  7. "node_modules/tinymce/plugins/codesample/plugin.js"() {
  8. init_define_APP_INFO();
  9. (function() {
  10. "use strict";
  11. var global$2 = tinymce.util.Tools.resolve("tinymce.PluginManager");
  12. var noop = function() {
  13. };
  14. var constant = function(value) {
  15. return function() {
  16. return value;
  17. };
  18. };
  19. var identity = function(x) {
  20. return x;
  21. };
  22. var never = constant(false);
  23. var always = constant(true);
  24. var none = function() {
  25. return NONE;
  26. };
  27. var NONE = function() {
  28. var call = function(thunk) {
  29. return thunk();
  30. };
  31. var id = identity;
  32. var me = {
  33. fold: function(n, _s) {
  34. return n();
  35. },
  36. isSome: never,
  37. isNone: always,
  38. getOr: id,
  39. getOrThunk: call,
  40. getOrDie: function(msg) {
  41. throw new Error(msg || "error: getOrDie called on none.");
  42. },
  43. getOrNull: constant(null),
  44. getOrUndefined: constant(void 0),
  45. or: id,
  46. orThunk: call,
  47. map: none,
  48. each: noop,
  49. bind: none,
  50. exists: never,
  51. forall: always,
  52. filter: function() {
  53. return none();
  54. },
  55. toArray: function() {
  56. return [];
  57. },
  58. toString: constant("none()")
  59. };
  60. return me;
  61. }();
  62. var some = function(a) {
  63. var constant_a = constant(a);
  64. var self2 = function() {
  65. return me;
  66. };
  67. var bind = function(f) {
  68. return f(a);
  69. };
  70. var me = {
  71. fold: function(n, s) {
  72. return s(a);
  73. },
  74. isSome: always,
  75. isNone: never,
  76. getOr: constant_a,
  77. getOrThunk: constant_a,
  78. getOrDie: constant_a,
  79. getOrNull: constant_a,
  80. getOrUndefined: constant_a,
  81. or: self2,
  82. orThunk: self2,
  83. map: function(f) {
  84. return some(f(a));
  85. },
  86. each: function(f) {
  87. f(a);
  88. },
  89. bind,
  90. exists: bind,
  91. forall: bind,
  92. filter: function(f) {
  93. return f(a) ? me : NONE;
  94. },
  95. toArray: function() {
  96. return [a];
  97. },
  98. toString: function() {
  99. return "some(" + a + ")";
  100. }
  101. };
  102. return me;
  103. };
  104. var from = function(value) {
  105. return value === null || value === void 0 ? NONE : some(value);
  106. };
  107. var Optional = {
  108. some,
  109. none,
  110. from
  111. };
  112. var get$1 = function(xs, i) {
  113. return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
  114. };
  115. var head = function(xs) {
  116. return get$1(xs, 0);
  117. };
  118. var someIf = function(b, a) {
  119. return b ? Optional.some(a) : Optional.none();
  120. };
  121. var global$1 = tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");
  122. var isCodeSample = function(elm) {
  123. return elm && elm.nodeName === "PRE" && elm.className.indexOf("language-") !== -1;
  124. };
  125. var trimArg = function(predicateFn) {
  126. return function(arg1, arg2) {
  127. return predicateFn(arg2);
  128. };
  129. };
  130. var Global = typeof window !== "undefined" ? window : Function("return this;")();
  131. var exports$1 = {}, module2 = { exports: exports$1 }, global = {};
  132. (function(define, exports2, module3, require2) {
  133. var oldprism = window.Prism;
  134. window.Prism = { manual: true };
  135. (function(global2, factory) {
  136. typeof exports2 === "object" && typeof module3 !== "undefined" ? module3.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.EphoxContactWrapper = factory());
  137. })(this, function() {
  138. var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  139. var prismCore = { exports: {} };
  140. (function(module4) {
  141. var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
  142. var Prism2 = function(_self2) {
  143. var lang = /\blang(?:uage)?-([\w-]+)\b/i;
  144. var uniqueId = 0;
  145. var plainTextGrammar = {};
  146. var _ = {
  147. manual: _self2.Prism && _self2.Prism.manual,
  148. disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
  149. util: {
  150. encode: function encode(tokens) {
  151. if (tokens instanceof Token) {
  152. return new Token(tokens.type, encode(tokens.content), tokens.alias);
  153. } else if (Array.isArray(tokens)) {
  154. return tokens.map(encode);
  155. } else {
  156. return tokens.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
  157. }
  158. },
  159. type: function(o) {
  160. return Object.prototype.toString.call(o).slice(8, -1);
  161. },
  162. objId: function(obj) {
  163. if (!obj["__id"]) {
  164. Object.defineProperty(obj, "__id", { value: ++uniqueId });
  165. }
  166. return obj["__id"];
  167. },
  168. clone: function deepClone(o, visited) {
  169. visited = visited || {};
  170. var clone;
  171. var id;
  172. switch (_.util.type(o)) {
  173. case "Object":
  174. id = _.util.objId(o);
  175. if (visited[id]) {
  176. return visited[id];
  177. }
  178. clone = {};
  179. visited[id] = clone;
  180. for (var key in o) {
  181. if (o.hasOwnProperty(key)) {
  182. clone[key] = deepClone(o[key], visited);
  183. }
  184. }
  185. return clone;
  186. case "Array":
  187. id = _.util.objId(o);
  188. if (visited[id]) {
  189. return visited[id];
  190. }
  191. clone = [];
  192. visited[id] = clone;
  193. o.forEach(function(v, i) {
  194. clone[i] = deepClone(v, visited);
  195. });
  196. return clone;
  197. default:
  198. return o;
  199. }
  200. },
  201. getLanguage: function(element) {
  202. while (element && !lang.test(element.className)) {
  203. element = element.parentElement;
  204. }
  205. if (element) {
  206. return (element.className.match(lang) || [
  207. ,
  208. "none"
  209. ])[1].toLowerCase();
  210. }
  211. return "none";
  212. },
  213. currentScript: function() {
  214. if (typeof document === "undefined") {
  215. return null;
  216. }
  217. if ("currentScript" in document && 1 < 2) {
  218. return document.currentScript;
  219. }
  220. try {
  221. throw new Error();
  222. } catch (err) {
  223. var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
  224. if (src) {
  225. var scripts = document.getElementsByTagName("script");
  226. for (var i in scripts) {
  227. if (scripts[i].src == src) {
  228. return scripts[i];
  229. }
  230. }
  231. }
  232. return null;
  233. }
  234. },
  235. isActive: function(element, className, defaultActivation) {
  236. var no = "no-" + className;
  237. while (element) {
  238. var classList = element.classList;
  239. if (classList.contains(className)) {
  240. return true;
  241. }
  242. if (classList.contains(no)) {
  243. return false;
  244. }
  245. element = element.parentElement;
  246. }
  247. return !!defaultActivation;
  248. }
  249. },
  250. languages: {
  251. plain: plainTextGrammar,
  252. plaintext: plainTextGrammar,
  253. text: plainTextGrammar,
  254. txt: plainTextGrammar,
  255. extend: function(id, redef) {
  256. var lang2 = _.util.clone(_.languages[id]);
  257. for (var key in redef) {
  258. lang2[key] = redef[key];
  259. }
  260. return lang2;
  261. },
  262. insertBefore: function(inside, before, insert, root) {
  263. root = root || _.languages;
  264. var grammar = root[inside];
  265. var ret = {};
  266. for (var token in grammar) {
  267. if (grammar.hasOwnProperty(token)) {
  268. if (token == before) {
  269. for (var newToken in insert) {
  270. if (insert.hasOwnProperty(newToken)) {
  271. ret[newToken] = insert[newToken];
  272. }
  273. }
  274. }
  275. if (!insert.hasOwnProperty(token)) {
  276. ret[token] = grammar[token];
  277. }
  278. }
  279. }
  280. var old = root[inside];
  281. root[inside] = ret;
  282. _.languages.DFS(_.languages, function(key, value) {
  283. if (value === old && key != inside) {
  284. this[key] = ret;
  285. }
  286. });
  287. return ret;
  288. },
  289. DFS: function DFS(o, callback, type, visited) {
  290. visited = visited || {};
  291. var objId = _.util.objId;
  292. for (var i in o) {
  293. if (o.hasOwnProperty(i)) {
  294. callback.call(o, i, o[i], type || i);
  295. var property = o[i];
  296. var propertyType = _.util.type(property);
  297. if (propertyType === "Object" && !visited[objId(property)]) {
  298. visited[objId(property)] = true;
  299. DFS(property, callback, null, visited);
  300. } else if (propertyType === "Array" && !visited[objId(property)]) {
  301. visited[objId(property)] = true;
  302. DFS(property, callback, i, visited);
  303. }
  304. }
  305. }
  306. }
  307. },
  308. plugins: {},
  309. highlightAll: function(async, callback) {
  310. _.highlightAllUnder(document, async, callback);
  311. },
  312. highlightAllUnder: function(container, async, callback) {
  313. var env = {
  314. callback,
  315. container,
  316. selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
  317. };
  318. _.hooks.run("before-highlightall", env);
  319. env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
  320. _.hooks.run("before-all-elements-highlight", env);
  321. for (var i = 0, element; element = env.elements[i++]; ) {
  322. _.highlightElement(element, async === true, env.callback);
  323. }
  324. },
  325. highlightElement: function(element, async, callback) {
  326. var language = _.util.getLanguage(element);
  327. var grammar = _.languages[language];
  328. element.className = element.className.replace(lang, "").replace(/\s+/g, " ") + " language-" + language;
  329. var parent = element.parentElement;
  330. if (parent && parent.nodeName.toLowerCase() === "pre") {
  331. parent.className = parent.className.replace(lang, "").replace(/\s+/g, " ") + " language-" + language;
  332. }
  333. var code = element.textContent;
  334. var env = {
  335. element,
  336. language,
  337. grammar,
  338. code
  339. };
  340. function insertHighlightedCode(highlightedCode) {
  341. env.highlightedCode = highlightedCode;
  342. _.hooks.run("before-insert", env);
  343. env.element.innerHTML = env.highlightedCode;
  344. _.hooks.run("after-highlight", env);
  345. _.hooks.run("complete", env);
  346. callback && callback.call(env.element);
  347. }
  348. _.hooks.run("before-sanity-check", env);
  349. parent = env.element.parentElement;
  350. if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
  351. parent.setAttribute("tabindex", "0");
  352. }
  353. if (!env.code) {
  354. _.hooks.run("complete", env);
  355. callback && callback.call(env.element);
  356. return;
  357. }
  358. _.hooks.run("before-highlight", env);
  359. if (!env.grammar) {
  360. insertHighlightedCode(_.util.encode(env.code));
  361. return;
  362. }
  363. if (async && _self2.Worker) {
  364. var worker = new Worker(_.filename);
  365. worker.onmessage = function(evt) {
  366. insertHighlightedCode(evt.data);
  367. };
  368. worker.postMessage(JSON.stringify({
  369. language: env.language,
  370. code: env.code,
  371. immediateClose: true
  372. }));
  373. } else {
  374. insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
  375. }
  376. },
  377. highlight: function(text, grammar, language) {
  378. var env = {
  379. code: text,
  380. grammar,
  381. language
  382. };
  383. _.hooks.run("before-tokenize", env);
  384. env.tokens = _.tokenize(env.code, env.grammar);
  385. _.hooks.run("after-tokenize", env);
  386. return Token.stringify(_.util.encode(env.tokens), env.language);
  387. },
  388. tokenize: function(text, grammar) {
  389. var rest = grammar.rest;
  390. if (rest) {
  391. for (var token in rest) {
  392. grammar[token] = rest[token];
  393. }
  394. delete grammar.rest;
  395. }
  396. var tokenList = new LinkedList();
  397. addAfter(tokenList, tokenList.head, text);
  398. matchGrammar(text, tokenList, grammar, tokenList.head, 0);
  399. return toArray(tokenList);
  400. },
  401. hooks: {
  402. all: {},
  403. add: function(name, callback) {
  404. var hooks = _.hooks.all;
  405. hooks[name] = hooks[name] || [];
  406. hooks[name].push(callback);
  407. },
  408. run: function(name, env) {
  409. var callbacks = _.hooks.all[name];
  410. if (!callbacks || !callbacks.length) {
  411. return;
  412. }
  413. for (var i = 0, callback; callback = callbacks[i++]; ) {
  414. callback(env);
  415. }
  416. }
  417. },
  418. Token
  419. };
  420. _self2.Prism = _;
  421. function Token(type, content, alias, matchedStr) {
  422. this.type = type;
  423. this.content = content;
  424. this.alias = alias;
  425. this.length = (matchedStr || "").length | 0;
  426. }
  427. Token.stringify = function stringify(o, language) {
  428. if (typeof o == "string") {
  429. return o;
  430. }
  431. if (Array.isArray(o)) {
  432. var s = "";
  433. o.forEach(function(e) {
  434. s += stringify(e, language);
  435. });
  436. return s;
  437. }
  438. var env = {
  439. type: o.type,
  440. content: stringify(o.content, language),
  441. tag: "span",
  442. classes: [
  443. "token",
  444. o.type
  445. ],
  446. attributes: {},
  447. language
  448. };
  449. var aliases = o.alias;
  450. if (aliases) {
  451. if (Array.isArray(aliases)) {
  452. Array.prototype.push.apply(env.classes, aliases);
  453. } else {
  454. env.classes.push(aliases);
  455. }
  456. }
  457. _.hooks.run("wrap", env);
  458. var attributes = "";
  459. for (var name in env.attributes) {
  460. attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, "&quot;") + '"';
  461. }
  462. return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
  463. };
  464. function matchPattern(pattern, pos, text, lookbehind) {
  465. pattern.lastIndex = pos;
  466. var match = pattern.exec(text);
  467. if (match && lookbehind && match[1]) {
  468. var lookbehindLength = match[1].length;
  469. match.index += lookbehindLength;
  470. match[0] = match[0].slice(lookbehindLength);
  471. }
  472. return match;
  473. }
  474. function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
  475. for (var token in grammar) {
  476. if (!grammar.hasOwnProperty(token) || !grammar[token]) {
  477. continue;
  478. }
  479. var patterns = grammar[token];
  480. patterns = Array.isArray(patterns) ? patterns : [patterns];
  481. for (var j = 0; j < patterns.length; ++j) {
  482. if (rematch && rematch.cause == token + "," + j) {
  483. return;
  484. }
  485. var patternObj = patterns[j];
  486. var inside = patternObj.inside;
  487. var lookbehind = !!patternObj.lookbehind;
  488. var greedy = !!patternObj.greedy;
  489. var alias = patternObj.alias;
  490. if (greedy && !patternObj.pattern.global) {
  491. var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
  492. patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
  493. }
  494. var pattern = patternObj.pattern || patternObj;
  495. for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
  496. if (rematch && pos >= rematch.reach) {
  497. break;
  498. }
  499. var str = currentNode.value;
  500. if (tokenList.length > text.length) {
  501. return;
  502. }
  503. if (str instanceof Token) {
  504. continue;
  505. }
  506. var removeCount = 1;
  507. var match;
  508. if (greedy) {
  509. match = matchPattern(pattern, pos, text, lookbehind);
  510. if (!match) {
  511. break;
  512. }
  513. var from2 = match.index;
  514. var to = match.index + match[0].length;
  515. var p = pos;
  516. p += currentNode.value.length;
  517. while (from2 >= p) {
  518. currentNode = currentNode.next;
  519. p += currentNode.value.length;
  520. }
  521. p -= currentNode.value.length;
  522. pos = p;
  523. if (currentNode.value instanceof Token) {
  524. continue;
  525. }
  526. for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
  527. removeCount++;
  528. p += k.value.length;
  529. }
  530. removeCount--;
  531. str = text.slice(pos, p);
  532. match.index -= pos;
  533. } else {
  534. match = matchPattern(pattern, 0, str, lookbehind);
  535. if (!match) {
  536. continue;
  537. }
  538. }
  539. var from2 = match.index;
  540. var matchStr = match[0];
  541. var before = str.slice(0, from2);
  542. var after = str.slice(from2 + matchStr.length);
  543. var reach = pos + str.length;
  544. if (rematch && reach > rematch.reach) {
  545. rematch.reach = reach;
  546. }
  547. var removeFrom = currentNode.prev;
  548. if (before) {
  549. removeFrom = addAfter(tokenList, removeFrom, before);
  550. pos += before.length;
  551. }
  552. removeRange(tokenList, removeFrom, removeCount);
  553. var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
  554. currentNode = addAfter(tokenList, removeFrom, wrapped);
  555. if (after) {
  556. addAfter(tokenList, currentNode, after);
  557. }
  558. if (removeCount > 1) {
  559. var nestedRematch = {
  560. cause: token + "," + j,
  561. reach
  562. };
  563. matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
  564. if (rematch && nestedRematch.reach > rematch.reach) {
  565. rematch.reach = nestedRematch.reach;
  566. }
  567. }
  568. }
  569. }
  570. }
  571. }
  572. function LinkedList() {
  573. var head2 = {
  574. value: null,
  575. prev: null,
  576. next: null
  577. };
  578. var tail = {
  579. value: null,
  580. prev: head2,
  581. next: null
  582. };
  583. head2.next = tail;
  584. this.head = head2;
  585. this.tail = tail;
  586. this.length = 0;
  587. }
  588. function addAfter(list, node, value) {
  589. var next = node.next;
  590. var newNode = {
  591. value,
  592. prev: node,
  593. next
  594. };
  595. node.next = newNode;
  596. next.prev = newNode;
  597. list.length++;
  598. return newNode;
  599. }
  600. function removeRange(list, node, count) {
  601. var next = node.next;
  602. for (var i = 0; i < count && next !== list.tail; i++) {
  603. next = next.next;
  604. }
  605. node.next = next;
  606. next.prev = node;
  607. list.length -= i;
  608. }
  609. function toArray(list) {
  610. var array = [];
  611. var node = list.head.next;
  612. while (node !== list.tail) {
  613. array.push(node.value);
  614. node = node.next;
  615. }
  616. return array;
  617. }
  618. if (!_self2.document) {
  619. if (!_self2.addEventListener) {
  620. return _;
  621. }
  622. if (!_.disableWorkerMessageHandler) {
  623. _self2.addEventListener("message", function(evt) {
  624. var message = JSON.parse(evt.data);
  625. var lang2 = message.language;
  626. var code = message.code;
  627. var immediateClose = message.immediateClose;
  628. _self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
  629. if (immediateClose) {
  630. _self2.close();
  631. }
  632. }, false);
  633. }
  634. return _;
  635. }
  636. var script = _.util.currentScript();
  637. if (script) {
  638. _.filename = script.src;
  639. if (script.hasAttribute("data-manual")) {
  640. _.manual = true;
  641. }
  642. }
  643. function highlightAutomaticallyCallback() {
  644. if (!_.manual) {
  645. _.highlightAll();
  646. }
  647. }
  648. if (!_.manual) {
  649. var readyState = document.readyState;
  650. if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
  651. document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
  652. } else {
  653. if (window.requestAnimationFrame) {
  654. window.requestAnimationFrame(highlightAutomaticallyCallback);
  655. } else {
  656. window.setTimeout(highlightAutomaticallyCallback, 16);
  657. }
  658. }
  659. }
  660. return _;
  661. }(_self);
  662. if (module4.exports) {
  663. module4.exports = Prism2;
  664. }
  665. if (typeof commonjsGlobal !== "undefined") {
  666. commonjsGlobal.Prism = Prism2;
  667. }
  668. })(prismCore);
  669. Prism.languages.clike = {
  670. "comment": [
  671. {
  672. pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
  673. lookbehind: true,
  674. greedy: true
  675. },
  676. {
  677. pattern: /(^|[^\\:])\/\/.*/,
  678. lookbehind: true,
  679. greedy: true
  680. }
  681. ],
  682. "string": {
  683. pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  684. greedy: true
  685. },
  686. "class-name": {
  687. pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
  688. lookbehind: true,
  689. inside: { "punctuation": /[.\\]/ }
  690. },
  691. "keyword": /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  692. "boolean": /\b(?:true|false)\b/,
  693. "function": /\b\w+(?=\()/,
  694. "number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
  695. "operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
  696. "punctuation": /[{}[\];(),.:]/
  697. };
  698. (function(Prism2) {
  699. function getPlaceholder(language, index) {
  700. return "___" + language.toUpperCase() + index + "___";
  701. }
  702. Object.defineProperties(Prism2.languages["markup-templating"] = {}, {
  703. buildPlaceholders: {
  704. value: function(env, language, placeholderPattern, replaceFilter) {
  705. if (env.language !== language) {
  706. return;
  707. }
  708. var tokenStack = env.tokenStack = [];
  709. env.code = env.code.replace(placeholderPattern, function(match) {
  710. if (typeof replaceFilter === "function" && !replaceFilter(match)) {
  711. return match;
  712. }
  713. var i = tokenStack.length;
  714. var placeholder;
  715. while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
  716. ++i;
  717. }
  718. tokenStack[i] = match;
  719. return placeholder;
  720. });
  721. env.grammar = Prism2.languages.markup;
  722. }
  723. },
  724. tokenizePlaceholders: {
  725. value: function(env, language) {
  726. if (env.language !== language || !env.tokenStack) {
  727. return;
  728. }
  729. env.grammar = Prism2.languages[language];
  730. var j = 0;
  731. var keys = Object.keys(env.tokenStack);
  732. function walkTokens(tokens) {
  733. for (var i = 0; i < tokens.length; i++) {
  734. if (j >= keys.length) {
  735. break;
  736. }
  737. var token = tokens[i];
  738. if (typeof token === "string" || token.content && typeof token.content === "string") {
  739. var k = keys[j];
  740. var t = env.tokenStack[k];
  741. var s = typeof token === "string" ? token : token.content;
  742. var placeholder = getPlaceholder(language, k);
  743. var index = s.indexOf(placeholder);
  744. if (index > -1) {
  745. ++j;
  746. var before = s.substring(0, index);
  747. var middle = new Prism2.Token(language, Prism2.tokenize(t, env.grammar), "language-" + language, t);
  748. var after = s.substring(index + placeholder.length);
  749. var replacement = [];
  750. if (before) {
  751. replacement.push.apply(replacement, walkTokens([before]));
  752. }
  753. replacement.push(middle);
  754. if (after) {
  755. replacement.push.apply(replacement, walkTokens([after]));
  756. }
  757. if (typeof token === "string") {
  758. tokens.splice.apply(tokens, [
  759. i,
  760. 1
  761. ].concat(replacement));
  762. } else {
  763. token.content = replacement;
  764. }
  765. }
  766. } else if (token.content) {
  767. walkTokens(token.content);
  768. }
  769. }
  770. return tokens;
  771. }
  772. walkTokens(env.tokens);
  773. }
  774. }
  775. });
  776. })(Prism);
  777. Prism.languages.c = Prism.languages.extend("clike", {
  778. "comment": {
  779. pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
  780. greedy: true
  781. },
  782. "class-name": {
  783. pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
  784. lookbehind: true
  785. },
  786. "keyword": /\b(?:__attribute__|_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
  787. "function": /\b[a-z_]\w*(?=\s*\()/i,
  788. "number": /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
  789. "operator": />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
  790. });
  791. Prism.languages.insertBefore("c", "string", {
  792. "macro": {
  793. pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
  794. lookbehind: true,
  795. greedy: true,
  796. alias: "property",
  797. inside: {
  798. "string": [
  799. {
  800. pattern: /^(#\s*include\s*)<[^>]+>/,
  801. lookbehind: true
  802. },
  803. Prism.languages.c["string"]
  804. ],
  805. "comment": Prism.languages.c["comment"],
  806. "macro-name": [
  807. {
  808. pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
  809. lookbehind: true
  810. },
  811. {
  812. pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
  813. lookbehind: true,
  814. alias: "function"
  815. }
  816. ],
  817. "directive": {
  818. pattern: /^(#\s*)[a-z]+/,
  819. lookbehind: true,
  820. alias: "keyword"
  821. },
  822. "directive-hash": /^#/,
  823. "punctuation": /##|\\(?=[\r\n])/,
  824. "expression": {
  825. pattern: /\S[\s\S]*/,
  826. inside: Prism.languages.c
  827. }
  828. }
  829. },
  830. "constant": /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
  831. });
  832. delete Prism.languages.c["boolean"];
  833. (function(Prism2) {
  834. var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
  835. var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function() {
  836. return keyword.source;
  837. });
  838. Prism2.languages.cpp = Prism2.languages.extend("c", {
  839. "class-name": [
  840. {
  841. pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g, function() {
  842. return keyword.source;
  843. })),
  844. lookbehind: true
  845. },
  846. /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
  847. /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
  848. /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
  849. ],
  850. "keyword": keyword,
  851. "number": {
  852. pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
  853. greedy: true
  854. },
  855. "operator": />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
  856. "boolean": /\b(?:true|false)\b/
  857. });
  858. Prism2.languages.insertBefore("cpp", "string", {
  859. "module": {
  860. pattern: RegExp(/(\b(?:module|import)\s+)/.source + "(?:" + /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + "|" + /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function() {
  861. return modName;
  862. }) + ")"),
  863. lookbehind: true,
  864. greedy: true,
  865. inside: {
  866. "string": /^[<"][\s\S]+/,
  867. "operator": /:/,
  868. "punctuation": /\./
  869. }
  870. },
  871. "raw-string": {
  872. pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
  873. alias: "string",
  874. greedy: true
  875. }
  876. });
  877. Prism2.languages.insertBefore("cpp", "keyword", {
  878. "generic-function": {
  879. pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
  880. inside: {
  881. "function": /^\w+/,
  882. "generic": {
  883. pattern: /<[\s\S]+/,
  884. alias: "class-name",
  885. inside: Prism2.languages.cpp
  886. }
  887. }
  888. }
  889. });
  890. Prism2.languages.insertBefore("cpp", "operator", {
  891. "double-colon": {
  892. pattern: /::/,
  893. alias: "punctuation"
  894. }
  895. });
  896. Prism2.languages.insertBefore("cpp", "class-name", {
  897. "base-clause": {
  898. pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
  899. lookbehind: true,
  900. greedy: true,
  901. inside: Prism2.languages.extend("cpp", {})
  902. }
  903. });
  904. Prism2.languages.insertBefore("inside", "double-colon", { "class-name": /\b[a-z_]\w*\b(?!\s*::)/i }, Prism2.languages.cpp["base-clause"]);
  905. })(Prism);
  906. (function(Prism2) {
  907. function replace(pattern, replacements) {
  908. return pattern.replace(/<<(\d+)>>/g, function(m, index) {
  909. return "(?:" + replacements[+index] + ")";
  910. });
  911. }
  912. function re(pattern, replacements, flags) {
  913. return RegExp(replace(pattern, replacements), flags || "");
  914. }
  915. function nested(pattern, depthLog2) {
  916. for (var i = 0; i < depthLog2; i++) {
  917. pattern = pattern.replace(/<<self>>/g, function() {
  918. return "(?:" + pattern + ")";
  919. });
  920. }
  921. return pattern.replace(/<<self>>/g, "[^\\s\\S]");
  922. }
  923. var keywordKinds = {
  924. type: "bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",
  925. typeDeclaration: "class enum interface record struct",
  926. contextual: "add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",
  927. other: "abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield"
  928. };
  929. function keywordsToPattern(words) {
  930. return "\\b(?:" + words.trim().replace(/ /g, "|") + ")\\b";
  931. }
  932. var typeDeclarationKeywords = keywordsToPattern(keywordKinds.typeDeclaration);
  933. var keywords = RegExp(keywordsToPattern(keywordKinds.type + " " + keywordKinds.typeDeclaration + " " + keywordKinds.contextual + " " + keywordKinds.other));
  934. var nonTypeKeywords = keywordsToPattern(keywordKinds.typeDeclaration + " " + keywordKinds.contextual + " " + keywordKinds.other);
  935. var nonContextualKeywords = keywordsToPattern(keywordKinds.type + " " + keywordKinds.typeDeclaration + " " + keywordKinds.other);
  936. var generic = nested(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2);
  937. var nestedRound = nested(/\((?:[^()]|<<self>>)*\)/.source, 2);
  938. var name = /@?\b[A-Za-z_]\w*\b/.source;
  939. var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [
  940. name,
  941. generic
  942. ]);
  943. var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [
  944. nonTypeKeywords,
  945. genericName
  946. ]);
  947. var array = /\[\s*(?:,\s*)*\]/.source;
  948. var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [
  949. identifier,
  950. array
  951. ]);
  952. var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [
  953. generic,
  954. nestedRound,
  955. array
  956. ]);
  957. var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
  958. var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [
  959. tuple,
  960. identifier,
  961. array
  962. ]);
  963. var typeInside = {
  964. "keyword": keywords,
  965. "punctuation": /[<>()?,.:[\]]/
  966. };
  967. var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source;
  968. var regularString = /"(?:\\.|[^\\"\r\n])*"/.source;
  969. var verbatimString = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
  970. Prism2.languages.csharp = Prism2.languages.extend("clike", {
  971. "string": [
  972. {
  973. pattern: re(/(^|[^$\\])<<0>>/.source, [verbatimString]),
  974. lookbehind: true,
  975. greedy: true
  976. },
  977. {
  978. pattern: re(/(^|[^@$\\])<<0>>/.source, [regularString]),
  979. lookbehind: true,
  980. greedy: true
  981. },
  982. {
  983. pattern: RegExp(character),
  984. greedy: true,
  985. alias: "character"
  986. }
  987. ],
  988. "class-name": [
  989. {
  990. pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [identifier]),
  991. lookbehind: true,
  992. inside: typeInside
  993. },
  994. {
  995. pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [
  996. name,
  997. typeExpression
  998. ]),
  999. lookbehind: true,
  1000. inside: typeInside
  1001. },
  1002. {
  1003. pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
  1004. lookbehind: true
  1005. },
  1006. {
  1007. pattern: re(/(\b<<0>>\s+)<<1>>/.source, [
  1008. typeDeclarationKeywords,
  1009. genericName
  1010. ]),
  1011. lookbehind: true,
  1012. inside: typeInside
  1013. },
  1014. {
  1015. pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
  1016. lookbehind: true,
  1017. inside: typeInside
  1018. },
  1019. {
  1020. pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
  1021. lookbehind: true
  1022. },
  1023. {
  1024. pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
  1025. lookbehind: true,
  1026. inside: typeInside
  1027. },
  1028. {
  1029. pattern: re(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [
  1030. typeExpression,
  1031. nonContextualKeywords,
  1032. name
  1033. ]),
  1034. inside: typeInside
  1035. }
  1036. ],
  1037. "keyword": keywords,
  1038. "number": /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:ul|lu|[dflmu])?\b/i,
  1039. "operator": />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
  1040. "punctuation": /\?\.?|::|[{}[\];(),.:]/
  1041. });
  1042. Prism2.languages.insertBefore("csharp", "number", {
  1043. "range": {
  1044. pattern: /\.\./,
  1045. alias: "operator"
  1046. }
  1047. });
  1048. Prism2.languages.insertBefore("csharp", "punctuation", {
  1049. "named-parameter": {
  1050. pattern: re(/([(,]\s*)<<0>>(?=\s*:)/.source, [name]),
  1051. lookbehind: true,
  1052. alias: "punctuation"
  1053. }
  1054. });
  1055. Prism2.languages.insertBefore("csharp", "class-name", {
  1056. "namespace": {
  1057. pattern: re(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [name]),
  1058. lookbehind: true,
  1059. inside: { "punctuation": /\./ }
  1060. },
  1061. "type-expression": {
  1062. pattern: re(/(\b(?:default|typeof|sizeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [nestedRound]),
  1063. lookbehind: true,
  1064. alias: "class-name",
  1065. inside: typeInside
  1066. },
  1067. "return-type": {
  1068. pattern: re(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [
  1069. typeExpression,
  1070. identifier
  1071. ]),
  1072. inside: typeInside,
  1073. alias: "class-name"
  1074. },
  1075. "constructor-invocation": {
  1076. pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
  1077. lookbehind: true,
  1078. inside: typeInside,
  1079. alias: "class-name"
  1080. },
  1081. "generic-method": {
  1082. pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [
  1083. name,
  1084. generic
  1085. ]),
  1086. inside: {
  1087. "function": re(/^<<0>>/.source, [name]),
  1088. "generic": {
  1089. pattern: RegExp(generic),
  1090. alias: "class-name",
  1091. inside: typeInside
  1092. }
  1093. }
  1094. },
  1095. "type-list": {
  1096. pattern: re(/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source, [
  1097. typeDeclarationKeywords,
  1098. genericName,
  1099. name,
  1100. typeExpression,
  1101. keywords.source,
  1102. nestedRound,
  1103. /\bnew\s*\(\s*\)/.source
  1104. ]),
  1105. lookbehind: true,
  1106. inside: {
  1107. "record-arguments": {
  1108. pattern: re(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [
  1109. genericName,
  1110. nestedRound
  1111. ]),
  1112. lookbehind: true,
  1113. greedy: true,
  1114. inside: Prism2.languages.csharp
  1115. },
  1116. "keyword": keywords,
  1117. "class-name": {
  1118. pattern: RegExp(typeExpression),
  1119. greedy: true,
  1120. inside: typeInside
  1121. },
  1122. "punctuation": /[,()]/
  1123. }
  1124. },
  1125. "preprocessor": {
  1126. pattern: /(^[\t ]*)#.*/m,
  1127. lookbehind: true,
  1128. alias: "property",
  1129. inside: {
  1130. "directive": {
  1131. pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
  1132. lookbehind: true,
  1133. alias: "keyword"
  1134. }
  1135. }
  1136. }
  1137. });
  1138. var regularStringOrCharacter = regularString + "|" + character;
  1139. var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
  1140. var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
  1141. var attrTarget = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
  1142. var attr = replace(/<<0>>(?:\s*\(<<1>>*\))?/.source, [
  1143. identifier,
  1144. roundExpression
  1145. ]);
  1146. Prism2.languages.insertBefore("csharp", "class-name", {
  1147. "attribute": {
  1148. pattern: re(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [
  1149. attrTarget,
  1150. attr
  1151. ]),
  1152. lookbehind: true,
  1153. greedy: true,
  1154. inside: {
  1155. "target": {
  1156. pattern: re(/^<<0>>(?=\s*:)/.source, [attrTarget]),
  1157. alias: "keyword"
  1158. },
  1159. "attribute-arguments": {
  1160. pattern: re(/\(<<0>>*\)/.source, [roundExpression]),
  1161. inside: Prism2.languages.csharp
  1162. },
  1163. "class-name": {
  1164. pattern: RegExp(identifier),
  1165. inside: { "punctuation": /\./ }
  1166. },
  1167. "punctuation": /[:,]/
  1168. }
  1169. }
  1170. });
  1171. var formatString = /:[^}\r\n]+/.source;
  1172. var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
  1173. var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [
  1174. mInterpolationRound,
  1175. formatString
  1176. ]);
  1177. var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
  1178. var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [
  1179. sInterpolationRound,
  1180. formatString
  1181. ]);
  1182. function createInterpolationInside(interpolation, interpolationRound) {
  1183. return {
  1184. "interpolation": {
  1185. pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
  1186. lookbehind: true,
  1187. inside: {
  1188. "format-string": {
  1189. pattern: re(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [
  1190. interpolationRound,
  1191. formatString
  1192. ]),
  1193. lookbehind: true,
  1194. inside: { "punctuation": /^:/ }
  1195. },
  1196. "punctuation": /^\{|\}$/,
  1197. "expression": {
  1198. pattern: /[\s\S]+/,
  1199. alias: "language-csharp",
  1200. inside: Prism2.languages.csharp
  1201. }
  1202. }
  1203. },
  1204. "string": /[\s\S]+/
  1205. };
  1206. }
  1207. Prism2.languages.insertBefore("csharp", "string", {
  1208. "interpolation-string": [
  1209. {
  1210. pattern: re(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [mInterpolation]),
  1211. lookbehind: true,
  1212. greedy: true,
  1213. inside: createInterpolationInside(mInterpolation, mInterpolationRound)
  1214. },
  1215. {
  1216. pattern: re(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [sInterpolation]),
  1217. lookbehind: true,
  1218. greedy: true,
  1219. inside: createInterpolationInside(sInterpolation, sInterpolationRound)
  1220. }
  1221. ]
  1222. });
  1223. })(Prism);
  1224. Prism.languages.dotnet = Prism.languages.cs = Prism.languages.csharp;
  1225. (function(Prism2) {
  1226. var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
  1227. Prism2.languages.css = {
  1228. "comment": /\/\*[\s\S]*?\*\//,
  1229. "atrule": {
  1230. pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
  1231. inside: {
  1232. "rule": /^@[\w-]+/,
  1233. "selector-function-argument": {
  1234. pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
  1235. lookbehind: true,
  1236. alias: "selector"
  1237. },
  1238. "keyword": {
  1239. pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
  1240. lookbehind: true
  1241. }
  1242. }
  1243. },
  1244. "url": {
  1245. pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
  1246. greedy: true,
  1247. inside: {
  1248. "function": /^url/i,
  1249. "punctuation": /^\(|\)$/,
  1250. "string": {
  1251. pattern: RegExp("^" + string.source + "$"),
  1252. alias: "url"
  1253. }
  1254. }
  1255. },
  1256. "selector": {
  1257. pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
  1258. lookbehind: true
  1259. },
  1260. "string": {
  1261. pattern: string,
  1262. greedy: true
  1263. },
  1264. "property": {
  1265. pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
  1266. lookbehind: true
  1267. },
  1268. "important": /!important\b/i,
  1269. "function": {
  1270. pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
  1271. lookbehind: true
  1272. },
  1273. "punctuation": /[(){};:,]/
  1274. };
  1275. Prism2.languages.css["atrule"].inside.rest = Prism2.languages.css;
  1276. var markup = Prism2.languages.markup;
  1277. if (markup) {
  1278. markup.tag.addInlined("style", "css");
  1279. markup.tag.addAttribute("style", "css");
  1280. }
  1281. })(Prism);
  1282. (function(Prism2) {
  1283. var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
  1284. var classNamePrefix = /(^|[^\w.])(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
  1285. var className = {
  1286. pattern: RegExp(classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
  1287. lookbehind: true,
  1288. inside: {
  1289. "namespace": {
  1290. pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
  1291. inside: { "punctuation": /\./ }
  1292. },
  1293. "punctuation": /\./
  1294. }
  1295. };
  1296. Prism2.languages.java = Prism2.languages.extend("clike", {
  1297. "class-name": [
  1298. className,
  1299. {
  1300. pattern: RegExp(classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()])/.source),
  1301. lookbehind: true,
  1302. inside: className.inside
  1303. }
  1304. ],
  1305. "keyword": keywords,
  1306. "function": [
  1307. Prism2.languages.clike.function,
  1308. {
  1309. pattern: /(::\s*)[a-z_]\w*/,
  1310. lookbehind: true
  1311. }
  1312. ],
  1313. "number": /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
  1314. "operator": {
  1315. pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
  1316. lookbehind: true
  1317. }
  1318. });
  1319. Prism2.languages.insertBefore("java", "string", {
  1320. "triple-quoted-string": {
  1321. pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
  1322. greedy: true,
  1323. alias: "string"
  1324. }
  1325. });
  1326. Prism2.languages.insertBefore("java", "class-name", {
  1327. "annotation": {
  1328. pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
  1329. lookbehind: true,
  1330. alias: "punctuation"
  1331. },
  1332. "generics": {
  1333. pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
  1334. inside: {
  1335. "class-name": className,
  1336. "keyword": keywords,
  1337. "punctuation": /[<>(),.:]/,
  1338. "operator": /[?&|]/
  1339. }
  1340. },
  1341. "namespace": {
  1342. pattern: RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
  1343. return keywords.source;
  1344. })),
  1345. lookbehind: true,
  1346. inside: { "punctuation": /\./ }
  1347. }
  1348. });
  1349. })(Prism);
  1350. Prism.languages.javascript = Prism.languages.extend("clike", {
  1351. "class-name": [
  1352. Prism.languages.clike["class-name"],
  1353. {
  1354. pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:prototype|constructor))/,
  1355. lookbehind: true
  1356. }
  1357. ],
  1358. "keyword": [
  1359. {
  1360. pattern: /((?:^|\})\s*)catch\b/,
  1361. lookbehind: true
  1362. },
  1363. {
  1364. pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
  1365. lookbehind: true
  1366. }
  1367. ],
  1368. "function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
  1369. "number": /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
  1370. "operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
  1371. });
  1372. Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
  1373. Prism.languages.insertBefore("javascript", "keyword", {
  1374. "regex": {
  1375. pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
  1376. lookbehind: true,
  1377. greedy: true,
  1378. inside: {
  1379. "regex-source": {
  1380. pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
  1381. lookbehind: true,
  1382. alias: "language-regex",
  1383. inside: Prism.languages.regex
  1384. },
  1385. "regex-delimiter": /^\/|\/$/,
  1386. "regex-flags": /^[a-z]+$/
  1387. }
  1388. },
  1389. "function-variable": {
  1390. pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
  1391. alias: "function"
  1392. },
  1393. "parameter": [
  1394. {
  1395. pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
  1396. lookbehind: true,
  1397. inside: Prism.languages.javascript
  1398. },
  1399. {
  1400. pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
  1401. lookbehind: true,
  1402. inside: Prism.languages.javascript
  1403. },
  1404. {
  1405. pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
  1406. lookbehind: true,
  1407. inside: Prism.languages.javascript
  1408. },
  1409. {
  1410. pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
  1411. lookbehind: true,
  1412. inside: Prism.languages.javascript
  1413. }
  1414. ],
  1415. "constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
  1416. });
  1417. Prism.languages.insertBefore("javascript", "string", {
  1418. "hashbang": {
  1419. pattern: /^#!.*/,
  1420. greedy: true,
  1421. alias: "comment"
  1422. },
  1423. "template-string": {
  1424. pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
  1425. greedy: true,
  1426. inside: {
  1427. "template-punctuation": {
  1428. pattern: /^`|`$/,
  1429. alias: "string"
  1430. },
  1431. "interpolation": {
  1432. pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
  1433. lookbehind: true,
  1434. inside: {
  1435. "interpolation-punctuation": {
  1436. pattern: /^\$\{|\}$/,
  1437. alias: "punctuation"
  1438. },
  1439. rest: Prism.languages.javascript
  1440. }
  1441. },
  1442. "string": /[\s\S]+/
  1443. }
  1444. }
  1445. });
  1446. if (Prism.languages.markup) {
  1447. Prism.languages.markup.tag.addInlined("script", "javascript");
  1448. Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, "javascript");
  1449. }
  1450. Prism.languages.js = Prism.languages.javascript;
  1451. Prism.languages.markup = {
  1452. "comment": {
  1453. pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
  1454. greedy: true
  1455. },
  1456. "prolog": {
  1457. pattern: /<\?[\s\S]+?\?>/,
  1458. greedy: true
  1459. },
  1460. "doctype": {
  1461. pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
  1462. greedy: true,
  1463. inside: {
  1464. "internal-subset": {
  1465. pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
  1466. lookbehind: true,
  1467. greedy: true,
  1468. inside: null
  1469. },
  1470. "string": {
  1471. pattern: /"[^"]*"|'[^']*'/,
  1472. greedy: true
  1473. },
  1474. "punctuation": /^<!|>$|[[\]]/,
  1475. "doctype-tag": /^DOCTYPE/i,
  1476. "name": /[^\s<>'"]+/
  1477. }
  1478. },
  1479. "cdata": {
  1480. pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
  1481. greedy: true
  1482. },
  1483. "tag": {
  1484. pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
  1485. greedy: true,
  1486. inside: {
  1487. "tag": {
  1488. pattern: /^<\/?[^\s>\/]+/,
  1489. inside: {
  1490. "punctuation": /^<\/?/,
  1491. "namespace": /^[^\s>\/:]+:/
  1492. }
  1493. },
  1494. "special-attr": [],
  1495. "attr-value": {
  1496. pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
  1497. inside: {
  1498. "punctuation": [
  1499. {
  1500. pattern: /^=/,
  1501. alias: "attr-equals"
  1502. },
  1503. /"|'/
  1504. ]
  1505. }
  1506. },
  1507. "punctuation": /\/?>/,
  1508. "attr-name": {
  1509. pattern: /[^\s>\/]+/,
  1510. inside: { "namespace": /^[^\s>\/:]+:/ }
  1511. }
  1512. }
  1513. },
  1514. "entity": [
  1515. {
  1516. pattern: /&[\da-z]{1,8};/i,
  1517. alias: "named-entity"
  1518. },
  1519. /&#x?[\da-f]{1,8};/i
  1520. ]
  1521. };
  1522. Prism.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism.languages.markup["entity"];
  1523. Prism.languages.markup["doctype"].inside["internal-subset"].inside = Prism.languages.markup;
  1524. Prism.hooks.add("wrap", function(env) {
  1525. if (env.type === "entity") {
  1526. env.attributes["title"] = env.content.replace(/&amp;/, "&");
  1527. }
  1528. });
  1529. Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
  1530. value: function addInlined(tagName, lang) {
  1531. var includedCdataInside = {};
  1532. includedCdataInside["language-" + lang] = {
  1533. pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
  1534. lookbehind: true,
  1535. inside: Prism.languages[lang]
  1536. };
  1537. includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
  1538. var inside = {
  1539. "included-cdata": {
  1540. pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
  1541. inside: includedCdataInside
  1542. }
  1543. };
  1544. inside["language-" + lang] = {
  1545. pattern: /[\s\S]+/,
  1546. inside: Prism.languages[lang]
  1547. };
  1548. var def = {};
  1549. def[tagName] = {
  1550. pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
  1551. return tagName;
  1552. }), "i"),
  1553. lookbehind: true,
  1554. greedy: true,
  1555. inside
  1556. };
  1557. Prism.languages.insertBefore("markup", "cdata", def);
  1558. }
  1559. });
  1560. Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
  1561. value: function(attrName, lang) {
  1562. Prism.languages.markup.tag.inside["special-attr"].push({
  1563. pattern: RegExp(/(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, "i"),
  1564. lookbehind: true,
  1565. inside: {
  1566. "attr-name": /^[^\s=]+/,
  1567. "attr-value": {
  1568. pattern: /=[\s\S]+/,
  1569. inside: {
  1570. "value": {
  1571. pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
  1572. lookbehind: true,
  1573. alias: [
  1574. lang,
  1575. "language-" + lang
  1576. ],
  1577. inside: Prism.languages[lang]
  1578. },
  1579. "punctuation": [
  1580. {
  1581. pattern: /^=/,
  1582. alias: "attr-equals"
  1583. },
  1584. /"|'/
  1585. ]
  1586. }
  1587. }
  1588. }
  1589. });
  1590. }
  1591. });
  1592. Prism.languages.html = Prism.languages.markup;
  1593. Prism.languages.mathml = Prism.languages.markup;
  1594. Prism.languages.svg = Prism.languages.markup;
  1595. Prism.languages.xml = Prism.languages.extend("markup", {});
  1596. Prism.languages.ssml = Prism.languages.xml;
  1597. Prism.languages.atom = Prism.languages.xml;
  1598. Prism.languages.rss = Prism.languages.xml;
  1599. (function(Prism2) {
  1600. var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
  1601. var constant2 = [
  1602. {
  1603. pattern: /\b(?:false|true)\b/i,
  1604. alias: "boolean"
  1605. },
  1606. {
  1607. pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
  1608. greedy: true,
  1609. lookbehind: true
  1610. },
  1611. {
  1612. pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
  1613. greedy: true,
  1614. lookbehind: true
  1615. },
  1616. /\b(?:null)\b/i,
  1617. /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/
  1618. ];
  1619. var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
  1620. var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
  1621. var punctuation = /[{}\[\](),:;]/;
  1622. Prism2.languages.php = {
  1623. "delimiter": {
  1624. pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
  1625. alias: "important"
  1626. },
  1627. "comment": comment,
  1628. "variable": /\$+(?:\w+\b|(?=\{))/i,
  1629. "package": {
  1630. pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
  1631. lookbehind: true,
  1632. inside: { "punctuation": /\\/ }
  1633. },
  1634. "class-name-definition": {
  1635. pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
  1636. lookbehind: true,
  1637. alias: "class-name"
  1638. },
  1639. "function-definition": {
  1640. pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
  1641. lookbehind: true,
  1642. alias: "function"
  1643. },
  1644. "keyword": [
  1645. {
  1646. pattern: /(\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array)\b(?=\s*\))/i,
  1647. alias: "type-casting",
  1648. greedy: true,
  1649. lookbehind: true
  1650. },
  1651. {
  1652. pattern: /([(,?]\s*)\b(?:bool|int|float|string|object|array(?!\s*\()|mixed|self|static|callable|iterable|(?:null|false)(?=\s*\|))\b(?=\s*\$)/i,
  1653. alias: "type-hint",
  1654. greedy: true,
  1655. lookbehind: true
  1656. },
  1657. {
  1658. pattern: /([(,?]\s*[\w|]\|\s*)(?:null|false)\b(?=\s*\$)/i,
  1659. alias: "type-hint",
  1660. greedy: true,
  1661. lookbehind: true
  1662. },
  1663. {
  1664. pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:bool|int|float|string|object|void|array(?!\s*\()|mixed|self|static|callable|iterable|(?:null|false)(?=\s*\|))\b/i,
  1665. alias: "return-type",
  1666. greedy: true,
  1667. lookbehind: true
  1668. },
  1669. {
  1670. pattern: /(\)\s*:\s*(?:\?\s*)?[\w|]\|\s*)(?:null|false)\b/i,
  1671. alias: "return-type",
  1672. greedy: true,
  1673. lookbehind: true
  1674. },
  1675. {
  1676. pattern: /\b(?:bool|int|float|string|object|void|array(?!\s*\()|mixed|iterable|(?:null|false)(?=\s*\|))\b/i,
  1677. alias: "type-declaration",
  1678. greedy: true
  1679. },
  1680. {
  1681. pattern: /(\|\s*)(?:null|false)\b/i,
  1682. alias: "type-declaration",
  1683. greedy: true,
  1684. lookbehind: true
  1685. },
  1686. {
  1687. pattern: /\b(?:parent|self|static)(?=\s*::)/i,
  1688. alias: "static-context",
  1689. greedy: true
  1690. },
  1691. {
  1692. pattern: /(\byield\s+)from\b/i,
  1693. lookbehind: true
  1694. },
  1695. /\bclass\b/i,
  1696. {
  1697. pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
  1698. lookbehind: true
  1699. }
  1700. ],
  1701. "argument-name": {
  1702. pattern: /([(,]\s+)\b[a-z_]\w*(?=\s*:(?!:))/i,
  1703. lookbehind: true
  1704. },
  1705. "class-name": [
  1706. {
  1707. pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
  1708. greedy: true,
  1709. lookbehind: true
  1710. },
  1711. {
  1712. pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
  1713. greedy: true,
  1714. lookbehind: true
  1715. },
  1716. {
  1717. pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
  1718. greedy: true
  1719. },
  1720. {
  1721. pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
  1722. alias: "class-name-fully-qualified",
  1723. greedy: true,
  1724. lookbehind: true,
  1725. inside: { "punctuation": /\\/ }
  1726. },
  1727. {
  1728. pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
  1729. alias: "class-name-fully-qualified",
  1730. greedy: true,
  1731. inside: { "punctuation": /\\/ }
  1732. },
  1733. {
  1734. pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
  1735. alias: "class-name-fully-qualified",
  1736. greedy: true,
  1737. lookbehind: true,
  1738. inside: { "punctuation": /\\/ }
  1739. },
  1740. {
  1741. pattern: /\b[a-z_]\w*(?=\s*\$)/i,
  1742. alias: "type-declaration",
  1743. greedy: true
  1744. },
  1745. {
  1746. pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
  1747. alias: [
  1748. "class-name-fully-qualified",
  1749. "type-declaration"
  1750. ],
  1751. greedy: true,
  1752. inside: { "punctuation": /\\/ }
  1753. },
  1754. {
  1755. pattern: /\b[a-z_]\w*(?=\s*::)/i,
  1756. alias: "static-context",
  1757. greedy: true
  1758. },
  1759. {
  1760. pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
  1761. alias: [
  1762. "class-name-fully-qualified",
  1763. "static-context"
  1764. ],
  1765. greedy: true,
  1766. inside: { "punctuation": /\\/ }
  1767. },
  1768. {
  1769. pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
  1770. alias: "type-hint",
  1771. greedy: true,
  1772. lookbehind: true
  1773. },
  1774. {
  1775. pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
  1776. alias: [
  1777. "class-name-fully-qualified",
  1778. "type-hint"
  1779. ],
  1780. greedy: true,
  1781. lookbehind: true,
  1782. inside: { "punctuation": /\\/ }
  1783. },
  1784. {
  1785. pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
  1786. alias: "return-type",
  1787. greedy: true,
  1788. lookbehind: true
  1789. },
  1790. {
  1791. pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
  1792. alias: [
  1793. "class-name-fully-qualified",
  1794. "return-type"
  1795. ],
  1796. greedy: true,
  1797. lookbehind: true,
  1798. inside: { "punctuation": /\\/ }
  1799. }
  1800. ],
  1801. "constant": constant2,
  1802. "function": {
  1803. pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
  1804. lookbehind: true,
  1805. inside: { "punctuation": /\\/ }
  1806. },
  1807. "property": {
  1808. pattern: /(->\s*)\w+/,
  1809. lookbehind: true
  1810. },
  1811. "number": number,
  1812. "operator": operator,
  1813. "punctuation": punctuation
  1814. };
  1815. var string_interpolation = {
  1816. pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
  1817. lookbehind: true,
  1818. inside: Prism2.languages.php
  1819. };
  1820. var string = [
  1821. {
  1822. pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
  1823. alias: "nowdoc-string",
  1824. greedy: true,
  1825. inside: {
  1826. "delimiter": {
  1827. pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
  1828. alias: "symbol",
  1829. inside: { "punctuation": /^<<<'?|[';]$/ }
  1830. }
  1831. }
  1832. },
  1833. {
  1834. pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
  1835. alias: "heredoc-string",
  1836. greedy: true,
  1837. inside: {
  1838. "delimiter": {
  1839. pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
  1840. alias: "symbol",
  1841. inside: { "punctuation": /^<<<"?|[";]$/ }
  1842. },
  1843. "interpolation": string_interpolation
  1844. }
  1845. },
  1846. {
  1847. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  1848. alias: "backtick-quoted-string",
  1849. greedy: true
  1850. },
  1851. {
  1852. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  1853. alias: "single-quoted-string",
  1854. greedy: true
  1855. },
  1856. {
  1857. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  1858. alias: "double-quoted-string",
  1859. greedy: true,
  1860. inside: { "interpolation": string_interpolation }
  1861. }
  1862. ];
  1863. Prism2.languages.insertBefore("php", "variable", {
  1864. "string": string,
  1865. "attribute": {
  1866. pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
  1867. greedy: true,
  1868. inside: {
  1869. "attribute-content": {
  1870. pattern: /^(#\[)[\s\S]+(?=\]$)/,
  1871. lookbehind: true,
  1872. inside: {
  1873. "comment": comment,
  1874. "string": string,
  1875. "attribute-class-name": [
  1876. {
  1877. pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
  1878. alias: "class-name",
  1879. greedy: true,
  1880. lookbehind: true
  1881. },
  1882. {
  1883. pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
  1884. alias: [
  1885. "class-name",
  1886. "class-name-fully-qualified"
  1887. ],
  1888. greedy: true,
  1889. lookbehind: true,
  1890. inside: { "punctuation": /\\/ }
  1891. }
  1892. ],
  1893. "constant": constant2,
  1894. "number": number,
  1895. "operator": operator,
  1896. "punctuation": punctuation
  1897. }
  1898. },
  1899. "delimiter": {
  1900. pattern: /^#\[|\]$/,
  1901. alias: "punctuation"
  1902. }
  1903. }
  1904. }
  1905. });
  1906. Prism2.hooks.add("before-tokenize", function(env) {
  1907. if (!/<\?/.test(env.code)) {
  1908. return;
  1909. }
  1910. var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/gi;
  1911. Prism2.languages["markup-templating"].buildPlaceholders(env, "php", phpPattern);
  1912. });
  1913. Prism2.hooks.add("after-tokenize", function(env) {
  1914. Prism2.languages["markup-templating"].tokenizePlaceholders(env, "php");
  1915. });
  1916. })(Prism);
  1917. Prism.languages.python = {
  1918. "comment": {
  1919. pattern: /(^|[^\\])#.*/,
  1920. lookbehind: true
  1921. },
  1922. "string-interpolation": {
  1923. pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
  1924. greedy: true,
  1925. inside: {
  1926. "interpolation": {
  1927. pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
  1928. lookbehind: true,
  1929. inside: {
  1930. "format-spec": {
  1931. pattern: /(:)[^:(){}]+(?=\}$)/,
  1932. lookbehind: true
  1933. },
  1934. "conversion-option": {
  1935. pattern: /![sra](?=[:}]$)/,
  1936. alias: "punctuation"
  1937. },
  1938. rest: null
  1939. }
  1940. },
  1941. "string": /[\s\S]+/
  1942. }
  1943. },
  1944. "triple-quoted-string": {
  1945. pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,
  1946. greedy: true,
  1947. alias: "string"
  1948. },
  1949. "string": {
  1950. pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
  1951. greedy: true
  1952. },
  1953. "function": {
  1954. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
  1955. lookbehind: true
  1956. },
  1957. "class-name": {
  1958. pattern: /(\bclass\s+)\w+/i,
  1959. lookbehind: true
  1960. },
  1961. "decorator": {
  1962. pattern: /(^[\t ]*)@\w+(?:\.\w+)*/im,
  1963. lookbehind: true,
  1964. alias: [
  1965. "annotation",
  1966. "punctuation"
  1967. ],
  1968. inside: { "punctuation": /\./ }
  1969. },
  1970. "keyword": /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
  1971. "builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
  1972. "boolean": /\b(?:True|False|None)\b/,
  1973. "number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?\b/i,
  1974. "operator": /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  1975. "punctuation": /[{}[\];(),.:]/
  1976. };
  1977. Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
  1978. Prism.languages.py = Prism.languages.python;
  1979. (function(Prism2) {
  1980. Prism2.languages.ruby = Prism2.languages.extend("clike", {
  1981. "comment": [
  1982. /#.*/,
  1983. {
  1984. pattern: /^=begin\s[\s\S]*?^=end/m,
  1985. greedy: true
  1986. }
  1987. ],
  1988. "class-name": {
  1989. pattern: /(\b(?:class)\s+|\bcatch\s+\()[\w.\\]+/i,
  1990. lookbehind: true,
  1991. inside: { "punctuation": /[.\\]/ }
  1992. },
  1993. "keyword": /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/
  1994. });
  1995. var interpolation = {
  1996. pattern: /#\{[^}]+\}/,
  1997. inside: {
  1998. "delimiter": {
  1999. pattern: /^#\{|\}$/,
  2000. alias: "tag"
  2001. },
  2002. rest: Prism2.languages.ruby
  2003. }
  2004. };
  2005. delete Prism2.languages.ruby.function;
  2006. Prism2.languages.insertBefore("ruby", "keyword", {
  2007. "regex": [
  2008. {
  2009. pattern: RegExp(/%r/.source + "(?:" + [
  2010. /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
  2011. /\((?:[^()\\]|\\[\s\S])*\)/.source,
  2012. /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source,
  2013. /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source,
  2014. /<(?:[^<>\\]|\\[\s\S])*>/.source
  2015. ].join("|") + ")" + /[egimnosux]{0,6}/.source),
  2016. greedy: true,
  2017. inside: { "interpolation": interpolation }
  2018. },
  2019. {
  2020. pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
  2021. lookbehind: true,
  2022. greedy: true,
  2023. inside: { "interpolation": interpolation }
  2024. }
  2025. ],
  2026. "variable": /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
  2027. "symbol": {
  2028. pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
  2029. lookbehind: true
  2030. },
  2031. "method-definition": {
  2032. pattern: /(\bdef\s+)[\w.]+/,
  2033. lookbehind: true,
  2034. inside: {
  2035. "function": /\w+$/,
  2036. rest: Prism2.languages.ruby
  2037. }
  2038. }
  2039. });
  2040. Prism2.languages.insertBefore("ruby", "number", {
  2041. "builtin": /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
  2042. "constant": /\b[A-Z]\w*(?:[?!]|\b)/
  2043. });
  2044. Prism2.languages.ruby.string = [
  2045. {
  2046. pattern: RegExp(/%[qQiIwWxs]?/.source + "(?:" + [
  2047. /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
  2048. /\((?:[^()\\]|\\[\s\S])*\)/.source,
  2049. /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source,
  2050. /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source,
  2051. /<(?:[^<>\\]|\\[\s\S])*>/.source
  2052. ].join("|") + ")"),
  2053. greedy: true,
  2054. inside: { "interpolation": interpolation }
  2055. },
  2056. {
  2057. pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
  2058. greedy: true,
  2059. inside: { "interpolation": interpolation }
  2060. },
  2061. {
  2062. pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
  2063. alias: "heredoc-string",
  2064. greedy: true,
  2065. inside: {
  2066. "delimiter": {
  2067. pattern: /^<<[-~]?[a-z_]\w*|[a-z_]\w*$/i,
  2068. alias: "symbol",
  2069. inside: { "punctuation": /^<<[-~]?/ }
  2070. },
  2071. "interpolation": interpolation
  2072. }
  2073. },
  2074. {
  2075. pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
  2076. alias: "heredoc-string",
  2077. greedy: true,
  2078. inside: {
  2079. "delimiter": {
  2080. pattern: /^<<[-~]?'[a-z_]\w*'|[a-z_]\w*$/i,
  2081. alias: "symbol",
  2082. inside: { "punctuation": /^<<[-~]?'|'$/ }
  2083. }
  2084. }
  2085. }
  2086. ];
  2087. Prism2.languages.rb = Prism2.languages.ruby;
  2088. })(Prism);
  2089. var Prism$12 = prismCore.exports;
  2090. var prismjs = { boltExport: Prism$12 };
  2091. return prismjs;
  2092. });
  2093. var prism = window.Prism;
  2094. window.Prism = oldprism;
  2095. return prism;
  2096. })(void 0, exports$1, module2);
  2097. var Prism$1 = module2.exports.boltExport;
  2098. var getLanguages$1 = function(editor) {
  2099. return editor.getParam("codesample_languages");
  2100. };
  2101. var useGlobalPrismJS = function(editor) {
  2102. return editor.getParam("codesample_global_prismjs", false, "boolean");
  2103. };
  2104. var get = function(editor) {
  2105. return Global.Prism && useGlobalPrismJS(editor) ? Global.Prism : Prism$1;
  2106. };
  2107. var getSelectedCodeSample = function(editor) {
  2108. var node = editor.selection ? editor.selection.getNode() : null;
  2109. return someIf(isCodeSample(node), node);
  2110. };
  2111. var insertCodeSample = function(editor, language, code) {
  2112. editor.undoManager.transact(function() {
  2113. var node = getSelectedCodeSample(editor);
  2114. code = global$1.DOM.encode(code);
  2115. return node.fold(function() {
  2116. editor.insertContent('<pre id="__new" class="language-' + language + '">' + code + "</pre>");
  2117. editor.selection.select(editor.$("#__new").removeAttr("id")[0]);
  2118. }, function(n) {
  2119. editor.dom.setAttrib(n, "class", "language-" + language);
  2120. n.innerHTML = code;
  2121. get(editor).highlightElement(n);
  2122. editor.selection.select(n);
  2123. });
  2124. });
  2125. };
  2126. var getCurrentCode = function(editor) {
  2127. var node = getSelectedCodeSample(editor);
  2128. return node.fold(constant(""), function(n) {
  2129. return n.textContent;
  2130. });
  2131. };
  2132. var getLanguages = function(editor) {
  2133. var defaultLanguages = [
  2134. {
  2135. text: "HTML/XML",
  2136. value: "markup"
  2137. },
  2138. {
  2139. text: "JavaScript",
  2140. value: "javascript"
  2141. },
  2142. {
  2143. text: "CSS",
  2144. value: "css"
  2145. },
  2146. {
  2147. text: "PHP",
  2148. value: "php"
  2149. },
  2150. {
  2151. text: "Ruby",
  2152. value: "ruby"
  2153. },
  2154. {
  2155. text: "Python",
  2156. value: "python"
  2157. },
  2158. {
  2159. text: "Java",
  2160. value: "java"
  2161. },
  2162. {
  2163. text: "C",
  2164. value: "c"
  2165. },
  2166. {
  2167. text: "C#",
  2168. value: "csharp"
  2169. },
  2170. {
  2171. text: "C++",
  2172. value: "cpp"
  2173. }
  2174. ];
  2175. var customLanguages = getLanguages$1(editor);
  2176. return customLanguages ? customLanguages : defaultLanguages;
  2177. };
  2178. var getCurrentLanguage = function(editor, fallback) {
  2179. var node = getSelectedCodeSample(editor);
  2180. return node.fold(function() {
  2181. return fallback;
  2182. }, function(n) {
  2183. var matches = n.className.match(/language-(\w+)/);
  2184. return matches ? matches[1] : fallback;
  2185. });
  2186. };
  2187. var open = function(editor) {
  2188. var languages = getLanguages(editor);
  2189. var defaultLanguage = head(languages).fold(constant(""), function(l) {
  2190. return l.value;
  2191. });
  2192. var currentLanguage = getCurrentLanguage(editor, defaultLanguage);
  2193. var currentCode = getCurrentCode(editor);
  2194. editor.windowManager.open({
  2195. title: "Insert/Edit Code Sample",
  2196. size: "large",
  2197. body: {
  2198. type: "panel",
  2199. items: [
  2200. {
  2201. type: "selectbox",
  2202. name: "language",
  2203. label: "Language",
  2204. items: languages
  2205. },
  2206. {
  2207. type: "textarea",
  2208. name: "code",
  2209. label: "Code view"
  2210. }
  2211. ]
  2212. },
  2213. buttons: [
  2214. {
  2215. type: "cancel",
  2216. name: "cancel",
  2217. text: "Cancel"
  2218. },
  2219. {
  2220. type: "submit",
  2221. name: "save",
  2222. text: "Save",
  2223. primary: true
  2224. }
  2225. ],
  2226. initialData: {
  2227. language: currentLanguage,
  2228. code: currentCode
  2229. },
  2230. onSubmit: function(api) {
  2231. var data = api.getData();
  2232. insertCodeSample(editor, data.language, data.code);
  2233. api.close();
  2234. }
  2235. });
  2236. };
  2237. var register$1 = function(editor) {
  2238. editor.addCommand("codesample", function() {
  2239. var node = editor.selection.getNode();
  2240. if (editor.selection.isCollapsed() || isCodeSample(node)) {
  2241. open(editor);
  2242. } else {
  2243. editor.formatter.toggle("code");
  2244. }
  2245. });
  2246. };
  2247. var setup = function(editor) {
  2248. var $ = editor.$;
  2249. editor.on("PreProcess", function(e) {
  2250. $("pre[contenteditable=false]", e.node).filter(trimArg(isCodeSample)).each(function(idx, elm) {
  2251. var $elm = $(elm), code = elm.textContent;
  2252. $elm.attr("class", $.trim($elm.attr("class")));
  2253. $elm.removeAttr("contentEditable");
  2254. $elm.empty().append($("<code></code>").each(function() {
  2255. this.textContent = code;
  2256. }));
  2257. });
  2258. });
  2259. editor.on("SetContent", function() {
  2260. var unprocessedCodeSamples = $("pre").filter(trimArg(isCodeSample)).filter(function(idx, elm) {
  2261. return elm.contentEditable !== "false";
  2262. });
  2263. if (unprocessedCodeSamples.length) {
  2264. editor.undoManager.transact(function() {
  2265. unprocessedCodeSamples.each(function(idx, elm) {
  2266. $(elm).find("br").each(function(idx2, elm2) {
  2267. elm2.parentNode.replaceChild(editor.getDoc().createTextNode("\n"), elm2);
  2268. });
  2269. elm.contentEditable = "false";
  2270. elm.innerHTML = editor.dom.encode(elm.textContent);
  2271. get(editor).highlightElement(elm);
  2272. elm.className = $.trim(elm.className);
  2273. });
  2274. });
  2275. }
  2276. });
  2277. };
  2278. var isCodeSampleSelection = function(editor) {
  2279. var node = editor.selection.getStart();
  2280. return editor.dom.is(node, 'pre[class*="language-"]');
  2281. };
  2282. var register = function(editor) {
  2283. var onAction = function() {
  2284. return editor.execCommand("codesample");
  2285. };
  2286. editor.ui.registry.addToggleButton("codesample", {
  2287. icon: "code-sample",
  2288. tooltip: "Insert/edit code sample",
  2289. onAction,
  2290. onSetup: function(api) {
  2291. var nodeChangeHandler = function() {
  2292. api.setActive(isCodeSampleSelection(editor));
  2293. };
  2294. editor.on("NodeChange", nodeChangeHandler);
  2295. return function() {
  2296. return editor.off("NodeChange", nodeChangeHandler);
  2297. };
  2298. }
  2299. });
  2300. editor.ui.registry.addMenuItem("codesample", {
  2301. text: "Code sample...",
  2302. icon: "code-sample",
  2303. onAction
  2304. });
  2305. };
  2306. function Plugin() {
  2307. global$2.add("codesample", function(editor) {
  2308. setup(editor);
  2309. register(editor);
  2310. register$1(editor);
  2311. editor.on("dblclick", function(ev) {
  2312. if (isCodeSample(ev.target)) {
  2313. open(editor);
  2314. }
  2315. });
  2316. });
  2317. }
  2318. Plugin();
  2319. })();
  2320. }
  2321. });
  2322. // node_modules/tinymce/plugins/codesample/index.js
  2323. var require_codesample = __commonJS({
  2324. "node_modules/tinymce/plugins/codesample/index.js"() {
  2325. init_define_APP_INFO();
  2326. require_plugin();
  2327. }
  2328. });
  2329. // dep:tinymce_plugins_codesample
  2330. init_define_APP_INFO();
  2331. var tinymce_plugins_codesample_default = require_codesample();
  2332. export {
  2333. tinymce_plugins_codesample_default as default
  2334. };
  2335. //# sourceMappingURL=tinymce_plugins_codesample.js.map