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