plugin.js 90 KB

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