1 | import { r as registerInstance, g as getElement } from './core-bb3ac537.js';
|
2 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
3 | function createCommonjsModule(fn, module) {
|
4 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
5 | }
|
6 | var marked = createCommonjsModule(function (module, exports) {
|
7 | (function (root) {
|
8 | |
9 |
|
10 |
|
11 | var block = {
|
12 | newline: /^\n+/,
|
13 | code: /^( {4}[^\n]+\n*)+/,
|
14 | fences: noop,
|
15 | hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
16 | heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
17 | nptable: noop,
|
18 | blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
19 | list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
20 | html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
21 | def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
22 | table: noop,
|
23 | lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
24 | paragraph: /^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,
|
25 | text: /^[^\n]+/
|
26 | };
|
27 | block._label = /(?:\\[\[\]]|[^\[\]])+/;
|
28 | block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/;
|
29 | block.def = edit(block.def)
|
30 | .replace('label', block._label)
|
31 | .replace('title', block._title)
|
32 | .getRegex();
|
33 | block.bullet = /(?:[*+-]|\d+\.)/;
|
34 | block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
35 | block.item = edit(block.item, 'gm')
|
36 | .replace(/bull/g, block.bullet)
|
37 | .getRegex();
|
38 | block.list = edit(block.list)
|
39 | .replace(/bull/g, block.bullet)
|
40 | .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
41 | .replace('def', '\\n+(?=' + block.def.source + ')')
|
42 | .getRegex();
|
43 | block._tag = '(?!(?:'
|
44 | + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
45 | + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
46 | + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b';
|
47 | block.html = edit(block.html)
|
48 | .replace('comment', //)
|
49 | .replace('closed', /<(tag)[\s\S]+?<\/\1>/)
|
50 | .replace('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/)
|
51 | .replace(/tag/g, block._tag)
|
52 | .getRegex();
|
53 | block.paragraph = edit(block.paragraph)
|
54 | .replace('hr', block.hr)
|
55 | .replace('heading', block.heading)
|
56 | .replace('lheading', block.lheading)
|
57 | .replace('tag', '<' + block._tag)
|
58 | .getRegex();
|
59 | block.blockquote = edit(block.blockquote)
|
60 | .replace('paragraph', block.paragraph)
|
61 | .getRegex();
|
62 | /**
|
63 | * Normal Block Grammar
|
64 | */
|
65 | block.normal = merge({}, block);
|
66 | /**
|
67 | * GFM Block Grammar
|
68 | */
|
69 | block.gfm = merge({}, block.normal, {
|
70 | fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
|
71 | paragraph: /^/,
|
72 | heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
73 | });
|
74 | block.gfm.paragraph = edit(block.paragraph)
|
75 | .replace('(?!', '(?!'
|
76 | + block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
77 | + block.list.source.replace('\\1', '\\3') + '|')
|
78 | .getRegex();
|
79 | /**
|
80 | * GFM + Tables Block Grammar
|
81 | */
|
82 | block.tables = merge({}, block.gfm, {
|
83 | nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
|
84 | table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
|
85 | });
|
86 | /**
|
87 | * Block Lexer
|
88 | */
|
89 | function Lexer(options) {
|
90 | this.tokens = [];
|
91 | this.tokens.links = {};
|
92 | this.options = options || marked.defaults;
|
93 | this.rules = block.normal;
|
94 | if (this.options.gfm) {
|
95 | if (this.options.tables) {
|
96 | this.rules = block.tables;
|
97 | }
|
98 | else {
|
99 | this.rules = block.gfm;
|
100 | }
|
101 | }
|
102 | }
|
103 | /**
|
104 | * Expose Block Rules
|
105 | */
|
106 | Lexer.rules = block;
|
107 | /**
|
108 | * Static Lex Method
|
109 | */
|
110 | Lexer.lex = function (src, options) {
|
111 | var lexer = new Lexer(options);
|
112 | return lexer.lex(src);
|
113 | };
|
114 | /**
|
115 | * Preprocessing
|
116 | */
|
117 | Lexer.prototype.lex = function (src) {
|
118 | src = src
|
119 | .replace(/\r\n|\r/g, '\n')
|
120 | .replace(/\t/g, ' ')
|
121 | .replace(/\u00a0/g, ' ')
|
122 | .replace(/\u2424/g, '\n');
|
123 | return this.token(src, true);
|
124 | };
|
125 | /**
|
126 | * Lexing
|
127 | */
|
128 | Lexer.prototype.token = function (src, top) {
|
129 | src = src.replace(/^ +$/gm, '');
|
130 | var next, loose, cap, bull, b, item, space, i, tag, l, isordered;
|
131 | while (src) {
|
132 | // newline
|
133 | if (cap = this.rules.newline.exec(src)) {
|
134 | src = src.substring(cap[0].length);
|
135 | if (cap[0].length > 1) {
|
136 | this.tokens.push({
|
137 | type: 'space'
|
138 | });
|
139 | }
|
140 | }
|
141 | // code
|
142 | if (cap = this.rules.code.exec(src)) {
|
143 | src = src.substring(cap[0].length);
|
144 | cap = cap[0].replace(/^ {4}/gm, '');
|
145 | this.tokens.push({
|
146 | type: 'code',
|
147 | text: !this.options.pedantic
|
148 | ? cap.replace(/\n+$/, '')
|
149 | : cap
|
150 | });
|
151 | continue;
|
152 | }
|
153 | // fences (gfm)
|
154 | if (cap = this.rules.fences.exec(src)) {
|
155 | src = src.substring(cap[0].length);
|
156 | this.tokens.push({
|
157 | type: 'code',
|
158 | lang: cap[2],
|
159 | text: cap[3] || ''
|
160 | });
|
161 | continue;
|
162 | }
|
163 | // heading
|
164 | if (cap = this.rules.heading.exec(src)) {
|
165 | src = src.substring(cap[0].length);
|
166 | this.tokens.push({
|
167 | type: 'heading',
|
168 | depth: cap[1].length,
|
169 | text: cap[2]
|
170 | });
|
171 | continue;
|
172 | }
|
173 | // table no leading pipe (gfm)
|
174 | if (top && (cap = this.rules.nptable.exec(src))) {
|
175 | src = src.substring(cap[0].length);
|
176 | item = {
|
177 | type: 'table',
|
178 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
179 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
180 | cells: cap[3].replace(/\n$/, '').split('\n')
|
181 | };
|
182 | for (i = 0; i < item.align.length; i++) {
|
183 | if (/^ *-+: *$/.test(item.align[i])) {
|
184 | item.align[i] = 'right';
|
185 | }
|
186 | else if (/^ *:-+: *$/.test(item.align[i])) {
|
187 | item.align[i] = 'center';
|
188 | }
|
189 | else if (/^ *:-+ *$/.test(item.align[i])) {
|
190 | item.align[i] = 'left';
|
191 | }
|
192 | else {
|
193 | item.align[i] = null;
|
194 | }
|
195 | }
|
196 | for (i = 0; i < item.cells.length; i++) {
|
197 | item.cells[i] = item.cells[i].split(/ *\| */);
|
198 | }
|
199 | this.tokens.push(item);
|
200 | continue;
|
201 | }
|
202 | // hr
|
203 | if (cap = this.rules.hr.exec(src)) {
|
204 | src = src.substring(cap[0].length);
|
205 | this.tokens.push({
|
206 | type: 'hr'
|
207 | });
|
208 | continue;
|
209 | }
|
210 | // blockquote
|
211 | if (cap = this.rules.blockquote.exec(src)) {
|
212 | src = src.substring(cap[0].length);
|
213 | this.tokens.push({
|
214 | type: 'blockquote_start'
|
215 | });
|
216 | cap = cap[0].replace(/^ *> ?/gm, '');
|
217 | // Pass `top` to keep the current
|
218 | // "toplevel" state. This is exactly
|
219 | // how markdown.pl works.
|
220 | this.token(cap, top);
|
221 | this.tokens.push({
|
222 | type: 'blockquote_end'
|
223 | });
|
224 | continue;
|
225 | }
|
226 | // list
|
227 | if (cap = this.rules.list.exec(src)) {
|
228 | src = src.substring(cap[0].length);
|
229 | bull = cap[2];
|
230 | isordered = bull.length > 1;
|
231 | this.tokens.push({
|
232 | type: 'list_start',
|
233 | ordered: isordered,
|
234 | start: isordered ? +bull : ''
|
235 | });
|
236 | // Get each top-level item.
|
237 | cap = cap[0].match(this.rules.item);
|
238 | next = false;
|
239 | l = cap.length;
|
240 | i = 0;
|
241 | for (; i < l; i++) {
|
242 | item = cap[i];
|
243 | // Remove the list item's bullet
|
244 | // so it is seen as the next token.
|
245 | space = item.length;
|
246 | item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
247 | // Outdent whatever the
|
248 | // list item contains. Hacky.
|
249 | if (~item.indexOf('\n ')) {
|
250 | space -= item.length;
|
251 | item = !this.options.pedantic
|
252 | ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
|
253 | : item.replace(/^ {1,4}/gm, '');
|
254 | }
|
255 | // Determine whether the next list item belongs here.
|
256 | // Backpedal if it does not belong in this list.
|
257 | if (this.options.smartLists && i !== l - 1) {
|
258 | b = block.bullet.exec(cap[i + 1])[0];
|
259 | if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
260 | src = cap.slice(i + 1).join('\n') + src;
|
261 | i = l - 1;
|
262 | }
|
263 | }
|
264 | // Determine whether item is loose or not.
|
265 | // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
266 | // for discount behavior.
|
267 | loose = next || /\n\n(?!\s*$)/.test(item);
|
268 | if (i !== l - 1) {
|
269 | next = item.charAt(item.length - 1) === '\n';
|
270 | if (!loose)
|
271 | loose = next;
|
272 | }
|
273 | this.tokens.push({
|
274 | type: loose
|
275 | ? 'loose_item_start'
|
276 | : 'list_item_start'
|
277 | });
|
278 | // Recurse.
|
279 | this.token(item, false);
|
280 | this.tokens.push({
|
281 | type: 'list_item_end'
|
282 | });
|
283 | }
|
284 | this.tokens.push({
|
285 | type: 'list_end'
|
286 | });
|
287 | continue;
|
288 | }
|
289 | // html
|
290 | if (cap = this.rules.html.exec(src)) {
|
291 | src = src.substring(cap[0].length);
|
292 | this.tokens.push({
|
293 | type: this.options.sanitize
|
294 | ? 'paragraph'
|
295 | : 'html',
|
296 | pre: !this.options.sanitizer
|
297 | && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
298 | text: cap[0]
|
299 | });
|
300 | continue;
|
301 | }
|
302 | // def
|
303 | if (top && (cap = this.rules.def.exec(src))) {
|
304 | src = src.substring(cap[0].length);
|
305 | if (cap[3])
|
306 | cap[3] = cap[3].substring(1, cap[3].length - 1);
|
307 | tag = cap[1].toLowerCase();
|
308 | if (!this.tokens.links[tag]) {
|
309 | this.tokens.links[tag] = {
|
310 | href: cap[2],
|
311 | title: cap[3]
|
312 | };
|
313 | }
|
314 | continue;
|
315 | }
|
316 | // table (gfm)
|
317 | if (top && (cap = this.rules.table.exec(src))) {
|
318 | src = src.substring(cap[0].length);
|
319 | item = {
|
320 | type: 'table',
|
321 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
322 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
323 | cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
|
324 | };
|
325 | for (i = 0; i < item.align.length; i++) {
|
326 | if (/^ *-+: *$/.test(item.align[i])) {
|
327 | item.align[i] = 'right';
|
328 | }
|
329 | else if (/^ *:-+: *$/.test(item.align[i])) {
|
330 | item.align[i] = 'center';
|
331 | }
|
332 | else if (/^ *:-+ *$/.test(item.align[i])) {
|
333 | item.align[i] = 'left';
|
334 | }
|
335 | else {
|
336 | item.align[i] = null;
|
337 | }
|
338 | }
|
339 | for (i = 0; i < item.cells.length; i++) {
|
340 | item.cells[i] = item.cells[i]
|
341 | .replace(/^ *\| *| *\| *$/g, '')
|
342 | .split(/ *\| */);
|
343 | }
|
344 | this.tokens.push(item);
|
345 | continue;
|
346 | }
|
347 | // lheading
|
348 | if (cap = this.rules.lheading.exec(src)) {
|
349 | src = src.substring(cap[0].length);
|
350 | this.tokens.push({
|
351 | type: 'heading',
|
352 | depth: cap[2] === '=' ? 1 : 2,
|
353 | text: cap[1]
|
354 | });
|
355 | continue;
|
356 | }
|
357 | // top-level paragraph
|
358 | if (top && (cap = this.rules.paragraph.exec(src))) {
|
359 | src = src.substring(cap[0].length);
|
360 | this.tokens.push({
|
361 | type: 'paragraph',
|
362 | text: cap[1].charAt(cap[1].length - 1) === '\n'
|
363 | ? cap[1].slice(0, -1)
|
364 | : cap[1]
|
365 | });
|
366 | continue;
|
367 | }
|
368 | // text
|
369 | if (cap = this.rules.text.exec(src)) {
|
370 | // Top-level should never reach here.
|
371 | src = src.substring(cap[0].length);
|
372 | this.tokens.push({
|
373 | type: 'text',
|
374 | text: cap[0]
|
375 | });
|
376 | continue;
|
377 | }
|
378 | if (src) {
|
379 | throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
380 | }
|
381 | }
|
382 | return this.tokens;
|
383 | };
|
384 | /**
|
385 | * Inline-Level Grammar
|
386 | */
|
387 | var inline = {
|
388 | escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
389 | autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
390 | url: noop,
|
391 | tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/,
|
392 | link: /^!?\[(inside)\]\(href\)/,
|
393 | reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
394 | nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
|
395 | strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
396 | em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,
|
397 | code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
|
398 | br: /^ {2,}\n(?!\s*$)/,
|
399 | del: noop,
|
400 | text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
|
401 | };
|
402 | inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
403 | inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
404 | inline.autolink = edit(inline.autolink)
|
405 | .replace('scheme', inline._scheme)
|
406 | .replace('email', inline._email)
|
407 | .getRegex();
|
408 | inline._inside = /(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
|
409 | inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
410 | inline.link = edit(inline.link)
|
411 | .replace('inside', inline._inside)
|
412 | .replace('href', inline._href)
|
413 | .getRegex();
|
414 | inline.reflink = edit(inline.reflink)
|
415 | .replace('inside', inline._inside)
|
416 | .getRegex();
|
417 | /**
|
418 | * Normal Inline Grammar
|
419 | */
|
420 | inline.normal = merge({}, inline);
|
421 | /**
|
422 | * Pedantic Inline Grammar
|
423 | */
|
424 | inline.pedantic = merge({}, inline.normal, {
|
425 | strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
426 | em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
|
427 | });
|
428 | /**
|
429 | * GFM Inline Grammar
|
430 | */
|
431 | inline.gfm = merge({}, inline.normal, {
|
432 | escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
433 | url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
|
434 | .replace('email', inline._email)
|
435 | .getRegex(),
|
436 | _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
437 | del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
438 | text: edit(inline.text)
|
439 | .replace(']|', '~]|')
|
440 | .replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|')
|
441 | .getRegex()
|
442 | });
|
443 | /**
|
444 | * GFM + Line Breaks Inline Grammar
|
445 | */
|
446 | inline.breaks = merge({}, inline.gfm, {
|
447 | br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
448 | text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
|
449 | });
|
450 | /**
|
451 | * Inline Lexer & Compiler
|
452 | */
|
453 | function InlineLexer(links, options) {
|
454 | this.options = options || marked.defaults;
|
455 | this.links = links;
|
456 | this.rules = inline.normal;
|
457 | this.renderer = this.options.renderer || new Renderer();
|
458 | this.renderer.options = this.options;
|
459 | if (!this.links) {
|
460 | throw new Error('Tokens array requires a `links` property.');
|
461 | }
|
462 | if (this.options.gfm) {
|
463 | if (this.options.breaks) {
|
464 | this.rules = inline.breaks;
|
465 | }
|
466 | else {
|
467 | this.rules = inline.gfm;
|
468 | }
|
469 | }
|
470 | else if (this.options.pedantic) {
|
471 | this.rules = inline.pedantic;
|
472 | }
|
473 | }
|
474 | /**
|
475 | * Expose Inline Rules
|
476 | */
|
477 | InlineLexer.rules = inline;
|
478 | /**
|
479 | * Static Lexing/Compiling Method
|
480 | */
|
481 | InlineLexer.output = function (src, links, options) {
|
482 | var inline = new InlineLexer(links, options);
|
483 | return inline.output(src);
|
484 | };
|
485 | /**
|
486 | * Lexing/Compiling
|
487 | */
|
488 | InlineLexer.prototype.output = function (src) {
|
489 | var out = '', link, text, href, cap;
|
490 | while (src) {
|
491 | // escape
|
492 | if (cap = this.rules.escape.exec(src)) {
|
493 | src = src.substring(cap[0].length);
|
494 | out += cap[1];
|
495 | continue;
|
496 | }
|
497 | // autolink
|
498 | if (cap = this.rules.autolink.exec(src)) {
|
499 | src = src.substring(cap[0].length);
|
500 | if (cap[2] === '@') {
|
501 | text = escape(this.mangle(cap[1]));
|
502 | href = 'mailto:' + text;
|
503 | }
|
504 | else {
|
505 | text = escape(cap[1]);
|
506 | href = text;
|
507 | }
|
508 | out += this.renderer.link(href, null, text);
|
509 | continue;
|
510 | }
|
511 | // url (gfm)
|
512 | if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
513 | cap[0] = this.rules._backpedal.exec(cap[0])[0];
|
514 | src = src.substring(cap[0].length);
|
515 | if (cap[2] === '@') {
|
516 | text = escape(cap[0]);
|
517 | href = 'mailto:' + text;
|
518 | }
|
519 | else {
|
520 | text = escape(cap[0]);
|
521 | if (cap[1] === 'www.') {
|
522 | href = 'http://' + text;
|
523 | }
|
524 | else {
|
525 | href = text;
|
526 | }
|
527 | }
|
528 | out += this.renderer.link(href, null, text);
|
529 | continue;
|
530 | }
|
531 | // tag
|
532 | if (cap = this.rules.tag.exec(src)) {
|
533 | if (!this.inLink && /^<a /i.test(cap[0])) {
|
534 | this.inLink = true;
|
535 | }
|
536 | else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
537 | this.inLink = false;
|
538 | }
|
539 | src = src.substring(cap[0].length);
|
540 | out += this.options.sanitize
|
541 | ? this.options.sanitizer
|
542 | ? this.options.sanitizer(cap[0])
|
543 | : escape(cap[0])
|
544 | : cap[0];
|
545 | continue;
|
546 | }
|
547 | // link
|
548 | if (cap = this.rules.link.exec(src)) {
|
549 | src = src.substring(cap[0].length);
|
550 | this.inLink = true;
|
551 | out += this.outputLink(cap, {
|
552 | href: cap[2],
|
553 | title: cap[3]
|
554 | });
|
555 | this.inLink = false;
|
556 | continue;
|
557 | }
|
558 | // reflink, nolink
|
559 | if ((cap = this.rules.reflink.exec(src))
|
560 | || (cap = this.rules.nolink.exec(src))) {
|
561 | src = src.substring(cap[0].length);
|
562 | link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
563 | link = this.links[link.toLowerCase()];
|
564 | if (!link || !link.href) {
|
565 | out += cap[0].charAt(0);
|
566 | src = cap[0].substring(1) + src;
|
567 | continue;
|
568 | }
|
569 | this.inLink = true;
|
570 | out += this.outputLink(cap, link);
|
571 | this.inLink = false;
|
572 | continue;
|
573 | }
|
574 | // strong
|
575 | if (cap = this.rules.strong.exec(src)) {
|
576 | src = src.substring(cap[0].length);
|
577 | out += this.renderer.strong(this.output(cap[2] || cap[1]));
|
578 | continue;
|
579 | }
|
580 | // em
|
581 | if (cap = this.rules.em.exec(src)) {
|
582 | src = src.substring(cap[0].length);
|
583 | out += this.renderer.em(this.output(cap[2] || cap[1]));
|
584 | continue;
|
585 | }
|
586 | // code
|
587 | if (cap = this.rules.code.exec(src)) {
|
588 | src = src.substring(cap[0].length);
|
589 | out += this.renderer.codespan(escape(cap[2].trim(), true));
|
590 | continue;
|
591 | }
|
592 | // br
|
593 | if (cap = this.rules.br.exec(src)) {
|
594 | src = src.substring(cap[0].length);
|
595 | out += this.renderer.br();
|
596 | continue;
|
597 | }
|
598 | // del (gfm)
|
599 | if (cap = this.rules.del.exec(src)) {
|
600 | src = src.substring(cap[0].length);
|
601 | out += this.renderer.del(this.output(cap[1]));
|
602 | continue;
|
603 | }
|
604 | // text
|
605 | if (cap = this.rules.text.exec(src)) {
|
606 | src = src.substring(cap[0].length);
|
607 | out += this.renderer.text(escape(this.smartypants(cap[0])));
|
608 | continue;
|
609 | }
|
610 | if (src) {
|
611 | throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
612 | }
|
613 | }
|
614 | return out;
|
615 | };
|
616 | /**
|
617 | * Compile Link
|
618 | */
|
619 | InlineLexer.prototype.outputLink = function (cap, link) {
|
620 | var href = escape(link.href), title = link.title ? escape(link.title) : null;
|
621 | return cap[0].charAt(0) !== '!'
|
622 | ? this.renderer.link(href, title, this.output(cap[1]))
|
623 | : this.renderer.image(href, title, escape(cap[1]));
|
624 | };
|
625 | /**
|
626 | * Smartypants Transformations
|
627 | */
|
628 | InlineLexer.prototype.smartypants = function (text) {
|
629 | if (!this.options.smartypants)
|
630 | return text;
|
631 | return text
|
632 | // em-dashes
|
633 | .replace(/---/g, '\u2014')
|
634 | // en-dashes
|
635 | .replace(/--/g, '\u2013')
|
636 | // opening singles
|
637 | .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
638 | // closing singles & apostrophes
|
639 | .replace(/'/g, '\u2019')
|
640 | // opening doubles
|
641 | .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
642 | // closing doubles
|
643 | .replace(/"/g, '\u201d')
|
644 | // ellipses
|
645 | .replace(/\.{3}/g, '\u2026');
|
646 | };
|
647 | /**
|
648 | * Mangle Links
|
649 | */
|
650 | InlineLexer.prototype.mangle = function (text) {
|
651 | if (!this.options.mangle)
|
652 | return text;
|
653 | var out = '', l = text.length, i = 0, ch;
|
654 | for (; i < l; i++) {
|
655 | ch = text.charCodeAt(i);
|
656 | if (Math.random() > 0.5) {
|
657 | ch = 'x' + ch.toString(16);
|
658 | }
|
659 | out += '&#' + ch + ';';
|
660 | }
|
661 | return out;
|
662 | };
|
663 | /**
|
664 | * Renderer
|
665 | */
|
666 | function Renderer(options) {
|
667 | this.options = options || {};
|
668 | }
|
669 | Renderer.prototype.code = function (code, lang, escaped) {
|
670 | if (this.options.highlight) {
|
671 | var out = this.options.highlight(code, lang);
|
672 | if (out != null && out !== code) {
|
673 | escaped = true;
|
674 | code = out;
|
675 | }
|
676 | }
|
677 | if (!lang) {
|
678 | return '<pre><code>'
|
679 | + (escaped ? code : escape(code, true))
|
680 | + '\n</code></pre>';
|
681 | }
|
682 | return '<pre><code class="'
|
683 | + this.options.langPrefix
|
684 | + escape(lang, true)
|
685 | + '">'
|
686 | + (escaped ? code : escape(code, true))
|
687 | + '\n</code></pre>\n';
|
688 | };
|
689 | Renderer.prototype.blockquote = function (quote) {
|
690 | return '<blockquote>\n' + quote + '</blockquote>\n';
|
691 | };
|
692 | Renderer.prototype.html = function (html) {
|
693 | return html;
|
694 | };
|
695 | Renderer.prototype.heading = function (text, level, raw) {
|
696 | return '<h'
|
697 | + level
|
698 | + ' id="'
|
699 | + this.options.headerPrefix
|
700 | + raw.toLowerCase().replace(/[^\w]+/g, '-')
|
701 | + '">'
|
702 | + text
|
703 | + '</h'
|
704 | + level
|
705 | + '>\n';
|
706 | };
|
707 | Renderer.prototype.hr = function () {
|
708 | return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
709 | };
|
710 | Renderer.prototype.list = function (body, ordered, start) {
|
711 | var type = ordered ? 'ol' : 'ul', startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
712 | return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
713 | };
|
714 | Renderer.prototype.listitem = function (text) {
|
715 | return '<li>' + text + '</li>\n';
|
716 | };
|
717 | Renderer.prototype.paragraph = function (text) {
|
718 | return '<p>' + text + '</p>\n';
|
719 | };
|
720 | Renderer.prototype.table = function (header, body) {
|
721 | return '<table>\n'
|
722 | + '<thead>\n'
|
723 | + header
|
724 | + '</thead>\n'
|
725 | + '<tbody>\n'
|
726 | + body
|
727 | + '</tbody>\n'
|
728 | + '</table>\n';
|
729 | };
|
730 | Renderer.prototype.tablerow = function (content) {
|
731 | return '<tr>\n' + content + '</tr>\n';
|
732 | };
|
733 | Renderer.prototype.tablecell = function (content, flags) {
|
734 | var type = flags.header ? 'th' : 'td';
|
735 | var tag = flags.align
|
736 | ? '<' + type + ' style="text-align:' + flags.align + '">'
|
737 | : '<' + type + '>';
|
738 | return tag + content + '</' + type + '>\n';
|
739 | };
|
740 | // span level renderer
|
741 | Renderer.prototype.strong = function (text) {
|
742 | return '<strong>' + text + '</strong>';
|
743 | };
|
744 | Renderer.prototype.em = function (text) {
|
745 | return '<em>' + text + '</em>';
|
746 | };
|
747 | Renderer.prototype.codespan = function (text) {
|
748 | return '<code>' + text + '</code>';
|
749 | };
|
750 | Renderer.prototype.br = function () {
|
751 | return this.options.xhtml ? '<br/>' : '<br>';
|
752 | };
|
753 | Renderer.prototype.del = function (text) {
|
754 | return '<del>' + text + '</del>';
|
755 | };
|
756 | Renderer.prototype.link = function (href, title, text) {
|
757 | if (this.options.sanitize) {
|
758 | try {
|
759 | var prot = decodeURIComponent(unescape(href))
|
760 | .replace(/[^\w:]/g, '')
|
761 | .toLowerCase();
|
762 | }
|
763 | catch (e) {
|
764 | return text;
|
765 | }
|
766 | if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
767 | return text;
|
768 | }
|
769 | }
|
770 | if (this.options.baseUrl && !originIndependentUrl.test(href)) {
|
771 | href = resolveUrl(this.options.baseUrl, href);
|
772 | }
|
773 | var out = '<a href="' + href + '"';
|
774 | if (title) {
|
775 | out += ' title="' + title + '"';
|
776 | }
|
777 | out += '>' + text + '</a>';
|
778 | return out;
|
779 | };
|
780 | Renderer.prototype.image = function (href, title, text) {
|
781 | if (this.options.baseUrl && !originIndependentUrl.test(href)) {
|
782 | href = resolveUrl(this.options.baseUrl, href);
|
783 | }
|
784 | var out = '<img src="' + href + '" alt="' + text + '"';
|
785 | if (title) {
|
786 | out += ' title="' + title + '"';
|
787 | }
|
788 | out += this.options.xhtml ? '/>' : '>';
|
789 | return out;
|
790 | };
|
791 | Renderer.prototype.text = function (text) {
|
792 | return text;
|
793 | };
|
794 | /**
|
795 | * TextRenderer
|
796 | * returns only the textual part of the token
|
797 | */
|
798 | function TextRenderer() { }
|
799 | // no need for block level renderers
|
800 | TextRenderer.prototype.strong =
|
801 | TextRenderer.prototype.em =
|
802 | TextRenderer.prototype.codespan =
|
803 | TextRenderer.prototype.del =
|
804 | TextRenderer.prototype.text = function (text) {
|
805 | return text;
|
806 | };
|
807 | TextRenderer.prototype.link =
|
808 | TextRenderer.prototype.image = function (href, title, text) {
|
809 | return '' + text;
|
810 | };
|
811 | TextRenderer.prototype.br = function () {
|
812 | return '';
|
813 | };
|
814 | /**
|
815 | * Parsing & Compiling
|
816 | */
|
817 | function Parser(options) {
|
818 | this.tokens = [];
|
819 | this.token = null;
|
820 | this.options = options || marked.defaults;
|
821 | this.options.renderer = this.options.renderer || new Renderer();
|
822 | this.renderer = this.options.renderer;
|
823 | this.renderer.options = this.options;
|
824 | }
|
825 | /**
|
826 | * Static Parse Method
|
827 | */
|
828 | Parser.parse = function (src, options) {
|
829 | var parser = new Parser(options);
|
830 | return parser.parse(src);
|
831 | };
|
832 | /**
|
833 | * Parse Loop
|
834 | */
|
835 | Parser.prototype.parse = function (src) {
|
836 | this.inline = new InlineLexer(src.links, this.options);
|
837 | // use an InlineLexer with a TextRenderer to extract pure text
|
838 | this.inlineText = new InlineLexer(src.links, merge({}, this.options, { renderer: new TextRenderer() }));
|
839 | this.tokens = src.reverse();
|
840 | var out = '';
|
841 | while (this.next()) {
|
842 | out += this.tok();
|
843 | }
|
844 | return out;
|
845 | };
|
846 | /**
|
847 | * Next Token
|
848 | */
|
849 | Parser.prototype.next = function () {
|
850 | return this.token = this.tokens.pop();
|
851 | };
|
852 | /**
|
853 | * Preview Next Token
|
854 | */
|
855 | Parser.prototype.peek = function () {
|
856 | return this.tokens[this.tokens.length - 1] || 0;
|
857 | };
|
858 | /**
|
859 | * Parse Text Tokens
|
860 | */
|
861 | Parser.prototype.parseText = function () {
|
862 | var body = this.token.text;
|
863 | while (this.peek().type === 'text') {
|
864 | body += '\n' + this.next().text;
|
865 | }
|
866 | return this.inline.output(body);
|
867 | };
|
868 | /**
|
869 | * Parse Current Token
|
870 | */
|
871 | Parser.prototype.tok = function () {
|
872 | switch (this.token.type) {
|
873 | case 'space': {
|
874 | return '';
|
875 | }
|
876 | case 'hr': {
|
877 | return this.renderer.hr();
|
878 | }
|
879 | case 'heading': {
|
880 | return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, unescape(this.inlineText.output(this.token.text)));
|
881 | }
|
882 | case 'code': {
|
883 | return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
|
884 | }
|
885 | case 'table': {
|
886 | var header = '', body = '', i, row, cell, j;
|
887 | // header
|
888 | cell = '';
|
889 | for (i = 0; i < this.token.header.length; i++) {
|
890 | cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), { header: true, align: this.token.align[i] });
|
891 | }
|
892 | header += this.renderer.tablerow(cell);
|
893 | for (i = 0; i < this.token.cells.length; i++) {
|
894 | row = this.token.cells[i];
|
895 | cell = '';
|
896 | for (j = 0; j < row.length; j++) {
|
897 | cell += this.renderer.tablecell(this.inline.output(row[j]), { header: false, align: this.token.align[j] });
|
898 | }
|
899 | body += this.renderer.tablerow(cell);
|
900 | }
|
901 | return this.renderer.table(header, body);
|
902 | }
|
903 | case 'blockquote_start': {
|
904 | body = '';
|
905 | while (this.next().type !== 'blockquote_end') {
|
906 | body += this.tok();
|
907 | }
|
908 | return this.renderer.blockquote(body);
|
909 | }
|
910 | case 'list_start': {
|
911 | body = '';
|
912 | var ordered = this.token.ordered, start = this.token.start;
|
913 | while (this.next().type !== 'list_end') {
|
914 | body += this.tok();
|
915 | }
|
916 | return this.renderer.list(body, ordered, start);
|
917 | }
|
918 | case 'list_item_start': {
|
919 | body = '';
|
920 | while (this.next().type !== 'list_item_end') {
|
921 | body += this.token.type === 'text'
|
922 | ? this.parseText()
|
923 | : this.tok();
|
924 | }
|
925 | return this.renderer.listitem(body);
|
926 | }
|
927 | case 'loose_item_start': {
|
928 | body = '';
|
929 | while (this.next().type !== 'list_item_end') {
|
930 | body += this.tok();
|
931 | }
|
932 | return this.renderer.listitem(body);
|
933 | }
|
934 | case 'html': {
|
935 | var html = !this.token.pre && !this.options.pedantic
|
936 | ? this.inline.output(this.token.text)
|
937 | : this.token.text;
|
938 | return this.renderer.html(html);
|
939 | }
|
940 | case 'paragraph': {
|
941 | return this.renderer.paragraph(this.inline.output(this.token.text));
|
942 | }
|
943 | case 'text': {
|
944 | return this.renderer.paragraph(this.parseText());
|
945 | }
|
946 | }
|
947 | };
|
948 | /**
|
949 | * Helpers
|
950 | */
|
951 | function escape(html, encode) {
|
952 | return html
|
953 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
|
954 | .replace(/</g, '<')
|
955 | .replace(/>/g, '>')
|
956 | .replace(/"/g, '"')
|
957 | .replace(/'/g, ''');
|
958 | }
|
959 | function unescape(html) {
|
960 | // explicitly match decimal, hex, and named HTML entities
|
961 | return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function (_, n) {
|
962 | n = n.toLowerCase();
|
963 | if (n === 'colon')
|
964 | return ':';
|
965 | if (n.charAt(0) === '#') {
|
966 | return n.charAt(1) === 'x'
|
967 | ? String.fromCharCode(parseInt(n.substring(2), 16))
|
968 | : String.fromCharCode(+n.substring(1));
|
969 | }
|
970 | return '';
|
971 | });
|
972 | }
|
973 | function edit(regex, opt) {
|
974 | regex = regex.source;
|
975 | opt = opt || '';
|
976 | return {
|
977 | replace: function (name, val) {
|
978 | val = val.source || val;
|
979 | val = val.replace(/(^|[^\[])\^/g, '$1');
|
980 | regex = regex.replace(name, val);
|
981 | return this;
|
982 | },
|
983 | getRegex: function () {
|
984 | return new RegExp(regex, opt);
|
985 | }
|
986 | };
|
987 | }
|
988 | function resolveUrl(base, href) {
|
989 | if (!baseUrls[' ' + base]) {
|
990 | // we can ignore everything in base after the last slash of its path component,
|
991 | // but we might need to add _that_
|
992 | // https://tools.ietf.org/html/rfc3986#section-3
|
993 | if (/^[^:]+:\/*[^/]*$/.test(base)) {
|
994 | baseUrls[' ' + base] = base + '/';
|
995 | }
|
996 | else {
|
997 | baseUrls[' ' + base] = base.replace(/[^/]*$/, '');
|
998 | }
|
999 | }
|
1000 | base = baseUrls[' ' + base];
|
1001 | if (href.slice(0, 2) === '//') {
|
1002 | return base.replace(/:[\s\S]*/, ':') + href;
|
1003 | }
|
1004 | else if (href.charAt(0) === '/') {
|
1005 | return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
|
1006 | }
|
1007 | else {
|
1008 | return base + href;
|
1009 | }
|
1010 | }
|
1011 | var baseUrls = {};
|
1012 | var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
1013 | function noop() { }
|
1014 | noop.exec = noop;
|
1015 | function merge(obj) {
|
1016 | var i = 1, target, key;
|
1017 | for (; i < arguments.length; i++) {
|
1018 | target = arguments[i];
|
1019 | for (key in target) {
|
1020 | if (Object.prototype.hasOwnProperty.call(target, key)) {
|
1021 | obj[key] = target[key];
|
1022 | }
|
1023 | }
|
1024 | }
|
1025 | return obj;
|
1026 | }
|
1027 | /**
|
1028 | * Marked
|
1029 | */
|
1030 | function marked(src, opt, callback) {
|
1031 | // throw error in case of non string input
|
1032 | if (typeof src === 'undefined' || src === null) {
|
1033 | throw new Error('marked(): input parameter is undefined or null');
|
1034 | }
|
1035 | if (typeof src !== 'string') {
|
1036 | throw new Error('marked(): input parameter is of type '
|
1037 | + Object.prototype.toString.call(src) + ', string expected');
|
1038 | }
|
1039 | if (callback || typeof opt === 'function') {
|
1040 | if (!callback) {
|
1041 | callback = opt;
|
1042 | opt = null;
|
1043 | }
|
1044 | opt = merge({}, marked.defaults, opt || {});
|
1045 | var highlight = opt.highlight, tokens, pending, i = 0;
|
1046 | try {
|
1047 | tokens = Lexer.lex(src, opt);
|
1048 | }
|
1049 | catch (e) {
|
1050 | return callback(e);
|
1051 | }
|
1052 | pending = tokens.length;
|
1053 | var done = function (err) {
|
1054 | if (err) {
|
1055 | opt.highlight = highlight;
|
1056 | return callback(err);
|
1057 | }
|
1058 | var out;
|
1059 | try {
|
1060 | out = Parser.parse(tokens, opt);
|
1061 | }
|
1062 | catch (e) {
|
1063 | err = e;
|
1064 | }
|
1065 | opt.highlight = highlight;
|
1066 | return err
|
1067 | ? callback(err)
|
1068 | : callback(null, out);
|
1069 | };
|
1070 | if (!highlight || highlight.length < 3) {
|
1071 | return done();
|
1072 | }
|
1073 | delete opt.highlight;
|
1074 | if (!pending)
|
1075 | return done();
|
1076 | for (; i < tokens.length; i++) {
|
1077 | (function (token) {
|
1078 | if (token.type !== 'code') {
|
1079 | return --pending || done();
|
1080 | }
|
1081 | return highlight(token.text, token.lang, function (err, code) {
|
1082 | if (err)
|
1083 | return done(err);
|
1084 | if (code == null || code === token.text) {
|
1085 | return --pending || done();
|
1086 | }
|
1087 | token.text = code;
|
1088 | token.escaped = true;
|
1089 | --pending || done();
|
1090 | });
|
1091 | })(tokens[i]);
|
1092 | }
|
1093 | return;
|
1094 | }
|
1095 | try {
|
1096 | if (opt)
|
1097 | opt = merge({}, marked.defaults, opt);
|
1098 | return Parser.parse(Lexer.lex(src, opt), opt);
|
1099 | }
|
1100 | catch (e) {
|
1101 | e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
1102 | if ((opt || marked.defaults).silent) {
|
1103 | return '<p>An error occurred:</p><pre>'
|
1104 | + escape(e.message + '', true)
|
1105 | + '</pre>';
|
1106 | }
|
1107 | throw e;
|
1108 | }
|
1109 | }
|
1110 | /**
|
1111 | * Options
|
1112 | */
|
1113 | marked.options =
|
1114 | marked.setOptions = function (opt) {
|
1115 | merge(marked.defaults, opt);
|
1116 | return marked;
|
1117 | };
|
1118 | marked.defaults = {
|
1119 | gfm: true,
|
1120 | tables: true,
|
1121 | breaks: false,
|
1122 | pedantic: false,
|
1123 | sanitize: false,
|
1124 | sanitizer: null,
|
1125 | mangle: true,
|
1126 | smartLists: false,
|
1127 | silent: false,
|
1128 | highlight: null,
|
1129 | langPrefix: 'lang-',
|
1130 | smartypants: false,
|
1131 | headerPrefix: '',
|
1132 | renderer: new Renderer(),
|
1133 | xhtml: false,
|
1134 | baseUrl: null
|
1135 | };
|
1136 | /**
|
1137 | * Expose
|
1138 | */
|
1139 | marked.Parser = Parser;
|
1140 | marked.parser = Parser.parse;
|
1141 | marked.Renderer = Renderer;
|
1142 | marked.TextRenderer = TextRenderer;
|
1143 | marked.Lexer = Lexer;
|
1144 | marked.lexer = Lexer.lex;
|
1145 | marked.InlineLexer = InlineLexer;
|
1146 | marked.inlineLexer = InlineLexer.output;
|
1147 | marked.parse = marked;
|
1148 | {
|
1149 | module.exports = marked;
|
1150 | }
|
1151 | })();
|
1152 | });
|
1153 | var prism = createCommonjsModule(function (module) {
|
1154 | /* **********************************************
|
1155 | Begin prism-core.js
|
1156 | ********************************************** */
|
1157 | var _self = (typeof window !== 'undefined')
|
1158 | ? window // if in browser
|
1159 | : ((typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
1160 | ? self // if in worker
|
1161 | : {} // if in node js
|
1162 | );
|
1163 | /**
|
1164 | * Prism: Lightweight, robust, elegant syntax highlighting
|
1165 | * MIT license http://www.opensource.org/licenses/mit-license.php/
|
1166 | * @author Lea Verou http://lea.verou.me
|
1167 | */
|
1168 | var Prism = (function () {
|
1169 | // Private helper vars
|
1170 | var lang = /\blang(?:uage)?-(\w+)\b/i;
|
1171 | var uniqueId = 0;
|
1172 | var _ = _self.Prism = {
|
1173 | manual: _self.Prism && _self.Prism.manual,
|
1174 | disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
1175 | util: {
|
1176 | encode: function (tokens) {
|
1177 | if (tokens instanceof Token) {
|
1178 | return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
|
1179 | }
|
1180 | else if (_.util.type(tokens) === 'Array') {
|
1181 | return tokens.map(_.util.encode);
|
1182 | }
|
1183 | else {
|
1184 | return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
1185 | }
|
1186 | },
|
1187 | type: function (o) {
|
1188 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
1189 | },
|
1190 | objId: function (obj) {
|
1191 | if (!obj['__id']) {
|
1192 | Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
1193 | }
|
1194 | return obj['__id'];
|
1195 | },
|
1196 | // Deep clone a language definition (e.g. to extend it)
|
1197 | clone: function (o) {
|
1198 | var type = _.util.type(o);
|
1199 | switch (type) {
|
1200 | case 'Object':
|
1201 | var clone = {};
|
1202 | for (var key in o) {
|
1203 | if (o.hasOwnProperty(key)) {
|
1204 | clone[key] = _.util.clone(o[key]);
|
1205 | }
|
1206 | }
|
1207 | return clone;
|
1208 | case 'Array':
|
1209 | return o.map(function (v) { return _.util.clone(v); });
|
1210 | }
|
1211 | return o;
|
1212 | }
|
1213 | },
|
1214 | languages: {
|
1215 | extend: function (id, redef) {
|
1216 | var lang = _.util.clone(_.languages[id]);
|
1217 | for (var key in redef) {
|
1218 | lang[key] = redef[key];
|
1219 | }
|
1220 | return lang;
|
1221 | },
|
1222 | /**
|
1223 | * Insert a token before another token in a language literal
|
1224 | * As this needs to recreate the object (we cannot actually insert before keys in object literals),
|
1225 | * we cannot just provide an object, we need anobject and a key.
|
1226 | * @param inside The key (or language id) of the parent
|
1227 | * @param before The key to insert before. If not provided, the function appends instead.
|
1228 | * @param insert Object with the key/value pairs to insert
|
1229 | * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
|
1230 | */
|
1231 | insertBefore: function (inside, before, insert, root) {
|
1232 | root = root || _.languages;
|
1233 | var grammar = root[inside];
|
1234 | if (arguments.length == 2) {
|
1235 | insert = arguments[1];
|
1236 | for (var newToken in insert) {
|
1237 | if (insert.hasOwnProperty(newToken)) {
|
1238 | grammar[newToken] = insert[newToken];
|
1239 | }
|
1240 | }
|
1241 | return grammar;
|
1242 | }
|
1243 | var ret = {};
|
1244 | for (var token in grammar) {
|
1245 | if (grammar.hasOwnProperty(token)) {
|
1246 | if (token == before) {
|
1247 | for (var newToken in insert) {
|
1248 | if (insert.hasOwnProperty(newToken)) {
|
1249 | ret[newToken] = insert[newToken];
|
1250 | }
|
1251 | }
|
1252 | }
|
1253 | ret[token] = grammar[token];
|
1254 | }
|
1255 | }
|
1256 | // Update references in other language definitions
|
1257 | _.languages.DFS(_.languages, function (key, value) {
|
1258 | if (value === root[inside] && key != inside) {
|
1259 | this[key] = ret;
|
1260 | }
|
1261 | });
|
1262 | return root[inside] = ret;
|
1263 | },
|
1264 | // Traverse a language definition with Depth First Search
|
1265 | DFS: function (o, callback, type, visited) {
|
1266 | visited = visited || {};
|
1267 | for (var i in o) {
|
1268 | if (o.hasOwnProperty(i)) {
|
1269 | callback.call(o, i, o[i], type || i);
|
1270 | if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
|
1271 | visited[_.util.objId(o[i])] = true;
|
1272 | _.languages.DFS(o[i], callback, null, visited);
|
1273 | }
|
1274 | else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
|
1275 | visited[_.util.objId(o[i])] = true;
|
1276 | _.languages.DFS(o[i], callback, i, visited);
|
1277 | }
|
1278 | }
|
1279 | }
|
1280 | }
|
1281 | },
|
1282 | plugins: {},
|
1283 | highlightAll: function (async, callback) {
|
1284 | _.highlightAllUnder(document, async, callback);
|
1285 | },
|
1286 | highlightAllUnder: function (container, async, callback) {
|
1287 | var env = {
|
1288 | callback: callback,
|
1289 | selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
1290 | };
|
1291 | _.hooks.run("before-highlightall", env);
|
1292 | var elements = env.elements || container.querySelectorAll(env.selector);
|
1293 | for (var i = 0, element; element = elements[i++];) {
|
1294 | _.highlightElement(element, async === true, env.callback);
|
1295 | }
|
1296 | },
|
1297 | highlightElement: function (element, async, callback) {
|
1298 | // Find language
|
1299 | var language, grammar, parent = element;
|
1300 | while (parent && !lang.test(parent.className)) {
|
1301 | parent = parent.parentNode;
|
1302 | }
|
1303 | if (parent) {
|
1304 | language = (parent.className.match(lang) || [, ''])[1].toLowerCase();
|
1305 | grammar = _.languages[language];
|
1306 | }
|
1307 | // Set language on the element, if not present
|
1308 | element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
1309 | if (element.parentNode) {
|
1310 | // Set language on the parent, for styling
|
1311 | parent = element.parentNode;
|
1312 | if (/pre/i.test(parent.nodeName)) {
|
1313 | parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
1314 | }
|
1315 | }
|
1316 | var code = element.textContent;
|
1317 | var env = {
|
1318 | element: element,
|
1319 | language: language,
|
1320 | grammar: grammar,
|
1321 | code: code
|
1322 | };
|
1323 | _.hooks.run('before-sanity-check', env);
|
1324 | if (!env.code || !env.grammar) {
|
1325 | if (env.code) {
|
1326 | _.hooks.run('before-highlight', env);
|
1327 | env.element.textContent = env.code;
|
1328 | _.hooks.run('after-highlight', env);
|
1329 | }
|
1330 | _.hooks.run('complete', env);
|
1331 | return;
|
1332 | }
|
1333 | _.hooks.run('before-highlight', env);
|
1334 | if (async && _self.Worker) {
|
1335 | var worker = new Worker(_.filename);
|
1336 | worker.onmessage = function (evt) {
|
1337 | env.highlightedCode = evt.data;
|
1338 | _.hooks.run('before-insert', env);
|
1339 | env.element.innerHTML = env.highlightedCode;
|
1340 | callback && callback.call(env.element);
|
1341 | _.hooks.run('after-highlight', env);
|
1342 | _.hooks.run('complete', env);
|
1343 | };
|
1344 | worker.postMessage(JSON.stringify({
|
1345 | language: env.language,
|
1346 | code: env.code,
|
1347 | immediateClose: true
|
1348 | }));
|
1349 | }
|
1350 | else {
|
1351 | env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
|
1352 | _.hooks.run('before-insert', env);
|
1353 | env.element.innerHTML = env.highlightedCode;
|
1354 | callback && callback.call(element);
|
1355 | _.hooks.run('after-highlight', env);
|
1356 | _.hooks.run('complete', env);
|
1357 | }
|
1358 | },
|
1359 | highlight: function (text, grammar, language) {
|
1360 | var tokens = _.tokenize(text, grammar);
|
1361 | return Token.stringify(_.util.encode(tokens), language);
|
1362 | },
|
1363 | matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
|
1364 | var Token = _.Token;
|
1365 | for (var token in grammar) {
|
1366 | if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
1367 | continue;
|
1368 | }
|
1369 | if (token == target) {
|
1370 | return;
|
1371 | }
|
1372 | var patterns = grammar[token];
|
1373 | patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
|
1374 | for (var j = 0; j < patterns.length; ++j) {
|
1375 | var pattern = patterns[j], inside = pattern.inside, lookbehind = !!pattern.lookbehind, greedy = !!pattern.greedy, lookbehindLength = 0, alias = pattern.alias;
|
1376 | if (greedy && !pattern.pattern.global) {
|
1377 | // Without the global flag, lastIndex won't work
|
1378 | var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
|
1379 | pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
|
1380 | }
|
1381 | pattern = pattern.pattern || pattern;
|
1382 | // Don’t cache length as it changes during the loop
|
1383 | for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
|
1384 | var str = strarr[i];
|
1385 | if (strarr.length > text.length) {
|
1386 | // Something went terribly wrong, ABORT, ABORT!
|
1387 | return;
|
1388 | }
|
1389 | if (str instanceof Token) {
|
1390 | continue;
|
1391 | }
|
1392 | pattern.lastIndex = 0;
|
1393 | var match = pattern.exec(str), delNum = 1;
|
1394 | // Greedy patterns can override/remove up to two previously matched tokens
|
1395 | if (!match && greedy && i != strarr.length - 1) {
|
1396 | pattern.lastIndex = pos;
|
1397 | match = pattern.exec(text);
|
1398 | if (!match) {
|
1399 | break;
|
1400 | }
|
1401 | var from = match.index + (lookbehind ? match[1].length : 0), to = match.index + match[0].length, k = i, p = pos;
|
1402 | for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
|
1403 | p += strarr[k].length;
|
1404 | // Move the index i to the element in strarr that is closest to from
|
1405 | if (from >= p) {
|
1406 | ++i;
|
1407 | pos = p;
|
1408 | }
|
1409 | }
|
1410 | /*
|
1411 | * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
|
1412 | * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
|
1413 | */
|
1414 | if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
|
1415 | continue;
|
1416 | }
|
1417 | // Number of tokens to delete and replace with the new match
|
1418 | delNum = k - i;
|
1419 | str = text.slice(pos, p);
|
1420 | match.index -= pos;
|
1421 | }
|
1422 | if (!match) {
|
1423 | if (oneshot) {
|
1424 | break;
|
1425 | }
|
1426 | continue;
|
1427 | }
|
1428 | if (lookbehind) {
|
1429 | lookbehindLength = match[1].length;
|
1430 | }
|
1431 | var from = match.index + lookbehindLength, match = match[0].slice(lookbehindLength), to = from + match.length, before = str.slice(0, from), after = str.slice(to);
|
1432 | var args = [i, delNum];
|
1433 | if (before) {
|
1434 | ++i;
|
1435 | pos += before.length;
|
1436 | args.push(before);
|
1437 | }
|
1438 | var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy);
|
1439 | args.push(wrapped);
|
1440 | if (after) {
|
1441 | args.push(after);
|
1442 | }
|
1443 | Array.prototype.splice.apply(strarr, args);
|
1444 | if (delNum != 1)
|
1445 | _.matchGrammar(text, strarr, grammar, i, pos, true, token);
|
1446 | if (oneshot)
|
1447 | break;
|
1448 | }
|
1449 | }
|
1450 | }
|
1451 | },
|
1452 | tokenize: function (text, grammar, language) {
|
1453 | var strarr = [text];
|
1454 | var rest = grammar.rest;
|
1455 | if (rest) {
|
1456 | for (var token in rest) {
|
1457 | grammar[token] = rest[token];
|
1458 | }
|
1459 | delete grammar.rest;
|
1460 | }
|
1461 | _.matchGrammar(text, strarr, grammar, 0, 0, false);
|
1462 | return strarr;
|
1463 | },
|
1464 | hooks: {
|
1465 | all: {},
|
1466 | add: function (name, callback) {
|
1467 | var hooks = _.hooks.all;
|
1468 | hooks[name] = hooks[name] || [];
|
1469 | hooks[name].push(callback);
|
1470 | },
|
1471 | run: function (name, env) {
|
1472 | var callbacks = _.hooks.all[name];
|
1473 | if (!callbacks || !callbacks.length) {
|
1474 | return;
|
1475 | }
|
1476 | for (var i = 0, callback; callback = callbacks[i++];) {
|
1477 | callback(env);
|
1478 | }
|
1479 | }
|
1480 | }
|
1481 | };
|
1482 | var Token = _.Token = function (type, content, alias, matchedStr, greedy) {
|
1483 | this.type = type;
|
1484 | this.content = content;
|
1485 | this.alias = alias;
|
1486 | // Copy of the full string this token was created from
|
1487 | this.length = (matchedStr || "").length | 0;
|
1488 | this.greedy = !!greedy;
|
1489 | };
|
1490 | Token.stringify = function (o, language, parent) {
|
1491 | if (typeof o == 'string') {
|
1492 | return o;
|
1493 | }
|
1494 | if (_.util.type(o) === 'Array') {
|
1495 | return o.map(function (element) {
|
1496 | return Token.stringify(element, language, o);
|
1497 | }).join('');
|
1498 | }
|
1499 | var env = {
|
1500 | type: o.type,
|
1501 | content: Token.stringify(o.content, language, parent),
|
1502 | tag: 'span',
|
1503 | classes: ['token', o.type],
|
1504 | attributes: {},
|
1505 | language: language,
|
1506 | parent: parent
|
1507 | };
|
1508 | if (o.alias) {
|
1509 | var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
|
1510 | Array.prototype.push.apply(env.classes, aliases);
|
1511 | }
|
1512 | _.hooks.run('wrap', env);
|
1513 | var attributes = Object.keys(env.attributes).map(function (name) {
|
1514 | return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
|
1515 | }).join(' ');
|
1516 | return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
|
1517 | };
|
1518 | if (!_self.document) {
|
1519 | if (!_self.addEventListener) {
|
1520 | // in Node.js
|
1521 | return _self.Prism;
|
1522 | }
|
1523 | if (!_.disableWorkerMessageHandler) {
|
1524 | // In worker
|
1525 | _self.addEventListener('message', function (evt) {
|
1526 | var message = JSON.parse(evt.data), lang = message.language, code = message.code, immediateClose = message.immediateClose;
|
1527 | _self.postMessage(_.highlight(code, _.languages[lang], lang));
|
1528 | if (immediateClose) {
|
1529 | _self.close();
|
1530 | }
|
1531 | }, false);
|
1532 | }
|
1533 | return _self.Prism;
|
1534 | }
|
1535 | //Get current script and highlight
|
1536 | var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
|
1537 | if (script) {
|
1538 | _.filename = script.src;
|
1539 | if (!_.manual && !script.hasAttribute('data-manual')) {
|
1540 | if (document.readyState !== "loading") {
|
1541 | if (window.requestAnimationFrame) {
|
1542 | window.requestAnimationFrame(_.highlightAll);
|
1543 | }
|
1544 | else {
|
1545 | window.setTimeout(_.highlightAll, 16);
|
1546 | }
|
1547 | }
|
1548 | else {
|
1549 | document.addEventListener('DOMContentLoaded', _.highlightAll);
|
1550 | }
|
1551 | }
|
1552 | }
|
1553 | return _self.Prism;
|
1554 | })();
|
1555 | if (module.exports) {
|
1556 | module.exports = Prism;
|
1557 | }
|
1558 | // hack for components to work correctly in node.js
|
1559 | if (typeof commonjsGlobal !== 'undefined') {
|
1560 | commonjsGlobal.Prism = Prism;
|
1561 | }
|
1562 | /* **********************************************
|
1563 | Begin prism-markup.js
|
1564 | ********************************************** */
|
1565 | Prism.languages.markup = {
|
1566 | 'comment': /<!--[\s\S]*?-->/,
|
1567 | 'prolog': /<\?[\s\S]+?\?>/,
|
1568 | 'doctype': /<!DOCTYPE[\s\S]+?>/i,
|
1569 | 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
|
1570 | 'tag': {
|
1571 | pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
|
1572 | inside: {
|
1573 | 'tag': {
|
1574 | pattern: /^<\/?[^\s>\/]+/i,
|
1575 | inside: {
|
1576 | 'punctuation': /^<\/?/,
|
1577 | 'namespace': /^[^\s>\/:]+:/
|
1578 | }
|
1579 | },
|
1580 | 'attr-value': {
|
1581 | pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,
|
1582 | inside: {
|
1583 | 'punctuation': [
|
1584 | /^=/,
|
1585 | {
|
1586 | pattern: /(^|[^\\])["']/,
|
1587 | lookbehind: true
|
1588 | }
|
1589 | ]
|
1590 | }
|
1591 | },
|
1592 | 'punctuation': /\/?>/,
|
1593 | 'attr-name': {
|
1594 | pattern: /[^\s>\/]+/,
|
1595 | inside: {
|
1596 | 'namespace': /^[^\s>\/:]+:/
|
1597 | }
|
1598 | }
|
1599 | }
|
1600 | },
|
1601 | 'entity': /&#?[\da-z]{1,8};/i
|
1602 | };
|
1603 | Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
|
1604 | Prism.languages.markup['entity'];
|
1605 | // Plugin to make entity title show the real entity, idea by Roman Komarov
|
1606 | Prism.hooks.add('wrap', function (env) {
|
1607 | if (env.type === 'entity') {
|
1608 | env.attributes['title'] = env.content.replace(/&/, '&');
|
1609 | }
|
1610 | });
|
1611 | Prism.languages.xml = Prism.languages.markup;
|
1612 | Prism.languages.html = Prism.languages.markup;
|
1613 | Prism.languages.mathml = Prism.languages.markup;
|
1614 | Prism.languages.svg = Prism.languages.markup;
|
1615 | /* **********************************************
|
1616 | Begin prism-css.js
|
1617 | ********************************************** */
|
1618 | Prism.languages.css = {
|
1619 | 'comment': /\/\*[\s\S]*?\*\//,
|
1620 | 'atrule': {
|
1621 | pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i,
|
1622 | inside: {
|
1623 | 'rule': /@[\w-]+/
|
1624 | // See rest below
|
1625 | }
|
1626 | },
|
1627 | 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
|
1628 | 'selector': /[^{}\s][^{};]*?(?=\s*\{)/,
|
1629 | 'string': {
|
1630 | pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
1631 | greedy: true
|
1632 | },
|
1633 | 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
|
1634 | 'important': /\B!important\b/i,
|
1635 | 'function': /[-a-z0-9]+(?=\()/i,
|
1636 | 'punctuation': /[(){};:]/
|
1637 | };
|
1638 | Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
|
1639 | if (Prism.languages.markup) {
|
1640 | Prism.languages.insertBefore('markup', 'tag', {
|
1641 | 'style': {
|
1642 | pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
|
1643 | lookbehind: true,
|
1644 | inside: Prism.languages.css,
|
1645 | alias: 'language-css',
|
1646 | greedy: true
|
1647 | }
|
1648 | });
|
1649 | Prism.languages.insertBefore('inside', 'attr-value', {
|
1650 | 'style-attr': {
|
1651 | pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
|
1652 | inside: {
|
1653 | 'attr-name': {
|
1654 | pattern: /^\s*style/i,
|
1655 | inside: Prism.languages.markup.tag.inside
|
1656 | },
|
1657 | 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
|
1658 | 'attr-value': {
|
1659 | pattern: /.+/i,
|
1660 | inside: Prism.languages.css
|
1661 | }
|
1662 | },
|
1663 | alias: 'language-css'
|
1664 | }
|
1665 | }, Prism.languages.markup.tag);
|
1666 | }
|
1667 | /* **********************************************
|
1668 | Begin prism-clike.js
|
1669 | ********************************************** */
|
1670 | Prism.languages.clike = {
|
1671 | 'comment': [
|
1672 | {
|
1673 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
1674 | lookbehind: true
|
1675 | },
|
1676 | {
|
1677 | pattern: /(^|[^\\:])\/\/.*/,
|
1678 | lookbehind: true
|
1679 | }
|
1680 | ],
|
1681 | 'string': {
|
1682 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
1683 | greedy: true
|
1684 | },
|
1685 | 'class-name': {
|
1686 | pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
|
1687 | lookbehind: true,
|
1688 | inside: {
|
1689 | punctuation: /[.\\]/
|
1690 | }
|
1691 | },
|
1692 | 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
1693 | 'boolean': /\b(?:true|false)\b/,
|
1694 | 'function': /[a-z0-9_]+(?=\()/i,
|
1695 | 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
|
1696 | 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
1697 | 'punctuation': /[{}[\];(),.:]/
|
1698 | };
|
1699 | /* **********************************************
|
1700 | Begin prism-javascript.js
|
1701 | ********************************************** */
|
1702 | Prism.languages.javascript = Prism.languages.extend('clike', {
|
1703 | 'keyword': /\b(?: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|var|void|while|with|yield)\b/,
|
1704 | 'number': /\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,
|
1705 | // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
1706 | 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,
|
1707 | 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
|
1708 | });
|
1709 | Prism.languages.insertBefore('javascript', 'keyword', {
|
1710 | 'regex': {
|
1711 | pattern: /(^|[^/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
|
1712 | lookbehind: true,
|
1713 | greedy: true
|
1714 | },
|
1715 | // This must be declared before keyword because we use "function" inside the look-forward
|
1716 | 'function-variable': {
|
1717 | pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,
|
1718 | alias: 'function'
|
1719 | }
|
1720 | });
|
1721 | Prism.languages.insertBefore('javascript', 'string', {
|
1722 | 'template-string': {
|
1723 | pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
1724 | greedy: true,
|
1725 | inside: {
|
1726 | 'interpolation': {
|
1727 | pattern: /\$\{[^}]+\}/,
|
1728 | inside: {
|
1729 | 'interpolation-punctuation': {
|
1730 | pattern: /^\$\{|\}$/,
|
1731 | alias: 'punctuation'
|
1732 | },
|
1733 | rest: Prism.languages.javascript
|
1734 | }
|
1735 | },
|
1736 | 'string': /[\s\S]+/
|
1737 | }
|
1738 | }
|
1739 | });
|
1740 | if (Prism.languages.markup) {
|
1741 | Prism.languages.insertBefore('markup', 'tag', {
|
1742 | 'script': {
|
1743 | pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
|
1744 | lookbehind: true,
|
1745 | inside: Prism.languages.javascript,
|
1746 | alias: 'language-javascript',
|
1747 | greedy: true
|
1748 | }
|
1749 | });
|
1750 | }
|
1751 | Prism.languages.js = Prism.languages.javascript;
|
1752 | /* **********************************************
|
1753 | Begin prism-file-highlight.js
|
1754 | ********************************************** */
|
1755 | (function () {
|
1756 | if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
|
1757 | return;
|
1758 | }
|
1759 | self.Prism.fileHighlight = function () {
|
1760 | var Extensions = {
|
1761 | 'js': 'javascript',
|
1762 | 'py': 'python',
|
1763 | 'rb': 'ruby',
|
1764 | 'ps1': 'powershell',
|
1765 | 'psm1': 'powershell',
|
1766 | 'sh': 'bash',
|
1767 | 'bat': 'batch',
|
1768 | 'h': 'c',
|
1769 | 'tex': 'latex'
|
1770 | };
|
1771 | Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
|
1772 | var src = pre.getAttribute('data-src');
|
1773 | var language, parent = pre;
|
1774 | var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
|
1775 | while (parent && !lang.test(parent.className)) {
|
1776 | parent = parent.parentNode;
|
1777 | }
|
1778 | if (parent) {
|
1779 | language = (pre.className.match(lang) || [, ''])[1];
|
1780 | }
|
1781 | if (!language) {
|
1782 | var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
|
1783 | language = Extensions[extension] || extension;
|
1784 | }
|
1785 | var code = document.createElement('code');
|
1786 | code.className = 'language-' + language;
|
1787 | pre.textContent = '';
|
1788 | code.textContent = 'Loading…';
|
1789 | pre.appendChild(code);
|
1790 | var xhr = new XMLHttpRequest();
|
1791 | xhr.open('GET', src, true);
|
1792 | xhr.onreadystatechange = function () {
|
1793 | if (xhr.readyState == 4) {
|
1794 | if (xhr.status < 400 && xhr.responseText) {
|
1795 | code.textContent = xhr.responseText;
|
1796 | Prism.highlightElement(code);
|
1797 | }
|
1798 | else if (xhr.status >= 400) {
|
1799 | code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
1800 | }
|
1801 | else {
|
1802 | code.textContent = '✖ Error: File does not exist or is empty';
|
1803 | }
|
1804 | }
|
1805 | };
|
1806 | xhr.send(null);
|
1807 | });
|
1808 | };
|
1809 | document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight);
|
1810 | })();
|
1811 | });
|
1812 | (function (Prism) {
|
1813 | Prism.languages.sass = Prism.languages.extend('css', {
|
1814 | // Sass comments don't need to be closed, only indented
|
1815 | 'comment': {
|
1816 | pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m,
|
1817 | lookbehind: true
|
1818 | }
|
1819 | });
|
1820 | Prism.languages.insertBefore('sass', 'atrule', {
|
1821 | // We want to consume the whole line
|
1822 | 'atrule-line': {
|
1823 | // Includes support for = and + shortcuts
|
1824 | pattern: /^(?:[ \t]*)[@+=].+/m,
|
1825 | inside: {
|
1826 | 'atrule': /(?:@[\w-]+|[+=])/m
|
1827 | }
|
1828 | }
|
1829 | });
|
1830 | delete Prism.languages.sass.atrule;
|
1831 | var variable = /\$[-\w]+|#\{\$[-\w]+\}/;
|
1832 | var operator = [
|
1833 | /[+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/,
|
1834 | {
|
1835 | pattern: /(\s+)-(?=\s)/,
|
1836 | lookbehind: true
|
1837 | }
|
1838 | ];
|
1839 | Prism.languages.insertBefore('sass', 'property', {
|
1840 | // We want to consume the whole line
|
1841 | 'variable-line': {
|
1842 | pattern: /^[ \t]*\$.+/m,
|
1843 | inside: {
|
1844 | 'punctuation': /:/,
|
1845 | 'variable': variable,
|
1846 | 'operator': operator
|
1847 | }
|
1848 | },
|
1849 | // We want to consume the whole line
|
1850 | 'property-line': {
|
1851 | pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s]+.*)/m,
|
1852 | inside: {
|
1853 | 'property': [
|
1854 | /[^:\s]+(?=\s*:)/,
|
1855 | {
|
1856 | pattern: /(:)[^:\s]+/,
|
1857 | lookbehind: true
|
1858 | }
|
1859 | ],
|
1860 | 'punctuation': /:/,
|
1861 | 'variable': variable,
|
1862 | 'operator': operator,
|
1863 | 'important': Prism.languages.sass.important
|
1864 | }
|
1865 | }
|
1866 | });
|
1867 | delete Prism.languages.sass.property;
|
1868 | delete Prism.languages.sass.important;
|
1869 | // Now that whole lines for other patterns are consumed,
|
1870 | // what's left should be selectors
|
1871 | delete Prism.languages.sass.selector;
|
1872 | Prism.languages.insertBefore('sass', 'punctuation', {
|
1873 | 'selector': {
|
1874 | pattern: /([ \t]*)\S(?:,?[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,?[^,\r\n]+)*)*/,
|
1875 | lookbehind: true
|
1876 | }
|
1877 | });
|
1878 | }(Prism));
|
1879 | Prism.languages.typescript = Prism.languages.extend('javascript', {
|
1880 | // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
|
1881 | 'keyword': /\b(?: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|var|void|while|with|yield|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/
|
1882 | });
|
1883 | Prism.languages.ts = Prism.languages.typescript;
|
1884 | var Markdown = /** @class */ (function () {
|
1885 | function Markdown(hostRef) {
|
1886 | registerInstance(this, hostRef);
|
1887 | }
|
1888 | Markdown.prototype.componentDidRender = function () {
|
1889 | this.renderMarkup();
|
1890 | };
|
1891 | Markdown.prototype.renderMarkup = function () {
|
1892 | this.element.innerHTML = marked(this.precompile(this.data));
|
1893 | prism.highlightAll(false);
|
1894 | };
|
1895 | Markdown.prototype.precompile = function (markdown) {
|
1896 | if (!markdown) {
|
1897 | return '';
|
1898 | }
|
1899 | var indentStart;
|
1900 | return markdown
|
1901 | .replace(/\>/g, '>')
|
1902 | .split('\n')
|
1903 | .map(function (line) {
|
1904 | // find position of 1st non-whitespace character
|
1905 | // to determine the markdown indentation start
|
1906 | if (line.length > 0 && isNaN(indentStart)) {
|
1907 | indentStart = line.search(/\S|$/);
|
1908 | }
|
1909 | // remove whitespaces before indentation start
|
1910 | return indentStart ? line.substring(indentStart) : line;
|
1911 | }).join('\n');
|
1912 | };
|
1913 | Object.defineProperty(Markdown.prototype, "element", {
|
1914 | get: function () { return getElement(this); },
|
1915 | enumerable: true,
|
1916 | configurable: true
|
1917 | });
|
1918 | Object.defineProperty(Markdown, "style", {
|
1919 | get: function () { return "ad-markdown{display:block}ad-markdown code[class*=language-],ad-markdown pre[class*=language-]{border-radius:.25rem;color:var(--anj-primary);background:none;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-ms-hyphens:none;hyphens:none}ad-markdown pre[class*=language-]{padding:1rem;margin:2rem 0;overflow:auto}ad-markdown :not(pre)>code[class*=language-],ad-markdown pre[class*=language-]{background:var(--anj-background);border:1px dashed var(--anj-border)}ad-markdown :not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}ad-markdown .token.inserted,ad-markdown .token.punctuation{color:var(--anj-secondary-dark)}ad-markdown .token.attr-value,ad-markdown .token.string{color:var(--anj-dark)}ad-markdown .token.attr-name,ad-markdown .token.char,ad-markdown .token.class-name,ad-markdown .token.constant,ad-markdown .token.function,ad-markdown .token.function-name,ad-markdown .token.property,ad-markdown .token.regex,ad-markdown .token.symbol,ad-markdown .token.variable{color:var(--anj-primary)}ad-markdown .token.atrule,ad-markdown .token.boolean,ad-markdown .token.builtin,ad-markdown .token.deleted,ad-markdown .token.important,ad-markdown .token.keyword,ad-markdown .token.namespace,ad-markdown .token.number,ad-markdown .token.selector,ad-markdown .token.tag{color:var(--anj-highlight-dark)}ad-markdown .token.block-comment,ad-markdown .token.cdata,ad-markdown .token.comment,ad-markdown .token.doctype,ad-markdown .token.entity,ad-markdown .token.operator,ad-markdown .token.prolog,ad-markdown .token.url{color:var(--anj-neutral)}ad-markdown .token.bold,ad-markdown .token.important{font-weight:700}ad-markdown .token.italic{font-style:italic}ad-markdown .token.entity{cursor:help}ad-markdown blockquote{padding:0 1em;color:var(--anj-primary);border-left:.25em solid var(--anj-neutral)}ad-markdown h1{font-size:2rem;font-weight:600;letter-spacing:var(--anj-spacing-wide);margin:0 0 1rem;padding:0}ad-markdown h2{font-size:1.5rem}ad-markdown h2,ad-markdown h3{font-weight:400;margin:1rem 0;padding:0}ad-markdown h3{font-size:1.25rem}ad-markdown h4{font-size:1rem}ad-markdown h4,ad-markdown h5{font-weight:400;margin:1rem 0;padding:0}ad-markdown h5{font-size:.875rem}"; },
|
1920 | enumerable: true,
|
1921 | configurable: true
|
1922 | });
|
1923 | return Markdown;
|
1924 | }());
|
1925 | export { Markdown as ad_markdown };
|