plugin.js 108 KB

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