tinymce_plugins_codesample.js 102 KB

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