plugin.js 97 KB

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