plugin.js 92 KB

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