plugin.js 102 KB

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