UNPKG

268 kBJavaScriptView Raw
1/*! markdown-it 12.0.2 https://github.com/markdown-it/markdown-it @license MIT */
2(function(global, factory) {
3 typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self,
4 global.markdownit = factory());
5})(this, (function() {
6 "use strict";
7 function createCommonjsModule(fn, basedir, module) {
8 return module = {
9 path: basedir,
10 exports: {},
11 require: function(path, base) {
12 return commonjsRequire(path, base === undefined || base === null ? module.path : base);
13 }
14 }, fn(module, module.exports), module.exports;
15 }
16 function getAugmentedNamespace(n) {
17 if (n.__esModule) return n;
18 var a = Object.defineProperty({}, "__esModule", {
19 value: true
20 });
21 Object.keys(n).forEach((function(k) {
22 var d = Object.getOwnPropertyDescriptor(n, k);
23 Object.defineProperty(a, k, d.get ? d : {
24 enumerable: true,
25 get: function() {
26 return n[k];
27 }
28 });
29 }));
30 return a;
31 }
32 function commonjsRequire() {
33 throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
34 }
35 var require$$0 = {
36 Aacute: "\xc1",
37 aacute: "\xe1",
38 Abreve: "\u0102",
39 abreve: "\u0103",
40 ac: "\u223e",
41 acd: "\u223f",
42 acE: "\u223e\u0333",
43 Acirc: "\xc2",
44 acirc: "\xe2",
45 acute: "\xb4",
46 Acy: "\u0410",
47 acy: "\u0430",
48 AElig: "\xc6",
49 aelig: "\xe6",
50 af: "\u2061",
51 Afr: "\ud835\udd04",
52 afr: "\ud835\udd1e",
53 Agrave: "\xc0",
54 agrave: "\xe0",
55 alefsym: "\u2135",
56 aleph: "\u2135",
57 Alpha: "\u0391",
58 alpha: "\u03b1",
59 Amacr: "\u0100",
60 amacr: "\u0101",
61 amalg: "\u2a3f",
62 amp: "&",
63 AMP: "&",
64 andand: "\u2a55",
65 And: "\u2a53",
66 and: "\u2227",
67 andd: "\u2a5c",
68 andslope: "\u2a58",
69 andv: "\u2a5a",
70 ang: "\u2220",
71 ange: "\u29a4",
72 angle: "\u2220",
73 angmsdaa: "\u29a8",
74 angmsdab: "\u29a9",
75 angmsdac: "\u29aa",
76 angmsdad: "\u29ab",
77 angmsdae: "\u29ac",
78 angmsdaf: "\u29ad",
79 angmsdag: "\u29ae",
80 angmsdah: "\u29af",
81 angmsd: "\u2221",
82 angrt: "\u221f",
83 angrtvb: "\u22be",
84 angrtvbd: "\u299d",
85 angsph: "\u2222",
86 angst: "\xc5",
87 angzarr: "\u237c",
88 Aogon: "\u0104",
89 aogon: "\u0105",
90 Aopf: "\ud835\udd38",
91 aopf: "\ud835\udd52",
92 apacir: "\u2a6f",
93 ap: "\u2248",
94 apE: "\u2a70",
95 ape: "\u224a",
96 apid: "\u224b",
97 apos: "'",
98 ApplyFunction: "\u2061",
99 approx: "\u2248",
100 approxeq: "\u224a",
101 Aring: "\xc5",
102 aring: "\xe5",
103 Ascr: "\ud835\udc9c",
104 ascr: "\ud835\udcb6",
105 Assign: "\u2254",
106 ast: "*",
107 asymp: "\u2248",
108 asympeq: "\u224d",
109 Atilde: "\xc3",
110 atilde: "\xe3",
111 Auml: "\xc4",
112 auml: "\xe4",
113 awconint: "\u2233",
114 awint: "\u2a11",
115 backcong: "\u224c",
116 backepsilon: "\u03f6",
117 backprime: "\u2035",
118 backsim: "\u223d",
119 backsimeq: "\u22cd",
120 Backslash: "\u2216",
121 Barv: "\u2ae7",
122 barvee: "\u22bd",
123 barwed: "\u2305",
124 Barwed: "\u2306",
125 barwedge: "\u2305",
126 bbrk: "\u23b5",
127 bbrktbrk: "\u23b6",
128 bcong: "\u224c",
129 Bcy: "\u0411",
130 bcy: "\u0431",
131 bdquo: "\u201e",
132 becaus: "\u2235",
133 because: "\u2235",
134 Because: "\u2235",
135 bemptyv: "\u29b0",
136 bepsi: "\u03f6",
137 bernou: "\u212c",
138 Bernoullis: "\u212c",
139 Beta: "\u0392",
140 beta: "\u03b2",
141 beth: "\u2136",
142 between: "\u226c",
143 Bfr: "\ud835\udd05",
144 bfr: "\ud835\udd1f",
145 bigcap: "\u22c2",
146 bigcirc: "\u25ef",
147 bigcup: "\u22c3",
148 bigodot: "\u2a00",
149 bigoplus: "\u2a01",
150 bigotimes: "\u2a02",
151 bigsqcup: "\u2a06",
152 bigstar: "\u2605",
153 bigtriangledown: "\u25bd",
154 bigtriangleup: "\u25b3",
155 biguplus: "\u2a04",
156 bigvee: "\u22c1",
157 bigwedge: "\u22c0",
158 bkarow: "\u290d",
159 blacklozenge: "\u29eb",
160 blacksquare: "\u25aa",
161 blacktriangle: "\u25b4",
162 blacktriangledown: "\u25be",
163 blacktriangleleft: "\u25c2",
164 blacktriangleright: "\u25b8",
165 blank: "\u2423",
166 blk12: "\u2592",
167 blk14: "\u2591",
168 blk34: "\u2593",
169 block: "\u2588",
170 bne: "=\u20e5",
171 bnequiv: "\u2261\u20e5",
172 bNot: "\u2aed",
173 bnot: "\u2310",
174 Bopf: "\ud835\udd39",
175 bopf: "\ud835\udd53",
176 bot: "\u22a5",
177 bottom: "\u22a5",
178 bowtie: "\u22c8",
179 boxbox: "\u29c9",
180 boxdl: "\u2510",
181 boxdL: "\u2555",
182 boxDl: "\u2556",
183 boxDL: "\u2557",
184 boxdr: "\u250c",
185 boxdR: "\u2552",
186 boxDr: "\u2553",
187 boxDR: "\u2554",
188 boxh: "\u2500",
189 boxH: "\u2550",
190 boxhd: "\u252c",
191 boxHd: "\u2564",
192 boxhD: "\u2565",
193 boxHD: "\u2566",
194 boxhu: "\u2534",
195 boxHu: "\u2567",
196 boxhU: "\u2568",
197 boxHU: "\u2569",
198 boxminus: "\u229f",
199 boxplus: "\u229e",
200 boxtimes: "\u22a0",
201 boxul: "\u2518",
202 boxuL: "\u255b",
203 boxUl: "\u255c",
204 boxUL: "\u255d",
205 boxur: "\u2514",
206 boxuR: "\u2558",
207 boxUr: "\u2559",
208 boxUR: "\u255a",
209 boxv: "\u2502",
210 boxV: "\u2551",
211 boxvh: "\u253c",
212 boxvH: "\u256a",
213 boxVh: "\u256b",
214 boxVH: "\u256c",
215 boxvl: "\u2524",
216 boxvL: "\u2561",
217 boxVl: "\u2562",
218 boxVL: "\u2563",
219 boxvr: "\u251c",
220 boxvR: "\u255e",
221 boxVr: "\u255f",
222 boxVR: "\u2560",
223 bprime: "\u2035",
224 breve: "\u02d8",
225 Breve: "\u02d8",
226 brvbar: "\xa6",
227 bscr: "\ud835\udcb7",
228 Bscr: "\u212c",
229 bsemi: "\u204f",
230 bsim: "\u223d",
231 bsime: "\u22cd",
232 bsolb: "\u29c5",
233 bsol: "\\",
234 bsolhsub: "\u27c8",
235 bull: "\u2022",
236 bullet: "\u2022",
237 bump: "\u224e",
238 bumpE: "\u2aae",
239 bumpe: "\u224f",
240 Bumpeq: "\u224e",
241 bumpeq: "\u224f",
242 Cacute: "\u0106",
243 cacute: "\u0107",
244 capand: "\u2a44",
245 capbrcup: "\u2a49",
246 capcap: "\u2a4b",
247 cap: "\u2229",
248 Cap: "\u22d2",
249 capcup: "\u2a47",
250 capdot: "\u2a40",
251 CapitalDifferentialD: "\u2145",
252 caps: "\u2229\ufe00",
253 caret: "\u2041",
254 caron: "\u02c7",
255 Cayleys: "\u212d",
256 ccaps: "\u2a4d",
257 Ccaron: "\u010c",
258 ccaron: "\u010d",
259 Ccedil: "\xc7",
260 ccedil: "\xe7",
261 Ccirc: "\u0108",
262 ccirc: "\u0109",
263 Cconint: "\u2230",
264 ccups: "\u2a4c",
265 ccupssm: "\u2a50",
266 Cdot: "\u010a",
267 cdot: "\u010b",
268 cedil: "\xb8",
269 Cedilla: "\xb8",
270 cemptyv: "\u29b2",
271 cent: "\xa2",
272 centerdot: "\xb7",
273 CenterDot: "\xb7",
274 cfr: "\ud835\udd20",
275 Cfr: "\u212d",
276 CHcy: "\u0427",
277 chcy: "\u0447",
278 check: "\u2713",
279 checkmark: "\u2713",
280 Chi: "\u03a7",
281 chi: "\u03c7",
282 circ: "\u02c6",
283 circeq: "\u2257",
284 circlearrowleft: "\u21ba",
285 circlearrowright: "\u21bb",
286 circledast: "\u229b",
287 circledcirc: "\u229a",
288 circleddash: "\u229d",
289 CircleDot: "\u2299",
290 circledR: "\xae",
291 circledS: "\u24c8",
292 CircleMinus: "\u2296",
293 CirclePlus: "\u2295",
294 CircleTimes: "\u2297",
295 cir: "\u25cb",
296 cirE: "\u29c3",
297 cire: "\u2257",
298 cirfnint: "\u2a10",
299 cirmid: "\u2aef",
300 cirscir: "\u29c2",
301 ClockwiseContourIntegral: "\u2232",
302 CloseCurlyDoubleQuote: "\u201d",
303 CloseCurlyQuote: "\u2019",
304 clubs: "\u2663",
305 clubsuit: "\u2663",
306 colon: ":",
307 Colon: "\u2237",
308 Colone: "\u2a74",
309 colone: "\u2254",
310 coloneq: "\u2254",
311 comma: ",",
312 commat: "@",
313 comp: "\u2201",
314 compfn: "\u2218",
315 complement: "\u2201",
316 complexes: "\u2102",
317 cong: "\u2245",
318 congdot: "\u2a6d",
319 Congruent: "\u2261",
320 conint: "\u222e",
321 Conint: "\u222f",
322 ContourIntegral: "\u222e",
323 copf: "\ud835\udd54",
324 Copf: "\u2102",
325 coprod: "\u2210",
326 Coproduct: "\u2210",
327 copy: "\xa9",
328 COPY: "\xa9",
329 copysr: "\u2117",
330 CounterClockwiseContourIntegral: "\u2233",
331 crarr: "\u21b5",
332 cross: "\u2717",
333 Cross: "\u2a2f",
334 Cscr: "\ud835\udc9e",
335 cscr: "\ud835\udcb8",
336 csub: "\u2acf",
337 csube: "\u2ad1",
338 csup: "\u2ad0",
339 csupe: "\u2ad2",
340 ctdot: "\u22ef",
341 cudarrl: "\u2938",
342 cudarrr: "\u2935",
343 cuepr: "\u22de",
344 cuesc: "\u22df",
345 cularr: "\u21b6",
346 cularrp: "\u293d",
347 cupbrcap: "\u2a48",
348 cupcap: "\u2a46",
349 CupCap: "\u224d",
350 cup: "\u222a",
351 Cup: "\u22d3",
352 cupcup: "\u2a4a",
353 cupdot: "\u228d",
354 cupor: "\u2a45",
355 cups: "\u222a\ufe00",
356 curarr: "\u21b7",
357 curarrm: "\u293c",
358 curlyeqprec: "\u22de",
359 curlyeqsucc: "\u22df",
360 curlyvee: "\u22ce",
361 curlywedge: "\u22cf",
362 curren: "\xa4",
363 curvearrowleft: "\u21b6",
364 curvearrowright: "\u21b7",
365 cuvee: "\u22ce",
366 cuwed: "\u22cf",
367 cwconint: "\u2232",
368 cwint: "\u2231",
369 cylcty: "\u232d",
370 dagger: "\u2020",
371 Dagger: "\u2021",
372 daleth: "\u2138",
373 darr: "\u2193",
374 Darr: "\u21a1",
375 dArr: "\u21d3",
376 dash: "\u2010",
377 Dashv: "\u2ae4",
378 dashv: "\u22a3",
379 dbkarow: "\u290f",
380 dblac: "\u02dd",
381 Dcaron: "\u010e",
382 dcaron: "\u010f",
383 Dcy: "\u0414",
384 dcy: "\u0434",
385 ddagger: "\u2021",
386 ddarr: "\u21ca",
387 DD: "\u2145",
388 dd: "\u2146",
389 DDotrahd: "\u2911",
390 ddotseq: "\u2a77",
391 deg: "\xb0",
392 Del: "\u2207",
393 Delta: "\u0394",
394 delta: "\u03b4",
395 demptyv: "\u29b1",
396 dfisht: "\u297f",
397 Dfr: "\ud835\udd07",
398 dfr: "\ud835\udd21",
399 dHar: "\u2965",
400 dharl: "\u21c3",
401 dharr: "\u21c2",
402 DiacriticalAcute: "\xb4",
403 DiacriticalDot: "\u02d9",
404 DiacriticalDoubleAcute: "\u02dd",
405 DiacriticalGrave: "`",
406 DiacriticalTilde: "\u02dc",
407 diam: "\u22c4",
408 diamond: "\u22c4",
409 Diamond: "\u22c4",
410 diamondsuit: "\u2666",
411 diams: "\u2666",
412 die: "\xa8",
413 DifferentialD: "\u2146",
414 digamma: "\u03dd",
415 disin: "\u22f2",
416 div: "\xf7",
417 divide: "\xf7",
418 divideontimes: "\u22c7",
419 divonx: "\u22c7",
420 DJcy: "\u0402",
421 djcy: "\u0452",
422 dlcorn: "\u231e",
423 dlcrop: "\u230d",
424 dollar: "$",
425 Dopf: "\ud835\udd3b",
426 dopf: "\ud835\udd55",
427 Dot: "\xa8",
428 dot: "\u02d9",
429 DotDot: "\u20dc",
430 doteq: "\u2250",
431 doteqdot: "\u2251",
432 DotEqual: "\u2250",
433 dotminus: "\u2238",
434 dotplus: "\u2214",
435 dotsquare: "\u22a1",
436 doublebarwedge: "\u2306",
437 DoubleContourIntegral: "\u222f",
438 DoubleDot: "\xa8",
439 DoubleDownArrow: "\u21d3",
440 DoubleLeftArrow: "\u21d0",
441 DoubleLeftRightArrow: "\u21d4",
442 DoubleLeftTee: "\u2ae4",
443 DoubleLongLeftArrow: "\u27f8",
444 DoubleLongLeftRightArrow: "\u27fa",
445 DoubleLongRightArrow: "\u27f9",
446 DoubleRightArrow: "\u21d2",
447 DoubleRightTee: "\u22a8",
448 DoubleUpArrow: "\u21d1",
449 DoubleUpDownArrow: "\u21d5",
450 DoubleVerticalBar: "\u2225",
451 DownArrowBar: "\u2913",
452 downarrow: "\u2193",
453 DownArrow: "\u2193",
454 Downarrow: "\u21d3",
455 DownArrowUpArrow: "\u21f5",
456 DownBreve: "\u0311",
457 downdownarrows: "\u21ca",
458 downharpoonleft: "\u21c3",
459 downharpoonright: "\u21c2",
460 DownLeftRightVector: "\u2950",
461 DownLeftTeeVector: "\u295e",
462 DownLeftVectorBar: "\u2956",
463 DownLeftVector: "\u21bd",
464 DownRightTeeVector: "\u295f",
465 DownRightVectorBar: "\u2957",
466 DownRightVector: "\u21c1",
467 DownTeeArrow: "\u21a7",
468 DownTee: "\u22a4",
469 drbkarow: "\u2910",
470 drcorn: "\u231f",
471 drcrop: "\u230c",
472 Dscr: "\ud835\udc9f",
473 dscr: "\ud835\udcb9",
474 DScy: "\u0405",
475 dscy: "\u0455",
476 dsol: "\u29f6",
477 Dstrok: "\u0110",
478 dstrok: "\u0111",
479 dtdot: "\u22f1",
480 dtri: "\u25bf",
481 dtrif: "\u25be",
482 duarr: "\u21f5",
483 duhar: "\u296f",
484 dwangle: "\u29a6",
485 DZcy: "\u040f",
486 dzcy: "\u045f",
487 dzigrarr: "\u27ff",
488 Eacute: "\xc9",
489 eacute: "\xe9",
490 easter: "\u2a6e",
491 Ecaron: "\u011a",
492 ecaron: "\u011b",
493 Ecirc: "\xca",
494 ecirc: "\xea",
495 ecir: "\u2256",
496 ecolon: "\u2255",
497 Ecy: "\u042d",
498 ecy: "\u044d",
499 eDDot: "\u2a77",
500 Edot: "\u0116",
501 edot: "\u0117",
502 eDot: "\u2251",
503 ee: "\u2147",
504 efDot: "\u2252",
505 Efr: "\ud835\udd08",
506 efr: "\ud835\udd22",
507 eg: "\u2a9a",
508 Egrave: "\xc8",
509 egrave: "\xe8",
510 egs: "\u2a96",
511 egsdot: "\u2a98",
512 el: "\u2a99",
513 Element: "\u2208",
514 elinters: "\u23e7",
515 ell: "\u2113",
516 els: "\u2a95",
517 elsdot: "\u2a97",
518 Emacr: "\u0112",
519 emacr: "\u0113",
520 empty: "\u2205",
521 emptyset: "\u2205",
522 EmptySmallSquare: "\u25fb",
523 emptyv: "\u2205",
524 EmptyVerySmallSquare: "\u25ab",
525 emsp13: "\u2004",
526 emsp14: "\u2005",
527 emsp: "\u2003",
528 ENG: "\u014a",
529 eng: "\u014b",
530 ensp: "\u2002",
531 Eogon: "\u0118",
532 eogon: "\u0119",
533 Eopf: "\ud835\udd3c",
534 eopf: "\ud835\udd56",
535 epar: "\u22d5",
536 eparsl: "\u29e3",
537 eplus: "\u2a71",
538 epsi: "\u03b5",
539 Epsilon: "\u0395",
540 epsilon: "\u03b5",
541 epsiv: "\u03f5",
542 eqcirc: "\u2256",
543 eqcolon: "\u2255",
544 eqsim: "\u2242",
545 eqslantgtr: "\u2a96",
546 eqslantless: "\u2a95",
547 Equal: "\u2a75",
548 equals: "=",
549 EqualTilde: "\u2242",
550 equest: "\u225f",
551 Equilibrium: "\u21cc",
552 equiv: "\u2261",
553 equivDD: "\u2a78",
554 eqvparsl: "\u29e5",
555 erarr: "\u2971",
556 erDot: "\u2253",
557 escr: "\u212f",
558 Escr: "\u2130",
559 esdot: "\u2250",
560 Esim: "\u2a73",
561 esim: "\u2242",
562 Eta: "\u0397",
563 eta: "\u03b7",
564 ETH: "\xd0",
565 eth: "\xf0",
566 Euml: "\xcb",
567 euml: "\xeb",
568 euro: "\u20ac",
569 excl: "!",
570 exist: "\u2203",
571 Exists: "\u2203",
572 expectation: "\u2130",
573 exponentiale: "\u2147",
574 ExponentialE: "\u2147",
575 fallingdotseq: "\u2252",
576 Fcy: "\u0424",
577 fcy: "\u0444",
578 female: "\u2640",
579 ffilig: "\ufb03",
580 fflig: "\ufb00",
581 ffllig: "\ufb04",
582 Ffr: "\ud835\udd09",
583 ffr: "\ud835\udd23",
584 filig: "\ufb01",
585 FilledSmallSquare: "\u25fc",
586 FilledVerySmallSquare: "\u25aa",
587 fjlig: "fj",
588 flat: "\u266d",
589 fllig: "\ufb02",
590 fltns: "\u25b1",
591 fnof: "\u0192",
592 Fopf: "\ud835\udd3d",
593 fopf: "\ud835\udd57",
594 forall: "\u2200",
595 ForAll: "\u2200",
596 fork: "\u22d4",
597 forkv: "\u2ad9",
598 Fouriertrf: "\u2131",
599 fpartint: "\u2a0d",
600 frac12: "\xbd",
601 frac13: "\u2153",
602 frac14: "\xbc",
603 frac15: "\u2155",
604 frac16: "\u2159",
605 frac18: "\u215b",
606 frac23: "\u2154",
607 frac25: "\u2156",
608 frac34: "\xbe",
609 frac35: "\u2157",
610 frac38: "\u215c",
611 frac45: "\u2158",
612 frac56: "\u215a",
613 frac58: "\u215d",
614 frac78: "\u215e",
615 frasl: "\u2044",
616 frown: "\u2322",
617 fscr: "\ud835\udcbb",
618 Fscr: "\u2131",
619 gacute: "\u01f5",
620 Gamma: "\u0393",
621 gamma: "\u03b3",
622 Gammad: "\u03dc",
623 gammad: "\u03dd",
624 gap: "\u2a86",
625 Gbreve: "\u011e",
626 gbreve: "\u011f",
627 Gcedil: "\u0122",
628 Gcirc: "\u011c",
629 gcirc: "\u011d",
630 Gcy: "\u0413",
631 gcy: "\u0433",
632 Gdot: "\u0120",
633 gdot: "\u0121",
634 ge: "\u2265",
635 gE: "\u2267",
636 gEl: "\u2a8c",
637 gel: "\u22db",
638 geq: "\u2265",
639 geqq: "\u2267",
640 geqslant: "\u2a7e",
641 gescc: "\u2aa9",
642 ges: "\u2a7e",
643 gesdot: "\u2a80",
644 gesdoto: "\u2a82",
645 gesdotol: "\u2a84",
646 gesl: "\u22db\ufe00",
647 gesles: "\u2a94",
648 Gfr: "\ud835\udd0a",
649 gfr: "\ud835\udd24",
650 gg: "\u226b",
651 Gg: "\u22d9",
652 ggg: "\u22d9",
653 gimel: "\u2137",
654 GJcy: "\u0403",
655 gjcy: "\u0453",
656 gla: "\u2aa5",
657 gl: "\u2277",
658 glE: "\u2a92",
659 glj: "\u2aa4",
660 gnap: "\u2a8a",
661 gnapprox: "\u2a8a",
662 gne: "\u2a88",
663 gnE: "\u2269",
664 gneq: "\u2a88",
665 gneqq: "\u2269",
666 gnsim: "\u22e7",
667 Gopf: "\ud835\udd3e",
668 gopf: "\ud835\udd58",
669 grave: "`",
670 GreaterEqual: "\u2265",
671 GreaterEqualLess: "\u22db",
672 GreaterFullEqual: "\u2267",
673 GreaterGreater: "\u2aa2",
674 GreaterLess: "\u2277",
675 GreaterSlantEqual: "\u2a7e",
676 GreaterTilde: "\u2273",
677 Gscr: "\ud835\udca2",
678 gscr: "\u210a",
679 gsim: "\u2273",
680 gsime: "\u2a8e",
681 gsiml: "\u2a90",
682 gtcc: "\u2aa7",
683 gtcir: "\u2a7a",
684 gt: ">",
685 GT: ">",
686 Gt: "\u226b",
687 gtdot: "\u22d7",
688 gtlPar: "\u2995",
689 gtquest: "\u2a7c",
690 gtrapprox: "\u2a86",
691 gtrarr: "\u2978",
692 gtrdot: "\u22d7",
693 gtreqless: "\u22db",
694 gtreqqless: "\u2a8c",
695 gtrless: "\u2277",
696 gtrsim: "\u2273",
697 gvertneqq: "\u2269\ufe00",
698 gvnE: "\u2269\ufe00",
699 Hacek: "\u02c7",
700 hairsp: "\u200a",
701 half: "\xbd",
702 hamilt: "\u210b",
703 HARDcy: "\u042a",
704 hardcy: "\u044a",
705 harrcir: "\u2948",
706 harr: "\u2194",
707 hArr: "\u21d4",
708 harrw: "\u21ad",
709 Hat: "^",
710 hbar: "\u210f",
711 Hcirc: "\u0124",
712 hcirc: "\u0125",
713 hearts: "\u2665",
714 heartsuit: "\u2665",
715 hellip: "\u2026",
716 hercon: "\u22b9",
717 hfr: "\ud835\udd25",
718 Hfr: "\u210c",
719 HilbertSpace: "\u210b",
720 hksearow: "\u2925",
721 hkswarow: "\u2926",
722 hoarr: "\u21ff",
723 homtht: "\u223b",
724 hookleftarrow: "\u21a9",
725 hookrightarrow: "\u21aa",
726 hopf: "\ud835\udd59",
727 Hopf: "\u210d",
728 horbar: "\u2015",
729 HorizontalLine: "\u2500",
730 hscr: "\ud835\udcbd",
731 Hscr: "\u210b",
732 hslash: "\u210f",
733 Hstrok: "\u0126",
734 hstrok: "\u0127",
735 HumpDownHump: "\u224e",
736 HumpEqual: "\u224f",
737 hybull: "\u2043",
738 hyphen: "\u2010",
739 Iacute: "\xcd",
740 iacute: "\xed",
741 ic: "\u2063",
742 Icirc: "\xce",
743 icirc: "\xee",
744 Icy: "\u0418",
745 icy: "\u0438",
746 Idot: "\u0130",
747 IEcy: "\u0415",
748 iecy: "\u0435",
749 iexcl: "\xa1",
750 iff: "\u21d4",
751 ifr: "\ud835\udd26",
752 Ifr: "\u2111",
753 Igrave: "\xcc",
754 igrave: "\xec",
755 ii: "\u2148",
756 iiiint: "\u2a0c",
757 iiint: "\u222d",
758 iinfin: "\u29dc",
759 iiota: "\u2129",
760 IJlig: "\u0132",
761 ijlig: "\u0133",
762 Imacr: "\u012a",
763 imacr: "\u012b",
764 image: "\u2111",
765 ImaginaryI: "\u2148",
766 imagline: "\u2110",
767 imagpart: "\u2111",
768 imath: "\u0131",
769 Im: "\u2111",
770 imof: "\u22b7",
771 imped: "\u01b5",
772 Implies: "\u21d2",
773 incare: "\u2105",
774 in: "\u2208",
775 infin: "\u221e",
776 infintie: "\u29dd",
777 inodot: "\u0131",
778 intcal: "\u22ba",
779 int: "\u222b",
780 Int: "\u222c",
781 integers: "\u2124",
782 Integral: "\u222b",
783 intercal: "\u22ba",
784 Intersection: "\u22c2",
785 intlarhk: "\u2a17",
786 intprod: "\u2a3c",
787 InvisibleComma: "\u2063",
788 InvisibleTimes: "\u2062",
789 IOcy: "\u0401",
790 iocy: "\u0451",
791 Iogon: "\u012e",
792 iogon: "\u012f",
793 Iopf: "\ud835\udd40",
794 iopf: "\ud835\udd5a",
795 Iota: "\u0399",
796 iota: "\u03b9",
797 iprod: "\u2a3c",
798 iquest: "\xbf",
799 iscr: "\ud835\udcbe",
800 Iscr: "\u2110",
801 isin: "\u2208",
802 isindot: "\u22f5",
803 isinE: "\u22f9",
804 isins: "\u22f4",
805 isinsv: "\u22f3",
806 isinv: "\u2208",
807 it: "\u2062",
808 Itilde: "\u0128",
809 itilde: "\u0129",
810 Iukcy: "\u0406",
811 iukcy: "\u0456",
812 Iuml: "\xcf",
813 iuml: "\xef",
814 Jcirc: "\u0134",
815 jcirc: "\u0135",
816 Jcy: "\u0419",
817 jcy: "\u0439",
818 Jfr: "\ud835\udd0d",
819 jfr: "\ud835\udd27",
820 jmath: "\u0237",
821 Jopf: "\ud835\udd41",
822 jopf: "\ud835\udd5b",
823 Jscr: "\ud835\udca5",
824 jscr: "\ud835\udcbf",
825 Jsercy: "\u0408",
826 jsercy: "\u0458",
827 Jukcy: "\u0404",
828 jukcy: "\u0454",
829 Kappa: "\u039a",
830 kappa: "\u03ba",
831 kappav: "\u03f0",
832 Kcedil: "\u0136",
833 kcedil: "\u0137",
834 Kcy: "\u041a",
835 kcy: "\u043a",
836 Kfr: "\ud835\udd0e",
837 kfr: "\ud835\udd28",
838 kgreen: "\u0138",
839 KHcy: "\u0425",
840 khcy: "\u0445",
841 KJcy: "\u040c",
842 kjcy: "\u045c",
843 Kopf: "\ud835\udd42",
844 kopf: "\ud835\udd5c",
845 Kscr: "\ud835\udca6",
846 kscr: "\ud835\udcc0",
847 lAarr: "\u21da",
848 Lacute: "\u0139",
849 lacute: "\u013a",
850 laemptyv: "\u29b4",
851 lagran: "\u2112",
852 Lambda: "\u039b",
853 lambda: "\u03bb",
854 lang: "\u27e8",
855 Lang: "\u27ea",
856 langd: "\u2991",
857 langle: "\u27e8",
858 lap: "\u2a85",
859 Laplacetrf: "\u2112",
860 laquo: "\xab",
861 larrb: "\u21e4",
862 larrbfs: "\u291f",
863 larr: "\u2190",
864 Larr: "\u219e",
865 lArr: "\u21d0",
866 larrfs: "\u291d",
867 larrhk: "\u21a9",
868 larrlp: "\u21ab",
869 larrpl: "\u2939",
870 larrsim: "\u2973",
871 larrtl: "\u21a2",
872 latail: "\u2919",
873 lAtail: "\u291b",
874 lat: "\u2aab",
875 late: "\u2aad",
876 lates: "\u2aad\ufe00",
877 lbarr: "\u290c",
878 lBarr: "\u290e",
879 lbbrk: "\u2772",
880 lbrace: "{",
881 lbrack: "[",
882 lbrke: "\u298b",
883 lbrksld: "\u298f",
884 lbrkslu: "\u298d",
885 Lcaron: "\u013d",
886 lcaron: "\u013e",
887 Lcedil: "\u013b",
888 lcedil: "\u013c",
889 lceil: "\u2308",
890 lcub: "{",
891 Lcy: "\u041b",
892 lcy: "\u043b",
893 ldca: "\u2936",
894 ldquo: "\u201c",
895 ldquor: "\u201e",
896 ldrdhar: "\u2967",
897 ldrushar: "\u294b",
898 ldsh: "\u21b2",
899 le: "\u2264",
900 lE: "\u2266",
901 LeftAngleBracket: "\u27e8",
902 LeftArrowBar: "\u21e4",
903 leftarrow: "\u2190",
904 LeftArrow: "\u2190",
905 Leftarrow: "\u21d0",
906 LeftArrowRightArrow: "\u21c6",
907 leftarrowtail: "\u21a2",
908 LeftCeiling: "\u2308",
909 LeftDoubleBracket: "\u27e6",
910 LeftDownTeeVector: "\u2961",
911 LeftDownVectorBar: "\u2959",
912 LeftDownVector: "\u21c3",
913 LeftFloor: "\u230a",
914 leftharpoondown: "\u21bd",
915 leftharpoonup: "\u21bc",
916 leftleftarrows: "\u21c7",
917 leftrightarrow: "\u2194",
918 LeftRightArrow: "\u2194",
919 Leftrightarrow: "\u21d4",
920 leftrightarrows: "\u21c6",
921 leftrightharpoons: "\u21cb",
922 leftrightsquigarrow: "\u21ad",
923 LeftRightVector: "\u294e",
924 LeftTeeArrow: "\u21a4",
925 LeftTee: "\u22a3",
926 LeftTeeVector: "\u295a",
927 leftthreetimes: "\u22cb",
928 LeftTriangleBar: "\u29cf",
929 LeftTriangle: "\u22b2",
930 LeftTriangleEqual: "\u22b4",
931 LeftUpDownVector: "\u2951",
932 LeftUpTeeVector: "\u2960",
933 LeftUpVectorBar: "\u2958",
934 LeftUpVector: "\u21bf",
935 LeftVectorBar: "\u2952",
936 LeftVector: "\u21bc",
937 lEg: "\u2a8b",
938 leg: "\u22da",
939 leq: "\u2264",
940 leqq: "\u2266",
941 leqslant: "\u2a7d",
942 lescc: "\u2aa8",
943 les: "\u2a7d",
944 lesdot: "\u2a7f",
945 lesdoto: "\u2a81",
946 lesdotor: "\u2a83",
947 lesg: "\u22da\ufe00",
948 lesges: "\u2a93",
949 lessapprox: "\u2a85",
950 lessdot: "\u22d6",
951 lesseqgtr: "\u22da",
952 lesseqqgtr: "\u2a8b",
953 LessEqualGreater: "\u22da",
954 LessFullEqual: "\u2266",
955 LessGreater: "\u2276",
956 lessgtr: "\u2276",
957 LessLess: "\u2aa1",
958 lesssim: "\u2272",
959 LessSlantEqual: "\u2a7d",
960 LessTilde: "\u2272",
961 lfisht: "\u297c",
962 lfloor: "\u230a",
963 Lfr: "\ud835\udd0f",
964 lfr: "\ud835\udd29",
965 lg: "\u2276",
966 lgE: "\u2a91",
967 lHar: "\u2962",
968 lhard: "\u21bd",
969 lharu: "\u21bc",
970 lharul: "\u296a",
971 lhblk: "\u2584",
972 LJcy: "\u0409",
973 ljcy: "\u0459",
974 llarr: "\u21c7",
975 ll: "\u226a",
976 Ll: "\u22d8",
977 llcorner: "\u231e",
978 Lleftarrow: "\u21da",
979 llhard: "\u296b",
980 lltri: "\u25fa",
981 Lmidot: "\u013f",
982 lmidot: "\u0140",
983 lmoustache: "\u23b0",
984 lmoust: "\u23b0",
985 lnap: "\u2a89",
986 lnapprox: "\u2a89",
987 lne: "\u2a87",
988 lnE: "\u2268",
989 lneq: "\u2a87",
990 lneqq: "\u2268",
991 lnsim: "\u22e6",
992 loang: "\u27ec",
993 loarr: "\u21fd",
994 lobrk: "\u27e6",
995 longleftarrow: "\u27f5",
996 LongLeftArrow: "\u27f5",
997 Longleftarrow: "\u27f8",
998 longleftrightarrow: "\u27f7",
999 LongLeftRightArrow: "\u27f7",
1000 Longleftrightarrow: "\u27fa",
1001 longmapsto: "\u27fc",
1002 longrightarrow: "\u27f6",
1003 LongRightArrow: "\u27f6",
1004 Longrightarrow: "\u27f9",
1005 looparrowleft: "\u21ab",
1006 looparrowright: "\u21ac",
1007 lopar: "\u2985",
1008 Lopf: "\ud835\udd43",
1009 lopf: "\ud835\udd5d",
1010 loplus: "\u2a2d",
1011 lotimes: "\u2a34",
1012 lowast: "\u2217",
1013 lowbar: "_",
1014 LowerLeftArrow: "\u2199",
1015 LowerRightArrow: "\u2198",
1016 loz: "\u25ca",
1017 lozenge: "\u25ca",
1018 lozf: "\u29eb",
1019 lpar: "(",
1020 lparlt: "\u2993",
1021 lrarr: "\u21c6",
1022 lrcorner: "\u231f",
1023 lrhar: "\u21cb",
1024 lrhard: "\u296d",
1025 lrm: "\u200e",
1026 lrtri: "\u22bf",
1027 lsaquo: "\u2039",
1028 lscr: "\ud835\udcc1",
1029 Lscr: "\u2112",
1030 lsh: "\u21b0",
1031 Lsh: "\u21b0",
1032 lsim: "\u2272",
1033 lsime: "\u2a8d",
1034 lsimg: "\u2a8f",
1035 lsqb: "[",
1036 lsquo: "\u2018",
1037 lsquor: "\u201a",
1038 Lstrok: "\u0141",
1039 lstrok: "\u0142",
1040 ltcc: "\u2aa6",
1041 ltcir: "\u2a79",
1042 lt: "<",
1043 LT: "<",
1044 Lt: "\u226a",
1045 ltdot: "\u22d6",
1046 lthree: "\u22cb",
1047 ltimes: "\u22c9",
1048 ltlarr: "\u2976",
1049 ltquest: "\u2a7b",
1050 ltri: "\u25c3",
1051 ltrie: "\u22b4",
1052 ltrif: "\u25c2",
1053 ltrPar: "\u2996",
1054 lurdshar: "\u294a",
1055 luruhar: "\u2966",
1056 lvertneqq: "\u2268\ufe00",
1057 lvnE: "\u2268\ufe00",
1058 macr: "\xaf",
1059 male: "\u2642",
1060 malt: "\u2720",
1061 maltese: "\u2720",
1062 Map: "\u2905",
1063 map: "\u21a6",
1064 mapsto: "\u21a6",
1065 mapstodown: "\u21a7",
1066 mapstoleft: "\u21a4",
1067 mapstoup: "\u21a5",
1068 marker: "\u25ae",
1069 mcomma: "\u2a29",
1070 Mcy: "\u041c",
1071 mcy: "\u043c",
1072 mdash: "\u2014",
1073 mDDot: "\u223a",
1074 measuredangle: "\u2221",
1075 MediumSpace: "\u205f",
1076 Mellintrf: "\u2133",
1077 Mfr: "\ud835\udd10",
1078 mfr: "\ud835\udd2a",
1079 mho: "\u2127",
1080 micro: "\xb5",
1081 midast: "*",
1082 midcir: "\u2af0",
1083 mid: "\u2223",
1084 middot: "\xb7",
1085 minusb: "\u229f",
1086 minus: "\u2212",
1087 minusd: "\u2238",
1088 minusdu: "\u2a2a",
1089 MinusPlus: "\u2213",
1090 mlcp: "\u2adb",
1091 mldr: "\u2026",
1092 mnplus: "\u2213",
1093 models: "\u22a7",
1094 Mopf: "\ud835\udd44",
1095 mopf: "\ud835\udd5e",
1096 mp: "\u2213",
1097 mscr: "\ud835\udcc2",
1098 Mscr: "\u2133",
1099 mstpos: "\u223e",
1100 Mu: "\u039c",
1101 mu: "\u03bc",
1102 multimap: "\u22b8",
1103 mumap: "\u22b8",
1104 nabla: "\u2207",
1105 Nacute: "\u0143",
1106 nacute: "\u0144",
1107 nang: "\u2220\u20d2",
1108 nap: "\u2249",
1109 napE: "\u2a70\u0338",
1110 napid: "\u224b\u0338",
1111 napos: "\u0149",
1112 napprox: "\u2249",
1113 natural: "\u266e",
1114 naturals: "\u2115",
1115 natur: "\u266e",
1116 nbsp: "\xa0",
1117 nbump: "\u224e\u0338",
1118 nbumpe: "\u224f\u0338",
1119 ncap: "\u2a43",
1120 Ncaron: "\u0147",
1121 ncaron: "\u0148",
1122 Ncedil: "\u0145",
1123 ncedil: "\u0146",
1124 ncong: "\u2247",
1125 ncongdot: "\u2a6d\u0338",
1126 ncup: "\u2a42",
1127 Ncy: "\u041d",
1128 ncy: "\u043d",
1129 ndash: "\u2013",
1130 nearhk: "\u2924",
1131 nearr: "\u2197",
1132 neArr: "\u21d7",
1133 nearrow: "\u2197",
1134 ne: "\u2260",
1135 nedot: "\u2250\u0338",
1136 NegativeMediumSpace: "\u200b",
1137 NegativeThickSpace: "\u200b",
1138 NegativeThinSpace: "\u200b",
1139 NegativeVeryThinSpace: "\u200b",
1140 nequiv: "\u2262",
1141 nesear: "\u2928",
1142 nesim: "\u2242\u0338",
1143 NestedGreaterGreater: "\u226b",
1144 NestedLessLess: "\u226a",
1145 NewLine: "\n",
1146 nexist: "\u2204",
1147 nexists: "\u2204",
1148 Nfr: "\ud835\udd11",
1149 nfr: "\ud835\udd2b",
1150 ngE: "\u2267\u0338",
1151 nge: "\u2271",
1152 ngeq: "\u2271",
1153 ngeqq: "\u2267\u0338",
1154 ngeqslant: "\u2a7e\u0338",
1155 nges: "\u2a7e\u0338",
1156 nGg: "\u22d9\u0338",
1157 ngsim: "\u2275",
1158 nGt: "\u226b\u20d2",
1159 ngt: "\u226f",
1160 ngtr: "\u226f",
1161 nGtv: "\u226b\u0338",
1162 nharr: "\u21ae",
1163 nhArr: "\u21ce",
1164 nhpar: "\u2af2",
1165 ni: "\u220b",
1166 nis: "\u22fc",
1167 nisd: "\u22fa",
1168 niv: "\u220b",
1169 NJcy: "\u040a",
1170 njcy: "\u045a",
1171 nlarr: "\u219a",
1172 nlArr: "\u21cd",
1173 nldr: "\u2025",
1174 nlE: "\u2266\u0338",
1175 nle: "\u2270",
1176 nleftarrow: "\u219a",
1177 nLeftarrow: "\u21cd",
1178 nleftrightarrow: "\u21ae",
1179 nLeftrightarrow: "\u21ce",
1180 nleq: "\u2270",
1181 nleqq: "\u2266\u0338",
1182 nleqslant: "\u2a7d\u0338",
1183 nles: "\u2a7d\u0338",
1184 nless: "\u226e",
1185 nLl: "\u22d8\u0338",
1186 nlsim: "\u2274",
1187 nLt: "\u226a\u20d2",
1188 nlt: "\u226e",
1189 nltri: "\u22ea",
1190 nltrie: "\u22ec",
1191 nLtv: "\u226a\u0338",
1192 nmid: "\u2224",
1193 NoBreak: "\u2060",
1194 NonBreakingSpace: "\xa0",
1195 nopf: "\ud835\udd5f",
1196 Nopf: "\u2115",
1197 Not: "\u2aec",
1198 not: "\xac",
1199 NotCongruent: "\u2262",
1200 NotCupCap: "\u226d",
1201 NotDoubleVerticalBar: "\u2226",
1202 NotElement: "\u2209",
1203 NotEqual: "\u2260",
1204 NotEqualTilde: "\u2242\u0338",
1205 NotExists: "\u2204",
1206 NotGreater: "\u226f",
1207 NotGreaterEqual: "\u2271",
1208 NotGreaterFullEqual: "\u2267\u0338",
1209 NotGreaterGreater: "\u226b\u0338",
1210 NotGreaterLess: "\u2279",
1211 NotGreaterSlantEqual: "\u2a7e\u0338",
1212 NotGreaterTilde: "\u2275",
1213 NotHumpDownHump: "\u224e\u0338",
1214 NotHumpEqual: "\u224f\u0338",
1215 notin: "\u2209",
1216 notindot: "\u22f5\u0338",
1217 notinE: "\u22f9\u0338",
1218 notinva: "\u2209",
1219 notinvb: "\u22f7",
1220 notinvc: "\u22f6",
1221 NotLeftTriangleBar: "\u29cf\u0338",
1222 NotLeftTriangle: "\u22ea",
1223 NotLeftTriangleEqual: "\u22ec",
1224 NotLess: "\u226e",
1225 NotLessEqual: "\u2270",
1226 NotLessGreater: "\u2278",
1227 NotLessLess: "\u226a\u0338",
1228 NotLessSlantEqual: "\u2a7d\u0338",
1229 NotLessTilde: "\u2274",
1230 NotNestedGreaterGreater: "\u2aa2\u0338",
1231 NotNestedLessLess: "\u2aa1\u0338",
1232 notni: "\u220c",
1233 notniva: "\u220c",
1234 notnivb: "\u22fe",
1235 notnivc: "\u22fd",
1236 NotPrecedes: "\u2280",
1237 NotPrecedesEqual: "\u2aaf\u0338",
1238 NotPrecedesSlantEqual: "\u22e0",
1239 NotReverseElement: "\u220c",
1240 NotRightTriangleBar: "\u29d0\u0338",
1241 NotRightTriangle: "\u22eb",
1242 NotRightTriangleEqual: "\u22ed",
1243 NotSquareSubset: "\u228f\u0338",
1244 NotSquareSubsetEqual: "\u22e2",
1245 NotSquareSuperset: "\u2290\u0338",
1246 NotSquareSupersetEqual: "\u22e3",
1247 NotSubset: "\u2282\u20d2",
1248 NotSubsetEqual: "\u2288",
1249 NotSucceeds: "\u2281",
1250 NotSucceedsEqual: "\u2ab0\u0338",
1251 NotSucceedsSlantEqual: "\u22e1",
1252 NotSucceedsTilde: "\u227f\u0338",
1253 NotSuperset: "\u2283\u20d2",
1254 NotSupersetEqual: "\u2289",
1255 NotTilde: "\u2241",
1256 NotTildeEqual: "\u2244",
1257 NotTildeFullEqual: "\u2247",
1258 NotTildeTilde: "\u2249",
1259 NotVerticalBar: "\u2224",
1260 nparallel: "\u2226",
1261 npar: "\u2226",
1262 nparsl: "\u2afd\u20e5",
1263 npart: "\u2202\u0338",
1264 npolint: "\u2a14",
1265 npr: "\u2280",
1266 nprcue: "\u22e0",
1267 nprec: "\u2280",
1268 npreceq: "\u2aaf\u0338",
1269 npre: "\u2aaf\u0338",
1270 nrarrc: "\u2933\u0338",
1271 nrarr: "\u219b",
1272 nrArr: "\u21cf",
1273 nrarrw: "\u219d\u0338",
1274 nrightarrow: "\u219b",
1275 nRightarrow: "\u21cf",
1276 nrtri: "\u22eb",
1277 nrtrie: "\u22ed",
1278 nsc: "\u2281",
1279 nsccue: "\u22e1",
1280 nsce: "\u2ab0\u0338",
1281 Nscr: "\ud835\udca9",
1282 nscr: "\ud835\udcc3",
1283 nshortmid: "\u2224",
1284 nshortparallel: "\u2226",
1285 nsim: "\u2241",
1286 nsime: "\u2244",
1287 nsimeq: "\u2244",
1288 nsmid: "\u2224",
1289 nspar: "\u2226",
1290 nsqsube: "\u22e2",
1291 nsqsupe: "\u22e3",
1292 nsub: "\u2284",
1293 nsubE: "\u2ac5\u0338",
1294 nsube: "\u2288",
1295 nsubset: "\u2282\u20d2",
1296 nsubseteq: "\u2288",
1297 nsubseteqq: "\u2ac5\u0338",
1298 nsucc: "\u2281",
1299 nsucceq: "\u2ab0\u0338",
1300 nsup: "\u2285",
1301 nsupE: "\u2ac6\u0338",
1302 nsupe: "\u2289",
1303 nsupset: "\u2283\u20d2",
1304 nsupseteq: "\u2289",
1305 nsupseteqq: "\u2ac6\u0338",
1306 ntgl: "\u2279",
1307 Ntilde: "\xd1",
1308 ntilde: "\xf1",
1309 ntlg: "\u2278",
1310 ntriangleleft: "\u22ea",
1311 ntrianglelefteq: "\u22ec",
1312 ntriangleright: "\u22eb",
1313 ntrianglerighteq: "\u22ed",
1314 Nu: "\u039d",
1315 nu: "\u03bd",
1316 num: "#",
1317 numero: "\u2116",
1318 numsp: "\u2007",
1319 nvap: "\u224d\u20d2",
1320 nvdash: "\u22ac",
1321 nvDash: "\u22ad",
1322 nVdash: "\u22ae",
1323 nVDash: "\u22af",
1324 nvge: "\u2265\u20d2",
1325 nvgt: ">\u20d2",
1326 nvHarr: "\u2904",
1327 nvinfin: "\u29de",
1328 nvlArr: "\u2902",
1329 nvle: "\u2264\u20d2",
1330 nvlt: "<\u20d2",
1331 nvltrie: "\u22b4\u20d2",
1332 nvrArr: "\u2903",
1333 nvrtrie: "\u22b5\u20d2",
1334 nvsim: "\u223c\u20d2",
1335 nwarhk: "\u2923",
1336 nwarr: "\u2196",
1337 nwArr: "\u21d6",
1338 nwarrow: "\u2196",
1339 nwnear: "\u2927",
1340 Oacute: "\xd3",
1341 oacute: "\xf3",
1342 oast: "\u229b",
1343 Ocirc: "\xd4",
1344 ocirc: "\xf4",
1345 ocir: "\u229a",
1346 Ocy: "\u041e",
1347 ocy: "\u043e",
1348 odash: "\u229d",
1349 Odblac: "\u0150",
1350 odblac: "\u0151",
1351 odiv: "\u2a38",
1352 odot: "\u2299",
1353 odsold: "\u29bc",
1354 OElig: "\u0152",
1355 oelig: "\u0153",
1356 ofcir: "\u29bf",
1357 Ofr: "\ud835\udd12",
1358 ofr: "\ud835\udd2c",
1359 ogon: "\u02db",
1360 Ograve: "\xd2",
1361 ograve: "\xf2",
1362 ogt: "\u29c1",
1363 ohbar: "\u29b5",
1364 ohm: "\u03a9",
1365 oint: "\u222e",
1366 olarr: "\u21ba",
1367 olcir: "\u29be",
1368 olcross: "\u29bb",
1369 oline: "\u203e",
1370 olt: "\u29c0",
1371 Omacr: "\u014c",
1372 omacr: "\u014d",
1373 Omega: "\u03a9",
1374 omega: "\u03c9",
1375 Omicron: "\u039f",
1376 omicron: "\u03bf",
1377 omid: "\u29b6",
1378 ominus: "\u2296",
1379 Oopf: "\ud835\udd46",
1380 oopf: "\ud835\udd60",
1381 opar: "\u29b7",
1382 OpenCurlyDoubleQuote: "\u201c",
1383 OpenCurlyQuote: "\u2018",
1384 operp: "\u29b9",
1385 oplus: "\u2295",
1386 orarr: "\u21bb",
1387 Or: "\u2a54",
1388 or: "\u2228",
1389 ord: "\u2a5d",
1390 order: "\u2134",
1391 orderof: "\u2134",
1392 ordf: "\xaa",
1393 ordm: "\xba",
1394 origof: "\u22b6",
1395 oror: "\u2a56",
1396 orslope: "\u2a57",
1397 orv: "\u2a5b",
1398 oS: "\u24c8",
1399 Oscr: "\ud835\udcaa",
1400 oscr: "\u2134",
1401 Oslash: "\xd8",
1402 oslash: "\xf8",
1403 osol: "\u2298",
1404 Otilde: "\xd5",
1405 otilde: "\xf5",
1406 otimesas: "\u2a36",
1407 Otimes: "\u2a37",
1408 otimes: "\u2297",
1409 Ouml: "\xd6",
1410 ouml: "\xf6",
1411 ovbar: "\u233d",
1412 OverBar: "\u203e",
1413 OverBrace: "\u23de",
1414 OverBracket: "\u23b4",
1415 OverParenthesis: "\u23dc",
1416 para: "\xb6",
1417 parallel: "\u2225",
1418 par: "\u2225",
1419 parsim: "\u2af3",
1420 parsl: "\u2afd",
1421 part: "\u2202",
1422 PartialD: "\u2202",
1423 Pcy: "\u041f",
1424 pcy: "\u043f",
1425 percnt: "%",
1426 period: ".",
1427 permil: "\u2030",
1428 perp: "\u22a5",
1429 pertenk: "\u2031",
1430 Pfr: "\ud835\udd13",
1431 pfr: "\ud835\udd2d",
1432 Phi: "\u03a6",
1433 phi: "\u03c6",
1434 phiv: "\u03d5",
1435 phmmat: "\u2133",
1436 phone: "\u260e",
1437 Pi: "\u03a0",
1438 pi: "\u03c0",
1439 pitchfork: "\u22d4",
1440 piv: "\u03d6",
1441 planck: "\u210f",
1442 planckh: "\u210e",
1443 plankv: "\u210f",
1444 plusacir: "\u2a23",
1445 plusb: "\u229e",
1446 pluscir: "\u2a22",
1447 plus: "+",
1448 plusdo: "\u2214",
1449 plusdu: "\u2a25",
1450 pluse: "\u2a72",
1451 PlusMinus: "\xb1",
1452 plusmn: "\xb1",
1453 plussim: "\u2a26",
1454 plustwo: "\u2a27",
1455 pm: "\xb1",
1456 Poincareplane: "\u210c",
1457 pointint: "\u2a15",
1458 popf: "\ud835\udd61",
1459 Popf: "\u2119",
1460 pound: "\xa3",
1461 prap: "\u2ab7",
1462 Pr: "\u2abb",
1463 pr: "\u227a",
1464 prcue: "\u227c",
1465 precapprox: "\u2ab7",
1466 prec: "\u227a",
1467 preccurlyeq: "\u227c",
1468 Precedes: "\u227a",
1469 PrecedesEqual: "\u2aaf",
1470 PrecedesSlantEqual: "\u227c",
1471 PrecedesTilde: "\u227e",
1472 preceq: "\u2aaf",
1473 precnapprox: "\u2ab9",
1474 precneqq: "\u2ab5",
1475 precnsim: "\u22e8",
1476 pre: "\u2aaf",
1477 prE: "\u2ab3",
1478 precsim: "\u227e",
1479 prime: "\u2032",
1480 Prime: "\u2033",
1481 primes: "\u2119",
1482 prnap: "\u2ab9",
1483 prnE: "\u2ab5",
1484 prnsim: "\u22e8",
1485 prod: "\u220f",
1486 Product: "\u220f",
1487 profalar: "\u232e",
1488 profline: "\u2312",
1489 profsurf: "\u2313",
1490 prop: "\u221d",
1491 Proportional: "\u221d",
1492 Proportion: "\u2237",
1493 propto: "\u221d",
1494 prsim: "\u227e",
1495 prurel: "\u22b0",
1496 Pscr: "\ud835\udcab",
1497 pscr: "\ud835\udcc5",
1498 Psi: "\u03a8",
1499 psi: "\u03c8",
1500 puncsp: "\u2008",
1501 Qfr: "\ud835\udd14",
1502 qfr: "\ud835\udd2e",
1503 qint: "\u2a0c",
1504 qopf: "\ud835\udd62",
1505 Qopf: "\u211a",
1506 qprime: "\u2057",
1507 Qscr: "\ud835\udcac",
1508 qscr: "\ud835\udcc6",
1509 quaternions: "\u210d",
1510 quatint: "\u2a16",
1511 quest: "?",
1512 questeq: "\u225f",
1513 quot: '"',
1514 QUOT: '"',
1515 rAarr: "\u21db",
1516 race: "\u223d\u0331",
1517 Racute: "\u0154",
1518 racute: "\u0155",
1519 radic: "\u221a",
1520 raemptyv: "\u29b3",
1521 rang: "\u27e9",
1522 Rang: "\u27eb",
1523 rangd: "\u2992",
1524 range: "\u29a5",
1525 rangle: "\u27e9",
1526 raquo: "\xbb",
1527 rarrap: "\u2975",
1528 rarrb: "\u21e5",
1529 rarrbfs: "\u2920",
1530 rarrc: "\u2933",
1531 rarr: "\u2192",
1532 Rarr: "\u21a0",
1533 rArr: "\u21d2",
1534 rarrfs: "\u291e",
1535 rarrhk: "\u21aa",
1536 rarrlp: "\u21ac",
1537 rarrpl: "\u2945",
1538 rarrsim: "\u2974",
1539 Rarrtl: "\u2916",
1540 rarrtl: "\u21a3",
1541 rarrw: "\u219d",
1542 ratail: "\u291a",
1543 rAtail: "\u291c",
1544 ratio: "\u2236",
1545 rationals: "\u211a",
1546 rbarr: "\u290d",
1547 rBarr: "\u290f",
1548 RBarr: "\u2910",
1549 rbbrk: "\u2773",
1550 rbrace: "}",
1551 rbrack: "]",
1552 rbrke: "\u298c",
1553 rbrksld: "\u298e",
1554 rbrkslu: "\u2990",
1555 Rcaron: "\u0158",
1556 rcaron: "\u0159",
1557 Rcedil: "\u0156",
1558 rcedil: "\u0157",
1559 rceil: "\u2309",
1560 rcub: "}",
1561 Rcy: "\u0420",
1562 rcy: "\u0440",
1563 rdca: "\u2937",
1564 rdldhar: "\u2969",
1565 rdquo: "\u201d",
1566 rdquor: "\u201d",
1567 rdsh: "\u21b3",
1568 real: "\u211c",
1569 realine: "\u211b",
1570 realpart: "\u211c",
1571 reals: "\u211d",
1572 Re: "\u211c",
1573 rect: "\u25ad",
1574 reg: "\xae",
1575 REG: "\xae",
1576 ReverseElement: "\u220b",
1577 ReverseEquilibrium: "\u21cb",
1578 ReverseUpEquilibrium: "\u296f",
1579 rfisht: "\u297d",
1580 rfloor: "\u230b",
1581 rfr: "\ud835\udd2f",
1582 Rfr: "\u211c",
1583 rHar: "\u2964",
1584 rhard: "\u21c1",
1585 rharu: "\u21c0",
1586 rharul: "\u296c",
1587 Rho: "\u03a1",
1588 rho: "\u03c1",
1589 rhov: "\u03f1",
1590 RightAngleBracket: "\u27e9",
1591 RightArrowBar: "\u21e5",
1592 rightarrow: "\u2192",
1593 RightArrow: "\u2192",
1594 Rightarrow: "\u21d2",
1595 RightArrowLeftArrow: "\u21c4",
1596 rightarrowtail: "\u21a3",
1597 RightCeiling: "\u2309",
1598 RightDoubleBracket: "\u27e7",
1599 RightDownTeeVector: "\u295d",
1600 RightDownVectorBar: "\u2955",
1601 RightDownVector: "\u21c2",
1602 RightFloor: "\u230b",
1603 rightharpoondown: "\u21c1",
1604 rightharpoonup: "\u21c0",
1605 rightleftarrows: "\u21c4",
1606 rightleftharpoons: "\u21cc",
1607 rightrightarrows: "\u21c9",
1608 rightsquigarrow: "\u219d",
1609 RightTeeArrow: "\u21a6",
1610 RightTee: "\u22a2",
1611 RightTeeVector: "\u295b",
1612 rightthreetimes: "\u22cc",
1613 RightTriangleBar: "\u29d0",
1614 RightTriangle: "\u22b3",
1615 RightTriangleEqual: "\u22b5",
1616 RightUpDownVector: "\u294f",
1617 RightUpTeeVector: "\u295c",
1618 RightUpVectorBar: "\u2954",
1619 RightUpVector: "\u21be",
1620 RightVectorBar: "\u2953",
1621 RightVector: "\u21c0",
1622 ring: "\u02da",
1623 risingdotseq: "\u2253",
1624 rlarr: "\u21c4",
1625 rlhar: "\u21cc",
1626 rlm: "\u200f",
1627 rmoustache: "\u23b1",
1628 rmoust: "\u23b1",
1629 rnmid: "\u2aee",
1630 roang: "\u27ed",
1631 roarr: "\u21fe",
1632 robrk: "\u27e7",
1633 ropar: "\u2986",
1634 ropf: "\ud835\udd63",
1635 Ropf: "\u211d",
1636 roplus: "\u2a2e",
1637 rotimes: "\u2a35",
1638 RoundImplies: "\u2970",
1639 rpar: ")",
1640 rpargt: "\u2994",
1641 rppolint: "\u2a12",
1642 rrarr: "\u21c9",
1643 Rrightarrow: "\u21db",
1644 rsaquo: "\u203a",
1645 rscr: "\ud835\udcc7",
1646 Rscr: "\u211b",
1647 rsh: "\u21b1",
1648 Rsh: "\u21b1",
1649 rsqb: "]",
1650 rsquo: "\u2019",
1651 rsquor: "\u2019",
1652 rthree: "\u22cc",
1653 rtimes: "\u22ca",
1654 rtri: "\u25b9",
1655 rtrie: "\u22b5",
1656 rtrif: "\u25b8",
1657 rtriltri: "\u29ce",
1658 RuleDelayed: "\u29f4",
1659 ruluhar: "\u2968",
1660 rx: "\u211e",
1661 Sacute: "\u015a",
1662 sacute: "\u015b",
1663 sbquo: "\u201a",
1664 scap: "\u2ab8",
1665 Scaron: "\u0160",
1666 scaron: "\u0161",
1667 Sc: "\u2abc",
1668 sc: "\u227b",
1669 sccue: "\u227d",
1670 sce: "\u2ab0",
1671 scE: "\u2ab4",
1672 Scedil: "\u015e",
1673 scedil: "\u015f",
1674 Scirc: "\u015c",
1675 scirc: "\u015d",
1676 scnap: "\u2aba",
1677 scnE: "\u2ab6",
1678 scnsim: "\u22e9",
1679 scpolint: "\u2a13",
1680 scsim: "\u227f",
1681 Scy: "\u0421",
1682 scy: "\u0441",
1683 sdotb: "\u22a1",
1684 sdot: "\u22c5",
1685 sdote: "\u2a66",
1686 searhk: "\u2925",
1687 searr: "\u2198",
1688 seArr: "\u21d8",
1689 searrow: "\u2198",
1690 sect: "\xa7",
1691 semi: ";",
1692 seswar: "\u2929",
1693 setminus: "\u2216",
1694 setmn: "\u2216",
1695 sext: "\u2736",
1696 Sfr: "\ud835\udd16",
1697 sfr: "\ud835\udd30",
1698 sfrown: "\u2322",
1699 sharp: "\u266f",
1700 SHCHcy: "\u0429",
1701 shchcy: "\u0449",
1702 SHcy: "\u0428",
1703 shcy: "\u0448",
1704 ShortDownArrow: "\u2193",
1705 ShortLeftArrow: "\u2190",
1706 shortmid: "\u2223",
1707 shortparallel: "\u2225",
1708 ShortRightArrow: "\u2192",
1709 ShortUpArrow: "\u2191",
1710 shy: "\xad",
1711 Sigma: "\u03a3",
1712 sigma: "\u03c3",
1713 sigmaf: "\u03c2",
1714 sigmav: "\u03c2",
1715 sim: "\u223c",
1716 simdot: "\u2a6a",
1717 sime: "\u2243",
1718 simeq: "\u2243",
1719 simg: "\u2a9e",
1720 simgE: "\u2aa0",
1721 siml: "\u2a9d",
1722 simlE: "\u2a9f",
1723 simne: "\u2246",
1724 simplus: "\u2a24",
1725 simrarr: "\u2972",
1726 slarr: "\u2190",
1727 SmallCircle: "\u2218",
1728 smallsetminus: "\u2216",
1729 smashp: "\u2a33",
1730 smeparsl: "\u29e4",
1731 smid: "\u2223",
1732 smile: "\u2323",
1733 smt: "\u2aaa",
1734 smte: "\u2aac",
1735 smtes: "\u2aac\ufe00",
1736 SOFTcy: "\u042c",
1737 softcy: "\u044c",
1738 solbar: "\u233f",
1739 solb: "\u29c4",
1740 sol: "/",
1741 Sopf: "\ud835\udd4a",
1742 sopf: "\ud835\udd64",
1743 spades: "\u2660",
1744 spadesuit: "\u2660",
1745 spar: "\u2225",
1746 sqcap: "\u2293",
1747 sqcaps: "\u2293\ufe00",
1748 sqcup: "\u2294",
1749 sqcups: "\u2294\ufe00",
1750 Sqrt: "\u221a",
1751 sqsub: "\u228f",
1752 sqsube: "\u2291",
1753 sqsubset: "\u228f",
1754 sqsubseteq: "\u2291",
1755 sqsup: "\u2290",
1756 sqsupe: "\u2292",
1757 sqsupset: "\u2290",
1758 sqsupseteq: "\u2292",
1759 square: "\u25a1",
1760 Square: "\u25a1",
1761 SquareIntersection: "\u2293",
1762 SquareSubset: "\u228f",
1763 SquareSubsetEqual: "\u2291",
1764 SquareSuperset: "\u2290",
1765 SquareSupersetEqual: "\u2292",
1766 SquareUnion: "\u2294",
1767 squarf: "\u25aa",
1768 squ: "\u25a1",
1769 squf: "\u25aa",
1770 srarr: "\u2192",
1771 Sscr: "\ud835\udcae",
1772 sscr: "\ud835\udcc8",
1773 ssetmn: "\u2216",
1774 ssmile: "\u2323",
1775 sstarf: "\u22c6",
1776 Star: "\u22c6",
1777 star: "\u2606",
1778 starf: "\u2605",
1779 straightepsilon: "\u03f5",
1780 straightphi: "\u03d5",
1781 strns: "\xaf",
1782 sub: "\u2282",
1783 Sub: "\u22d0",
1784 subdot: "\u2abd",
1785 subE: "\u2ac5",
1786 sube: "\u2286",
1787 subedot: "\u2ac3",
1788 submult: "\u2ac1",
1789 subnE: "\u2acb",
1790 subne: "\u228a",
1791 subplus: "\u2abf",
1792 subrarr: "\u2979",
1793 subset: "\u2282",
1794 Subset: "\u22d0",
1795 subseteq: "\u2286",
1796 subseteqq: "\u2ac5",
1797 SubsetEqual: "\u2286",
1798 subsetneq: "\u228a",
1799 subsetneqq: "\u2acb",
1800 subsim: "\u2ac7",
1801 subsub: "\u2ad5",
1802 subsup: "\u2ad3",
1803 succapprox: "\u2ab8",
1804 succ: "\u227b",
1805 succcurlyeq: "\u227d",
1806 Succeeds: "\u227b",
1807 SucceedsEqual: "\u2ab0",
1808 SucceedsSlantEqual: "\u227d",
1809 SucceedsTilde: "\u227f",
1810 succeq: "\u2ab0",
1811 succnapprox: "\u2aba",
1812 succneqq: "\u2ab6",
1813 succnsim: "\u22e9",
1814 succsim: "\u227f",
1815 SuchThat: "\u220b",
1816 sum: "\u2211",
1817 Sum: "\u2211",
1818 sung: "\u266a",
1819 sup1: "\xb9",
1820 sup2: "\xb2",
1821 sup3: "\xb3",
1822 sup: "\u2283",
1823 Sup: "\u22d1",
1824 supdot: "\u2abe",
1825 supdsub: "\u2ad8",
1826 supE: "\u2ac6",
1827 supe: "\u2287",
1828 supedot: "\u2ac4",
1829 Superset: "\u2283",
1830 SupersetEqual: "\u2287",
1831 suphsol: "\u27c9",
1832 suphsub: "\u2ad7",
1833 suplarr: "\u297b",
1834 supmult: "\u2ac2",
1835 supnE: "\u2acc",
1836 supne: "\u228b",
1837 supplus: "\u2ac0",
1838 supset: "\u2283",
1839 Supset: "\u22d1",
1840 supseteq: "\u2287",
1841 supseteqq: "\u2ac6",
1842 supsetneq: "\u228b",
1843 supsetneqq: "\u2acc",
1844 supsim: "\u2ac8",
1845 supsub: "\u2ad4",
1846 supsup: "\u2ad6",
1847 swarhk: "\u2926",
1848 swarr: "\u2199",
1849 swArr: "\u21d9",
1850 swarrow: "\u2199",
1851 swnwar: "\u292a",
1852 szlig: "\xdf",
1853 Tab: "\t",
1854 target: "\u2316",
1855 Tau: "\u03a4",
1856 tau: "\u03c4",
1857 tbrk: "\u23b4",
1858 Tcaron: "\u0164",
1859 tcaron: "\u0165",
1860 Tcedil: "\u0162",
1861 tcedil: "\u0163",
1862 Tcy: "\u0422",
1863 tcy: "\u0442",
1864 tdot: "\u20db",
1865 telrec: "\u2315",
1866 Tfr: "\ud835\udd17",
1867 tfr: "\ud835\udd31",
1868 there4: "\u2234",
1869 therefore: "\u2234",
1870 Therefore: "\u2234",
1871 Theta: "\u0398",
1872 theta: "\u03b8",
1873 thetasym: "\u03d1",
1874 thetav: "\u03d1",
1875 thickapprox: "\u2248",
1876 thicksim: "\u223c",
1877 ThickSpace: "\u205f\u200a",
1878 ThinSpace: "\u2009",
1879 thinsp: "\u2009",
1880 thkap: "\u2248",
1881 thksim: "\u223c",
1882 THORN: "\xde",
1883 thorn: "\xfe",
1884 tilde: "\u02dc",
1885 Tilde: "\u223c",
1886 TildeEqual: "\u2243",
1887 TildeFullEqual: "\u2245",
1888 TildeTilde: "\u2248",
1889 timesbar: "\u2a31",
1890 timesb: "\u22a0",
1891 times: "\xd7",
1892 timesd: "\u2a30",
1893 tint: "\u222d",
1894 toea: "\u2928",
1895 topbot: "\u2336",
1896 topcir: "\u2af1",
1897 top: "\u22a4",
1898 Topf: "\ud835\udd4b",
1899 topf: "\ud835\udd65",
1900 topfork: "\u2ada",
1901 tosa: "\u2929",
1902 tprime: "\u2034",
1903 trade: "\u2122",
1904 TRADE: "\u2122",
1905 triangle: "\u25b5",
1906 triangledown: "\u25bf",
1907 triangleleft: "\u25c3",
1908 trianglelefteq: "\u22b4",
1909 triangleq: "\u225c",
1910 triangleright: "\u25b9",
1911 trianglerighteq: "\u22b5",
1912 tridot: "\u25ec",
1913 trie: "\u225c",
1914 triminus: "\u2a3a",
1915 TripleDot: "\u20db",
1916 triplus: "\u2a39",
1917 trisb: "\u29cd",
1918 tritime: "\u2a3b",
1919 trpezium: "\u23e2",
1920 Tscr: "\ud835\udcaf",
1921 tscr: "\ud835\udcc9",
1922 TScy: "\u0426",
1923 tscy: "\u0446",
1924 TSHcy: "\u040b",
1925 tshcy: "\u045b",
1926 Tstrok: "\u0166",
1927 tstrok: "\u0167",
1928 twixt: "\u226c",
1929 twoheadleftarrow: "\u219e",
1930 twoheadrightarrow: "\u21a0",
1931 Uacute: "\xda",
1932 uacute: "\xfa",
1933 uarr: "\u2191",
1934 Uarr: "\u219f",
1935 uArr: "\u21d1",
1936 Uarrocir: "\u2949",
1937 Ubrcy: "\u040e",
1938 ubrcy: "\u045e",
1939 Ubreve: "\u016c",
1940 ubreve: "\u016d",
1941 Ucirc: "\xdb",
1942 ucirc: "\xfb",
1943 Ucy: "\u0423",
1944 ucy: "\u0443",
1945 udarr: "\u21c5",
1946 Udblac: "\u0170",
1947 udblac: "\u0171",
1948 udhar: "\u296e",
1949 ufisht: "\u297e",
1950 Ufr: "\ud835\udd18",
1951 ufr: "\ud835\udd32",
1952 Ugrave: "\xd9",
1953 ugrave: "\xf9",
1954 uHar: "\u2963",
1955 uharl: "\u21bf",
1956 uharr: "\u21be",
1957 uhblk: "\u2580",
1958 ulcorn: "\u231c",
1959 ulcorner: "\u231c",
1960 ulcrop: "\u230f",
1961 ultri: "\u25f8",
1962 Umacr: "\u016a",
1963 umacr: "\u016b",
1964 uml: "\xa8",
1965 UnderBar: "_",
1966 UnderBrace: "\u23df",
1967 UnderBracket: "\u23b5",
1968 UnderParenthesis: "\u23dd",
1969 Union: "\u22c3",
1970 UnionPlus: "\u228e",
1971 Uogon: "\u0172",
1972 uogon: "\u0173",
1973 Uopf: "\ud835\udd4c",
1974 uopf: "\ud835\udd66",
1975 UpArrowBar: "\u2912",
1976 uparrow: "\u2191",
1977 UpArrow: "\u2191",
1978 Uparrow: "\u21d1",
1979 UpArrowDownArrow: "\u21c5",
1980 updownarrow: "\u2195",
1981 UpDownArrow: "\u2195",
1982 Updownarrow: "\u21d5",
1983 UpEquilibrium: "\u296e",
1984 upharpoonleft: "\u21bf",
1985 upharpoonright: "\u21be",
1986 uplus: "\u228e",
1987 UpperLeftArrow: "\u2196",
1988 UpperRightArrow: "\u2197",
1989 upsi: "\u03c5",
1990 Upsi: "\u03d2",
1991 upsih: "\u03d2",
1992 Upsilon: "\u03a5",
1993 upsilon: "\u03c5",
1994 UpTeeArrow: "\u21a5",
1995 UpTee: "\u22a5",
1996 upuparrows: "\u21c8",
1997 urcorn: "\u231d",
1998 urcorner: "\u231d",
1999 urcrop: "\u230e",
2000 Uring: "\u016e",
2001 uring: "\u016f",
2002 urtri: "\u25f9",
2003 Uscr: "\ud835\udcb0",
2004 uscr: "\ud835\udcca",
2005 utdot: "\u22f0",
2006 Utilde: "\u0168",
2007 utilde: "\u0169",
2008 utri: "\u25b5",
2009 utrif: "\u25b4",
2010 uuarr: "\u21c8",
2011 Uuml: "\xdc",
2012 uuml: "\xfc",
2013 uwangle: "\u29a7",
2014 vangrt: "\u299c",
2015 varepsilon: "\u03f5",
2016 varkappa: "\u03f0",
2017 varnothing: "\u2205",
2018 varphi: "\u03d5",
2019 varpi: "\u03d6",
2020 varpropto: "\u221d",
2021 varr: "\u2195",
2022 vArr: "\u21d5",
2023 varrho: "\u03f1",
2024 varsigma: "\u03c2",
2025 varsubsetneq: "\u228a\ufe00",
2026 varsubsetneqq: "\u2acb\ufe00",
2027 varsupsetneq: "\u228b\ufe00",
2028 varsupsetneqq: "\u2acc\ufe00",
2029 vartheta: "\u03d1",
2030 vartriangleleft: "\u22b2",
2031 vartriangleright: "\u22b3",
2032 vBar: "\u2ae8",
2033 Vbar: "\u2aeb",
2034 vBarv: "\u2ae9",
2035 Vcy: "\u0412",
2036 vcy: "\u0432",
2037 vdash: "\u22a2",
2038 vDash: "\u22a8",
2039 Vdash: "\u22a9",
2040 VDash: "\u22ab",
2041 Vdashl: "\u2ae6",
2042 veebar: "\u22bb",
2043 vee: "\u2228",
2044 Vee: "\u22c1",
2045 veeeq: "\u225a",
2046 vellip: "\u22ee",
2047 verbar: "|",
2048 Verbar: "\u2016",
2049 vert: "|",
2050 Vert: "\u2016",
2051 VerticalBar: "\u2223",
2052 VerticalLine: "|",
2053 VerticalSeparator: "\u2758",
2054 VerticalTilde: "\u2240",
2055 VeryThinSpace: "\u200a",
2056 Vfr: "\ud835\udd19",
2057 vfr: "\ud835\udd33",
2058 vltri: "\u22b2",
2059 vnsub: "\u2282\u20d2",
2060 vnsup: "\u2283\u20d2",
2061 Vopf: "\ud835\udd4d",
2062 vopf: "\ud835\udd67",
2063 vprop: "\u221d",
2064 vrtri: "\u22b3",
2065 Vscr: "\ud835\udcb1",
2066 vscr: "\ud835\udccb",
2067 vsubnE: "\u2acb\ufe00",
2068 vsubne: "\u228a\ufe00",
2069 vsupnE: "\u2acc\ufe00",
2070 vsupne: "\u228b\ufe00",
2071 Vvdash: "\u22aa",
2072 vzigzag: "\u299a",
2073 Wcirc: "\u0174",
2074 wcirc: "\u0175",
2075 wedbar: "\u2a5f",
2076 wedge: "\u2227",
2077 Wedge: "\u22c0",
2078 wedgeq: "\u2259",
2079 weierp: "\u2118",
2080 Wfr: "\ud835\udd1a",
2081 wfr: "\ud835\udd34",
2082 Wopf: "\ud835\udd4e",
2083 wopf: "\ud835\udd68",
2084 wp: "\u2118",
2085 wr: "\u2240",
2086 wreath: "\u2240",
2087 Wscr: "\ud835\udcb2",
2088 wscr: "\ud835\udccc",
2089 xcap: "\u22c2",
2090 xcirc: "\u25ef",
2091 xcup: "\u22c3",
2092 xdtri: "\u25bd",
2093 Xfr: "\ud835\udd1b",
2094 xfr: "\ud835\udd35",
2095 xharr: "\u27f7",
2096 xhArr: "\u27fa",
2097 Xi: "\u039e",
2098 xi: "\u03be",
2099 xlarr: "\u27f5",
2100 xlArr: "\u27f8",
2101 xmap: "\u27fc",
2102 xnis: "\u22fb",
2103 xodot: "\u2a00",
2104 Xopf: "\ud835\udd4f",
2105 xopf: "\ud835\udd69",
2106 xoplus: "\u2a01",
2107 xotime: "\u2a02",
2108 xrarr: "\u27f6",
2109 xrArr: "\u27f9",
2110 Xscr: "\ud835\udcb3",
2111 xscr: "\ud835\udccd",
2112 xsqcup: "\u2a06",
2113 xuplus: "\u2a04",
2114 xutri: "\u25b3",
2115 xvee: "\u22c1",
2116 xwedge: "\u22c0",
2117 Yacute: "\xdd",
2118 yacute: "\xfd",
2119 YAcy: "\u042f",
2120 yacy: "\u044f",
2121 Ycirc: "\u0176",
2122 ycirc: "\u0177",
2123 Ycy: "\u042b",
2124 ycy: "\u044b",
2125 yen: "\xa5",
2126 Yfr: "\ud835\udd1c",
2127 yfr: "\ud835\udd36",
2128 YIcy: "\u0407",
2129 yicy: "\u0457",
2130 Yopf: "\ud835\udd50",
2131 yopf: "\ud835\udd6a",
2132 Yscr: "\ud835\udcb4",
2133 yscr: "\ud835\udcce",
2134 YUcy: "\u042e",
2135 yucy: "\u044e",
2136 yuml: "\xff",
2137 Yuml: "\u0178",
2138 Zacute: "\u0179",
2139 zacute: "\u017a",
2140 Zcaron: "\u017d",
2141 zcaron: "\u017e",
2142 Zcy: "\u0417",
2143 zcy: "\u0437",
2144 Zdot: "\u017b",
2145 zdot: "\u017c",
2146 zeetrf: "\u2128",
2147 ZeroWidthSpace: "\u200b",
2148 Zeta: "\u0396",
2149 zeta: "\u03b6",
2150 zfr: "\ud835\udd37",
2151 Zfr: "\u2128",
2152 ZHcy: "\u0416",
2153 zhcy: "\u0436",
2154 zigrarr: "\u21dd",
2155 zopf: "\ud835\udd6b",
2156 Zopf: "\u2124",
2157 Zscr: "\ud835\udcb5",
2158 zscr: "\ud835\udccf",
2159 zwj: "\u200d",
2160 zwnj: "\u200c"
2161 };
2162 /*eslint quotes:0*/ var entities = require$$0;
2163 var regex = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;
2164 var encodeCache = {};
2165 // Create a lookup array where anything but characters in `chars` string
2166 // and alphanumeric chars is percent-encoded.
2167
2168 function getEncodeCache(exclude) {
2169 var i, ch, cache = encodeCache[exclude];
2170 if (cache) {
2171 return cache;
2172 }
2173 cache = encodeCache[exclude] = [];
2174 for (i = 0; i < 128; i++) {
2175 ch = String.fromCharCode(i);
2176 if (/^[0-9a-z]$/i.test(ch)) {
2177 // always allow unencoded alphanumeric characters
2178 cache.push(ch);
2179 } else {
2180 cache.push("%" + ("0" + i.toString(16).toUpperCase()).slice(-2));
2181 }
2182 }
2183 for (i = 0; i < exclude.length; i++) {
2184 cache[exclude.charCodeAt(i)] = exclude[i];
2185 }
2186 return cache;
2187 }
2188 // Encode unsafe characters with percent-encoding, skipping already
2189 // encoded sequences.
2190
2191 // - string - string to encode
2192 // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
2193 // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
2194
2195 function encode(string, exclude, keepEscaped) {
2196 var i, l, code, nextCode, cache, result = "";
2197 if (typeof exclude !== "string") {
2198 // encode(string, keepEscaped)
2199 keepEscaped = exclude;
2200 exclude = encode.defaultChars;
2201 }
2202 if (typeof keepEscaped === "undefined") {
2203 keepEscaped = true;
2204 }
2205 cache = getEncodeCache(exclude);
2206 for (i = 0, l = string.length; i < l; i++) {
2207 code = string.charCodeAt(i);
2208 if (keepEscaped && code === 37 /* % */ && i + 2 < l) {
2209 if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {
2210 result += string.slice(i, i + 3);
2211 i += 2;
2212 continue;
2213 }
2214 }
2215 if (code < 128) {
2216 result += cache[code];
2217 continue;
2218 }
2219 if (code >= 55296 && code <= 57343) {
2220 if (code >= 55296 && code <= 56319 && i + 1 < l) {
2221 nextCode = string.charCodeAt(i + 1);
2222 if (nextCode >= 56320 && nextCode <= 57343) {
2223 result += encodeURIComponent(string[i] + string[i + 1]);
2224 i++;
2225 continue;
2226 }
2227 }
2228 result += "%EF%BF%BD";
2229 continue;
2230 }
2231 result += encodeURIComponent(string[i]);
2232 }
2233 return result;
2234 }
2235 encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";
2236 encode.componentChars = "-_.!~*'()";
2237 var encode_1 = encode;
2238 /* eslint-disable no-bitwise */ var decodeCache = {};
2239 function getDecodeCache(exclude) {
2240 var i, ch, cache = decodeCache[exclude];
2241 if (cache) {
2242 return cache;
2243 }
2244 cache = decodeCache[exclude] = [];
2245 for (i = 0; i < 128; i++) {
2246 ch = String.fromCharCode(i);
2247 cache.push(ch);
2248 }
2249 for (i = 0; i < exclude.length; i++) {
2250 ch = exclude.charCodeAt(i);
2251 cache[ch] = "%" + ("0" + ch.toString(16).toUpperCase()).slice(-2);
2252 }
2253 return cache;
2254 }
2255 // Decode percent-encoded string.
2256
2257 function decode(string, exclude) {
2258 var cache;
2259 if (typeof exclude !== "string") {
2260 exclude = decode.defaultChars;
2261 }
2262 cache = getDecodeCache(exclude);
2263 return string.replace(/(%[a-f0-9]{2})+/gi, (function(seq) {
2264 var i, l, b1, b2, b3, b4, chr, result = "";
2265 for (i = 0, l = seq.length; i < l; i += 3) {
2266 b1 = parseInt(seq.slice(i + 1, i + 3), 16);
2267 if (b1 < 128) {
2268 result += cache[b1];
2269 continue;
2270 }
2271 if ((b1 & 224) === 192 && i + 3 < l) {
2272 // 110xxxxx 10xxxxxx
2273 b2 = parseInt(seq.slice(i + 4, i + 6), 16);
2274 if ((b2 & 192) === 128) {
2275 chr = b1 << 6 & 1984 | b2 & 63;
2276 if (chr < 128) {
2277 result += "\ufffd\ufffd";
2278 } else {
2279 result += String.fromCharCode(chr);
2280 }
2281 i += 3;
2282 continue;
2283 }
2284 }
2285 if ((b1 & 240) === 224 && i + 6 < l) {
2286 // 1110xxxx 10xxxxxx 10xxxxxx
2287 b2 = parseInt(seq.slice(i + 4, i + 6), 16);
2288 b3 = parseInt(seq.slice(i + 7, i + 9), 16);
2289 if ((b2 & 192) === 128 && (b3 & 192) === 128) {
2290 chr = b1 << 12 & 61440 | b2 << 6 & 4032 | b3 & 63;
2291 if (chr < 2048 || chr >= 55296 && chr <= 57343) {
2292 result += "\ufffd\ufffd\ufffd";
2293 } else {
2294 result += String.fromCharCode(chr);
2295 }
2296 i += 6;
2297 continue;
2298 }
2299 }
2300 if ((b1 & 248) === 240 && i + 9 < l) {
2301 // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
2302 b2 = parseInt(seq.slice(i + 4, i + 6), 16);
2303 b3 = parseInt(seq.slice(i + 7, i + 9), 16);
2304 b4 = parseInt(seq.slice(i + 10, i + 12), 16);
2305 if ((b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128) {
2306 chr = b1 << 18 & 1835008 | b2 << 12 & 258048 | b3 << 6 & 4032 | b4 & 63;
2307 if (chr < 65536 || chr > 1114111) {
2308 result += "\ufffd\ufffd\ufffd\ufffd";
2309 } else {
2310 chr -= 65536;
2311 result += String.fromCharCode(55296 + (chr >> 10), 56320 + (chr & 1023));
2312 }
2313 i += 9;
2314 continue;
2315 }
2316 }
2317 result += "\ufffd";
2318 }
2319 return result;
2320 }));
2321 }
2322 decode.defaultChars = ";/?:@&=+$,#";
2323 decode.componentChars = "";
2324 var decode_1 = decode;
2325 var format = function format(url) {
2326 var result = "";
2327 result += url.protocol || "";
2328 result += url.slashes ? "//" : "";
2329 result += url.auth ? url.auth + "@" : "";
2330 if (url.hostname && url.hostname.indexOf(":") !== -1) {
2331 // ipv6 address
2332 result += "[" + url.hostname + "]";
2333 } else {
2334 result += url.hostname || "";
2335 }
2336 result += url.port ? ":" + url.port : "";
2337 result += url.pathname || "";
2338 result += url.search || "";
2339 result += url.hash || "";
2340 return result;
2341 };
2342 // Copyright Joyent, Inc. and other Node contributors.
2343
2344 // Changes from joyent/node:
2345
2346 // 1. No leading slash in paths,
2347 // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`
2348
2349 // 2. Backslashes are not replaced with slashes,
2350 // so `http:\\example.org\` is treated like a relative path
2351
2352 // 3. Trailing colon is treated like a part of the path,
2353 // i.e. in `http://example.org:foo` pathname is `:foo`
2354
2355 // 4. Nothing is URL-encoded in the resulting object,
2356 // (in joyent/node some chars in auth and paths are encoded)
2357
2358 // 5. `url.parse()` does not have `parseQueryString` argument
2359
2360 // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
2361 // which can be constructed using other parts of the url.
2362
2363 function Url() {
2364 this.protocol = null;
2365 this.slashes = null;
2366 this.auth = null;
2367 this.port = null;
2368 this.hostname = null;
2369 this.hash = null;
2370 this.search = null;
2371 this.pathname = null;
2372 }
2373 // Reference: RFC 3986, RFC 1808, RFC 2396
2374 // define these here so at least they only have to be
2375 // compiled once on the first module load.
2376 var protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/,
2377 // Special case for a simple path URL
2378 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
2379 // RFC 2396: characters reserved for delimiting URLs.
2380 // We actually just auto-escape these.
2381 delims = [ "<", ">", '"', "`", " ", "\r", "\n", "\t" ],
2382 // RFC 2396: characters not allowed for various reasons.
2383 unwise = [ "{", "}", "|", "\\", "^", "`" ].concat(delims),
2384 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
2385 autoEscape = [ "'" ].concat(unwise),
2386 // Characters that are never ever allowed in a hostname.
2387 // Note that any invalid chars are also handled, but these
2388 // are the ones that are *expected* to be seen, so we fast-path
2389 // them.
2390 nonHostChars = [ "%", "/", "?", ";", "#" ].concat(autoEscape), hostEndingChars = [ "/", "?", "#" ], hostnameMaxLen = 255, hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
2391 // protocols that can allow "unsafe" and "unwise" chars.
2392 /* eslint-disable no-script-url */
2393 // protocols that never have a hostname.
2394 hostlessProtocol = {
2395 javascript: true,
2396 "javascript:": true
2397 },
2398 // protocols that always contain a // bit.
2399 slashedProtocol = {
2400 http: true,
2401 https: true,
2402 ftp: true,
2403 gopher: true,
2404 file: true,
2405 "http:": true,
2406 "https:": true,
2407 "ftp:": true,
2408 "gopher:": true,
2409 "file:": true
2410 };
2411 /* eslint-enable no-script-url */ function urlParse(url, slashesDenoteHost) {
2412 if (url && url instanceof Url) {
2413 return url;
2414 }
2415 var u = new Url;
2416 u.parse(url, slashesDenoteHost);
2417 return u;
2418 }
2419 Url.prototype.parse = function(url, slashesDenoteHost) {
2420 var i, l, lowerProto, hec, slashes, rest = url;
2421 // trim before proceeding.
2422 // This is to support parse stuff like " http://foo.com \n"
2423 rest = rest.trim();
2424 if (!slashesDenoteHost && url.split("#").length === 1) {
2425 // Try fast path regexp
2426 var simplePath = simplePathPattern.exec(rest);
2427 if (simplePath) {
2428 this.pathname = simplePath[1];
2429 if (simplePath[2]) {
2430 this.search = simplePath[2];
2431 }
2432 return this;
2433 }
2434 }
2435 var proto = protocolPattern.exec(rest);
2436 if (proto) {
2437 proto = proto[0];
2438 lowerProto = proto.toLowerCase();
2439 this.protocol = proto;
2440 rest = rest.substr(proto.length);
2441 }
2442 // figure out if it's got a host
2443 // user@server is *always* interpreted as a hostname, and url
2444 // resolution will treat //foo/bar as host=foo,path=bar because that's
2445 // how the browser resolves relative URLs.
2446 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
2447 slashes = rest.substr(0, 2) === "//";
2448 if (slashes && !(proto && hostlessProtocol[proto])) {
2449 rest = rest.substr(2);
2450 this.slashes = true;
2451 }
2452 }
2453 if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
2454 // there's a hostname.
2455 // the first instance of /, ?, ;, or # ends the host.
2456 // If there is an @ in the hostname, then non-host chars *are* allowed
2457 // to the left of the last @ sign, unless some host-ending character
2458 // comes *before* the @-sign.
2459 // URLs are obnoxious.
2460 // ex:
2461 // http://a@b@c/ => user:a@b host:c
2462 // http://a@b?@c => user:a host:c path:/?@c
2463 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
2464 // Review our test case against browsers more comprehensively.
2465 // find the first instance of any hostEndingChars
2466 var hostEnd = -1;
2467 for (i = 0; i < hostEndingChars.length; i++) {
2468 hec = rest.indexOf(hostEndingChars[i]);
2469 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
2470 hostEnd = hec;
2471 }
2472 }
2473 // at this point, either we have an explicit point where the
2474 // auth portion cannot go past, or the last @ char is the decider.
2475 var auth, atSign;
2476 if (hostEnd === -1) {
2477 // atSign can be anywhere.
2478 atSign = rest.lastIndexOf("@");
2479 } else {
2480 // atSign must be in auth portion.
2481 // http://a@b/c@d => host:b auth:a path:/c@d
2482 atSign = rest.lastIndexOf("@", hostEnd);
2483 }
2484 // Now we have a portion which is definitely the auth.
2485 // Pull that off.
2486 if (atSign !== -1) {
2487 auth = rest.slice(0, atSign);
2488 rest = rest.slice(atSign + 1);
2489 this.auth = auth;
2490 }
2491 // the host is the remaining to the left of the first non-host char
2492 hostEnd = -1;
2493 for (i = 0; i < nonHostChars.length; i++) {
2494 hec = rest.indexOf(nonHostChars[i]);
2495 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
2496 hostEnd = hec;
2497 }
2498 }
2499 // if we still have not hit it, then the entire thing is a host.
2500 if (hostEnd === -1) {
2501 hostEnd = rest.length;
2502 }
2503 if (rest[hostEnd - 1] === ":") {
2504 hostEnd--;
2505 }
2506 var host = rest.slice(0, hostEnd);
2507 rest = rest.slice(hostEnd);
2508 // pull out port.
2509 this.parseHost(host);
2510 // we've indicated that there is a hostname,
2511 // so even if it's empty, it has to be present.
2512 this.hostname = this.hostname || "";
2513 // if hostname begins with [ and ends with ]
2514 // assume that it's an IPv6 address.
2515 var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
2516 // validate a little.
2517 if (!ipv6Hostname) {
2518 var hostparts = this.hostname.split(/\./);
2519 for (i = 0, l = hostparts.length; i < l; i++) {
2520 var part = hostparts[i];
2521 if (!part) {
2522 continue;
2523 }
2524 if (!part.match(hostnamePartPattern)) {
2525 var newpart = "";
2526 for (var j = 0, k = part.length; j < k; j++) {
2527 if (part.charCodeAt(j) > 127) {
2528 // we replace non-ASCII char with a temporary placeholder
2529 // we need this to make sure size of hostname is not
2530 // broken by replacing non-ASCII by nothing
2531 newpart += "x";
2532 } else {
2533 newpart += part[j];
2534 }
2535 }
2536 // we test again with ASCII char only
2537 if (!newpart.match(hostnamePartPattern)) {
2538 var validParts = hostparts.slice(0, i);
2539 var notHost = hostparts.slice(i + 1);
2540 var bit = part.match(hostnamePartStart);
2541 if (bit) {
2542 validParts.push(bit[1]);
2543 notHost.unshift(bit[2]);
2544 }
2545 if (notHost.length) {
2546 rest = notHost.join(".") + rest;
2547 }
2548 this.hostname = validParts.join(".");
2549 break;
2550 }
2551 }
2552 }
2553 }
2554 if (this.hostname.length > hostnameMaxLen) {
2555 this.hostname = "";
2556 }
2557 // strip [ and ] from the hostname
2558 // the host field still retains them, though
2559 if (ipv6Hostname) {
2560 this.hostname = this.hostname.substr(1, this.hostname.length - 2);
2561 }
2562 }
2563 // chop off from the tail first.
2564 var hash = rest.indexOf("#");
2565 if (hash !== -1) {
2566 // got a fragment string.
2567 this.hash = rest.substr(hash);
2568 rest = rest.slice(0, hash);
2569 }
2570 var qm = rest.indexOf("?");
2571 if (qm !== -1) {
2572 this.search = rest.substr(qm);
2573 rest = rest.slice(0, qm);
2574 }
2575 if (rest) {
2576 this.pathname = rest;
2577 }
2578 if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
2579 this.pathname = "";
2580 }
2581 return this;
2582 };
2583 Url.prototype.parseHost = function(host) {
2584 var port = portPattern.exec(host);
2585 if (port) {
2586 port = port[0];
2587 if (port !== ":") {
2588 this.port = port.substr(1);
2589 }
2590 host = host.substr(0, host.length - port.length);
2591 }
2592 if (host) {
2593 this.hostname = host;
2594 }
2595 };
2596 var parse = urlParse;
2597 var encode$1 = encode_1;
2598 var decode$1 = decode_1;
2599 var format$1 = format;
2600 var parse$1 = parse;
2601 var mdurl = {
2602 encode: encode$1,
2603 decode: decode$1,
2604 format: format$1,
2605 parse: parse$1
2606 };
2607 var regex$1 = /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
2608 var regex$2 = /[\0-\x1F\x7F-\x9F]/;
2609 var regex$3 = /[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;
2610 var regex$4 = /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
2611 var Any = regex$1;
2612 var Cc = regex$2;
2613 var Cf = regex$3;
2614 var P = regex;
2615 var Z = regex$4;
2616 var uc_micro = {
2617 Any: Any,
2618 Cc: Cc,
2619 Cf: Cf,
2620 P: P,
2621 Z: Z
2622 };
2623 var utils = createCommonjsModule((function(module, exports) {
2624 function _class(obj) {
2625 return Object.prototype.toString.call(obj);
2626 }
2627 function isString(obj) {
2628 return _class(obj) === "[object String]";
2629 }
2630 var _hasOwnProperty = Object.prototype.hasOwnProperty;
2631 function has(object, key) {
2632 return _hasOwnProperty.call(object, key);
2633 }
2634 // Merge objects
2635
2636 function assign(obj /*from1, from2, from3, ...*/) {
2637 var sources = Array.prototype.slice.call(arguments, 1);
2638 sources.forEach((function(source) {
2639 if (!source) {
2640 return;
2641 }
2642 if (typeof source !== "object") {
2643 throw new TypeError(source + "must be object");
2644 }
2645 Object.keys(source).forEach((function(key) {
2646 obj[key] = source[key];
2647 }));
2648 }));
2649 return obj;
2650 }
2651 // Remove element from array and put another array at those position.
2652 // Useful for some operations with tokens
2653 function arrayReplaceAt(src, pos, newElements) {
2654 return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
2655 }
2656 ////////////////////////////////////////////////////////////////////////////////
2657 function isValidEntityCode(c) {
2658 /*eslint no-bitwise:0*/
2659 // broken sequence
2660 if (c >= 55296 && c <= 57343) {
2661 return false;
2662 }
2663 // never used
2664 if (c >= 64976 && c <= 65007) {
2665 return false;
2666 }
2667 if ((c & 65535) === 65535 || (c & 65535) === 65534) {
2668 return false;
2669 }
2670 // control codes
2671 if (c >= 0 && c <= 8) {
2672 return false;
2673 }
2674 if (c === 11) {
2675 return false;
2676 }
2677 if (c >= 14 && c <= 31) {
2678 return false;
2679 }
2680 if (c >= 127 && c <= 159) {
2681 return false;
2682 }
2683 // out of range
2684 if (c > 1114111) {
2685 return false;
2686 }
2687 return true;
2688 }
2689 function fromCodePoint(c) {
2690 /*eslint no-bitwise:0*/
2691 if (c > 65535) {
2692 c -= 65536;
2693 var surrogate1 = 55296 + (c >> 10), surrogate2 = 56320 + (c & 1023);
2694 return String.fromCharCode(surrogate1, surrogate2);
2695 }
2696 return String.fromCharCode(c);
2697 }
2698 var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
2699 var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
2700 var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + "|" + ENTITY_RE.source, "gi");
2701 var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
2702 function replaceEntityPattern(match, name) {
2703 var code = 0;
2704 if (has(entities, name)) {
2705 return entities[name];
2706 }
2707 if (name.charCodeAt(0) === 35 /* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
2708 code = name[1].toLowerCase() === "x" ? parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
2709 if (isValidEntityCode(code)) {
2710 return fromCodePoint(code);
2711 }
2712 }
2713 return match;
2714 }
2715 /*function replaceEntities(str) {
2716 if (str.indexOf('&') < 0) { return str; }
2717
2718 return str.replace(ENTITY_RE, replaceEntityPattern);
2719 }*/ function unescapeMd(str) {
2720 if (str.indexOf("\\") < 0) {
2721 return str;
2722 }
2723 return str.replace(UNESCAPE_MD_RE, "$1");
2724 }
2725 function unescapeAll(str) {
2726 if (str.indexOf("\\") < 0 && str.indexOf("&") < 0) {
2727 return str;
2728 }
2729 return str.replace(UNESCAPE_ALL_RE, (function(match, escaped, entity) {
2730 if (escaped) {
2731 return escaped;
2732 }
2733 return replaceEntityPattern(match, entity);
2734 }));
2735 }
2736 ////////////////////////////////////////////////////////////////////////////////
2737 var HTML_ESCAPE_TEST_RE = /[&<>"]/;
2738 var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
2739 var HTML_REPLACEMENTS = {
2740 "&": "&amp;",
2741 "<": "&lt;",
2742 ">": "&gt;",
2743 '"': "&quot;"
2744 };
2745 function replaceUnsafeChar(ch) {
2746 return HTML_REPLACEMENTS[ch];
2747 }
2748 function escapeHtml(str) {
2749 if (HTML_ESCAPE_TEST_RE.test(str)) {
2750 return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
2751 }
2752 return str;
2753 }
2754 ////////////////////////////////////////////////////////////////////////////////
2755 var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
2756 function escapeRE(str) {
2757 return str.replace(REGEXP_ESCAPE_RE, "\\$&");
2758 }
2759 ////////////////////////////////////////////////////////////////////////////////
2760 function isSpace(code) {
2761 switch (code) {
2762 case 9:
2763 case 32:
2764 return true;
2765 }
2766 return false;
2767 }
2768 // Zs (unicode class) || [\t\f\v\r\n]
2769 function isWhiteSpace(code) {
2770 if (code >= 8192 && code <= 8202) {
2771 return true;
2772 }
2773 switch (code) {
2774 case 9:
2775 // \t
2776 case 10:
2777 // \n
2778 case 11:
2779 // \v
2780 case 12:
2781 // \f
2782 case 13:
2783 // \r
2784 case 32:
2785 case 160:
2786 case 5760:
2787 case 8239:
2788 case 8287:
2789 case 12288:
2790 return true;
2791 }
2792 return false;
2793 }
2794 ////////////////////////////////////////////////////////////////////////////////
2795 /*eslint-disable max-len*/
2796 // Currently without astral characters support.
2797 function isPunctChar(ch) {
2798 return regex.test(ch);
2799 }
2800 // Markdown ASCII punctuation characters.
2801
2802 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
2803 // http://spec.commonmark.org/0.15/#ascii-punctuation-character
2804
2805 // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
2806
2807 function isMdAsciiPunct(ch) {
2808 switch (ch) {
2809 case 33 /* ! */ :
2810 case 34 /* " */ :
2811 case 35 /* # */ :
2812 case 36 /* $ */ :
2813 case 37 /* % */ :
2814 case 38 /* & */ :
2815 case 39 /* ' */ :
2816 case 40 /* ( */ :
2817 case 41 /* ) */ :
2818 case 42 /* * */ :
2819 case 43 /* + */ :
2820 case 44 /* , */ :
2821 case 45 /* - */ :
2822 case 46 /* . */ :
2823 case 47 /* / */ :
2824 case 58 /* : */ :
2825 case 59 /* ; */ :
2826 case 60 /* < */ :
2827 case 61 /* = */ :
2828 case 62 /* > */ :
2829 case 63 /* ? */ :
2830 case 64 /* @ */ :
2831 case 91 /* [ */ :
2832 case 92 /* \ */ :
2833 case 93 /* ] */ :
2834 case 94 /* ^ */ :
2835 case 95 /* _ */ :
2836 case 96 /* ` */ :
2837 case 123 /* { */ :
2838 case 124 /* | */ :
2839 case 125 /* } */ :
2840 case 126 /* ~ */ :
2841 return true;
2842
2843 default:
2844 return false;
2845 }
2846 }
2847 // Hepler to unify [reference labels].
2848
2849 function normalizeReference(str) {
2850 // Trim and collapse whitespace
2851 str = str.trim().replace(/\s+/g, " ");
2852 // In node v10 'ẞ'.toLowerCase() === 'Ṿ', which is presumed to be a bug
2853 // fixed in v12 (couldn't find any details).
2854
2855 // So treat this one as a special case
2856 // (remove this when node v10 is no longer supported).
2857
2858 if ("\u1e9e".toLowerCase() === "\u1e7e") {
2859 str = str.replace(/\u1e9e/g, "\xdf");
2860 }
2861 // .toLowerCase().toUpperCase() should get rid of all differences
2862 // between letter variants.
2863
2864 // Simple .toLowerCase() doesn't normalize 125 code points correctly,
2865 // and .toUpperCase doesn't normalize 6 of them (list of exceptions:
2866 // İ, ϴ, ẞ, Ω, K, Å - those are already uppercased, but have differently
2867 // uppercased versions).
2868
2869 // Here's an example showing how it happens. Lets take greek letter omega:
2870 // uppercase U+0398 (Θ), U+03f4 (ϴ) and lowercase U+03b8 (θ), U+03d1 (ϑ)
2871
2872 // Unicode entries:
2873 // 0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8;
2874 // 03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398
2875 // 03D1;GREEK THETA SYMBOL;Ll;0;L;<compat> 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398
2876 // 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L;<compat> 0398;;;;N;;;;03B8;
2877
2878 // Case-insensitive comparison should treat all of them as equivalent.
2879
2880 // But .toLowerCase() doesn't change ϑ (it's already lowercase),
2881 // and .toUpperCase() doesn't change ϴ (already uppercase).
2882
2883 // Applying first lower then upper case normalizes any character:
2884 // '\u0398\u03f4\u03b8\u03d1'.toLowerCase().toUpperCase() === '\u0398\u0398\u0398\u0398'
2885
2886 // Note: this is equivalent to unicode case folding; unicode normalization
2887 // is a different step that is not required here.
2888
2889 // Final result should be uppercased, because it's later stored in an object
2890 // (this avoid a conflict with Object.prototype members,
2891 // most notably, `__proto__`)
2892
2893 return str.toLowerCase().toUpperCase();
2894 }
2895 ////////////////////////////////////////////////////////////////////////////////
2896 // Re-export libraries commonly used in both markdown-it and its plugins,
2897 // so plugins won't have to depend on them explicitly, which reduces their
2898 // bundled size (e.g. a browser build).
2899
2900 exports.lib = {};
2901 exports.lib.mdurl = mdurl;
2902 exports.lib.ucmicro = uc_micro;
2903 exports.assign = assign;
2904 exports.isString = isString;
2905 exports.has = has;
2906 exports.unescapeMd = unescapeMd;
2907 exports.unescapeAll = unescapeAll;
2908 exports.isValidEntityCode = isValidEntityCode;
2909 exports.fromCodePoint = fromCodePoint;
2910 // exports.replaceEntities = replaceEntities;
2911 exports.escapeHtml = escapeHtml;
2912 exports.arrayReplaceAt = arrayReplaceAt;
2913 exports.isSpace = isSpace;
2914 exports.isWhiteSpace = isWhiteSpace;
2915 exports.isMdAsciiPunct = isMdAsciiPunct;
2916 exports.isPunctChar = isPunctChar;
2917 exports.escapeRE = escapeRE;
2918 exports.normalizeReference = normalizeReference;
2919 }));
2920 // Parse link label
2921 var parse_link_label = function parseLinkLabel(state, start, disableNested) {
2922 var level, found, marker, prevPos, labelEnd = -1, max = state.posMax, oldPos = state.pos;
2923 state.pos = start + 1;
2924 level = 1;
2925 while (state.pos < max) {
2926 marker = state.src.charCodeAt(state.pos);
2927 if (marker === 93 /* ] */) {
2928 level--;
2929 if (level === 0) {
2930 found = true;
2931 break;
2932 }
2933 }
2934 prevPos = state.pos;
2935 state.md.inline.skipToken(state);
2936 if (marker === 91 /* [ */) {
2937 if (prevPos === state.pos - 1) {
2938 // increase level if we find text `[`, which is not a part of any token
2939 level++;
2940 } else if (disableNested) {
2941 state.pos = oldPos;
2942 return -1;
2943 }
2944 }
2945 }
2946 if (found) {
2947 labelEnd = state.pos;
2948 }
2949 // restore old state
2950 state.pos = oldPos;
2951 return labelEnd;
2952 };
2953 var unescapeAll = utils.unescapeAll;
2954 var parse_link_destination = function parseLinkDestination(str, pos, max) {
2955 var code, level, lines = 0, start = pos, result = {
2956 ok: false,
2957 pos: 0,
2958 lines: 0,
2959 str: ""
2960 };
2961 if (str.charCodeAt(pos) === 60 /* < */) {
2962 pos++;
2963 while (pos < max) {
2964 code = str.charCodeAt(pos);
2965 if (code === 10 /* \n */) {
2966 return result;
2967 }
2968 if (code === 62 /* > */) {
2969 result.pos = pos + 1;
2970 result.str = unescapeAll(str.slice(start + 1, pos));
2971 result.ok = true;
2972 return result;
2973 }
2974 if (code === 92 /* \ */ && pos + 1 < max) {
2975 pos += 2;
2976 continue;
2977 }
2978 pos++;
2979 }
2980 // no closing '>'
2981 return result;
2982 }
2983 // this should be ... } else { ... branch
2984 level = 0;
2985 while (pos < max) {
2986 code = str.charCodeAt(pos);
2987 if (code === 32) {
2988 break;
2989 }
2990 // ascii control characters
2991 if (code < 32 || code === 127) {
2992 break;
2993 }
2994 if (code === 92 /* \ */ && pos + 1 < max) {
2995 pos += 2;
2996 continue;
2997 }
2998 if (code === 40 /* ( */) {
2999 level++;
3000 }
3001 if (code === 41 /* ) */) {
3002 if (level === 0) {
3003 break;
3004 }
3005 level--;
3006 }
3007 pos++;
3008 }
3009 if (start === pos) {
3010 return result;
3011 }
3012 if (level !== 0) {
3013 return result;
3014 }
3015 result.str = unescapeAll(str.slice(start, pos));
3016 result.lines = lines;
3017 result.pos = pos;
3018 result.ok = true;
3019 return result;
3020 };
3021 var unescapeAll$1 = utils.unescapeAll;
3022 var parse_link_title = function parseLinkTitle(str, pos, max) {
3023 var code, marker, lines = 0, start = pos, result = {
3024 ok: false,
3025 pos: 0,
3026 lines: 0,
3027 str: ""
3028 };
3029 if (pos >= max) {
3030 return result;
3031 }
3032 marker = str.charCodeAt(pos);
3033 if (marker !== 34 /* " */ && marker !== 39 /* ' */ && marker !== 40 /* ( */) {
3034 return result;
3035 }
3036 pos++;
3037 // if opening marker is "(", switch it to closing marker ")"
3038 if (marker === 40) {
3039 marker = 41;
3040 }
3041 while (pos < max) {
3042 code = str.charCodeAt(pos);
3043 if (code === marker) {
3044 result.pos = pos + 1;
3045 result.lines = lines;
3046 result.str = unescapeAll$1(str.slice(start + 1, pos));
3047 result.ok = true;
3048 return result;
3049 } else if (code === 10) {
3050 lines++;
3051 } else if (code === 92 /* \ */ && pos + 1 < max) {
3052 pos++;
3053 if (str.charCodeAt(pos) === 10) {
3054 lines++;
3055 }
3056 }
3057 pos++;
3058 }
3059 return result;
3060 };
3061 var parseLinkLabel = parse_link_label;
3062 var parseLinkDestination = parse_link_destination;
3063 var parseLinkTitle = parse_link_title;
3064 var helpers = {
3065 parseLinkLabel: parseLinkLabel,
3066 parseLinkDestination: parseLinkDestination,
3067 parseLinkTitle: parseLinkTitle
3068 };
3069 var assign = utils.assign;
3070 var unescapeAll$2 = utils.unescapeAll;
3071 var escapeHtml = utils.escapeHtml;
3072 ////////////////////////////////////////////////////////////////////////////////
3073 var default_rules = {};
3074 default_rules.code_inline = function(tokens, idx, options, env, slf) {
3075 var token = tokens[idx];
3076 return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(tokens[idx].content) + "</code>";
3077 };
3078 default_rules.code_block = function(tokens, idx, options, env, slf) {
3079 var token = tokens[idx];
3080 return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
3081 };
3082 default_rules.fence = function(tokens, idx, options, env, slf) {
3083 var token = tokens[idx], info = token.info ? unescapeAll$2(token.info).trim() : "", langName = "", langAttrs = "", highlighted, i, arr, tmpAttrs, tmpToken;
3084 if (info) {
3085 arr = info.split(/(\s+)/g);
3086 langName = arr[0];
3087 langAttrs = arr.slice(2).join("");
3088 }
3089 if (options.highlight) {
3090 highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
3091 } else {
3092 highlighted = escapeHtml(token.content);
3093 }
3094 if (highlighted.indexOf("<pre") === 0) {
3095 return highlighted + "\n";
3096 }
3097 // If language exists, inject class gently, without modifying original token.
3098 // May be, one day we will add .clone() for token and simplify this part, but
3099 // now we prefer to keep things local.
3100 if (info) {
3101 i = token.attrIndex("class");
3102 tmpAttrs = token.attrs ? token.attrs.slice() : [];
3103 if (i < 0) {
3104 tmpAttrs.push([ "class", options.langPrefix + langName ]);
3105 } else {
3106 tmpAttrs[i][1] += " " + options.langPrefix + langName;
3107 }
3108 // Fake token just to render attributes
3109 tmpToken = {
3110 attrs: tmpAttrs
3111 };
3112 return "<pre><code" + slf.renderAttrs(tmpToken) + ">" + highlighted + "</code></pre>\n";
3113 }
3114 return "<pre><code" + slf.renderAttrs(token) + ">" + highlighted + "</code></pre>\n";
3115 };
3116 default_rules.image = function(tokens, idx, options, env, slf) {
3117 var token = tokens[idx];
3118 // "alt" attr MUST be set, even if empty. Because it's mandatory and
3119 // should be placed on proper position for tests.
3120
3121 // Replace content with actual value
3122 token.attrs[token.attrIndex("alt")][1] = slf.renderInlineAsText(token.children, options, env);
3123 return slf.renderToken(tokens, idx, options);
3124 };
3125 default_rules.hardbreak = function(tokens, idx, options /*, env */) {
3126 return options.xhtmlOut ? "<br />\n" : "<br>\n";
3127 };
3128 default_rules.softbreak = function(tokens, idx, options /*, env */) {
3129 return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
3130 };
3131 default_rules.text = function(tokens, idx /*, options, env */) {
3132 return escapeHtml(tokens[idx].content);
3133 };
3134 default_rules.html_block = function(tokens, idx /*, options, env */) {
3135 return tokens[idx].content;
3136 };
3137 default_rules.html_inline = function(tokens, idx /*, options, env */) {
3138 return tokens[idx].content;
3139 };
3140 /**
3141 * new Renderer()
3142 *
3143 * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
3144 **/ function Renderer() {
3145 /**
3146 * Renderer#rules -> Object
3147 *
3148 * Contains render rules for tokens. Can be updated and extended.
3149 *
3150 * ##### Example
3151 *
3152 * ```javascript
3153 * var md = require('markdown-it')();
3154 *
3155 * md.renderer.rules.strong_open = function () { return '<b>'; };
3156 * md.renderer.rules.strong_close = function () { return '</b>'; };
3157 *
3158 * var result = md.renderInline(...);
3159 * ```
3160 *
3161 * Each rule is called as independent static function with fixed signature:
3162 *
3163 * ```javascript
3164 * function my_token_render(tokens, idx, options, env, renderer) {
3165 * // ...
3166 * return renderedHTML;
3167 * }
3168 * ```
3169 *
3170 * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
3171 * for more details and examples.
3172 **/
3173 this.rules = assign({}, default_rules);
3174 }
3175 /**
3176 * Renderer.renderAttrs(token) -> String
3177 *
3178 * Render token attributes to string.
3179 **/ Renderer.prototype.renderAttrs = function renderAttrs(token) {
3180 var i, l, result;
3181 if (!token.attrs) {
3182 return "";
3183 }
3184 result = "";
3185 for (i = 0, l = token.attrs.length; i < l; i++) {
3186 result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
3187 }
3188 return result;
3189 };
3190 /**
3191 * Renderer.renderToken(tokens, idx, options) -> String
3192 * - tokens (Array): list of tokens
3193 * - idx (Numbed): token index to render
3194 * - options (Object): params of parser instance
3195 *
3196 * Default token renderer. Can be overriden by custom function
3197 * in [[Renderer#rules]].
3198 **/ Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
3199 var nextToken, result = "", needLf = false, token = tokens[idx];
3200 // Tight list paragraphs
3201 if (token.hidden) {
3202 return "";
3203 }
3204 // Insert a newline between hidden paragraph and subsequent opening
3205 // block-level tag.
3206
3207 // For example, here we should insert a newline before blockquote:
3208 // - a
3209 // >
3210
3211 if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
3212 result += "\n";
3213 }
3214 // Add token name, e.g. `<img`
3215 result += (token.nesting === -1 ? "</" : "<") + token.tag;
3216 // Encode attributes, e.g. `<img src="foo"`
3217 result += this.renderAttrs(token);
3218 // Add a slash for self-closing tags, e.g. `<img src="foo" /`
3219 if (token.nesting === 0 && options.xhtmlOut) {
3220 result += " /";
3221 }
3222 // Check if we need to add a newline after this tag
3223 if (token.block) {
3224 needLf = true;
3225 if (token.nesting === 1) {
3226 if (idx + 1 < tokens.length) {
3227 nextToken = tokens[idx + 1];
3228 if (nextToken.type === "inline" || nextToken.hidden) {
3229 // Block-level tag containing an inline tag.
3230 needLf = false;
3231 } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
3232 // Opening tag + closing tag of the same type. E.g. `<li></li>`.
3233 needLf = false;
3234 }
3235 }
3236 }
3237 }
3238 result += needLf ? ">\n" : ">";
3239 return result;
3240 };
3241 /**
3242 * Renderer.renderInline(tokens, options, env) -> String
3243 * - tokens (Array): list on block tokens to renter
3244 * - options (Object): params of parser instance
3245 * - env (Object): additional data from parsed input (references, for example)
3246 *
3247 * The same as [[Renderer.render]], but for single token of `inline` type.
3248 **/ Renderer.prototype.renderInline = function(tokens, options, env) {
3249 var type, result = "", rules = this.rules;
3250 for (var i = 0, len = tokens.length; i < len; i++) {
3251 type = tokens[i].type;
3252 if (typeof rules[type] !== "undefined") {
3253 result += rules[type](tokens, i, options, env, this);
3254 } else {
3255 result += this.renderToken(tokens, i, options);
3256 }
3257 }
3258 return result;
3259 };
3260 /** internal
3261 * Renderer.renderInlineAsText(tokens, options, env) -> String
3262 * - tokens (Array): list on block tokens to renter
3263 * - options (Object): params of parser instance
3264 * - env (Object): additional data from parsed input (references, for example)
3265 *
3266 * Special kludge for image `alt` attributes to conform CommonMark spec.
3267 * Don't try to use it! Spec requires to show `alt` content with stripped markup,
3268 * instead of simple escaping.
3269 **/ Renderer.prototype.renderInlineAsText = function(tokens, options, env) {
3270 var result = "";
3271 for (var i = 0, len = tokens.length; i < len; i++) {
3272 if (tokens[i].type === "text") {
3273 result += tokens[i].content;
3274 } else if (tokens[i].type === "image") {
3275 result += this.renderInlineAsText(tokens[i].children, options, env);
3276 }
3277 }
3278 return result;
3279 };
3280 /**
3281 * Renderer.render(tokens, options, env) -> String
3282 * - tokens (Array): list on block tokens to renter
3283 * - options (Object): params of parser instance
3284 * - env (Object): additional data from parsed input (references, for example)
3285 *
3286 * Takes token stream and generates HTML. Probably, you will never need to call
3287 * this method directly.
3288 **/ Renderer.prototype.render = function(tokens, options, env) {
3289 var i, len, type, result = "", rules = this.rules;
3290 for (i = 0, len = tokens.length; i < len; i++) {
3291 type = tokens[i].type;
3292 if (type === "inline") {
3293 result += this.renderInline(tokens[i].children, options, env);
3294 } else if (typeof rules[type] !== "undefined") {
3295 result += rules[tokens[i].type](tokens, i, options, env, this);
3296 } else {
3297 result += this.renderToken(tokens, i, options, env);
3298 }
3299 }
3300 return result;
3301 };
3302 var renderer = Renderer;
3303 /**
3304 * class Ruler
3305 *
3306 * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
3307 * [[MarkdownIt#inline]] to manage sequences of functions (rules):
3308 *
3309 * - keep rules in defined order
3310 * - assign the name to each rule
3311 * - enable/disable rules
3312 * - add/replace rules
3313 * - allow assign rules to additional named chains (in the same)
3314 * - cacheing lists of active rules
3315 *
3316 * You will not need use this class directly until write plugins. For simple
3317 * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
3318 * [[MarkdownIt.use]].
3319 **/
3320 /**
3321 * new Ruler()
3322 **/ function Ruler() {
3323 // List of added rules. Each element is:
3324 // {
3325 // name: XXX,
3326 // enabled: Boolean,
3327 // fn: Function(),
3328 // alt: [ name2, name3 ]
3329 // }
3330 this.__rules__ = [];
3331 // Cached rule chains.
3332
3333 // First level - chain name, '' for default.
3334 // Second level - diginal anchor for fast filtering by charcodes.
3335
3336 this.__cache__ = null;
3337 }
3338 ////////////////////////////////////////////////////////////////////////////////
3339 // Helper methods, should not be used directly
3340 // Find rule index by name
3341
3342 Ruler.prototype.__find__ = function(name) {
3343 for (var i = 0; i < this.__rules__.length; i++) {
3344 if (this.__rules__[i].name === name) {
3345 return i;
3346 }
3347 }
3348 return -1;
3349 };
3350 // Build rules lookup cache
3351
3352 Ruler.prototype.__compile__ = function() {
3353 var self = this;
3354 var chains = [ "" ];
3355 // collect unique names
3356 self.__rules__.forEach((function(rule) {
3357 if (!rule.enabled) {
3358 return;
3359 }
3360 rule.alt.forEach((function(altName) {
3361 if (chains.indexOf(altName) < 0) {
3362 chains.push(altName);
3363 }
3364 }));
3365 }));
3366 self.__cache__ = {};
3367 chains.forEach((function(chain) {
3368 self.__cache__[chain] = [];
3369 self.__rules__.forEach((function(rule) {
3370 if (!rule.enabled) {
3371 return;
3372 }
3373 if (chain && rule.alt.indexOf(chain) < 0) {
3374 return;
3375 }
3376 self.__cache__[chain].push(rule.fn);
3377 }));
3378 }));
3379 };
3380 /**
3381 * Ruler.at(name, fn [, options])
3382 * - name (String): rule name to replace.
3383 * - fn (Function): new rule function.
3384 * - options (Object): new rule options (not mandatory).
3385 *
3386 * Replace rule by name with new function & options. Throws error if name not
3387 * found.
3388 *
3389 * ##### Options:
3390 *
3391 * - __alt__ - array with names of "alternate" chains.
3392 *
3393 * ##### Example
3394 *
3395 * Replace existing typographer replacement rule with new one:
3396 *
3397 * ```javascript
3398 * var md = require('markdown-it')();
3399 *
3400 * md.core.ruler.at('replacements', function replace(state) {
3401 * //...
3402 * });
3403 * ```
3404 **/ Ruler.prototype.at = function(name, fn, options) {
3405 var index = this.__find__(name);
3406 var opt = options || {};
3407 if (index === -1) {
3408 throw new Error("Parser rule not found: " + name);
3409 }
3410 this.__rules__[index].fn = fn;
3411 this.__rules__[index].alt = opt.alt || [];
3412 this.__cache__ = null;
3413 };
3414 /**
3415 * Ruler.before(beforeName, ruleName, fn [, options])
3416 * - beforeName (String): new rule will be added before this one.
3417 * - ruleName (String): name of added rule.
3418 * - fn (Function): rule function.
3419 * - options (Object): rule options (not mandatory).
3420 *
3421 * Add new rule to chain before one with given name. See also
3422 * [[Ruler.after]], [[Ruler.push]].
3423 *
3424 * ##### Options:
3425 *
3426 * - __alt__ - array with names of "alternate" chains.
3427 *
3428 * ##### Example
3429 *
3430 * ```javascript
3431 * var md = require('markdown-it')();
3432 *
3433 * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
3434 * //...
3435 * });
3436 * ```
3437 **/ Ruler.prototype.before = function(beforeName, ruleName, fn, options) {
3438 var index = this.__find__(beforeName);
3439 var opt = options || {};
3440 if (index === -1) {
3441 throw new Error("Parser rule not found: " + beforeName);
3442 }
3443 this.__rules__.splice(index, 0, {
3444 name: ruleName,
3445 enabled: true,
3446 fn: fn,
3447 alt: opt.alt || []
3448 });
3449 this.__cache__ = null;
3450 };
3451 /**
3452 * Ruler.after(afterName, ruleName, fn [, options])
3453 * - afterName (String): new rule will be added after this one.
3454 * - ruleName (String): name of added rule.
3455 * - fn (Function): rule function.
3456 * - options (Object): rule options (not mandatory).
3457 *
3458 * Add new rule to chain after one with given name. See also
3459 * [[Ruler.before]], [[Ruler.push]].
3460 *
3461 * ##### Options:
3462 *
3463 * - __alt__ - array with names of "alternate" chains.
3464 *
3465 * ##### Example
3466 *
3467 * ```javascript
3468 * var md = require('markdown-it')();
3469 *
3470 * md.inline.ruler.after('text', 'my_rule', function replace(state) {
3471 * //...
3472 * });
3473 * ```
3474 **/ Ruler.prototype.after = function(afterName, ruleName, fn, options) {
3475 var index = this.__find__(afterName);
3476 var opt = options || {};
3477 if (index === -1) {
3478 throw new Error("Parser rule not found: " + afterName);
3479 }
3480 this.__rules__.splice(index + 1, 0, {
3481 name: ruleName,
3482 enabled: true,
3483 fn: fn,
3484 alt: opt.alt || []
3485 });
3486 this.__cache__ = null;
3487 };
3488 /**
3489 * Ruler.push(ruleName, fn [, options])
3490 * - ruleName (String): name of added rule.
3491 * - fn (Function): rule function.
3492 * - options (Object): rule options (not mandatory).
3493 *
3494 * Push new rule to the end of chain. See also
3495 * [[Ruler.before]], [[Ruler.after]].
3496 *
3497 * ##### Options:
3498 *
3499 * - __alt__ - array with names of "alternate" chains.
3500 *
3501 * ##### Example
3502 *
3503 * ```javascript
3504 * var md = require('markdown-it')();
3505 *
3506 * md.core.ruler.push('my_rule', function replace(state) {
3507 * //...
3508 * });
3509 * ```
3510 **/ Ruler.prototype.push = function(ruleName, fn, options) {
3511 var opt = options || {};
3512 this.__rules__.push({
3513 name: ruleName,
3514 enabled: true,
3515 fn: fn,
3516 alt: opt.alt || []
3517 });
3518 this.__cache__ = null;
3519 };
3520 /**
3521 * Ruler.enable(list [, ignoreInvalid]) -> Array
3522 * - list (String|Array): list of rule names to enable.
3523 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
3524 *
3525 * Enable rules with given names. If any rule name not found - throw Error.
3526 * Errors can be disabled by second param.
3527 *
3528 * Returns list of found rule names (if no exception happened).
3529 *
3530 * See also [[Ruler.disable]], [[Ruler.enableOnly]].
3531 **/ Ruler.prototype.enable = function(list, ignoreInvalid) {
3532 if (!Array.isArray(list)) {
3533 list = [ list ];
3534 }
3535 var result = [];
3536 // Search by name and enable
3537 list.forEach((function(name) {
3538 var idx = this.__find__(name);
3539 if (idx < 0) {
3540 if (ignoreInvalid) {
3541 return;
3542 }
3543 throw new Error("Rules manager: invalid rule name " + name);
3544 }
3545 this.__rules__[idx].enabled = true;
3546 result.push(name);
3547 }), this);
3548 this.__cache__ = null;
3549 return result;
3550 };
3551 /**
3552 * Ruler.enableOnly(list [, ignoreInvalid])
3553 * - list (String|Array): list of rule names to enable (whitelist).
3554 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
3555 *
3556 * Enable rules with given names, and disable everything else. If any rule name
3557 * not found - throw Error. Errors can be disabled by second param.
3558 *
3559 * See also [[Ruler.disable]], [[Ruler.enable]].
3560 **/ Ruler.prototype.enableOnly = function(list, ignoreInvalid) {
3561 if (!Array.isArray(list)) {
3562 list = [ list ];
3563 }
3564 this.__rules__.forEach((function(rule) {
3565 rule.enabled = false;
3566 }));
3567 this.enable(list, ignoreInvalid);
3568 };
3569 /**
3570 * Ruler.disable(list [, ignoreInvalid]) -> Array
3571 * - list (String|Array): list of rule names to disable.
3572 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
3573 *
3574 * Disable rules with given names. If any rule name not found - throw Error.
3575 * Errors can be disabled by second param.
3576 *
3577 * Returns list of found rule names (if no exception happened).
3578 *
3579 * See also [[Ruler.enable]], [[Ruler.enableOnly]].
3580 **/ Ruler.prototype.disable = function(list, ignoreInvalid) {
3581 if (!Array.isArray(list)) {
3582 list = [ list ];
3583 }
3584 var result = [];
3585 // Search by name and disable
3586 list.forEach((function(name) {
3587 var idx = this.__find__(name);
3588 if (idx < 0) {
3589 if (ignoreInvalid) {
3590 return;
3591 }
3592 throw new Error("Rules manager: invalid rule name " + name);
3593 }
3594 this.__rules__[idx].enabled = false;
3595 result.push(name);
3596 }), this);
3597 this.__cache__ = null;
3598 return result;
3599 };
3600 /**
3601 * Ruler.getRules(chainName) -> Array
3602 *
3603 * Return array of active functions (rules) for given chain name. It analyzes
3604 * rules configuration, compiles caches if not exists and returns result.
3605 *
3606 * Default chain name is `''` (empty string). It can't be skipped. That's
3607 * done intentionally, to keep signature monomorphic for high speed.
3608 **/ Ruler.prototype.getRules = function(chainName) {
3609 if (this.__cache__ === null) {
3610 this.__compile__();
3611 }
3612 // Chain can be empty, if rules disabled. But we still have to return Array.
3613 return this.__cache__[chainName] || [];
3614 };
3615 var ruler = Ruler;
3616 // Normalize input string
3617 // https://spec.commonmark.org/0.29/#line-ending
3618 var NEWLINES_RE = /\r\n?|\n/g;
3619 var NULL_RE = /\0/g;
3620 var normalize = function normalize(state) {
3621 var str;
3622 // Normalize newlines
3623 str = state.src.replace(NEWLINES_RE, "\n");
3624 // Replace NULL characters
3625 str = str.replace(NULL_RE, "\ufffd");
3626 state.src = str;
3627 };
3628 var block = function block(state) {
3629 var token;
3630 if (state.inlineMode) {
3631 token = new state.Token("inline", "", 0);
3632 token.content = state.src;
3633 token.map = [ 0, 1 ];
3634 token.children = [];
3635 state.tokens.push(token);
3636 } else {
3637 state.md.block.parse(state.src, state.md, state.env, state.tokens);
3638 }
3639 };
3640 var inline = function inline(state) {
3641 var tokens = state.tokens, tok, i, l;
3642 // Parse inlines
3643 for (i = 0, l = tokens.length; i < l; i++) {
3644 tok = tokens[i];
3645 if (tok.type === "inline") {
3646 state.md.inline.parse(tok.content, state.md, state.env, tok.children);
3647 }
3648 }
3649 };
3650 var arrayReplaceAt = utils.arrayReplaceAt;
3651 function isLinkOpen(str) {
3652 return /^<a[>\s]/i.test(str);
3653 }
3654 function isLinkClose(str) {
3655 return /^<\/a\s*>/i.test(str);
3656 }
3657 var linkify = function linkify(state) {
3658 var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos, level, htmlLinkLevel, url, fullUrl, urlText, blockTokens = state.tokens, links;
3659 if (!state.md.options.linkify) {
3660 return;
3661 }
3662 for (j = 0, l = blockTokens.length; j < l; j++) {
3663 if (blockTokens[j].type !== "inline" || !state.md.linkify.pretest(blockTokens[j].content)) {
3664 continue;
3665 }
3666 tokens = blockTokens[j].children;
3667 htmlLinkLevel = 0;
3668 // We scan from the end, to keep position when new tags added.
3669 // Use reversed logic in links start/end match
3670 for (i = tokens.length - 1; i >= 0; i--) {
3671 currentToken = tokens[i];
3672 // Skip content of markdown links
3673 if (currentToken.type === "link_close") {
3674 i--;
3675 while (tokens[i].level !== currentToken.level && tokens[i].type !== "link_open") {
3676 i--;
3677 }
3678 continue;
3679 }
3680 // Skip content of html tag links
3681 if (currentToken.type === "html_inline") {
3682 if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
3683 htmlLinkLevel--;
3684 }
3685 if (isLinkClose(currentToken.content)) {
3686 htmlLinkLevel++;
3687 }
3688 }
3689 if (htmlLinkLevel > 0) {
3690 continue;
3691 }
3692 if (currentToken.type === "text" && state.md.linkify.test(currentToken.content)) {
3693 text = currentToken.content;
3694 links = state.md.linkify.match(text);
3695 // Now split string to nodes
3696 nodes = [];
3697 level = currentToken.level;
3698 lastPos = 0;
3699 for (ln = 0; ln < links.length; ln++) {
3700 url = links[ln].url;
3701 fullUrl = state.md.normalizeLink(url);
3702 if (!state.md.validateLink(fullUrl)) {
3703 continue;
3704 }
3705 urlText = links[ln].text;
3706 // Linkifier might send raw hostnames like "example.com", where url
3707 // starts with domain name. So we prepend http:// in those cases,
3708 // and remove it afterwards.
3709
3710 if (!links[ln].schema) {
3711 urlText = state.md.normalizeLinkText("http://" + urlText).replace(/^http:\/\//, "");
3712 } else if (links[ln].schema === "mailto:" && !/^mailto:/i.test(urlText)) {
3713 urlText = state.md.normalizeLinkText("mailto:" + urlText).replace(/^mailto:/, "");
3714 } else {
3715 urlText = state.md.normalizeLinkText(urlText);
3716 }
3717 pos = links[ln].index;
3718 if (pos > lastPos) {
3719 token = new state.Token("text", "", 0);
3720 token.content = text.slice(lastPos, pos);
3721 token.level = level;
3722 nodes.push(token);
3723 }
3724 token = new state.Token("link_open", "a", 1);
3725 token.attrs = [ [ "href", fullUrl ] ];
3726 token.level = level++;
3727 token.markup = "linkify";
3728 token.info = "auto";
3729 nodes.push(token);
3730 token = new state.Token("text", "", 0);
3731 token.content = urlText;
3732 token.level = level;
3733 nodes.push(token);
3734 token = new state.Token("link_close", "a", -1);
3735 token.level = --level;
3736 token.markup = "linkify";
3737 token.info = "auto";
3738 nodes.push(token);
3739 lastPos = links[ln].lastIndex;
3740 }
3741 if (lastPos < text.length) {
3742 token = new state.Token("text", "", 0);
3743 token.content = text.slice(lastPos);
3744 token.level = level;
3745 nodes.push(token);
3746 }
3747 // replace current node
3748 blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
3749 }
3750 }
3751 }
3752 };
3753 // Simple typographic replacements
3754 // TODO:
3755 // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
3756 // - miltiplication 2 x 4 -> 2 × 4
3757 var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
3758 // Workaround for phantomjs - need regex without /g flag,
3759 // or root check will fail every second time
3760 var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i;
3761 var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/gi;
3762 var SCOPED_ABBR = {
3763 c: "\xa9",
3764 r: "\xae",
3765 p: "\xa7",
3766 tm: "\u2122"
3767 };
3768 function replaceFn(match, name) {
3769 return SCOPED_ABBR[name.toLowerCase()];
3770 }
3771 function replace_scoped(inlineTokens) {
3772 var i, token, inside_autolink = 0;
3773 for (i = inlineTokens.length - 1; i >= 0; i--) {
3774 token = inlineTokens[i];
3775 if (token.type === "text" && !inside_autolink) {
3776 token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
3777 }
3778 if (token.type === "link_open" && token.info === "auto") {
3779 inside_autolink--;
3780 }
3781 if (token.type === "link_close" && token.info === "auto") {
3782 inside_autolink++;
3783 }
3784 }
3785 }
3786 function replace_rare(inlineTokens) {
3787 var i, token, inside_autolink = 0;
3788 for (i = inlineTokens.length - 1; i >= 0; i--) {
3789 token = inlineTokens[i];
3790 if (token.type === "text" && !inside_autolink) {
3791 if (RARE_RE.test(token.content)) {
3792 token.content = token.content.replace(/\+-/g, "\xb1").replace(/\.{2,}/g, "\u2026").replace(/([?!])\u2026/g, "$1..").replace(/([?!]){4,}/g, "$1$1$1").replace(/,{2,}/g, ",").replace(/(^|[^-])---(?=[^-]|$)/gm, "$1\u2014").replace(/(^|\s)--(?=\s|$)/gm, "$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm, "$1\u2013");
3793 }
3794 }
3795 if (token.type === "link_open" && token.info === "auto") {
3796 inside_autolink--;
3797 }
3798 if (token.type === "link_close" && token.info === "auto") {
3799 inside_autolink++;
3800 }
3801 }
3802 }
3803 var replacements = function replace(state) {
3804 var blkIdx;
3805 if (!state.md.options.typographer) {
3806 return;
3807 }
3808 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
3809 if (state.tokens[blkIdx].type !== "inline") {
3810 continue;
3811 }
3812 if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
3813 replace_scoped(state.tokens[blkIdx].children);
3814 }
3815 if (RARE_RE.test(state.tokens[blkIdx].content)) {
3816 replace_rare(state.tokens[blkIdx].children);
3817 }
3818 }
3819 };
3820 var isWhiteSpace = utils.isWhiteSpace;
3821 var isPunctChar = utils.isPunctChar;
3822 var isMdAsciiPunct = utils.isMdAsciiPunct;
3823 var QUOTE_TEST_RE = /['"]/;
3824 var QUOTE_RE = /['"]/g;
3825 var APOSTROPHE = "\u2019";
3826 /* ’ */ function replaceAt(str, index, ch) {
3827 return str.substr(0, index) + ch + str.substr(index + 1);
3828 }
3829 function process_inlines(tokens, state) {
3830 var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
3831 stack = [];
3832 for (i = 0; i < tokens.length; i++) {
3833 token = tokens[i];
3834 thisLevel = tokens[i].level;
3835 for (j = stack.length - 1; j >= 0; j--) {
3836 if (stack[j].level <= thisLevel) {
3837 break;
3838 }
3839 }
3840 stack.length = j + 1;
3841 if (token.type !== "text") {
3842 continue;
3843 }
3844 text = token.content;
3845 pos = 0;
3846 max = text.length;
3847 /*eslint no-labels:0,block-scoped-var:0*/ OUTER: while (pos < max) {
3848 QUOTE_RE.lastIndex = pos;
3849 t = QUOTE_RE.exec(text);
3850 if (!t) {
3851 break;
3852 }
3853 canOpen = canClose = true;
3854 pos = t.index + 1;
3855 isSingle = t[0] === "'";
3856 // Find previous character,
3857 // default to space if it's the beginning of the line
3858
3859 lastChar = 32;
3860 if (t.index - 1 >= 0) {
3861 lastChar = text.charCodeAt(t.index - 1);
3862 } else {
3863 for (j = i - 1; j >= 0; j--) {
3864 if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
3865 // lastChar defaults to 0x20
3866 if (!tokens[j].content) continue;
3867 // should skip all tokens except 'text', 'html_inline' or 'code_inline'
3868 lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
3869 break;
3870 }
3871 }
3872 // Find next character,
3873 // default to space if it's the end of the line
3874
3875 nextChar = 32;
3876 if (pos < max) {
3877 nextChar = text.charCodeAt(pos);
3878 } else {
3879 for (j = i + 1; j < tokens.length; j++) {
3880 if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
3881 // nextChar defaults to 0x20
3882 if (!tokens[j].content) continue;
3883 // should skip all tokens except 'text', 'html_inline' or 'code_inline'
3884 nextChar = tokens[j].content.charCodeAt(0);
3885 break;
3886 }
3887 }
3888 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
3889 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
3890 isLastWhiteSpace = isWhiteSpace(lastChar);
3891 isNextWhiteSpace = isWhiteSpace(nextChar);
3892 if (isNextWhiteSpace) {
3893 canOpen = false;
3894 } else if (isNextPunctChar) {
3895 if (!(isLastWhiteSpace || isLastPunctChar)) {
3896 canOpen = false;
3897 }
3898 }
3899 if (isLastWhiteSpace) {
3900 canClose = false;
3901 } else if (isLastPunctChar) {
3902 if (!(isNextWhiteSpace || isNextPunctChar)) {
3903 canClose = false;
3904 }
3905 }
3906 if (nextChar === 34 /* " */ && t[0] === '"') {
3907 if (lastChar >= 48 /* 0 */ && lastChar <= 57 /* 9 */) {
3908 // special case: 1"" - count first quote as an inch
3909 canClose = canOpen = false;
3910 }
3911 }
3912 if (canOpen && canClose) {
3913 // Replace quotes in the middle of punctuation sequence, but not
3914 // in the middle of the words, i.e.:
3915 // 1. foo " bar " baz - not replaced
3916 // 2. foo-"-bar-"-baz - replaced
3917 // 3. foo"bar"baz - not replaced
3918 canOpen = isLastPunctChar;
3919 canClose = isNextPunctChar;
3920 }
3921 if (!canOpen && !canClose) {
3922 // middle of word
3923 if (isSingle) {
3924 token.content = replaceAt(token.content, t.index, APOSTROPHE);
3925 }
3926 continue;
3927 }
3928 if (canClose) {
3929 // this could be a closing quote, rewind the stack to get a match
3930 for (j = stack.length - 1; j >= 0; j--) {
3931 item = stack[j];
3932 if (stack[j].level < thisLevel) {
3933 break;
3934 }
3935 if (item.single === isSingle && stack[j].level === thisLevel) {
3936 item = stack[j];
3937 if (isSingle) {
3938 openQuote = state.md.options.quotes[2];
3939 closeQuote = state.md.options.quotes[3];
3940 } else {
3941 openQuote = state.md.options.quotes[0];
3942 closeQuote = state.md.options.quotes[1];
3943 }
3944 // replace token.content *before* tokens[item.token].content,
3945 // because, if they are pointing at the same token, replaceAt
3946 // could mess up indices when quote length != 1
3947 token.content = replaceAt(token.content, t.index, closeQuote);
3948 tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, openQuote);
3949 pos += closeQuote.length - 1;
3950 if (item.token === i) {
3951 pos += openQuote.length - 1;
3952 }
3953 text = token.content;
3954 max = text.length;
3955 stack.length = j;
3956 continue OUTER;
3957 }
3958 }
3959 }
3960 if (canOpen) {
3961 stack.push({
3962 token: i,
3963 pos: t.index,
3964 single: isSingle,
3965 level: thisLevel
3966 });
3967 } else if (canClose && isSingle) {
3968 token.content = replaceAt(token.content, t.index, APOSTROPHE);
3969 }
3970 }
3971 }
3972 }
3973 var smartquotes = function smartquotes(state) {
3974 /*eslint max-depth:0*/
3975 var blkIdx;
3976 if (!state.md.options.typographer) {
3977 return;
3978 }
3979 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
3980 if (state.tokens[blkIdx].type !== "inline" || !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
3981 continue;
3982 }
3983 process_inlines(state.tokens[blkIdx].children, state);
3984 }
3985 };
3986 // Token class
3987 /**
3988 * class Token
3989 **/
3990 /**
3991 * new Token(type, tag, nesting)
3992 *
3993 * Create new token and fill passed properties.
3994 **/ function Token(type, tag, nesting) {
3995 /**
3996 * Token#type -> String
3997 *
3998 * Type of the token (string, e.g. "paragraph_open")
3999 **/
4000 this.type = type;
4001 /**
4002 * Token#tag -> String
4003 *
4004 * html tag name, e.g. "p"
4005 **/ this.tag = tag;
4006 /**
4007 * Token#attrs -> Array
4008 *
4009 * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
4010 **/ this.attrs = null;
4011 /**
4012 * Token#map -> Array
4013 *
4014 * Source map info. Format: `[ line_begin, line_end ]`
4015 **/ this.map = null;
4016 /**
4017 * Token#nesting -> Number
4018 *
4019 * Level change (number in {-1, 0, 1} set), where:
4020 *
4021 * - `1` means the tag is opening
4022 * - `0` means the tag is self-closing
4023 * - `-1` means the tag is closing
4024 **/ this.nesting = nesting;
4025 /**
4026 * Token#level -> Number
4027 *
4028 * nesting level, the same as `state.level`
4029 **/ this.level = 0;
4030 /**
4031 * Token#children -> Array
4032 *
4033 * An array of child nodes (inline and img tokens)
4034 **/ this.children = null;
4035 /**
4036 * Token#content -> String
4037 *
4038 * In a case of self-closing tag (code, html, fence, etc.),
4039 * it has contents of this tag.
4040 **/ this.content = "";
4041 /**
4042 * Token#markup -> String
4043 *
4044 * '*' or '_' for emphasis, fence string for fence, etc.
4045 **/ this.markup = "";
4046 /**
4047 * Token#info -> String
4048 *
4049 * fence infostring
4050 **/ this.info = "";
4051 /**
4052 * Token#meta -> Object
4053 *
4054 * A place for plugins to store an arbitrary data
4055 **/ this.meta = null;
4056 /**
4057 * Token#block -> Boolean
4058 *
4059 * True for block-level tokens, false for inline tokens.
4060 * Used in renderer to calculate line breaks
4061 **/ this.block = false;
4062 /**
4063 * Token#hidden -> Boolean
4064 *
4065 * If it's true, ignore this element when rendering. Used for tight lists
4066 * to hide paragraphs.
4067 **/ this.hidden = false;
4068 }
4069 /**
4070 * Token.attrIndex(name) -> Number
4071 *
4072 * Search attribute index by name.
4073 **/ Token.prototype.attrIndex = function attrIndex(name) {
4074 var attrs, i, len;
4075 if (!this.attrs) {
4076 return -1;
4077 }
4078 attrs = this.attrs;
4079 for (i = 0, len = attrs.length; i < len; i++) {
4080 if (attrs[i][0] === name) {
4081 return i;
4082 }
4083 }
4084 return -1;
4085 };
4086 /**
4087 * Token.attrPush(attrData)
4088 *
4089 * Add `[ name, value ]` attribute to list. Init attrs if necessary
4090 **/ Token.prototype.attrPush = function attrPush(attrData) {
4091 if (this.attrs) {
4092 this.attrs.push(attrData);
4093 } else {
4094 this.attrs = [ attrData ];
4095 }
4096 };
4097 /**
4098 * Token.attrSet(name, value)
4099 *
4100 * Set `name` attribute to `value`. Override old value if exists.
4101 **/ Token.prototype.attrSet = function attrSet(name, value) {
4102 var idx = this.attrIndex(name), attrData = [ name, value ];
4103 if (idx < 0) {
4104 this.attrPush(attrData);
4105 } else {
4106 this.attrs[idx] = attrData;
4107 }
4108 };
4109 /**
4110 * Token.attrGet(name)
4111 *
4112 * Get the value of attribute `name`, or null if it does not exist.
4113 **/ Token.prototype.attrGet = function attrGet(name) {
4114 var idx = this.attrIndex(name), value = null;
4115 if (idx >= 0) {
4116 value = this.attrs[idx][1];
4117 }
4118 return value;
4119 };
4120 /**
4121 * Token.attrJoin(name, value)
4122 *
4123 * Join value to existing attribute via space. Or create new attribute if not
4124 * exists. Useful to operate with token classes.
4125 **/ Token.prototype.attrJoin = function attrJoin(name, value) {
4126 var idx = this.attrIndex(name);
4127 if (idx < 0) {
4128 this.attrPush([ name, value ]);
4129 } else {
4130 this.attrs[idx][1] = this.attrs[idx][1] + " " + value;
4131 }
4132 };
4133 var token = Token;
4134 function StateCore(src, md, env) {
4135 this.src = src;
4136 this.env = env;
4137 this.tokens = [];
4138 this.inlineMode = false;
4139 this.md = md;
4140 // link to parser instance
4141 }
4142 // re-export Token class to use in core rules
4143 StateCore.prototype.Token = token;
4144 var state_core = StateCore;
4145 var _rules = [ [ "normalize", normalize ], [ "block", block ], [ "inline", inline ], [ "linkify", linkify ], [ "replacements", replacements ], [ "smartquotes", smartquotes ] ];
4146 /**
4147 * new Core()
4148 **/ function Core() {
4149 /**
4150 * Core#ruler -> Ruler
4151 *
4152 * [[Ruler]] instance. Keep configuration of core rules.
4153 **/
4154 this.ruler = new ruler;
4155 for (var i = 0; i < _rules.length; i++) {
4156 this.ruler.push(_rules[i][0], _rules[i][1]);
4157 }
4158 }
4159 /**
4160 * Core.process(state)
4161 *
4162 * Executes core chain rules.
4163 **/ Core.prototype.process = function(state) {
4164 var i, l, rules;
4165 rules = this.ruler.getRules("");
4166 for (i = 0, l = rules.length; i < l; i++) {
4167 rules[i](state);
4168 }
4169 };
4170 Core.prototype.State = state_core;
4171 var parser_core = Core;
4172 var isSpace = utils.isSpace;
4173 function getLine(state, line) {
4174 var pos = state.bMarks[line] + state.tShift[line], max = state.eMarks[line];
4175 return state.src.substr(pos, max - pos);
4176 }
4177 function escapedSplit(str) {
4178 var result = [], pos = 0, max = str.length, ch, isEscaped = false, lastPos = 0, current = "";
4179 ch = str.charCodeAt(pos);
4180 while (pos < max) {
4181 if (ch === 124 /* | */) {
4182 if (!isEscaped) {
4183 // pipe separating cells, '|'
4184 result.push(current + str.substring(lastPos, pos));
4185 current = "";
4186 lastPos = pos + 1;
4187 } else {
4188 // escaped pipe, '\|'
4189 current += str.substring(lastPos, pos - 1);
4190 lastPos = pos;
4191 }
4192 }
4193 isEscaped = ch === 92 /* \ */;
4194 pos++;
4195 ch = str.charCodeAt(pos);
4196 }
4197 result.push(current + str.substring(lastPos));
4198 return result;
4199 }
4200 var table = function table(state, startLine, endLine, silent) {
4201 var ch, lineText, pos, i, l, nextLine, columns, columnCount, token, aligns, t, tableLines, tbodyLines, oldParentType, terminate, terminatorRules;
4202 // should have at least two lines
4203 if (startLine + 2 > endLine) {
4204 return false;
4205 }
4206 nextLine = startLine + 1;
4207 if (state.sCount[nextLine] < state.blkIndent) {
4208 return false;
4209 }
4210 // if it's indented more than 3 spaces, it should be a code block
4211 if (state.sCount[nextLine] - state.blkIndent >= 4) {
4212 return false;
4213 }
4214 // first character of the second line should be '|', '-', ':',
4215 // and no other characters are allowed but spaces;
4216 // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
4217 pos = state.bMarks[nextLine] + state.tShift[nextLine];
4218 if (pos >= state.eMarks[nextLine]) {
4219 return false;
4220 }
4221 ch = state.src.charCodeAt(pos++);
4222 if (ch !== 124 /* | */ && ch !== 45 /* - */ && ch !== 58 /* : */) {
4223 return false;
4224 }
4225 while (pos < state.eMarks[nextLine]) {
4226 ch = state.src.charCodeAt(pos);
4227 if (ch !== 124 /* | */ && ch !== 45 /* - */ && ch !== 58 /* : */ && !isSpace(ch)) {
4228 return false;
4229 }
4230 pos++;
4231 }
4232 lineText = getLine(state, startLine + 1);
4233 columns = lineText.split("|");
4234 aligns = [];
4235 for (i = 0; i < columns.length; i++) {
4236 t = columns[i].trim();
4237 if (!t) {
4238 // allow empty columns before and after table, but not in between columns;
4239 // e.g. allow ` |---| `, disallow ` ---||--- `
4240 if (i === 0 || i === columns.length - 1) {
4241 continue;
4242 } else {
4243 return false;
4244 }
4245 }
4246 if (!/^:?-+:?$/.test(t)) {
4247 return false;
4248 }
4249 if (t.charCodeAt(t.length - 1) === 58 /* : */) {
4250 aligns.push(t.charCodeAt(0) === 58 /* : */ ? "center" : "right");
4251 } else if (t.charCodeAt(0) === 58 /* : */) {
4252 aligns.push("left");
4253 } else {
4254 aligns.push("");
4255 }
4256 }
4257 lineText = getLine(state, startLine).trim();
4258 if (lineText.indexOf("|") === -1) {
4259 return false;
4260 }
4261 if (state.sCount[startLine] - state.blkIndent >= 4) {
4262 return false;
4263 }
4264 columns = escapedSplit(lineText);
4265 if (columns.length && columns[0] === "") columns.shift();
4266 if (columns.length && columns[columns.length - 1] === "") columns.pop();
4267 // header row will define an amount of columns in the entire table,
4268 // and align row should be exactly the same (the rest of the rows can differ)
4269 columnCount = columns.length;
4270 if (columnCount === 0 || columnCount !== aligns.length) {
4271 return false;
4272 }
4273 if (silent) {
4274 return true;
4275 }
4276 oldParentType = state.parentType;
4277 state.parentType = "table";
4278 // use 'blockquote' lists for termination because it's
4279 // the most similar to tables
4280 terminatorRules = state.md.block.ruler.getRules("blockquote");
4281 token = state.push("table_open", "table", 1);
4282 token.map = tableLines = [ startLine, 0 ];
4283 token = state.push("thead_open", "thead", 1);
4284 token.map = [ startLine, startLine + 1 ];
4285 token = state.push("tr_open", "tr", 1);
4286 token.map = [ startLine, startLine + 1 ];
4287 for (i = 0; i < columns.length; i++) {
4288 token = state.push("th_open", "th", 1);
4289 if (aligns[i]) {
4290 token.attrs = [ [ "style", "text-align:" + aligns[i] ] ];
4291 }
4292 token = state.push("inline", "", 0);
4293 token.content = columns[i].trim();
4294 token.children = [];
4295 token = state.push("th_close", "th", -1);
4296 }
4297 token = state.push("tr_close", "tr", -1);
4298 token = state.push("thead_close", "thead", -1);
4299 for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
4300 if (state.sCount[nextLine] < state.blkIndent) {
4301 break;
4302 }
4303 terminate = false;
4304 for (i = 0, l = terminatorRules.length; i < l; i++) {
4305 if (terminatorRules[i](state, nextLine, endLine, true)) {
4306 terminate = true;
4307 break;
4308 }
4309 }
4310 if (terminate) {
4311 break;
4312 }
4313 lineText = getLine(state, nextLine).trim();
4314 if (!lineText) {
4315 break;
4316 }
4317 if (state.sCount[nextLine] - state.blkIndent >= 4) {
4318 break;
4319 }
4320 columns = escapedSplit(lineText);
4321 if (columns.length && columns[0] === "") columns.shift();
4322 if (columns.length && columns[columns.length - 1] === "") columns.pop();
4323 if (nextLine === startLine + 2) {
4324 token = state.push("tbody_open", "tbody", 1);
4325 token.map = tbodyLines = [ startLine + 2, 0 ];
4326 }
4327 token = state.push("tr_open", "tr", 1);
4328 token.map = [ nextLine, nextLine + 1 ];
4329 for (i = 0; i < columnCount; i++) {
4330 token = state.push("td_open", "td", 1);
4331 if (aligns[i]) {
4332 token.attrs = [ [ "style", "text-align:" + aligns[i] ] ];
4333 }
4334 token = state.push("inline", "", 0);
4335 token.content = columns[i] ? columns[i].trim() : "";
4336 token.children = [];
4337 token = state.push("td_close", "td", -1);
4338 }
4339 token = state.push("tr_close", "tr", -1);
4340 }
4341 if (tbodyLines) {
4342 token = state.push("tbody_close", "tbody", -1);
4343 tbodyLines[1] = nextLine;
4344 }
4345 token = state.push("table_close", "table", -1);
4346 tableLines[1] = nextLine;
4347 state.parentType = oldParentType;
4348 state.line = nextLine;
4349 return true;
4350 };
4351 // Code block (4 spaces padded)
4352 var code = function code(state, startLine, endLine /*, silent*/) {
4353 var nextLine, last, token;
4354 if (state.sCount[startLine] - state.blkIndent < 4) {
4355 return false;
4356 }
4357 last = nextLine = startLine + 1;
4358 while (nextLine < endLine) {
4359 if (state.isEmpty(nextLine)) {
4360 nextLine++;
4361 continue;
4362 }
4363 if (state.sCount[nextLine] - state.blkIndent >= 4) {
4364 nextLine++;
4365 last = nextLine;
4366 continue;
4367 }
4368 break;
4369 }
4370 state.line = last;
4371 token = state.push("code_block", "code", 0);
4372 token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);
4373 token.map = [ startLine, state.line ];
4374 return true;
4375 };
4376 // fences (``` lang, ~~~ lang)
4377 var fence = function fence(state, startLine, endLine, silent) {
4378 var marker, len, params, nextLine, mem, token, markup, haveEndMarker = false, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
4379 // if it's indented more than 3 spaces, it should be a code block
4380 if (state.sCount[startLine] - state.blkIndent >= 4) {
4381 return false;
4382 }
4383 if (pos + 3 > max) {
4384 return false;
4385 }
4386 marker = state.src.charCodeAt(pos);
4387 if (marker !== 126 /* ~ */ && marker !== 96 /* ` */) {
4388 return false;
4389 }
4390 // scan marker length
4391 mem = pos;
4392 pos = state.skipChars(pos, marker);
4393 len = pos - mem;
4394 if (len < 3) {
4395 return false;
4396 }
4397 markup = state.src.slice(mem, pos);
4398 params = state.src.slice(pos, max);
4399 if (marker === 96 /* ` */) {
4400 if (params.indexOf(String.fromCharCode(marker)) >= 0) {
4401 return false;
4402 }
4403 }
4404 // Since start is found, we can report success here in validation mode
4405 if (silent) {
4406 return true;
4407 }
4408 // search end of block
4409 nextLine = startLine;
4410 for (;;) {
4411 nextLine++;
4412 if (nextLine >= endLine) {
4413 // unclosed block should be autoclosed by end of document.
4414 // also block seems to be autoclosed by end of parent
4415 break;
4416 }
4417 pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
4418 max = state.eMarks[nextLine];
4419 if (pos < max && state.sCount[nextLine] < state.blkIndent) {
4420 // non-empty line with negative indent should stop the list:
4421 // - ```
4422 // test
4423 break;
4424 }
4425 if (state.src.charCodeAt(pos) !== marker) {
4426 continue;
4427 }
4428 if (state.sCount[nextLine] - state.blkIndent >= 4) {
4429 // closing fence should be indented less than 4 spaces
4430 continue;
4431 }
4432 pos = state.skipChars(pos, marker);
4433 // closing code fence must be at least as long as the opening one
4434 if (pos - mem < len) {
4435 continue;
4436 }
4437 // make sure tail has spaces only
4438 pos = state.skipSpaces(pos);
4439 if (pos < max) {
4440 continue;
4441 }
4442 haveEndMarker = true;
4443 // found!
4444 break;
4445 }
4446 // If a fence has heading spaces, they should be removed from its inner block
4447 len = state.sCount[startLine];
4448 state.line = nextLine + (haveEndMarker ? 1 : 0);
4449 token = state.push("fence", "code", 0);
4450 token.info = params;
4451 token.content = state.getLines(startLine + 1, nextLine, len, true);
4452 token.markup = markup;
4453 token.map = [ startLine, state.line ];
4454 return true;
4455 };
4456 var isSpace$1 = utils.isSpace;
4457 var blockquote = function blockquote(state, startLine, endLine, silent) {
4458 var adjustTab, ch, i, initial, l, lastLineEmpty, lines, nextLine, offset, oldBMarks, oldBSCount, oldIndent, oldParentType, oldSCount, oldTShift, spaceAfterMarker, terminate, terminatorRules, token, isOutdented, oldLineMax = state.lineMax, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
4459 // if it's indented more than 3 spaces, it should be a code block
4460 if (state.sCount[startLine] - state.blkIndent >= 4) {
4461 return false;
4462 }
4463 // check the block quote marker
4464 if (state.src.charCodeAt(pos++) !== 62 /* > */) {
4465 return false;
4466 }
4467 // we know that it's going to be a valid blockquote,
4468 // so no point trying to find the end of it in silent mode
4469 if (silent) {
4470 return true;
4471 }
4472 // set offset past spaces and ">"
4473 initial = offset = state.sCount[startLine] + 1;
4474 // skip one optional space after '>'
4475 if (state.src.charCodeAt(pos) === 32 /* space */) {
4476 // ' > test '
4477 // ^ -- position start of line here:
4478 pos++;
4479 initial++;
4480 offset++;
4481 adjustTab = false;
4482 spaceAfterMarker = true;
4483 } else if (state.src.charCodeAt(pos) === 9 /* tab */) {
4484 spaceAfterMarker = true;
4485 if ((state.bsCount[startLine] + offset) % 4 === 3) {
4486 // ' >\t test '
4487 // ^ -- position start of line here (tab has width===1)
4488 pos++;
4489 initial++;
4490 offset++;
4491 adjustTab = false;
4492 } else {
4493 // ' >\t test '
4494 // ^ -- position start of line here + shift bsCount slightly
4495 // to make extra space appear
4496 adjustTab = true;
4497 }
4498 } else {
4499 spaceAfterMarker = false;
4500 }
4501 oldBMarks = [ state.bMarks[startLine] ];
4502 state.bMarks[startLine] = pos;
4503 while (pos < max) {
4504 ch = state.src.charCodeAt(pos);
4505 if (isSpace$1(ch)) {
4506 if (ch === 9) {
4507 offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
4508 } else {
4509 offset++;
4510 }
4511 } else {
4512 break;
4513 }
4514 pos++;
4515 }
4516 oldBSCount = [ state.bsCount[startLine] ];
4517 state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
4518 lastLineEmpty = pos >= max;
4519 oldSCount = [ state.sCount[startLine] ];
4520 state.sCount[startLine] = offset - initial;
4521 oldTShift = [ state.tShift[startLine] ];
4522 state.tShift[startLine] = pos - state.bMarks[startLine];
4523 terminatorRules = state.md.block.ruler.getRules("blockquote");
4524 oldParentType = state.parentType;
4525 state.parentType = "blockquote";
4526 // Search the end of the block
4527
4528 // Block ends with either:
4529 // 1. an empty line outside:
4530 // ```
4531 // > test
4532
4533 // ```
4534 // 2. an empty line inside:
4535 // ```
4536 // >
4537 // test
4538 // ```
4539 // 3. another tag:
4540 // ```
4541 // > test
4542 // - - -
4543 // ```
4544 for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
4545 // check if it's outdented, i.e. it's inside list item and indented
4546 // less than said list item:
4547 // ```
4548 // 1. anything
4549 // > current blockquote
4550 // 2. checking this line
4551 // ```
4552 isOutdented = state.sCount[nextLine] < state.blkIndent;
4553 pos = state.bMarks[nextLine] + state.tShift[nextLine];
4554 max = state.eMarks[nextLine];
4555 if (pos >= max) {
4556 // Case 1: line is not inside the blockquote, and this line is empty.
4557 break;
4558 }
4559 if (state.src.charCodeAt(pos++) === 62 /* > */ && !isOutdented) {
4560 // This line is inside the blockquote.
4561 // set offset past spaces and ">"
4562 initial = offset = state.sCount[nextLine] + 1;
4563 // skip one optional space after '>'
4564 if (state.src.charCodeAt(pos) === 32 /* space */) {
4565 // ' > test '
4566 // ^ -- position start of line here:
4567 pos++;
4568 initial++;
4569 offset++;
4570 adjustTab = false;
4571 spaceAfterMarker = true;
4572 } else if (state.src.charCodeAt(pos) === 9 /* tab */) {
4573 spaceAfterMarker = true;
4574 if ((state.bsCount[nextLine] + offset) % 4 === 3) {
4575 // ' >\t test '
4576 // ^ -- position start of line here (tab has width===1)
4577 pos++;
4578 initial++;
4579 offset++;
4580 adjustTab = false;
4581 } else {
4582 // ' >\t test '
4583 // ^ -- position start of line here + shift bsCount slightly
4584 // to make extra space appear
4585 adjustTab = true;
4586 }
4587 } else {
4588 spaceAfterMarker = false;
4589 }
4590 oldBMarks.push(state.bMarks[nextLine]);
4591 state.bMarks[nextLine] = pos;
4592 while (pos < max) {
4593 ch = state.src.charCodeAt(pos);
4594 if (isSpace$1(ch)) {
4595 if (ch === 9) {
4596 offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
4597 } else {
4598 offset++;
4599 }
4600 } else {
4601 break;
4602 }
4603 pos++;
4604 }
4605 lastLineEmpty = pos >= max;
4606 oldBSCount.push(state.bsCount[nextLine]);
4607 state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
4608 oldSCount.push(state.sCount[nextLine]);
4609 state.sCount[nextLine] = offset - initial;
4610 oldTShift.push(state.tShift[nextLine]);
4611 state.tShift[nextLine] = pos - state.bMarks[nextLine];
4612 continue;
4613 }
4614 // Case 2: line is not inside the blockquote, and the last line was empty.
4615 if (lastLineEmpty) {
4616 break;
4617 }
4618 // Case 3: another tag found.
4619 terminate = false;
4620 for (i = 0, l = terminatorRules.length; i < l; i++) {
4621 if (terminatorRules[i](state, nextLine, endLine, true)) {
4622 terminate = true;
4623 break;
4624 }
4625 }
4626 if (terminate) {
4627 // Quirk to enforce "hard termination mode" for paragraphs;
4628 // normally if you call `tokenize(state, startLine, nextLine)`,
4629 // paragraphs will look below nextLine for paragraph continuation,
4630 // but if blockquote is terminated by another tag, they shouldn't
4631 state.lineMax = nextLine;
4632 if (state.blkIndent !== 0) {
4633 // state.blkIndent was non-zero, we now set it to zero,
4634 // so we need to re-calculate all offsets to appear as
4635 // if indent wasn't changed
4636 oldBMarks.push(state.bMarks[nextLine]);
4637 oldBSCount.push(state.bsCount[nextLine]);
4638 oldTShift.push(state.tShift[nextLine]);
4639 oldSCount.push(state.sCount[nextLine]);
4640 state.sCount[nextLine] -= state.blkIndent;
4641 }
4642 break;
4643 }
4644 oldBMarks.push(state.bMarks[nextLine]);
4645 oldBSCount.push(state.bsCount[nextLine]);
4646 oldTShift.push(state.tShift[nextLine]);
4647 oldSCount.push(state.sCount[nextLine]);
4648 // A negative indentation means that this is a paragraph continuation
4649
4650 state.sCount[nextLine] = -1;
4651 }
4652 oldIndent = state.blkIndent;
4653 state.blkIndent = 0;
4654 token = state.push("blockquote_open", "blockquote", 1);
4655 token.markup = ">";
4656 token.map = lines = [ startLine, 0 ];
4657 state.md.block.tokenize(state, startLine, nextLine);
4658 token = state.push("blockquote_close", "blockquote", -1);
4659 token.markup = ">";
4660 state.lineMax = oldLineMax;
4661 state.parentType = oldParentType;
4662 lines[1] = state.line;
4663 // Restore original tShift; this might not be necessary since the parser
4664 // has already been here, but just to make sure we can do that.
4665 for (i = 0; i < oldTShift.length; i++) {
4666 state.bMarks[i + startLine] = oldBMarks[i];
4667 state.tShift[i + startLine] = oldTShift[i];
4668 state.sCount[i + startLine] = oldSCount[i];
4669 state.bsCount[i + startLine] = oldBSCount[i];
4670 }
4671 state.blkIndent = oldIndent;
4672 return true;
4673 };
4674 var isSpace$2 = utils.isSpace;
4675 var hr = function hr(state, startLine, endLine, silent) {
4676 var marker, cnt, ch, token, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
4677 // if it's indented more than 3 spaces, it should be a code block
4678 if (state.sCount[startLine] - state.blkIndent >= 4) {
4679 return false;
4680 }
4681 marker = state.src.charCodeAt(pos++);
4682 // Check hr marker
4683 if (marker !== 42 /* * */ && marker !== 45 /* - */ && marker !== 95 /* _ */) {
4684 return false;
4685 }
4686 // markers can be mixed with spaces, but there should be at least 3 of them
4687 cnt = 1;
4688 while (pos < max) {
4689 ch = state.src.charCodeAt(pos++);
4690 if (ch !== marker && !isSpace$2(ch)) {
4691 return false;
4692 }
4693 if (ch === marker) {
4694 cnt++;
4695 }
4696 }
4697 if (cnt < 3) {
4698 return false;
4699 }
4700 if (silent) {
4701 return true;
4702 }
4703 state.line = startLine + 1;
4704 token = state.push("hr", "hr", 0);
4705 token.map = [ startLine, state.line ];
4706 token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
4707 return true;
4708 };
4709 var isSpace$3 = utils.isSpace;
4710 // Search `[-+*][\n ]`, returns next pos after marker on success
4711 // or -1 on fail.
4712 function skipBulletListMarker(state, startLine) {
4713 var marker, pos, max, ch;
4714 pos = state.bMarks[startLine] + state.tShift[startLine];
4715 max = state.eMarks[startLine];
4716 marker = state.src.charCodeAt(pos++);
4717 // Check bullet
4718 if (marker !== 42 /* * */ && marker !== 45 /* - */ && marker !== 43 /* + */) {
4719 return -1;
4720 }
4721 if (pos < max) {
4722 ch = state.src.charCodeAt(pos);
4723 if (!isSpace$3(ch)) {
4724 // " -test " - is not a list item
4725 return -1;
4726 }
4727 }
4728 return pos;
4729 }
4730 // Search `\d+[.)][\n ]`, returns next pos after marker on success
4731 // or -1 on fail.
4732 function skipOrderedListMarker(state, startLine) {
4733 var ch, start = state.bMarks[startLine] + state.tShift[startLine], pos = start, max = state.eMarks[startLine];
4734 // List marker should have at least 2 chars (digit + dot)
4735 if (pos + 1 >= max) {
4736 return -1;
4737 }
4738 ch = state.src.charCodeAt(pos++);
4739 if (ch < 48 /* 0 */ || ch > 57 /* 9 */) {
4740 return -1;
4741 }
4742 for (;;) {
4743 // EOL -> fail
4744 if (pos >= max) {
4745 return -1;
4746 }
4747 ch = state.src.charCodeAt(pos++);
4748 if (ch >= 48 /* 0 */ && ch <= 57 /* 9 */) {
4749 // List marker should have no more than 9 digits
4750 // (prevents integer overflow in browsers)
4751 if (pos - start >= 10) {
4752 return -1;
4753 }
4754 continue;
4755 }
4756 // found valid marker
4757 if (ch === 41 /* ) */ || ch === 46 /* . */) {
4758 break;
4759 }
4760 return -1;
4761 }
4762 if (pos < max) {
4763 ch = state.src.charCodeAt(pos);
4764 if (!isSpace$3(ch)) {
4765 // " 1.test " - is not a list item
4766 return -1;
4767 }
4768 }
4769 return pos;
4770 }
4771 function markTightParagraphs(state, idx) {
4772 var i, l, level = state.level + 2;
4773 for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
4774 if (state.tokens[i].level === level && state.tokens[i].type === "paragraph_open") {
4775 state.tokens[i + 2].hidden = true;
4776 state.tokens[i].hidden = true;
4777 i += 2;
4778 }
4779 }
4780 }
4781 var list = function list(state, startLine, endLine, silent) {
4782 var ch, contentStart, i, indent, indentAfterMarker, initial, isOrdered, itemLines, l, listLines, listTokIdx, markerCharCode, markerValue, max, nextLine, offset, oldListIndent, oldParentType, oldSCount, oldTShift, oldTight, pos, posAfterMarker, prevEmptyEnd, start, terminate, terminatorRules, token, isTerminatingParagraph = false, tight = true;
4783 // if it's indented more than 3 spaces, it should be a code block
4784 if (state.sCount[startLine] - state.blkIndent >= 4) {
4785 return false;
4786 }
4787 // Special case:
4788 // - item 1
4789 // - item 2
4790 // - item 3
4791 // - item 4
4792 // - this one is a paragraph continuation
4793 if (state.listIndent >= 0 && state.sCount[startLine] - state.listIndent >= 4 && state.sCount[startLine] < state.blkIndent) {
4794 return false;
4795 }
4796 // limit conditions when list can interrupt
4797 // a paragraph (validation mode only)
4798 if (silent && state.parentType === "paragraph") {
4799 // Next list item should still terminate previous list item;
4800 // This code can fail if plugins use blkIndent as well as lists,
4801 // but I hope the spec gets fixed long before that happens.
4802 if (state.tShift[startLine] >= state.blkIndent) {
4803 isTerminatingParagraph = true;
4804 }
4805 }
4806 // Detect list type and position after marker
4807 if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
4808 isOrdered = true;
4809 start = state.bMarks[startLine] + state.tShift[startLine];
4810 markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
4811 // If we're starting a new ordered list right after
4812 // a paragraph, it should start with 1.
4813 if (isTerminatingParagraph && markerValue !== 1) return false;
4814 } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
4815 isOrdered = false;
4816 } else {
4817 return false;
4818 }
4819 // If we're starting a new unordered list right after
4820 // a paragraph, first line should not be empty.
4821 if (isTerminatingParagraph) {
4822 if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
4823 }
4824 // We should terminate list on style change. Remember first one to compare.
4825 markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
4826 // For validation mode we can terminate immediately
4827 if (silent) {
4828 return true;
4829 }
4830 // Start list
4831 listTokIdx = state.tokens.length;
4832 if (isOrdered) {
4833 token = state.push("ordered_list_open", "ol", 1);
4834 if (markerValue !== 1) {
4835 token.attrs = [ [ "start", markerValue ] ];
4836 }
4837 } else {
4838 token = state.push("bullet_list_open", "ul", 1);
4839 }
4840 token.map = listLines = [ startLine, 0 ];
4841 token.markup = String.fromCharCode(markerCharCode);
4842
4843 // Iterate list items
4844
4845 nextLine = startLine;
4846 prevEmptyEnd = false;
4847 terminatorRules = state.md.block.ruler.getRules("list");
4848 oldParentType = state.parentType;
4849 state.parentType = "list";
4850 while (nextLine < endLine) {
4851 pos = posAfterMarker;
4852 max = state.eMarks[nextLine];
4853 initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
4854 while (pos < max) {
4855 ch = state.src.charCodeAt(pos);
4856 if (ch === 9) {
4857 offset += 4 - (offset + state.bsCount[nextLine]) % 4;
4858 } else if (ch === 32) {
4859 offset++;
4860 } else {
4861 break;
4862 }
4863 pos++;
4864 }
4865 contentStart = pos;
4866 if (contentStart >= max) {
4867 // trimming space in "- \n 3" case, indent is 1 here
4868 indentAfterMarker = 1;
4869 } else {
4870 indentAfterMarker = offset - initial;
4871 }
4872 // If we have more than 4 spaces, the indent is 1
4873 // (the rest is just indented code block)
4874 if (indentAfterMarker > 4) {
4875 indentAfterMarker = 1;
4876 }
4877 // " - test"
4878 // ^^^^^ - calculating total length of this thing
4879 indent = initial + indentAfterMarker;
4880 // Run subparser & write tokens
4881 token = state.push("list_item_open", "li", 1);
4882 token.markup = String.fromCharCode(markerCharCode);
4883 token.map = itemLines = [ startLine, 0 ];
4884 // change current state, then restore it after parser subcall
4885 oldTight = state.tight;
4886 oldTShift = state.tShift[startLine];
4887 oldSCount = state.sCount[startLine];
4888 // - example list
4889 // ^ listIndent position will be here
4890 // ^ blkIndent position will be here
4891
4892 oldListIndent = state.listIndent;
4893 state.listIndent = state.blkIndent;
4894 state.blkIndent = indent;
4895 state.tight = true;
4896 state.tShift[startLine] = contentStart - state.bMarks[startLine];
4897 state.sCount[startLine] = offset;
4898 if (contentStart >= max && state.isEmpty(startLine + 1)) {
4899 // workaround for this case
4900 // (list item is empty, list terminates before "foo"):
4901 // ~~~~~~~~
4902 // -
4903 // foo
4904 // ~~~~~~~~
4905 state.line = Math.min(state.line + 2, endLine);
4906 } else {
4907 state.md.block.tokenize(state, startLine, endLine, true);
4908 }
4909 // If any of list item is tight, mark list as tight
4910 if (!state.tight || prevEmptyEnd) {
4911 tight = false;
4912 }
4913 // Item become loose if finish with empty line,
4914 // but we should filter last element, because it means list finish
4915 prevEmptyEnd = state.line - startLine > 1 && state.isEmpty(state.line - 1);
4916 state.blkIndent = state.listIndent;
4917 state.listIndent = oldListIndent;
4918 state.tShift[startLine] = oldTShift;
4919 state.sCount[startLine] = oldSCount;
4920 state.tight = oldTight;
4921 token = state.push("list_item_close", "li", -1);
4922 token.markup = String.fromCharCode(markerCharCode);
4923 nextLine = startLine = state.line;
4924 itemLines[1] = nextLine;
4925 contentStart = state.bMarks[startLine];
4926 if (nextLine >= endLine) {
4927 break;
4928 }
4929
4930 // Try to check if list is terminated or continued.
4931
4932 if (state.sCount[nextLine] < state.blkIndent) {
4933 break;
4934 }
4935 // if it's indented more than 3 spaces, it should be a code block
4936 if (state.sCount[startLine] - state.blkIndent >= 4) {
4937 break;
4938 }
4939 // fail if terminating block found
4940 terminate = false;
4941 for (i = 0, l = terminatorRules.length; i < l; i++) {
4942 if (terminatorRules[i](state, nextLine, endLine, true)) {
4943 terminate = true;
4944 break;
4945 }
4946 }
4947 if (terminate) {
4948 break;
4949 }
4950 // fail if list has another type
4951 if (isOrdered) {
4952 posAfterMarker = skipOrderedListMarker(state, nextLine);
4953 if (posAfterMarker < 0) {
4954 break;
4955 }
4956 } else {
4957 posAfterMarker = skipBulletListMarker(state, nextLine);
4958 if (posAfterMarker < 0) {
4959 break;
4960 }
4961 }
4962 if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) {
4963 break;
4964 }
4965 }
4966 // Finalize list
4967 if (isOrdered) {
4968 token = state.push("ordered_list_close", "ol", -1);
4969 } else {
4970 token = state.push("bullet_list_close", "ul", -1);
4971 }
4972 token.markup = String.fromCharCode(markerCharCode);
4973 listLines[1] = nextLine;
4974 state.line = nextLine;
4975 state.parentType = oldParentType;
4976 // mark paragraphs tight if needed
4977 if (tight) {
4978 markTightParagraphs(state, listTokIdx);
4979 }
4980 return true;
4981 };
4982 var normalizeReference = utils.normalizeReference;
4983 var isSpace$4 = utils.isSpace;
4984 var reference = function reference(state, startLine, _endLine, silent) {
4985 var ch, destEndPos, destEndLineNo, endLine, href, i, l, label, labelEnd, oldParentType, res, start, str, terminate, terminatorRules, title, lines = 0, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine], nextLine = startLine + 1;
4986 // if it's indented more than 3 spaces, it should be a code block
4987 if (state.sCount[startLine] - state.blkIndent >= 4) {
4988 return false;
4989 }
4990 if (state.src.charCodeAt(pos) !== 91 /* [ */) {
4991 return false;
4992 }
4993 // Simple check to quickly interrupt scan on [link](url) at the start of line.
4994 // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
4995 while (++pos < max) {
4996 if (state.src.charCodeAt(pos) === 93 /* ] */ && state.src.charCodeAt(pos - 1) !== 92 /* \ */) {
4997 if (pos + 1 === max) {
4998 return false;
4999 }
5000 if (state.src.charCodeAt(pos + 1) !== 58 /* : */) {
5001 return false;
5002 }
5003 break;
5004 }
5005 }
5006 endLine = state.lineMax;
5007 // jump line-by-line until empty one or EOF
5008 terminatorRules = state.md.block.ruler.getRules("reference");
5009 oldParentType = state.parentType;
5010 state.parentType = "reference";
5011 for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
5012 // this would be a code block normally, but after paragraph
5013 // it's considered a lazy continuation regardless of what's there
5014 if (state.sCount[nextLine] - state.blkIndent > 3) {
5015 continue;
5016 }
5017 // quirk for blockquotes, this line should already be checked by that rule
5018 if (state.sCount[nextLine] < 0) {
5019 continue;
5020 }
5021 // Some tags can terminate paragraph without empty line.
5022 terminate = false;
5023 for (i = 0, l = terminatorRules.length; i < l; i++) {
5024 if (terminatorRules[i](state, nextLine, endLine, true)) {
5025 terminate = true;
5026 break;
5027 }
5028 }
5029 if (terminate) {
5030 break;
5031 }
5032 }
5033 str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
5034 max = str.length;
5035 for (pos = 1; pos < max; pos++) {
5036 ch = str.charCodeAt(pos);
5037 if (ch === 91 /* [ */) {
5038 return false;
5039 } else if (ch === 93 /* ] */) {
5040 labelEnd = pos;
5041 break;
5042 } else if (ch === 10 /* \n */) {
5043 lines++;
5044 } else if (ch === 92 /* \ */) {
5045 pos++;
5046 if (pos < max && str.charCodeAt(pos) === 10) {
5047 lines++;
5048 }
5049 }
5050 }
5051 if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58 /* : */) {
5052 return false;
5053 }
5054 // [label]: destination 'title'
5055 // ^^^ skip optional whitespace here
5056 for (pos = labelEnd + 2; pos < max; pos++) {
5057 ch = str.charCodeAt(pos);
5058 if (ch === 10) {
5059 lines++;
5060 } else if (isSpace$4(ch)) ; else {
5061 break;
5062 }
5063 }
5064 // [label]: destination 'title'
5065 // ^^^^^^^^^^^ parse this
5066 res = state.md.helpers.parseLinkDestination(str, pos, max);
5067 if (!res.ok) {
5068 return false;
5069 }
5070 href = state.md.normalizeLink(res.str);
5071 if (!state.md.validateLink(href)) {
5072 return false;
5073 }
5074 pos = res.pos;
5075 lines += res.lines;
5076 // save cursor state, we could require to rollback later
5077 destEndPos = pos;
5078 destEndLineNo = lines;
5079 // [label]: destination 'title'
5080 // ^^^ skipping those spaces
5081 start = pos;
5082 for (;pos < max; pos++) {
5083 ch = str.charCodeAt(pos);
5084 if (ch === 10) {
5085 lines++;
5086 } else if (isSpace$4(ch)) ; else {
5087 break;
5088 }
5089 }
5090 // [label]: destination 'title'
5091 // ^^^^^^^ parse this
5092 res = state.md.helpers.parseLinkTitle(str, pos, max);
5093 if (pos < max && start !== pos && res.ok) {
5094 title = res.str;
5095 pos = res.pos;
5096 lines += res.lines;
5097 } else {
5098 title = "";
5099 pos = destEndPos;
5100 lines = destEndLineNo;
5101 }
5102 // skip trailing spaces until the rest of the line
5103 while (pos < max) {
5104 ch = str.charCodeAt(pos);
5105 if (!isSpace$4(ch)) {
5106 break;
5107 }
5108 pos++;
5109 }
5110 if (pos < max && str.charCodeAt(pos) !== 10) {
5111 if (title) {
5112 // garbage at the end of the line after title,
5113 // but it could still be a valid reference if we roll back
5114 title = "";
5115 pos = destEndPos;
5116 lines = destEndLineNo;
5117 while (pos < max) {
5118 ch = str.charCodeAt(pos);
5119 if (!isSpace$4(ch)) {
5120 break;
5121 }
5122 pos++;
5123 }
5124 }
5125 }
5126 if (pos < max && str.charCodeAt(pos) !== 10) {
5127 // garbage at the end of the line
5128 return false;
5129 }
5130 label = normalizeReference(str.slice(1, labelEnd));
5131 if (!label) {
5132 // CommonMark 0.20 disallows empty labels
5133 return false;
5134 }
5135 // Reference can not terminate anything. This check is for safety only.
5136 /*istanbul ignore if*/ if (silent) {
5137 return true;
5138 }
5139 if (typeof state.env.references === "undefined") {
5140 state.env.references = {};
5141 }
5142 if (typeof state.env.references[label] === "undefined") {
5143 state.env.references[label] = {
5144 title: title,
5145 href: href
5146 };
5147 }
5148 state.parentType = oldParentType;
5149 state.line = startLine + lines + 1;
5150 return true;
5151 };
5152 var isSpace$5 = utils.isSpace;
5153 var heading = function heading(state, startLine, endLine, silent) {
5154 var ch, level, tmp, token, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
5155 // if it's indented more than 3 spaces, it should be a code block
5156 if (state.sCount[startLine] - state.blkIndent >= 4) {
5157 return false;
5158 }
5159 ch = state.src.charCodeAt(pos);
5160 if (ch !== 35 /* # */ || pos >= max) {
5161 return false;
5162 }
5163 // count heading level
5164 level = 1;
5165 ch = state.src.charCodeAt(++pos);
5166 while (ch === 35 /* # */ && pos < max && level <= 6) {
5167 level++;
5168 ch = state.src.charCodeAt(++pos);
5169 }
5170 if (level > 6 || pos < max && !isSpace$5(ch)) {
5171 return false;
5172 }
5173 if (silent) {
5174 return true;
5175 }
5176 // Let's cut tails like ' ### ' from the end of string
5177 max = state.skipSpacesBack(max, pos);
5178 tmp = state.skipCharsBack(max, 35, pos);
5179 // #
5180 if (tmp > pos && isSpace$5(state.src.charCodeAt(tmp - 1))) {
5181 max = tmp;
5182 }
5183 state.line = startLine + 1;
5184 token = state.push("heading_open", "h" + String(level), 1);
5185 token.markup = "########".slice(0, level);
5186 token.map = [ startLine, state.line ];
5187 token = state.push("inline", "", 0);
5188 token.content = state.src.slice(pos, max).trim();
5189 token.map = [ startLine, state.line ];
5190 token.children = [];
5191 token = state.push("heading_close", "h" + String(level), -1);
5192 token.markup = "########".slice(0, level);
5193 return true;
5194 };
5195 // lheading (---, ===)
5196 var lheading = function lheading(state, startLine, endLine /*, silent*/) {
5197 var content, terminate, i, l, token, pos, max, level, marker, nextLine = startLine + 1, oldParentType, terminatorRules = state.md.block.ruler.getRules("paragraph");
5198 // if it's indented more than 3 spaces, it should be a code block
5199 if (state.sCount[startLine] - state.blkIndent >= 4) {
5200 return false;
5201 }
5202 oldParentType = state.parentType;
5203 state.parentType = "paragraph";
5204 // use paragraph to match terminatorRules
5205 // jump line-by-line until empty one or EOF
5206 for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
5207 // this would be a code block normally, but after paragraph
5208 // it's considered a lazy continuation regardless of what's there
5209 if (state.sCount[nextLine] - state.blkIndent > 3) {
5210 continue;
5211 }
5212
5213 // Check for underline in setext header
5214
5215 if (state.sCount[nextLine] >= state.blkIndent) {
5216 pos = state.bMarks[nextLine] + state.tShift[nextLine];
5217 max = state.eMarks[nextLine];
5218 if (pos < max) {
5219 marker = state.src.charCodeAt(pos);
5220 if (marker === 45 /* - */ || marker === 61 /* = */) {
5221 pos = state.skipChars(pos, marker);
5222 pos = state.skipSpaces(pos);
5223 if (pos >= max) {
5224 level = marker === 61 /* = */ ? 1 : 2;
5225 break;
5226 }
5227 }
5228 }
5229 }
5230 // quirk for blockquotes, this line should already be checked by that rule
5231 if (state.sCount[nextLine] < 0) {
5232 continue;
5233 }
5234 // Some tags can terminate paragraph without empty line.
5235 terminate = false;
5236 for (i = 0, l = terminatorRules.length; i < l; i++) {
5237 if (terminatorRules[i](state, nextLine, endLine, true)) {
5238 terminate = true;
5239 break;
5240 }
5241 }
5242 if (terminate) {
5243 break;
5244 }
5245 }
5246 if (!level) {
5247 // Didn't find valid underline
5248 return false;
5249 }
5250 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
5251 state.line = nextLine + 1;
5252 token = state.push("heading_open", "h" + String(level), 1);
5253 token.markup = String.fromCharCode(marker);
5254 token.map = [ startLine, state.line ];
5255 token = state.push("inline", "", 0);
5256 token.content = content;
5257 token.map = [ startLine, state.line - 1 ];
5258 token.children = [];
5259 token = state.push("heading_close", "h" + String(level), -1);
5260 token.markup = String.fromCharCode(marker);
5261 state.parentType = oldParentType;
5262 return true;
5263 };
5264 // List of valid html blocks names, accorting to commonmark spec
5265 var html_blocks = [ "address", "article", "aside", "base", "basefont", "blockquote", "body", "caption", "center", "col", "colgroup", "dd", "details", "dialog", "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hr", "html", "iframe", "legend", "li", "link", "main", "menu", "menuitem", "meta", "nav", "noframes", "ol", "optgroup", "option", "p", "param", "section", "source", "summary", "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track", "ul" ];
5266 // Regexps to match html elements
5267 var attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";
5268 var unquoted = "[^\"'=<>`\\x00-\\x20]+";
5269 var single_quoted = "'[^']*'";
5270 var double_quoted = '"[^"]*"';
5271 var attr_value = "(?:" + unquoted + "|" + single_quoted + "|" + double_quoted + ")";
5272 var attribute = "(?:\\s+" + attr_name + "(?:\\s*=\\s*" + attr_value + ")?)";
5273 var open_tag = "<[A-Za-z][A-Za-z0-9\\-]*" + attribute + "*\\s*\\/?>";
5274 var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";
5275 var comment = "\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e";
5276 var processing = "<[?].*?[?]>";
5277 var declaration = "<![A-Z]+\\s+[^>]*>";
5278 var cdata = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";
5279 var HTML_TAG_RE = new RegExp("^(?:" + open_tag + "|" + close_tag + "|" + comment + "|" + processing + "|" + declaration + "|" + cdata + ")");
5280 var HTML_OPEN_CLOSE_TAG_RE = new RegExp("^(?:" + open_tag + "|" + close_tag + ")");
5281 var HTML_TAG_RE_1 = HTML_TAG_RE;
5282 var HTML_OPEN_CLOSE_TAG_RE_1 = HTML_OPEN_CLOSE_TAG_RE;
5283 var html_re = {
5284 HTML_TAG_RE: HTML_TAG_RE_1,
5285 HTML_OPEN_CLOSE_TAG_RE: HTML_OPEN_CLOSE_TAG_RE_1
5286 };
5287 var HTML_OPEN_CLOSE_TAG_RE$1 = html_re.HTML_OPEN_CLOSE_TAG_RE;
5288 // An array of opening and corresponding closing sequences for html tags,
5289 // last argument defines whether it can terminate a paragraph or not
5290
5291 var HTML_SEQUENCES = [ [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ], [ /^<!--/, /-->/, true ], [ /^<\?/, /\?>/, true ], [ /^<![A-Z]/, />/, true ], [ /^<!\[CDATA\[/, /\]\]>/, true ], [ new RegExp("^</?(" + html_blocks.join("|") + ")(?=(\\s|/?>|$))", "i"), /^$/, true ], [ new RegExp(HTML_OPEN_CLOSE_TAG_RE$1.source + "\\s*$"), /^$/, false ] ];
5292 var html_block = function html_block(state, startLine, endLine, silent) {
5293 var i, nextLine, token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
5294 // if it's indented more than 3 spaces, it should be a code block
5295 if (state.sCount[startLine] - state.blkIndent >= 4) {
5296 return false;
5297 }
5298 if (!state.md.options.html) {
5299 return false;
5300 }
5301 if (state.src.charCodeAt(pos) !== 60 /* < */) {
5302 return false;
5303 }
5304 lineText = state.src.slice(pos, max);
5305 for (i = 0; i < HTML_SEQUENCES.length; i++) {
5306 if (HTML_SEQUENCES[i][0].test(lineText)) {
5307 break;
5308 }
5309 }
5310 if (i === HTML_SEQUENCES.length) {
5311 return false;
5312 }
5313 if (silent) {
5314 // true if this sequence can be a terminator, false otherwise
5315 return HTML_SEQUENCES[i][2];
5316 }
5317 nextLine = startLine + 1;
5318 // If we are here - we detected HTML block.
5319 // Let's roll down till block end.
5320 if (!HTML_SEQUENCES[i][1].test(lineText)) {
5321 for (;nextLine < endLine; nextLine++) {
5322 if (state.sCount[nextLine] < state.blkIndent) {
5323 break;
5324 }
5325 pos = state.bMarks[nextLine] + state.tShift[nextLine];
5326 max = state.eMarks[nextLine];
5327 lineText = state.src.slice(pos, max);
5328 if (HTML_SEQUENCES[i][1].test(lineText)) {
5329 if (lineText.length !== 0) {
5330 nextLine++;
5331 }
5332 break;
5333 }
5334 }
5335 }
5336 state.line = nextLine;
5337 token = state.push("html_block", "", 0);
5338 token.map = [ startLine, nextLine ];
5339 token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
5340 return true;
5341 };
5342 // Paragraph
5343 var paragraph = function paragraph(state, startLine /*, endLine*/) {
5344 var content, terminate, i, l, token, oldParentType, nextLine = startLine + 1, terminatorRules = state.md.block.ruler.getRules("paragraph"), endLine = state.lineMax;
5345 oldParentType = state.parentType;
5346 state.parentType = "paragraph";
5347 // jump line-by-line until empty one or EOF
5348 for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
5349 // this would be a code block normally, but after paragraph
5350 // it's considered a lazy continuation regardless of what's there
5351 if (state.sCount[nextLine] - state.blkIndent > 3) {
5352 continue;
5353 }
5354 // quirk for blockquotes, this line should already be checked by that rule
5355 if (state.sCount[nextLine] < 0) {
5356 continue;
5357 }
5358 // Some tags can terminate paragraph without empty line.
5359 terminate = false;
5360 for (i = 0, l = terminatorRules.length; i < l; i++) {
5361 if (terminatorRules[i](state, nextLine, endLine, true)) {
5362 terminate = true;
5363 break;
5364 }
5365 }
5366 if (terminate) {
5367 break;
5368 }
5369 }
5370 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
5371 state.line = nextLine;
5372 token = state.push("paragraph_open", "p", 1);
5373 token.map = [ startLine, state.line ];
5374 token = state.push("inline", "", 0);
5375 token.content = content;
5376 token.map = [ startLine, state.line ];
5377 token.children = [];
5378 token = state.push("paragraph_close", "p", -1);
5379 state.parentType = oldParentType;
5380 return true;
5381 };
5382 var isSpace$6 = utils.isSpace;
5383 function StateBlock(src, md, env, tokens) {
5384 var ch, s, start, pos, len, indent, offset, indent_found;
5385 this.src = src;
5386 // link to parser instance
5387 this.md = md;
5388 this.env = env;
5389
5390 // Internal state vartiables
5391
5392 this.tokens = tokens;
5393 this.bMarks = [];
5394 // line begin offsets for fast jumps
5395 this.eMarks = [];
5396 // line end offsets for fast jumps
5397 this.tShift = [];
5398 // offsets of the first non-space characters (tabs not expanded)
5399 this.sCount = [];
5400 // indents for each line (tabs expanded)
5401 // An amount of virtual spaces (tabs expanded) between beginning
5402 // of each line (bMarks) and real beginning of that line.
5403
5404 // It exists only as a hack because blockquotes override bMarks
5405 // losing information in the process.
5406
5407 // It's used only when expanding tabs, you can think about it as
5408 // an initial tab length, e.g. bsCount=21 applied to string `\t123`
5409 // means first tab should be expanded to 4-21%4 === 3 spaces.
5410
5411 this.bsCount = [];
5412 // block parser variables
5413 this.blkIndent = 0;
5414 // required block content indent (for example, if we are
5415 // inside a list, it would be positioned after list marker)
5416 this.line = 0;
5417 // line index in src
5418 this.lineMax = 0;
5419 // lines count
5420 this.tight = false;
5421 // loose/tight mode for lists
5422 this.ddIndent = -1;
5423 // indent of the current dd block (-1 if there isn't any)
5424 this.listIndent = -1;
5425 // indent of the current list block (-1 if there isn't any)
5426 // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
5427 // used in lists to determine if they interrupt a paragraph
5428 this.parentType = "root";
5429 this.level = 0;
5430 // renderer
5431 this.result = "";
5432 // Create caches
5433 // Generate markers.
5434 s = this.src;
5435 indent_found = false;
5436 for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
5437 ch = s.charCodeAt(pos);
5438 if (!indent_found) {
5439 if (isSpace$6(ch)) {
5440 indent++;
5441 if (ch === 9) {
5442 offset += 4 - offset % 4;
5443 } else {
5444 offset++;
5445 }
5446 continue;
5447 } else {
5448 indent_found = true;
5449 }
5450 }
5451 if (ch === 10 || pos === len - 1) {
5452 if (ch !== 10) {
5453 pos++;
5454 }
5455 this.bMarks.push(start);
5456 this.eMarks.push(pos);
5457 this.tShift.push(indent);
5458 this.sCount.push(offset);
5459 this.bsCount.push(0);
5460 indent_found = false;
5461 indent = 0;
5462 offset = 0;
5463 start = pos + 1;
5464 }
5465 }
5466 // Push fake entry to simplify cache bounds checks
5467 this.bMarks.push(s.length);
5468 this.eMarks.push(s.length);
5469 this.tShift.push(0);
5470 this.sCount.push(0);
5471 this.bsCount.push(0);
5472 this.lineMax = this.bMarks.length - 1;
5473 // don't count last fake line
5474 }
5475 // Push new token to "stream".
5476
5477 StateBlock.prototype.push = function(type, tag, nesting) {
5478 var token$1 = new token(type, tag, nesting);
5479 token$1.block = true;
5480 if (nesting < 0) this.level--;
5481 // closing tag
5482 token$1.level = this.level;
5483 if (nesting > 0) this.level++;
5484 // opening tag
5485 this.tokens.push(token$1);
5486 return token$1;
5487 };
5488 StateBlock.prototype.isEmpty = function isEmpty(line) {
5489 return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
5490 };
5491 StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
5492 for (var max = this.lineMax; from < max; from++) {
5493 if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
5494 break;
5495 }
5496 }
5497 return from;
5498 };
5499 // Skip spaces from given position.
5500 StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
5501 var ch;
5502 for (var max = this.src.length; pos < max; pos++) {
5503 ch = this.src.charCodeAt(pos);
5504 if (!isSpace$6(ch)) {
5505 break;
5506 }
5507 }
5508 return pos;
5509 };
5510 // Skip spaces from given position in reverse.
5511 StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
5512 if (pos <= min) {
5513 return pos;
5514 }
5515 while (pos > min) {
5516 if (!isSpace$6(this.src.charCodeAt(--pos))) {
5517 return pos + 1;
5518 }
5519 }
5520 return pos;
5521 };
5522 // Skip char codes from given position
5523 StateBlock.prototype.skipChars = function skipChars(pos, code) {
5524 for (var max = this.src.length; pos < max; pos++) {
5525 if (this.src.charCodeAt(pos) !== code) {
5526 break;
5527 }
5528 }
5529 return pos;
5530 };
5531 // Skip char codes reverse from given position - 1
5532 StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
5533 if (pos <= min) {
5534 return pos;
5535 }
5536 while (pos > min) {
5537 if (code !== this.src.charCodeAt(--pos)) {
5538 return pos + 1;
5539 }
5540 }
5541 return pos;
5542 };
5543 // cut lines range from source.
5544 StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
5545 var i, lineIndent, ch, first, last, queue, lineStart, line = begin;
5546 if (begin >= end) {
5547 return "";
5548 }
5549 queue = new Array(end - begin);
5550 for (i = 0; line < end; line++, i++) {
5551 lineIndent = 0;
5552 lineStart = first = this.bMarks[line];
5553 if (line + 1 < end || keepLastLF) {
5554 // No need for bounds check because we have fake entry on tail.
5555 last = this.eMarks[line] + 1;
5556 } else {
5557 last = this.eMarks[line];
5558 }
5559 while (first < last && lineIndent < indent) {
5560 ch = this.src.charCodeAt(first);
5561 if (isSpace$6(ch)) {
5562 if (ch === 9) {
5563 lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
5564 } else {
5565 lineIndent++;
5566 }
5567 } else if (first - lineStart < this.tShift[line]) {
5568 // patched tShift masked characters to look like spaces (blockquotes, list markers)
5569 lineIndent++;
5570 } else {
5571 break;
5572 }
5573 first++;
5574 }
5575 if (lineIndent > indent) {
5576 // partially expanding tabs in code blocks, e.g '\t\tfoobar'
5577 // with indent=2 becomes ' \tfoobar'
5578 queue[i] = new Array(lineIndent - indent + 1).join(" ") + this.src.slice(first, last);
5579 } else {
5580 queue[i] = this.src.slice(first, last);
5581 }
5582 }
5583 return queue.join("");
5584 };
5585 // re-export Token class to use in block rules
5586 StateBlock.prototype.Token = token;
5587 var state_block = StateBlock;
5588 var _rules$1 = [
5589 // First 2 params - rule name & source. Secondary array - list of rules,
5590 // which can be terminated by this one.
5591 [ "table", table, [ "paragraph", "reference" ] ], [ "code", code ], [ "fence", fence, [ "paragraph", "reference", "blockquote", "list" ] ], [ "blockquote", blockquote, [ "paragraph", "reference", "blockquote", "list" ] ], [ "hr", hr, [ "paragraph", "reference", "blockquote", "list" ] ], [ "list", list, [ "paragraph", "reference", "blockquote" ] ], [ "reference", reference ], [ "heading", heading, [ "paragraph", "reference", "blockquote" ] ], [ "lheading", lheading ], [ "html_block", html_block, [ "paragraph", "reference", "blockquote" ] ], [ "paragraph", paragraph ] ];
5592 /**
5593 * new ParserBlock()
5594 **/ function ParserBlock() {
5595 /**
5596 * ParserBlock#ruler -> Ruler
5597 *
5598 * [[Ruler]] instance. Keep configuration of block rules.
5599 **/
5600 this.ruler = new ruler;
5601 for (var i = 0; i < _rules$1.length; i++) {
5602 this.ruler.push(_rules$1[i][0], _rules$1[i][1], {
5603 alt: (_rules$1[i][2] || []).slice()
5604 });
5605 }
5606 }
5607 // Generate tokens for input range
5608
5609 ParserBlock.prototype.tokenize = function(state, startLine, endLine) {
5610 var ok, i, rules = this.ruler.getRules(""), len = rules.length, line = startLine, hasEmptyLines = false, maxNesting = state.md.options.maxNesting;
5611 while (line < endLine) {
5612 state.line = line = state.skipEmptyLines(line);
5613 if (line >= endLine) {
5614 break;
5615 }
5616 // Termination condition for nested calls.
5617 // Nested calls currently used for blockquotes & lists
5618 if (state.sCount[line] < state.blkIndent) {
5619 break;
5620 }
5621 // If nesting level exceeded - skip tail to the end. That's not ordinary
5622 // situation and we should not care about content.
5623 if (state.level >= maxNesting) {
5624 state.line = endLine;
5625 break;
5626 }
5627 // Try all possible rules.
5628 // On success, rule should:
5629
5630 // - update `state.line`
5631 // - update `state.tokens`
5632 // - return true
5633 for (i = 0; i < len; i++) {
5634 ok = rules[i](state, line, endLine, false);
5635 if (ok) {
5636 break;
5637 }
5638 }
5639 // set state.tight if we had an empty line before current tag
5640 // i.e. latest empty line should not count
5641 state.tight = !hasEmptyLines;
5642 // paragraph might "eat" one newline after it in nested lists
5643 if (state.isEmpty(state.line - 1)) {
5644 hasEmptyLines = true;
5645 }
5646 line = state.line;
5647 if (line < endLine && state.isEmpty(line)) {
5648 hasEmptyLines = true;
5649 line++;
5650 state.line = line;
5651 }
5652 }
5653 };
5654 /**
5655 * ParserBlock.parse(str, md, env, outTokens)
5656 *
5657 * Process input string and push block tokens into `outTokens`
5658 **/ ParserBlock.prototype.parse = function(src, md, env, outTokens) {
5659 var state;
5660 if (!src) {
5661 return;
5662 }
5663 state = new this.State(src, md, env, outTokens);
5664 this.tokenize(state, state.line, state.lineMax);
5665 };
5666 ParserBlock.prototype.State = state_block;
5667 var parser_block = ParserBlock;
5668 // Skip text characters for text token, place those to pending buffer
5669 // Rule to skip pure text
5670 // '{}$%@~+=:' reserved for extentions
5671 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
5672 // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
5673 // http://spec.commonmark.org/0.15/#ascii-punctuation-character
5674 function isTerminatorChar(ch) {
5675 switch (ch) {
5676 case 10 /* \n */ :
5677 case 33 /* ! */ :
5678 case 35 /* # */ :
5679 case 36 /* $ */ :
5680 case 37 /* % */ :
5681 case 38 /* & */ :
5682 case 42 /* * */ :
5683 case 43 /* + */ :
5684 case 45 /* - */ :
5685 case 58 /* : */ :
5686 case 60 /* < */ :
5687 case 61 /* = */ :
5688 case 62 /* > */ :
5689 case 64 /* @ */ :
5690 case 91 /* [ */ :
5691 case 92 /* \ */ :
5692 case 93 /* ] */ :
5693 case 94 /* ^ */ :
5694 case 95 /* _ */ :
5695 case 96 /* ` */ :
5696 case 123 /* { */ :
5697 case 125 /* } */ :
5698 case 126 /* ~ */ :
5699 return true;
5700
5701 default:
5702 return false;
5703 }
5704 }
5705 var text = function text(state, silent) {
5706 var pos = state.pos;
5707 while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
5708 pos++;
5709 }
5710 if (pos === state.pos) {
5711 return false;
5712 }
5713 if (!silent) {
5714 state.pending += state.src.slice(state.pos, pos);
5715 }
5716 state.pos = pos;
5717 return true;
5718 };
5719 var isSpace$7 = utils.isSpace;
5720 var newline = function newline(state, silent) {
5721 var pmax, max, pos = state.pos;
5722 if (state.src.charCodeAt(pos) !== 10 /* \n */) {
5723 return false;
5724 }
5725 pmax = state.pending.length - 1;
5726 max = state.posMax;
5727 // ' \n' -> hardbreak
5728 // Lookup in pending chars is bad practice! Don't copy to other rules!
5729 // Pending string is stored in concat mode, indexed lookups will cause
5730 // convertion to flat mode.
5731 if (!silent) {
5732 if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) {
5733 if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) {
5734 state.pending = state.pending.replace(/ +$/, "");
5735 state.push("hardbreak", "br", 0);
5736 } else {
5737 state.pending = state.pending.slice(0, -1);
5738 state.push("softbreak", "br", 0);
5739 }
5740 } else {
5741 state.push("softbreak", "br", 0);
5742 }
5743 }
5744 pos++;
5745 // skip heading spaces for next line
5746 while (pos < max && isSpace$7(state.src.charCodeAt(pos))) {
5747 pos++;
5748 }
5749 state.pos = pos;
5750 return true;
5751 };
5752 var isSpace$8 = utils.isSpace;
5753 var ESCAPED = [];
5754 for (var i = 0; i < 256; i++) {
5755 ESCAPED.push(0);
5756 }
5757 "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(ch) {
5758 ESCAPED[ch.charCodeAt(0)] = 1;
5759 }));
5760 var _escape = function escape(state, silent) {
5761 var ch, pos = state.pos, max = state.posMax;
5762 if (state.src.charCodeAt(pos) !== 92 /* \ */) {
5763 return false;
5764 }
5765 pos++;
5766 if (pos < max) {
5767 ch = state.src.charCodeAt(pos);
5768 if (ch < 256 && ESCAPED[ch] !== 0) {
5769 if (!silent) {
5770 state.pending += state.src[pos];
5771 }
5772 state.pos += 2;
5773 return true;
5774 }
5775 if (ch === 10) {
5776 if (!silent) {
5777 state.push("hardbreak", "br", 0);
5778 }
5779 pos++;
5780 // skip leading whitespaces from next line
5781 while (pos < max) {
5782 ch = state.src.charCodeAt(pos);
5783 if (!isSpace$8(ch)) {
5784 break;
5785 }
5786 pos++;
5787 }
5788 state.pos = pos;
5789 return true;
5790 }
5791 }
5792 if (!silent) {
5793 state.pending += "\\";
5794 }
5795 state.pos++;
5796 return true;
5797 };
5798 // Parse backticks
5799 var backticks = function backtick(state, silent) {
5800 var start, max, marker, matchStart, matchEnd, token, pos = state.pos, ch = state.src.charCodeAt(pos);
5801 if (ch !== 96 /* ` */) {
5802 return false;
5803 }
5804 start = pos;
5805 pos++;
5806 max = state.posMax;
5807 while (pos < max && state.src.charCodeAt(pos) === 96 /* ` */) {
5808 pos++;
5809 }
5810 marker = state.src.slice(start, pos);
5811 matchStart = matchEnd = pos;
5812 while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1) {
5813 matchEnd = matchStart + 1;
5814 while (matchEnd < max && state.src.charCodeAt(matchEnd) === 96 /* ` */) {
5815 matchEnd++;
5816 }
5817 if (matchEnd - matchStart === marker.length) {
5818 if (!silent) {
5819 token = state.push("code_inline", "code", 0);
5820 token.markup = marker;
5821 token.content = state.src.slice(pos, matchStart).replace(/\n/g, " ").replace(/^ (.+) $/, "$1");
5822 }
5823 state.pos = matchEnd;
5824 return true;
5825 }
5826 }
5827 if (!silent) {
5828 state.pending += marker;
5829 }
5830 state.pos += marker.length;
5831 return true;
5832 };
5833 // ~~strike through~~
5834 // Insert each marker as a separate text token, and add it to delimiter list
5835
5836 var tokenize = function strikethrough(state, silent) {
5837 var i, scanned, token, len, ch, start = state.pos, marker = state.src.charCodeAt(start);
5838 if (silent) {
5839 return false;
5840 }
5841 if (marker !== 126 /* ~ */) {
5842 return false;
5843 }
5844 scanned = state.scanDelims(state.pos, true);
5845 len = scanned.length;
5846 ch = String.fromCharCode(marker);
5847 if (len < 2) {
5848 return false;
5849 }
5850 if (len % 2) {
5851 token = state.push("text", "", 0);
5852 token.content = ch;
5853 len--;
5854 }
5855 for (i = 0; i < len; i += 2) {
5856 token = state.push("text", "", 0);
5857 token.content = ch + ch;
5858 state.delimiters.push({
5859 marker: marker,
5860 length: 0,
5861 // disable "rule of 3" length checks meant for emphasis
5862 jump: i,
5863 token: state.tokens.length - 1,
5864 end: -1,
5865 open: scanned.can_open,
5866 close: scanned.can_close
5867 });
5868 }
5869 state.pos += scanned.length;
5870 return true;
5871 };
5872 function postProcess(state, delimiters) {
5873 var i, j, startDelim, endDelim, token, loneMarkers = [], max = delimiters.length;
5874 for (i = 0; i < max; i++) {
5875 startDelim = delimiters[i];
5876 if (startDelim.marker !== 126 /* ~ */) {
5877 continue;
5878 }
5879 if (startDelim.end === -1) {
5880 continue;
5881 }
5882 endDelim = delimiters[startDelim.end];
5883 token = state.tokens[startDelim.token];
5884 token.type = "s_open";
5885 token.tag = "s";
5886 token.nesting = 1;
5887 token.markup = "~~";
5888 token.content = "";
5889 token = state.tokens[endDelim.token];
5890 token.type = "s_close";
5891 token.tag = "s";
5892 token.nesting = -1;
5893 token.markup = "~~";
5894 token.content = "";
5895 if (state.tokens[endDelim.token - 1].type === "text" && state.tokens[endDelim.token - 1].content === "~") {
5896 loneMarkers.push(endDelim.token - 1);
5897 }
5898 }
5899 // If a marker sequence has an odd number of characters, it's splitted
5900 // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
5901 // start of the sequence.
5902
5903 // So, we have to move all those markers after subsequent s_close tags.
5904
5905 while (loneMarkers.length) {
5906 i = loneMarkers.pop();
5907 j = i + 1;
5908 while (j < state.tokens.length && state.tokens[j].type === "s_close") {
5909 j++;
5910 }
5911 j--;
5912 if (i !== j) {
5913 token = state.tokens[j];
5914 state.tokens[j] = state.tokens[i];
5915 state.tokens[i] = token;
5916 }
5917 }
5918 }
5919 // Walk through delimiter list and replace text tokens with tags
5920
5921 var postProcess_1 = function strikethrough(state) {
5922 var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
5923 postProcess(state, state.delimiters);
5924 for (curr = 0; curr < max; curr++) {
5925 if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
5926 postProcess(state, tokens_meta[curr].delimiters);
5927 }
5928 }
5929 };
5930 var strikethrough = {
5931 tokenize: tokenize,
5932 postProcess: postProcess_1
5933 };
5934 // Process *this* and _that_
5935 // Insert each marker as a separate text token, and add it to delimiter list
5936
5937 var tokenize$1 = function emphasis(state, silent) {
5938 var i, scanned, token, start = state.pos, marker = state.src.charCodeAt(start);
5939 if (silent) {
5940 return false;
5941 }
5942 if (marker !== 95 /* _ */ && marker !== 42 /* * */) {
5943 return false;
5944 }
5945 scanned = state.scanDelims(state.pos, marker === 42);
5946 for (i = 0; i < scanned.length; i++) {
5947 token = state.push("text", "", 0);
5948 token.content = String.fromCharCode(marker);
5949 state.delimiters.push({
5950 // Char code of the starting marker (number).
5951 marker: marker,
5952 // Total length of these series of delimiters.
5953 length: scanned.length,
5954 // An amount of characters before this one that's equivalent to
5955 // current one. In plain English: if this delimiter does not open
5956 // an emphasis, neither do previous `jump` characters.
5957 // Used to skip sequences like "*****" in one step, for 1st asterisk
5958 // value will be 0, for 2nd it's 1 and so on.
5959 jump: i,
5960 // A position of the token this delimiter corresponds to.
5961 token: state.tokens.length - 1,
5962 // If this delimiter is matched as a valid opener, `end` will be
5963 // equal to its position, otherwise it's `-1`.
5964 end: -1,
5965 // Boolean flags that determine if this delimiter could open or close
5966 // an emphasis.
5967 open: scanned.can_open,
5968 close: scanned.can_close
5969 });
5970 }
5971 state.pos += scanned.length;
5972 return true;
5973 };
5974 function postProcess$1(state, delimiters) {
5975 var i, startDelim, endDelim, token, ch, isStrong, max = delimiters.length;
5976 for (i = max - 1; i >= 0; i--) {
5977 startDelim = delimiters[i];
5978 if (startDelim.marker !== 95 /* _ */ && startDelim.marker !== 42 /* * */) {
5979 continue;
5980 }
5981 // Process only opening markers
5982 if (startDelim.end === -1) {
5983 continue;
5984 }
5985 endDelim = delimiters[startDelim.end];
5986 // If the previous delimiter has the same marker and is adjacent to this one,
5987 // merge those into one strong delimiter.
5988
5989 // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
5990
5991 isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 && delimiters[i - 1].token === startDelim.token - 1 && delimiters[startDelim.end + 1].token === endDelim.token + 1 && delimiters[i - 1].marker === startDelim.marker;
5992 ch = String.fromCharCode(startDelim.marker);
5993 token = state.tokens[startDelim.token];
5994 token.type = isStrong ? "strong_open" : "em_open";
5995 token.tag = isStrong ? "strong" : "em";
5996 token.nesting = 1;
5997 token.markup = isStrong ? ch + ch : ch;
5998 token.content = "";
5999 token = state.tokens[endDelim.token];
6000 token.type = isStrong ? "strong_close" : "em_close";
6001 token.tag = isStrong ? "strong" : "em";
6002 token.nesting = -1;
6003 token.markup = isStrong ? ch + ch : ch;
6004 token.content = "";
6005 if (isStrong) {
6006 state.tokens[delimiters[i - 1].token].content = "";
6007 state.tokens[delimiters[startDelim.end + 1].token].content = "";
6008 i--;
6009 }
6010 }
6011 }
6012 // Walk through delimiter list and replace text tokens with tags
6013
6014 var postProcess_1$1 = function emphasis(state) {
6015 var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
6016 postProcess$1(state, state.delimiters);
6017 for (curr = 0; curr < max; curr++) {
6018 if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
6019 postProcess$1(state, tokens_meta[curr].delimiters);
6020 }
6021 }
6022 };
6023 var emphasis = {
6024 tokenize: tokenize$1,
6025 postProcess: postProcess_1$1
6026 };
6027 var normalizeReference$1 = utils.normalizeReference;
6028 var isSpace$9 = utils.isSpace;
6029 var link = function link(state, silent) {
6030 var attrs, code, label, labelEnd, labelStart, pos, res, ref, title, token, href = "", oldPos = state.pos, max = state.posMax, start = state.pos, parseReference = true;
6031 if (state.src.charCodeAt(state.pos) !== 91 /* [ */) {
6032 return false;
6033 }
6034 labelStart = state.pos + 1;
6035 labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
6036 // parser failed to find ']', so it's not a valid link
6037 if (labelEnd < 0) {
6038 return false;
6039 }
6040 pos = labelEnd + 1;
6041 if (pos < max && state.src.charCodeAt(pos) === 40 /* ( */) {
6042 // Inline link
6043 // might have found a valid shortcut link, disable reference parsing
6044 parseReference = false;
6045 // [link]( <href> "title" )
6046 // ^^ skipping these spaces
6047 pos++;
6048 for (;pos < max; pos++) {
6049 code = state.src.charCodeAt(pos);
6050 if (!isSpace$9(code) && code !== 10) {
6051 break;
6052 }
6053 }
6054 if (pos >= max) {
6055 return false;
6056 }
6057 // [link]( <href> "title" )
6058 // ^^^^^^ parsing link destination
6059 start = pos;
6060 res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
6061 if (res.ok) {
6062 href = state.md.normalizeLink(res.str);
6063 if (state.md.validateLink(href)) {
6064 pos = res.pos;
6065 } else {
6066 href = "";
6067 }
6068 }
6069 // [link]( <href> "title" )
6070 // ^^ skipping these spaces
6071 start = pos;
6072 for (;pos < max; pos++) {
6073 code = state.src.charCodeAt(pos);
6074 if (!isSpace$9(code) && code !== 10) {
6075 break;
6076 }
6077 }
6078 // [link]( <href> "title" )
6079 // ^^^^^^^ parsing link title
6080 res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
6081 if (pos < max && start !== pos && res.ok) {
6082 title = res.str;
6083 pos = res.pos;
6084 // [link]( <href> "title" )
6085 // ^^ skipping these spaces
6086 for (;pos < max; pos++) {
6087 code = state.src.charCodeAt(pos);
6088 if (!isSpace$9(code) && code !== 10) {
6089 break;
6090 }
6091 }
6092 } else {
6093 title = "";
6094 }
6095 if (pos >= max || state.src.charCodeAt(pos) !== 41 /* ) */) {
6096 // parsing a valid shortcut link failed, fallback to reference
6097 parseReference = true;
6098 }
6099 pos++;
6100 }
6101 if (parseReference) {
6102 // Link reference
6103 if (typeof state.env.references === "undefined") {
6104 return false;
6105 }
6106 if (pos < max && state.src.charCodeAt(pos) === 91 /* [ */) {
6107 start = pos + 1;
6108 pos = state.md.helpers.parseLinkLabel(state, pos);
6109 if (pos >= 0) {
6110 label = state.src.slice(start, pos++);
6111 } else {
6112 pos = labelEnd + 1;
6113 }
6114 } else {
6115 pos = labelEnd + 1;
6116 }
6117 // covers label === '' and label === undefined
6118 // (collapsed reference link and shortcut reference link respectively)
6119 if (!label) {
6120 label = state.src.slice(labelStart, labelEnd);
6121 }
6122 ref = state.env.references[normalizeReference$1(label)];
6123 if (!ref) {
6124 state.pos = oldPos;
6125 return false;
6126 }
6127 href = ref.href;
6128 title = ref.title;
6129 }
6130
6131 // We found the end of the link, and know for a fact it's a valid link;
6132 // so all that's left to do is to call tokenizer.
6133
6134 if (!silent) {
6135 state.pos = labelStart;
6136 state.posMax = labelEnd;
6137 token = state.push("link_open", "a", 1);
6138 token.attrs = attrs = [ [ "href", href ] ];
6139 if (title) {
6140 attrs.push([ "title", title ]);
6141 }
6142 state.md.inline.tokenize(state);
6143 token = state.push("link_close", "a", -1);
6144 }
6145 state.pos = pos;
6146 state.posMax = max;
6147 return true;
6148 };
6149 var normalizeReference$2 = utils.normalizeReference;
6150 var isSpace$a = utils.isSpace;
6151 var image = function image(state, silent) {
6152 var attrs, code, content, label, labelEnd, labelStart, pos, ref, res, title, token, tokens, start, href = "", oldPos = state.pos, max = state.posMax;
6153 if (state.src.charCodeAt(state.pos) !== 33 /* ! */) {
6154 return false;
6155 }
6156 if (state.src.charCodeAt(state.pos + 1) !== 91 /* [ */) {
6157 return false;
6158 }
6159 labelStart = state.pos + 2;
6160 labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
6161 // parser failed to find ']', so it's not a valid link
6162 if (labelEnd < 0) {
6163 return false;
6164 }
6165 pos = labelEnd + 1;
6166 if (pos < max && state.src.charCodeAt(pos) === 40 /* ( */) {
6167 // Inline link
6168 // [link]( <href> "title" )
6169 // ^^ skipping these spaces
6170 pos++;
6171 for (;pos < max; pos++) {
6172 code = state.src.charCodeAt(pos);
6173 if (!isSpace$a(code) && code !== 10) {
6174 break;
6175 }
6176 }
6177 if (pos >= max) {
6178 return false;
6179 }
6180 // [link]( <href> "title" )
6181 // ^^^^^^ parsing link destination
6182 start = pos;
6183 res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
6184 if (res.ok) {
6185 href = state.md.normalizeLink(res.str);
6186 if (state.md.validateLink(href)) {
6187 pos = res.pos;
6188 } else {
6189 href = "";
6190 }
6191 }
6192 // [link]( <href> "title" )
6193 // ^^ skipping these spaces
6194 start = pos;
6195 for (;pos < max; pos++) {
6196 code = state.src.charCodeAt(pos);
6197 if (!isSpace$a(code) && code !== 10) {
6198 break;
6199 }
6200 }
6201 // [link]( <href> "title" )
6202 // ^^^^^^^ parsing link title
6203 res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
6204 if (pos < max && start !== pos && res.ok) {
6205 title = res.str;
6206 pos = res.pos;
6207 // [link]( <href> "title" )
6208 // ^^ skipping these spaces
6209 for (;pos < max; pos++) {
6210 code = state.src.charCodeAt(pos);
6211 if (!isSpace$a(code) && code !== 10) {
6212 break;
6213 }
6214 }
6215 } else {
6216 title = "";
6217 }
6218 if (pos >= max || state.src.charCodeAt(pos) !== 41 /* ) */) {
6219 state.pos = oldPos;
6220 return false;
6221 }
6222 pos++;
6223 } else {
6224 // Link reference
6225 if (typeof state.env.references === "undefined") {
6226 return false;
6227 }
6228 if (pos < max && state.src.charCodeAt(pos) === 91 /* [ */) {
6229 start = pos + 1;
6230 pos = state.md.helpers.parseLinkLabel(state, pos);
6231 if (pos >= 0) {
6232 label = state.src.slice(start, pos++);
6233 } else {
6234 pos = labelEnd + 1;
6235 }
6236 } else {
6237 pos = labelEnd + 1;
6238 }
6239 // covers label === '' and label === undefined
6240 // (collapsed reference link and shortcut reference link respectively)
6241 if (!label) {
6242 label = state.src.slice(labelStart, labelEnd);
6243 }
6244 ref = state.env.references[normalizeReference$2(label)];
6245 if (!ref) {
6246 state.pos = oldPos;
6247 return false;
6248 }
6249 href = ref.href;
6250 title = ref.title;
6251 }
6252
6253 // We found the end of the link, and know for a fact it's a valid link;
6254 // so all that's left to do is to call tokenizer.
6255
6256 if (!silent) {
6257 content = state.src.slice(labelStart, labelEnd);
6258 state.md.inline.parse(content, state.md, state.env, tokens = []);
6259 token = state.push("image", "img", 0);
6260 token.attrs = attrs = [ [ "src", href ], [ "alt", "" ] ];
6261 token.children = tokens;
6262 token.content = content;
6263 if (title) {
6264 attrs.push([ "title", title ]);
6265 }
6266 }
6267 state.pos = pos;
6268 state.posMax = max;
6269 return true;
6270 };
6271 // Process autolinks '<protocol:...>'
6272 /*eslint max-len:0*/ var EMAIL_RE = /^<([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])?)*)>/;
6273 var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;
6274 var autolink = function autolink(state, silent) {
6275 var tail, linkMatch, emailMatch, url, fullUrl, token, pos = state.pos;
6276 if (state.src.charCodeAt(pos) !== 60 /* < */) {
6277 return false;
6278 }
6279 tail = state.src.slice(pos);
6280 if (tail.indexOf(">") < 0) {
6281 return false;
6282 }
6283 if (AUTOLINK_RE.test(tail)) {
6284 linkMatch = tail.match(AUTOLINK_RE);
6285 url = linkMatch[0].slice(1, -1);
6286 fullUrl = state.md.normalizeLink(url);
6287 if (!state.md.validateLink(fullUrl)) {
6288 return false;
6289 }
6290 if (!silent) {
6291 token = state.push("link_open", "a", 1);
6292 token.attrs = [ [ "href", fullUrl ] ];
6293 token.markup = "autolink";
6294 token.info = "auto";
6295 token = state.push("text", "", 0);
6296 token.content = state.md.normalizeLinkText(url);
6297 token = state.push("link_close", "a", -1);
6298 token.markup = "autolink";
6299 token.info = "auto";
6300 }
6301 state.pos += linkMatch[0].length;
6302 return true;
6303 }
6304 if (EMAIL_RE.test(tail)) {
6305 emailMatch = tail.match(EMAIL_RE);
6306 url = emailMatch[0].slice(1, -1);
6307 fullUrl = state.md.normalizeLink("mailto:" + url);
6308 if (!state.md.validateLink(fullUrl)) {
6309 return false;
6310 }
6311 if (!silent) {
6312 token = state.push("link_open", "a", 1);
6313 token.attrs = [ [ "href", fullUrl ] ];
6314 token.markup = "autolink";
6315 token.info = "auto";
6316 token = state.push("text", "", 0);
6317 token.content = state.md.normalizeLinkText(url);
6318 token = state.push("link_close", "a", -1);
6319 token.markup = "autolink";
6320 token.info = "auto";
6321 }
6322 state.pos += emailMatch[0].length;
6323 return true;
6324 }
6325 return false;
6326 };
6327 var HTML_TAG_RE$1 = html_re.HTML_TAG_RE;
6328 function isLetter(ch) {
6329 /*eslint no-bitwise:0*/
6330 var lc = ch | 32;
6331 // to lower case
6332 return lc >= 97 /* a */ && lc <= 122 /* z */;
6333 }
6334 var html_inline = function html_inline(state, silent) {
6335 var ch, match, max, token, pos = state.pos;
6336 if (!state.md.options.html) {
6337 return false;
6338 }
6339 // Check start
6340 max = state.posMax;
6341 if (state.src.charCodeAt(pos) !== 60 /* < */ || pos + 2 >= max) {
6342 return false;
6343 }
6344 // Quick fail on second char
6345 ch = state.src.charCodeAt(pos + 1);
6346 if (ch !== 33 /* ! */ && ch !== 63 /* ? */ && ch !== 47 /* / */ && !isLetter(ch)) {
6347 return false;
6348 }
6349 match = state.src.slice(pos).match(HTML_TAG_RE$1);
6350 if (!match) {
6351 return false;
6352 }
6353 if (!silent) {
6354 token = state.push("html_inline", "", 0);
6355 token.content = state.src.slice(pos, pos + match[0].length);
6356 }
6357 state.pos += match[0].length;
6358 return true;
6359 };
6360 var has = utils.has;
6361 var isValidEntityCode = utils.isValidEntityCode;
6362 var fromCodePoint = utils.fromCodePoint;
6363 var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
6364 var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
6365 var entity = function entity(state, silent) {
6366 var ch, code, match, pos = state.pos, max = state.posMax;
6367 if (state.src.charCodeAt(pos) !== 38 /* & */) {
6368 return false;
6369 }
6370 if (pos + 1 < max) {
6371 ch = state.src.charCodeAt(pos + 1);
6372 if (ch === 35 /* # */) {
6373 match = state.src.slice(pos).match(DIGITAL_RE);
6374 if (match) {
6375 if (!silent) {
6376 code = match[1][0].toLowerCase() === "x" ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
6377 state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(65533);
6378 }
6379 state.pos += match[0].length;
6380 return true;
6381 }
6382 } else {
6383 match = state.src.slice(pos).match(NAMED_RE);
6384 if (match) {
6385 if (has(entities, match[1])) {
6386 if (!silent) {
6387 state.pending += entities[match[1]];
6388 }
6389 state.pos += match[0].length;
6390 return true;
6391 }
6392 }
6393 }
6394 }
6395 if (!silent) {
6396 state.pending += "&";
6397 }
6398 state.pos++;
6399 return true;
6400 };
6401 // For each opening emphasis-like marker find a matching closing one
6402 function processDelimiters(state, delimiters) {
6403 var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx, isOddMatch, lastJump, openersBottom = {}, max = delimiters.length;
6404 for (closerIdx = 0; closerIdx < max; closerIdx++) {
6405 closer = delimiters[closerIdx];
6406 // Length is only used for emphasis-specific "rule of 3",
6407 // if it's not defined (in strikethrough or 3rd party plugins),
6408 // we can default it to 0 to disable those checks.
6409
6410 closer.length = closer.length || 0;
6411 if (!closer.close) continue;
6412 // Previously calculated lower bounds (previous fails)
6413 // for each marker and each delimiter length modulo 3.
6414 if (!openersBottom.hasOwnProperty(closer.marker)) {
6415 openersBottom[closer.marker] = [ -1, -1, -1 ];
6416 }
6417 minOpenerIdx = openersBottom[closer.marker][closer.length % 3];
6418 newMinOpenerIdx = -1;
6419 openerIdx = closerIdx - closer.jump - 1;
6420 for (;openerIdx > minOpenerIdx; openerIdx -= opener.jump + 1) {
6421 opener = delimiters[openerIdx];
6422 if (opener.marker !== closer.marker) continue;
6423 if (newMinOpenerIdx === -1) newMinOpenerIdx = openerIdx;
6424 if (opener.open && opener.end < 0) {
6425 isOddMatch = false;
6426 // from spec:
6427
6428 // If one of the delimiters can both open and close emphasis, then the
6429 // sum of the lengths of the delimiter runs containing the opening and
6430 // closing delimiters must not be a multiple of 3 unless both lengths
6431 // are multiples of 3.
6432
6433 if (opener.close || closer.open) {
6434 if ((opener.length + closer.length) % 3 === 0) {
6435 if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {
6436 isOddMatch = true;
6437 }
6438 }
6439 }
6440 if (!isOddMatch) {
6441 // If previous delimiter cannot be an opener, we can safely skip
6442 // the entire sequence in future checks. This is required to make
6443 // sure algorithm has linear complexity (see *_*_*_*_*_... case).
6444 lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ? delimiters[openerIdx - 1].jump + 1 : 0;
6445 closer.jump = closerIdx - openerIdx + lastJump;
6446 closer.open = false;
6447 opener.end = closerIdx;
6448 opener.jump = lastJump;
6449 opener.close = false;
6450 newMinOpenerIdx = -1;
6451 break;
6452 }
6453 }
6454 }
6455 if (newMinOpenerIdx !== -1) {
6456 // If match for this delimiter run failed, we want to set lower bound for
6457 // future lookups. This is required to make sure algorithm has linear
6458 // complexity.
6459 // See details here:
6460 // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
6461 openersBottom[closer.marker][(closer.length || 0) % 3] = newMinOpenerIdx;
6462 }
6463 }
6464 }
6465 var balance_pairs = function link_pairs(state) {
6466 var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
6467 processDelimiters(state, state.delimiters);
6468 for (curr = 0; curr < max; curr++) {
6469 if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
6470 processDelimiters(state, tokens_meta[curr].delimiters);
6471 }
6472 }
6473 };
6474 // Clean up tokens after emphasis and strikethrough postprocessing:
6475 var text_collapse = function text_collapse(state) {
6476 var curr, last, level = 0, tokens = state.tokens, max = state.tokens.length;
6477 for (curr = last = 0; curr < max; curr++) {
6478 // re-calculate levels after emphasis/strikethrough turns some text nodes
6479 // into opening/closing tags
6480 if (tokens[curr].nesting < 0) level--;
6481 // closing tag
6482 tokens[curr].level = level;
6483 if (tokens[curr].nesting > 0) level++;
6484 // opening tag
6485 if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") {
6486 // collapse two adjacent text nodes
6487 tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
6488 } else {
6489 if (curr !== last) {
6490 tokens[last] = tokens[curr];
6491 }
6492 last++;
6493 }
6494 }
6495 if (curr !== last) {
6496 tokens.length = last;
6497 }
6498 };
6499 var isWhiteSpace$1 = utils.isWhiteSpace;
6500 var isPunctChar$1 = utils.isPunctChar;
6501 var isMdAsciiPunct$1 = utils.isMdAsciiPunct;
6502 function StateInline(src, md, env, outTokens) {
6503 this.src = src;
6504 this.env = env;
6505 this.md = md;
6506 this.tokens = outTokens;
6507 this.tokens_meta = Array(outTokens.length);
6508 this.pos = 0;
6509 this.posMax = this.src.length;
6510 this.level = 0;
6511 this.pending = "";
6512 this.pendingLevel = 0;
6513 // Stores { start: end } pairs. Useful for backtrack
6514 // optimization of pairs parse (emphasis, strikes).
6515 this.cache = {};
6516 // List of emphasis-like delimiters for current tag
6517 this.delimiters = [];
6518 // Stack of delimiter lists for upper level tags
6519 this._prev_delimiters = [];
6520 }
6521 // Flush pending text
6522
6523 StateInline.prototype.pushPending = function() {
6524 var token$1 = new token("text", "", 0);
6525 token$1.content = this.pending;
6526 token$1.level = this.pendingLevel;
6527 this.tokens.push(token$1);
6528 this.pending = "";
6529 return token$1;
6530 };
6531 // Push new token to "stream".
6532 // If pending text exists - flush it as text token
6533
6534 StateInline.prototype.push = function(type, tag, nesting) {
6535 if (this.pending) {
6536 this.pushPending();
6537 }
6538 var token$1 = new token(type, tag, nesting);
6539 var token_meta = null;
6540 if (nesting < 0) {
6541 // closing tag
6542 this.level--;
6543 this.delimiters = this._prev_delimiters.pop();
6544 }
6545 token$1.level = this.level;
6546 if (nesting > 0) {
6547 // opening tag
6548 this.level++;
6549 this._prev_delimiters.push(this.delimiters);
6550 this.delimiters = [];
6551 token_meta = {
6552 delimiters: this.delimiters
6553 };
6554 }
6555 this.pendingLevel = this.level;
6556 this.tokens.push(token$1);
6557 this.tokens_meta.push(token_meta);
6558 return token$1;
6559 };
6560 // Scan a sequence of emphasis-like markers, and determine whether
6561 // it can start an emphasis sequence or end an emphasis sequence.
6562
6563 // - start - position to scan from (it should point at a valid marker);
6564 // - canSplitWord - determine if these markers can be found inside a word
6565
6566 StateInline.prototype.scanDelims = function(start, canSplitWord) {
6567 var pos = start, lastChar, nextChar, count, can_open, can_close, isLastWhiteSpace, isLastPunctChar, isNextWhiteSpace, isNextPunctChar, left_flanking = true, right_flanking = true, max = this.posMax, marker = this.src.charCodeAt(start);
6568 // treat beginning of the line as a whitespace
6569 lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 32;
6570 while (pos < max && this.src.charCodeAt(pos) === marker) {
6571 pos++;
6572 }
6573 count = pos - start;
6574 // treat end of the line as a whitespace
6575 nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
6576 isLastPunctChar = isMdAsciiPunct$1(lastChar) || isPunctChar$1(String.fromCharCode(lastChar));
6577 isNextPunctChar = isMdAsciiPunct$1(nextChar) || isPunctChar$1(String.fromCharCode(nextChar));
6578 isLastWhiteSpace = isWhiteSpace$1(lastChar);
6579 isNextWhiteSpace = isWhiteSpace$1(nextChar);
6580 if (isNextWhiteSpace) {
6581 left_flanking = false;
6582 } else if (isNextPunctChar) {
6583 if (!(isLastWhiteSpace || isLastPunctChar)) {
6584 left_flanking = false;
6585 }
6586 }
6587 if (isLastWhiteSpace) {
6588 right_flanking = false;
6589 } else if (isLastPunctChar) {
6590 if (!(isNextWhiteSpace || isNextPunctChar)) {
6591 right_flanking = false;
6592 }
6593 }
6594 if (!canSplitWord) {
6595 can_open = left_flanking && (!right_flanking || isLastPunctChar);
6596 can_close = right_flanking && (!left_flanking || isNextPunctChar);
6597 } else {
6598 can_open = left_flanking;
6599 can_close = right_flanking;
6600 }
6601 return {
6602 can_open: can_open,
6603 can_close: can_close,
6604 length: count
6605 };
6606 };
6607 // re-export Token class to use in block rules
6608 StateInline.prototype.Token = token;
6609 var state_inline = StateInline;
6610 ////////////////////////////////////////////////////////////////////////////////
6611 // Parser rules
6612 var _rules$2 = [ [ "text", text ], [ "newline", newline ], [ "escape", _escape ], [ "backticks", backticks ], [ "strikethrough", strikethrough.tokenize ], [ "emphasis", emphasis.tokenize ], [ "link", link ], [ "image", image ], [ "autolink", autolink ], [ "html_inline", html_inline ], [ "entity", entity ] ];
6613 var _rules2 = [ [ "balance_pairs", balance_pairs ], [ "strikethrough", strikethrough.postProcess ], [ "emphasis", emphasis.postProcess ], [ "text_collapse", text_collapse ] ];
6614 /**
6615 * new ParserInline()
6616 **/ function ParserInline() {
6617 var i;
6618 /**
6619 * ParserInline#ruler -> Ruler
6620 *
6621 * [[Ruler]] instance. Keep configuration of inline rules.
6622 **/ this.ruler = new ruler;
6623 for (i = 0; i < _rules$2.length; i++) {
6624 this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
6625 }
6626 /**
6627 * ParserInline#ruler2 -> Ruler
6628 *
6629 * [[Ruler]] instance. Second ruler used for post-processing
6630 * (e.g. in emphasis-like rules).
6631 **/ this.ruler2 = new ruler;
6632 for (i = 0; i < _rules2.length; i++) {
6633 this.ruler2.push(_rules2[i][0], _rules2[i][1]);
6634 }
6635 }
6636 // Skip single token by running all rules in validation mode;
6637 // returns `true` if any rule reported success
6638
6639 ParserInline.prototype.skipToken = function(state) {
6640 var ok, i, pos = state.pos, rules = this.ruler.getRules(""), len = rules.length, maxNesting = state.md.options.maxNesting, cache = state.cache;
6641 if (typeof cache[pos] !== "undefined") {
6642 state.pos = cache[pos];
6643 return;
6644 }
6645 if (state.level < maxNesting) {
6646 for (i = 0; i < len; i++) {
6647 // Increment state.level and decrement it later to limit recursion.
6648 // It's harmless to do here, because no tokens are created. But ideally,
6649 // we'd need a separate private state variable for this purpose.
6650 state.level++;
6651 ok = rules[i](state, true);
6652 state.level--;
6653 if (ok) {
6654 break;
6655 }
6656 }
6657 } else {
6658 // Too much nesting, just skip until the end of the paragraph.
6659 // NOTE: this will cause links to behave incorrectly in the following case,
6660 // when an amount of `[` is exactly equal to `maxNesting + 1`:
6661 // [[[[[[[[[[[[[[[[[[[[[foo]()
6662 // TODO: remove this workaround when CM standard will allow nested links
6663 // (we can replace it by preventing links from being parsed in
6664 // validation mode)
6665 state.pos = state.posMax;
6666 }
6667 if (!ok) {
6668 state.pos++;
6669 }
6670 cache[pos] = state.pos;
6671 };
6672 // Generate tokens for input range
6673
6674 ParserInline.prototype.tokenize = function(state) {
6675 var ok, i, rules = this.ruler.getRules(""), len = rules.length, end = state.posMax, maxNesting = state.md.options.maxNesting;
6676 while (state.pos < end) {
6677 // Try all possible rules.
6678 // On success, rule should:
6679 // - update `state.pos`
6680 // - update `state.tokens`
6681 // - return true
6682 if (state.level < maxNesting) {
6683 for (i = 0; i < len; i++) {
6684 ok = rules[i](state, false);
6685 if (ok) {
6686 break;
6687 }
6688 }
6689 }
6690 if (ok) {
6691 if (state.pos >= end) {
6692 break;
6693 }
6694 continue;
6695 }
6696 state.pending += state.src[state.pos++];
6697 }
6698 if (state.pending) {
6699 state.pushPending();
6700 }
6701 };
6702 /**
6703 * ParserInline.parse(str, md, env, outTokens)
6704 *
6705 * Process input string and push inline tokens into `outTokens`
6706 **/ ParserInline.prototype.parse = function(str, md, env, outTokens) {
6707 var i, rules, len;
6708 var state = new this.State(str, md, env, outTokens);
6709 this.tokenize(state);
6710 rules = this.ruler2.getRules("");
6711 len = rules.length;
6712 for (i = 0; i < len; i++) {
6713 rules[i](state);
6714 }
6715 };
6716 ParserInline.prototype.State = state_inline;
6717 var parser_inline = ParserInline;
6718 var re = function(opts) {
6719 var re = {};
6720 // Use direct extract instead of `regenerate` to reduse browserified size
6721 re.src_Any = regex$1.source;
6722 re.src_Cc = regex$2.source;
6723 re.src_Z = regex$4.source;
6724 re.src_P = regex.source;
6725 // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
6726 re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join("|");
6727 // \p{\Z\Cc} (white spaces + control)
6728 re.src_ZCc = [ re.src_Z, re.src_Cc ].join("|");
6729 // Experimental. List of chars, completely prohibited in links
6730 // because can separate it from other part of text
6731 var text_separators = "[><\uff5c]";
6732 // All possible word characters (everything without punctuation, spaces & controls)
6733 // Defined via punctuation & spaces to save space
6734 // Should be something like \p{\L\N\S\M} (\w but without `_`)
6735 re.src_pseudo_letter = "(?:(?!" + text_separators + "|" + re.src_ZPCc + ")" + re.src_Any + ")";
6736 // The same as abothe but without [0-9]
6737 // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
6738 ////////////////////////////////////////////////////////////////////////////////
6739 re.src_ip4 = "(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
6740 // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
6741 re.src_auth = "(?:(?:(?!" + re.src_ZCc + "|[@/\\[\\]()]).)+@)?";
6742 re.src_port = "(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";
6743 re.src_host_terminator = "(?=$|" + text_separators + "|" + re.src_ZPCc + ")(?!-|_|:\\d|\\.-|\\.(?!$|" + re.src_ZPCc + "))";
6744 re.src_path = "(?:" + "[/?#]" + "(?:" + "(?!" + re.src_ZCc + "|" + text_separators + "|[()[\\]{}.,\"'?!\\-]).|" + "\\[(?:(?!" + re.src_ZCc + "|\\]).)*\\]|" + "\\((?:(?!" + re.src_ZCc + "|[)]).)*\\)|" + "\\{(?:(?!" + re.src_ZCc + "|[}]).)*\\}|" + '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' + "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" + "\\'(?=" + re.src_pseudo_letter + "|[-]).|" + // allow `I'm_king` if no pair found
6745 "\\.{2,}[a-zA-Z0-9%/&]|" + // google has many dots in "google search" links (#66, #81).
6746 // github has ... in commit range links,
6747 // Restrict to
6748 // - english
6749 // - percent-encoded
6750 // - parts of file path
6751 // - params separator
6752 // until more examples found.
6753 "\\.(?!" + re.src_ZCc + "|[.]).|" + (opts && opts["---"] ? "\\-(?!--(?:[^-]|$))(?:-*)|" : "\\-+|") + "\\,(?!" + re.src_ZCc + ").|" + // allow `,,,` in paths
6754 "\\!+(?!" + re.src_ZCc + "|[!]).|" + // allow `!!!` in paths, but not at the end
6755 "\\?(?!" + re.src_ZCc + "|[?])." + ")+" + "|\\/" + ")?";
6756 // Allow anything in markdown spec, forbid quote (") at the first position
6757 // because emails enclosed in quotes are far more common
6758 re.src_email_name = '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
6759 re.src_xn = "xn--[a-z0-9\\-]{1,59}";
6760 // More to read about domain names
6761 // http://serverfault.com/questions/638260/
6762 re.src_domain_root =
6763 // Allow letters & digits (http://test1)
6764 "(?:" + re.src_xn + "|" + re.src_pseudo_letter + "{1,63}" + ")";
6765 re.src_domain = "(?:" + re.src_xn + "|" + "(?:" + re.src_pseudo_letter + ")" + "|" + "(?:" + re.src_pseudo_letter + "(?:-|" + re.src_pseudo_letter + "){0,61}" + re.src_pseudo_letter + ")" + ")";
6766 re.src_host = "(?:" +
6767 // Don't need IP check, because digits are already allowed in normal domain names
6768 // src_ip4 +
6769 // '|' +
6770 "(?:(?:(?:" + re.src_domain + ")\\.)*" + re.src_domain /*_root*/ + ")" + ")";
6771 re.tpl_host_fuzzy = "(?:" + re.src_ip4 + "|" + "(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%))" + ")";
6772 re.tpl_host_no_ip_fuzzy = "(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%))";
6773 re.src_host_strict = re.src_host + re.src_host_terminator;
6774 re.tpl_host_fuzzy_strict = re.tpl_host_fuzzy + re.src_host_terminator;
6775 re.src_host_port_strict = re.src_host + re.src_port + re.src_host_terminator;
6776 re.tpl_host_port_fuzzy_strict = re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
6777 re.tpl_host_port_no_ip_fuzzy_strict = re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
6778 ////////////////////////////////////////////////////////////////////////////////
6779 // Main rules
6780 // Rude test fuzzy links by host, for quick deny
6781 re.tpl_host_fuzzy_test = "localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:" + re.src_ZPCc + "|>|$))";
6782 re.tpl_email_fuzzy = "(^|" + text_separators + '|"|\\(|' + re.src_ZCc + ")" + "(" + re.src_email_name + "@" + re.tpl_host_fuzzy_strict + ")";
6783 re.tpl_link_fuzzy =
6784 // Fuzzy link can't be prepended with .:/\- and non punctuation.
6785 // but can start with > (markdown blockquote)
6786 "(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|" + re.src_ZPCc + "))" + "((?![$+<=>^`|\uff5c])" + re.tpl_host_port_fuzzy_strict + re.src_path + ")";
6787 re.tpl_link_no_ip_fuzzy =
6788 // Fuzzy link can't be prepended with .:/\- and non punctuation.
6789 // but can start with > (markdown blockquote)
6790 "(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|" + re.src_ZPCc + "))" + "((?![$+<=>^`|\uff5c])" + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ")";
6791 return re;
6792 };
6793 ////////////////////////////////////////////////////////////////////////////////
6794 // Helpers
6795 // Merge objects
6796
6797 function assign$1(obj /*from1, from2, from3, ...*/) {
6798 var sources = Array.prototype.slice.call(arguments, 1);
6799 sources.forEach((function(source) {
6800 if (!source) {
6801 return;
6802 }
6803 Object.keys(source).forEach((function(key) {
6804 obj[key] = source[key];
6805 }));
6806 }));
6807 return obj;
6808 }
6809 function _class(obj) {
6810 return Object.prototype.toString.call(obj);
6811 }
6812 function isString(obj) {
6813 return _class(obj) === "[object String]";
6814 }
6815 function isObject(obj) {
6816 return _class(obj) === "[object Object]";
6817 }
6818 function isRegExp(obj) {
6819 return _class(obj) === "[object RegExp]";
6820 }
6821 function isFunction(obj) {
6822 return _class(obj) === "[object Function]";
6823 }
6824 function escapeRE(str) {
6825 return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
6826 }
6827 ////////////////////////////////////////////////////////////////////////////////
6828 var defaultOptions = {
6829 fuzzyLink: true,
6830 fuzzyEmail: true,
6831 fuzzyIP: false
6832 };
6833 function isOptionsObj(obj) {
6834 return Object.keys(obj || {}).reduce((function(acc, k) {
6835 return acc || defaultOptions.hasOwnProperty(k);
6836 }), false);
6837 }
6838 var defaultSchemas = {
6839 "http:": {
6840 validate: function(text, pos, self) {
6841 var tail = text.slice(pos);
6842 if (!self.re.http) {
6843 // compile lazily, because "host"-containing variables can change on tlds update.
6844 self.re.http = new RegExp("^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, "i");
6845 }
6846 if (self.re.http.test(tail)) {
6847 return tail.match(self.re.http)[0].length;
6848 }
6849 return 0;
6850 }
6851 },
6852 "https:": "http:",
6853 "ftp:": "http:",
6854 "//": {
6855 validate: function(text, pos, self) {
6856 var tail = text.slice(pos);
6857 if (!self.re.no_http) {
6858 // compile lazily, because "host"-containing variables can change on tlds update.
6859 self.re.no_http = new RegExp("^" + self.re.src_auth +
6860 // Don't allow single-level domains, because of false positives like '//test'
6861 // with code comments
6862 "(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path, "i");
6863 }
6864 if (self.re.no_http.test(tail)) {
6865 // should not be `://` & `///`, that protects from errors in protocol name
6866 if (pos >= 3 && text[pos - 3] === ":") {
6867 return 0;
6868 }
6869 if (pos >= 3 && text[pos - 3] === "/") {
6870 return 0;
6871 }
6872 return tail.match(self.re.no_http)[0].length;
6873 }
6874 return 0;
6875 }
6876 },
6877 "mailto:": {
6878 validate: function(text, pos, self) {
6879 var tail = text.slice(pos);
6880 if (!self.re.mailto) {
6881 self.re.mailto = new RegExp("^" + self.re.src_email_name + "@" + self.re.src_host_strict, "i");
6882 }
6883 if (self.re.mailto.test(tail)) {
6884 return tail.match(self.re.mailto)[0].length;
6885 }
6886 return 0;
6887 }
6888 }
6889 };
6890 /*eslint-disable max-len*/
6891 // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
6892 var tlds_2ch_src_re = "a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";
6893 // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
6894 var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");
6895 /*eslint-enable max-len*/
6896 ////////////////////////////////////////////////////////////////////////////////
6897 function resetScanCache(self) {
6898 self.__index__ = -1;
6899 self.__text_cache__ = "";
6900 }
6901 function createValidator(re) {
6902 return function(text, pos) {
6903 var tail = text.slice(pos);
6904 if (re.test(tail)) {
6905 return tail.match(re)[0].length;
6906 }
6907 return 0;
6908 };
6909 }
6910 function createNormalizer() {
6911 return function(match, self) {
6912 self.normalize(match);
6913 };
6914 }
6915 // Schemas compiler. Build regexps.
6916
6917 function compile(self) {
6918 // Load & clone RE patterns.
6919 var re$1 = self.re = re(self.__opts__);
6920 // Define dynamic patterns
6921 var tlds = self.__tlds__.slice();
6922 self.onCompile();
6923 if (!self.__tlds_replaced__) {
6924 tlds.push(tlds_2ch_src_re);
6925 }
6926 tlds.push(re$1.src_xn);
6927 re$1.src_tlds = tlds.join("|");
6928 function untpl(tpl) {
6929 return tpl.replace("%TLDS%", re$1.src_tlds);
6930 }
6931 re$1.email_fuzzy = RegExp(untpl(re$1.tpl_email_fuzzy), "i");
6932 re$1.link_fuzzy = RegExp(untpl(re$1.tpl_link_fuzzy), "i");
6933 re$1.link_no_ip_fuzzy = RegExp(untpl(re$1.tpl_link_no_ip_fuzzy), "i");
6934 re$1.host_fuzzy_test = RegExp(untpl(re$1.tpl_host_fuzzy_test), "i");
6935
6936 // Compile each schema
6937
6938 var aliases = [];
6939 self.__compiled__ = {};
6940 // Reset compiled data
6941 function schemaError(name, val) {
6942 throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
6943 }
6944 Object.keys(self.__schemas__).forEach((function(name) {
6945 var val = self.__schemas__[name];
6946 // skip disabled methods
6947 if (val === null) {
6948 return;
6949 }
6950 var compiled = {
6951 validate: null,
6952 link: null
6953 };
6954 self.__compiled__[name] = compiled;
6955 if (isObject(val)) {
6956 if (isRegExp(val.validate)) {
6957 compiled.validate = createValidator(val.validate);
6958 } else if (isFunction(val.validate)) {
6959 compiled.validate = val.validate;
6960 } else {
6961 schemaError(name, val);
6962 }
6963 if (isFunction(val.normalize)) {
6964 compiled.normalize = val.normalize;
6965 } else if (!val.normalize) {
6966 compiled.normalize = createNormalizer();
6967 } else {
6968 schemaError(name, val);
6969 }
6970 return;
6971 }
6972 if (isString(val)) {
6973 aliases.push(name);
6974 return;
6975 }
6976 schemaError(name, val);
6977 }));
6978
6979 // Compile postponed aliases
6980
6981 aliases.forEach((function(alias) {
6982 if (!self.__compiled__[self.__schemas__[alias]]) {
6983 // Silently fail on missed schemas to avoid errons on disable.
6984 // schemaError(alias, self.__schemas__[alias]);
6985 return;
6986 }
6987 self.__compiled__[alias].validate = self.__compiled__[self.__schemas__[alias]].validate;
6988 self.__compiled__[alias].normalize = self.__compiled__[self.__schemas__[alias]].normalize;
6989 }));
6990
6991 // Fake record for guessed links
6992
6993 self.__compiled__[""] = {
6994 validate: null,
6995 normalize: createNormalizer()
6996 };
6997
6998 // Build schema condition
6999
7000 var slist = Object.keys(self.__compiled__).filter((function(name) {
7001 // Filter disabled & fake schemas
7002 return name.length > 0 && self.__compiled__[name];
7003 })).map(escapeRE).join("|");
7004 // (?!_) cause 1.5x slowdown
7005 self.re.schema_test = RegExp("(^|(?!_)(?:[><\uff5c]|" + re$1.src_ZPCc + "))(" + slist + ")", "i");
7006 self.re.schema_search = RegExp("(^|(?!_)(?:[><\uff5c]|" + re$1.src_ZPCc + "))(" + slist + ")", "ig");
7007 self.re.pretest = RegExp("(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@", "i");
7008
7009 // Cleanup
7010
7011 resetScanCache(self);
7012 }
7013 /**
7014 * class Match
7015 *
7016 * Match result. Single element of array, returned by [[LinkifyIt#match]]
7017 **/ function Match(self, shift) {
7018 var start = self.__index__, end = self.__last_index__, text = self.__text_cache__.slice(start, end);
7019 /**
7020 * Match#schema -> String
7021 *
7022 * Prefix (protocol) for matched string.
7023 **/ this.schema = self.__schema__.toLowerCase();
7024 /**
7025 * Match#index -> Number
7026 *
7027 * First position of matched string.
7028 **/ this.index = start + shift;
7029 /**
7030 * Match#lastIndex -> Number
7031 *
7032 * Next position after matched string.
7033 **/ this.lastIndex = end + shift;
7034 /**
7035 * Match#raw -> String
7036 *
7037 * Matched string.
7038 **/ this.raw = text;
7039 /**
7040 * Match#text -> String
7041 *
7042 * Notmalized text of matched string.
7043 **/ this.text = text;
7044 /**
7045 * Match#url -> String
7046 *
7047 * Normalized url of matched string.
7048 **/ this.url = text;
7049 }
7050 function createMatch(self, shift) {
7051 var match = new Match(self, shift);
7052 self.__compiled__[match.schema].normalize(match, self);
7053 return match;
7054 }
7055 /**
7056 * class LinkifyIt
7057 **/
7058 /**
7059 * new LinkifyIt(schemas, options)
7060 * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
7061 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
7062 *
7063 * Creates new linkifier instance with optional additional schemas.
7064 * Can be called without `new` keyword for convenience.
7065 *
7066 * By default understands:
7067 *
7068 * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
7069 * - "fuzzy" links and emails (example.com, foo@bar.com).
7070 *
7071 * `schemas` is an object, where each key/value describes protocol/rule:
7072 *
7073 * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
7074 * for example). `linkify-it` makes shure that prefix is not preceeded with
7075 * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
7076 * - __value__ - rule to check tail after link prefix
7077 * - _String_ - just alias to existing rule
7078 * - _Object_
7079 * - _validate_ - validator function (should return matched length on success),
7080 * or `RegExp`.
7081 * - _normalize_ - optional function to normalize text & url of matched result
7082 * (for example, for @twitter mentions).
7083 *
7084 * `options`:
7085 *
7086 * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
7087 * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
7088 * like version numbers. Default `false`.
7089 * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
7090 *
7091 **/ function LinkifyIt(schemas, options) {
7092 if (!(this instanceof LinkifyIt)) {
7093 return new LinkifyIt(schemas, options);
7094 }
7095 if (!options) {
7096 if (isOptionsObj(schemas)) {
7097 options = schemas;
7098 schemas = {};
7099 }
7100 }
7101 this.__opts__ = assign$1({}, defaultOptions, options);
7102 // Cache last tested result. Used to skip repeating steps on next `match` call.
7103 this.__index__ = -1;
7104 this.__last_index__ = -1;
7105 // Next scan position
7106 this.__schema__ = "";
7107 this.__text_cache__ = "";
7108 this.__schemas__ = assign$1({}, defaultSchemas, schemas);
7109 this.__compiled__ = {};
7110 this.__tlds__ = tlds_default;
7111 this.__tlds_replaced__ = false;
7112 this.re = {};
7113 compile(this);
7114 }
7115 /** chainable
7116 * LinkifyIt#add(schema, definition)
7117 * - schema (String): rule name (fixed pattern prefix)
7118 * - definition (String|RegExp|Object): schema definition
7119 *
7120 * Add new rule definition. See constructor description for details.
7121 **/ LinkifyIt.prototype.add = function add(schema, definition) {
7122 this.__schemas__[schema] = definition;
7123 compile(this);
7124 return this;
7125 };
7126 /** chainable
7127 * LinkifyIt#set(options)
7128 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
7129 *
7130 * Set recognition options for links without schema.
7131 **/ LinkifyIt.prototype.set = function set(options) {
7132 this.__opts__ = assign$1(this.__opts__, options);
7133 return this;
7134 };
7135 /**
7136 * LinkifyIt#test(text) -> Boolean
7137 *
7138 * Searches linkifiable pattern and returns `true` on success or `false` on fail.
7139 **/ LinkifyIt.prototype.test = function test(text) {
7140 // Reset scan cache
7141 this.__text_cache__ = text;
7142 this.__index__ = -1;
7143 if (!text.length) {
7144 return false;
7145 }
7146 var m, ml, me, len, shift, next, re, tld_pos, at_pos;
7147 // try to scan for link with schema - that's the most simple rule
7148 if (this.re.schema_test.test(text)) {
7149 re = this.re.schema_search;
7150 re.lastIndex = 0;
7151 while ((m = re.exec(text)) !== null) {
7152 len = this.testSchemaAt(text, m[2], re.lastIndex);
7153 if (len) {
7154 this.__schema__ = m[2];
7155 this.__index__ = m.index + m[1].length;
7156 this.__last_index__ = m.index + m[0].length + len;
7157 break;
7158 }
7159 }
7160 }
7161 if (this.__opts__.fuzzyLink && this.__compiled__["http:"]) {
7162 // guess schemaless links
7163 tld_pos = text.search(this.re.host_fuzzy_test);
7164 if (tld_pos >= 0) {
7165 // if tld is located after found link - no need to check fuzzy pattern
7166 if (this.__index__ < 0 || tld_pos < this.__index__) {
7167 if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
7168 shift = ml.index + ml[1].length;
7169 if (this.__index__ < 0 || shift < this.__index__) {
7170 this.__schema__ = "";
7171 this.__index__ = shift;
7172 this.__last_index__ = ml.index + ml[0].length;
7173 }
7174 }
7175 }
7176 }
7177 }
7178 if (this.__opts__.fuzzyEmail && this.__compiled__["mailto:"]) {
7179 // guess schemaless emails
7180 at_pos = text.indexOf("@");
7181 if (at_pos >= 0) {
7182 // We can't skip this check, because this cases are possible:
7183 // 192.168.1.1@gmail.com, my.in@example.com
7184 if ((me = text.match(this.re.email_fuzzy)) !== null) {
7185 shift = me.index + me[1].length;
7186 next = me.index + me[0].length;
7187 if (this.__index__ < 0 || shift < this.__index__ || shift === this.__index__ && next > this.__last_index__) {
7188 this.__schema__ = "mailto:";
7189 this.__index__ = shift;
7190 this.__last_index__ = next;
7191 }
7192 }
7193 }
7194 }
7195 return this.__index__ >= 0;
7196 };
7197 /**
7198 * LinkifyIt#pretest(text) -> Boolean
7199 *
7200 * Very quick check, that can give false positives. Returns true if link MAY BE
7201 * can exists. Can be used for speed optimization, when you need to check that
7202 * link NOT exists.
7203 **/ LinkifyIt.prototype.pretest = function pretest(text) {
7204 return this.re.pretest.test(text);
7205 };
7206 /**
7207 * LinkifyIt#testSchemaAt(text, name, position) -> Number
7208 * - text (String): text to scan
7209 * - name (String): rule (schema) name
7210 * - position (Number): text offset to check from
7211 *
7212 * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
7213 * at given position. Returns length of found pattern (0 on fail).
7214 **/ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
7215 // If not supported schema check requested - terminate
7216 if (!this.__compiled__[schema.toLowerCase()]) {
7217 return 0;
7218 }
7219 return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
7220 };
7221 /**
7222 * LinkifyIt#match(text) -> Array|null
7223 *
7224 * Returns array of found link descriptions or `null` on fail. We strongly
7225 * recommend to use [[LinkifyIt#test]] first, for best speed.
7226 *
7227 * ##### Result match description
7228 *
7229 * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
7230 * protocol-neutral links.
7231 * - __index__ - offset of matched text
7232 * - __lastIndex__ - index of next char after mathch end
7233 * - __raw__ - matched text
7234 * - __text__ - normalized text
7235 * - __url__ - link, generated from matched text
7236 **/ LinkifyIt.prototype.match = function match(text) {
7237 var shift = 0, result = [];
7238 // Try to take previous element from cache, if .test() called before
7239 if (this.__index__ >= 0 && this.__text_cache__ === text) {
7240 result.push(createMatch(this, shift));
7241 shift = this.__last_index__;
7242 }
7243 // Cut head if cache was used
7244 var tail = shift ? text.slice(shift) : text;
7245 // Scan string until end reached
7246 while (this.test(tail)) {
7247 result.push(createMatch(this, shift));
7248 tail = tail.slice(this.__last_index__);
7249 shift += this.__last_index__;
7250 }
7251 if (result.length) {
7252 return result;
7253 }
7254 return null;
7255 };
7256 /** chainable
7257 * LinkifyIt#tlds(list [, keepOld]) -> this
7258 * - list (Array): list of tlds
7259 * - keepOld (Boolean): merge with current list if `true` (`false` by default)
7260 *
7261 * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
7262 * to avoid false positives. By default this algorythm used:
7263 *
7264 * - hostname with any 2-letter root zones are ok.
7265 * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
7266 * are ok.
7267 * - encoded (`xn--...`) root zones are ok.
7268 *
7269 * If list is replaced, then exact match for 2-chars root zones will be checked.
7270 **/ LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
7271 list = Array.isArray(list) ? list : [ list ];
7272 if (!keepOld) {
7273 this.__tlds__ = list.slice();
7274 this.__tlds_replaced__ = true;
7275 compile(this);
7276 return this;
7277 }
7278 this.__tlds__ = this.__tlds__.concat(list).sort().filter((function(el, idx, arr) {
7279 return el !== arr[idx - 1];
7280 })).reverse();
7281 compile(this);
7282 return this;
7283 };
7284 /**
7285 * LinkifyIt#normalize(match)
7286 *
7287 * Default normalizer (if schema does not define it's own).
7288 **/ LinkifyIt.prototype.normalize = function normalize(match) {
7289 // Do minimal possible changes by default. Need to collect feedback prior
7290 // to move forward https://github.com/markdown-it/linkify-it/issues/1
7291 if (!match.schema) {
7292 match.url = "http://" + match.url;
7293 }
7294 if (match.schema === "mailto:" && !/^mailto:/i.test(match.url)) {
7295 match.url = "mailto:" + match.url;
7296 }
7297 };
7298 /**
7299 * LinkifyIt#onCompile()
7300 *
7301 * Override to modify basic RegExp-s.
7302 **/ LinkifyIt.prototype.onCompile = function onCompile() {};
7303 var linkifyIt = LinkifyIt;
7304 /*! https://mths.be/punycode v1.4.1 by @mathias */
7305 /** Highest positive signed 32-bit float value */ var maxInt = 2147483647;
7306 // aka. 0x7FFFFFFF or 2^31-1
7307 /** Bootstring parameters */ var base = 36;
7308 var tMin = 1;
7309 var tMax = 26;
7310 var skew = 38;
7311 var damp = 700;
7312 var initialBias = 72;
7313 var initialN = 128;
7314 // 0x80
7315 var delimiter = "-";
7316 // '\x2D'
7317 /** Regular expressions */ var regexPunycode = /^xn--/;
7318 var regexNonASCII = /[^\x20-\x7E]/;
7319 // unprintable ASCII chars + non-ASCII chars
7320 var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
7321 // RFC 3490 separators
7322 /** Error messages */ var errors = {
7323 overflow: "Overflow: input needs wider integers to process",
7324 "not-basic": "Illegal input >= 0x80 (not a basic code point)",
7325 "invalid-input": "Invalid input"
7326 };
7327 /** Convenience shortcuts */ var baseMinusTMin = base - tMin;
7328 var floor = Math.floor;
7329 var stringFromCharCode = String.fromCharCode;
7330 /*--------------------------------------------------------------------------*/
7331 /**
7332 * A generic error utility function.
7333 * @private
7334 * @param {String} type The error type.
7335 * @returns {Error} Throws a `RangeError` with the applicable error message.
7336 */ function error(type) {
7337 throw new RangeError(errors[type]);
7338 }
7339 /**
7340 * A generic `Array#map` utility function.
7341 * @private
7342 * @param {Array} array The array to iterate over.
7343 * @param {Function} callback The function that gets called for every array
7344 * item.
7345 * @returns {Array} A new array of values returned by the callback function.
7346 */ function map(array, fn) {
7347 var length = array.length;
7348 var result = [];
7349 while (length--) {
7350 result[length] = fn(array[length]);
7351 }
7352 return result;
7353 }
7354 /**
7355 * A simple `Array#map`-like wrapper to work with domain name strings or email
7356 * addresses.
7357 * @private
7358 * @param {String} domain The domain name or email address.
7359 * @param {Function} callback The function that gets called for every
7360 * character.
7361 * @returns {Array} A new string of characters returned by the callback
7362 * function.
7363 */ function mapDomain(string, fn) {
7364 var parts = string.split("@");
7365 var result = "";
7366 if (parts.length > 1) {
7367 // In email addresses, only the domain name should be punycoded. Leave
7368 // the local part (i.e. everything up to `@`) intact.
7369 result = parts[0] + "@";
7370 string = parts[1];
7371 }
7372 // Avoid `split(regex)` for IE8 compatibility. See #17.
7373 string = string.replace(regexSeparators, ".");
7374 var labels = string.split(".");
7375 var encoded = map(labels, fn).join(".");
7376 return result + encoded;
7377 }
7378 /**
7379 * Creates an array containing the numeric code points of each Unicode
7380 * character in the string. While JavaScript uses UCS-2 internally,
7381 * this function will convert a pair of surrogate halves (each of which
7382 * UCS-2 exposes as separate characters) into a single code point,
7383 * matching UTF-16.
7384 * @see `punycode.ucs2.encode`
7385 * @see <https://mathiasbynens.be/notes/javascript-encoding>
7386 * @memberOf punycode.ucs2
7387 * @name decode
7388 * @param {String} string The Unicode input string (UCS-2).
7389 * @returns {Array} The new array of code points.
7390 */ function ucs2decode(string) {
7391 var output = [], counter = 0, length = string.length, value, extra;
7392 while (counter < length) {
7393 value = string.charCodeAt(counter++);
7394 if (value >= 55296 && value <= 56319 && counter < length) {
7395 // high surrogate, and there is a next character
7396 extra = string.charCodeAt(counter++);
7397 if ((extra & 64512) == 56320) {
7398 // low surrogate
7399 output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
7400 } else {
7401 // unmatched surrogate; only append this code unit, in case the next
7402 // code unit is the high surrogate of a surrogate pair
7403 output.push(value);
7404 counter--;
7405 }
7406 } else {
7407 output.push(value);
7408 }
7409 }
7410 return output;
7411 }
7412 /**
7413 * Creates a string based on an array of numeric code points.
7414 * @see `punycode.ucs2.decode`
7415 * @memberOf punycode.ucs2
7416 * @name encode
7417 * @param {Array} codePoints The array of numeric code points.
7418 * @returns {String} The new Unicode string (UCS-2).
7419 */ function ucs2encode(array) {
7420 return map(array, (function(value) {
7421 var output = "";
7422 if (value > 65535) {
7423 value -= 65536;
7424 output += stringFromCharCode(value >>> 10 & 1023 | 55296);
7425 value = 56320 | value & 1023;
7426 }
7427 output += stringFromCharCode(value);
7428 return output;
7429 })).join("");
7430 }
7431 /**
7432 * Converts a basic code point into a digit/integer.
7433 * @see `digitToBasic()`
7434 * @private
7435 * @param {Number} codePoint The basic numeric code point value.
7436 * @returns {Number} The numeric value of a basic code point (for use in
7437 * representing integers) in the range `0` to `base - 1`, or `base` if
7438 * the code point does not represent a value.
7439 */ function basicToDigit(codePoint) {
7440 if (codePoint - 48 < 10) {
7441 return codePoint - 22;
7442 }
7443 if (codePoint - 65 < 26) {
7444 return codePoint - 65;
7445 }
7446 if (codePoint - 97 < 26) {
7447 return codePoint - 97;
7448 }
7449 return base;
7450 }
7451 /**
7452 * Converts a digit/integer into a basic code point.
7453 * @see `basicToDigit()`
7454 * @private
7455 * @param {Number} digit The numeric value of a basic code point.
7456 * @returns {Number} The basic code point whose value (when used for
7457 * representing integers) is `digit`, which needs to be in the range
7458 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
7459 * used; else, the lowercase form is used. The behavior is undefined
7460 * if `flag` is non-zero and `digit` has no uppercase form.
7461 */ function digitToBasic(digit, flag) {
7462 // 0..25 map to ASCII a..z or A..Z
7463 // 26..35 map to ASCII 0..9
7464 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
7465 }
7466 /**
7467 * Bias adaptation function as per section 3.4 of RFC 3492.
7468 * https://tools.ietf.org/html/rfc3492#section-3.4
7469 * @private
7470 */ function adapt(delta, numPoints, firstTime) {
7471 var k = 0;
7472 delta = firstTime ? floor(delta / damp) : delta >> 1;
7473 delta += floor(delta / numPoints);
7474 for (;delta > baseMinusTMin * tMax >> 1; k += base) {
7475 delta = floor(delta / baseMinusTMin);
7476 }
7477 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
7478 }
7479 /**
7480 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
7481 * symbols.
7482 * @memberOf punycode
7483 * @param {String} input The Punycode string of ASCII-only symbols.
7484 * @returns {String} The resulting string of Unicode symbols.
7485 */ function decode$2(input) {
7486 // Don't use UCS-2
7487 var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t,
7488 /** Cached calculation results */
7489 baseMinusT;
7490 // Handle the basic code points: let `basic` be the number of input code
7491 // points before the last delimiter, or `0` if there is none, then copy
7492 // the first basic code points to the output.
7493 basic = input.lastIndexOf(delimiter);
7494 if (basic < 0) {
7495 basic = 0;
7496 }
7497 for (j = 0; j < basic; ++j) {
7498 // if it's not a basic code point
7499 if (input.charCodeAt(j) >= 128) {
7500 error("not-basic");
7501 }
7502 output.push(input.charCodeAt(j));
7503 }
7504 // Main decoding loop: start just after the last delimiter if any basic code
7505 // points were copied; start at the beginning otherwise.
7506 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
7507 // `index` is the index of the next character to be consumed.
7508 // Decode a generalized variable-length integer into `delta`,
7509 // which gets added to `i`. The overflow checking is easier
7510 // if we increase `i` as we go, then subtract off its starting
7511 // value at the end to obtain `delta`.
7512 for (oldi = i, w = 1, k = base; ;k += base) {
7513 if (index >= inputLength) {
7514 error("invalid-input");
7515 }
7516 digit = basicToDigit(input.charCodeAt(index++));
7517 if (digit >= base || digit > floor((maxInt - i) / w)) {
7518 error("overflow");
7519 }
7520 i += digit * w;
7521 t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
7522 if (digit < t) {
7523 break;
7524 }
7525 baseMinusT = base - t;
7526 if (w > floor(maxInt / baseMinusT)) {
7527 error("overflow");
7528 }
7529 w *= baseMinusT;
7530 }
7531 out = output.length + 1;
7532 bias = adapt(i - oldi, out, oldi == 0);
7533 // `i` was supposed to wrap around from `out` to `0`,
7534 // incrementing `n` each time, so we'll fix that now:
7535 if (floor(i / out) > maxInt - n) {
7536 error("overflow");
7537 }
7538 n += floor(i / out);
7539 i %= out;
7540 // Insert `n` at position `i` of the output
7541 output.splice(i++, 0, n);
7542 }
7543 return ucs2encode(output);
7544 }
7545 /**
7546 * Converts a string of Unicode symbols (e.g. a domain name label) to a
7547 * Punycode string of ASCII-only symbols.
7548 * @memberOf punycode
7549 * @param {String} input The string of Unicode symbols.
7550 * @returns {String} The resulting Punycode string of ASCII-only symbols.
7551 */ function encode$2(input) {
7552 var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [],
7553 /** `inputLength` will hold the number of code points in `input`. */
7554 inputLength,
7555 /** Cached calculation results */
7556 handledCPCountPlusOne, baseMinusT, qMinusT;
7557 // Convert the input in UCS-2 to Unicode
7558 input = ucs2decode(input);
7559 // Cache the length
7560 inputLength = input.length;
7561 // Initialize the state
7562 n = initialN;
7563 delta = 0;
7564 bias = initialBias;
7565 // Handle the basic code points
7566 for (j = 0; j < inputLength; ++j) {
7567 currentValue = input[j];
7568 if (currentValue < 128) {
7569 output.push(stringFromCharCode(currentValue));
7570 }
7571 }
7572 handledCPCount = basicLength = output.length;
7573 // `handledCPCount` is the number of code points that have been handled;
7574 // `basicLength` is the number of basic code points.
7575 // Finish the basic string - if it is not empty - with a delimiter
7576 if (basicLength) {
7577 output.push(delimiter);
7578 }
7579 // Main encoding loop:
7580 while (handledCPCount < inputLength) {
7581 // All non-basic code points < n have been handled already. Find the next
7582 // larger one:
7583 for (m = maxInt, j = 0; j < inputLength; ++j) {
7584 currentValue = input[j];
7585 if (currentValue >= n && currentValue < m) {
7586 m = currentValue;
7587 }
7588 }
7589 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
7590 // but guard against overflow
7591 handledCPCountPlusOne = handledCPCount + 1;
7592 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
7593 error("overflow");
7594 }
7595 delta += (m - n) * handledCPCountPlusOne;
7596 n = m;
7597 for (j = 0; j < inputLength; ++j) {
7598 currentValue = input[j];
7599 if (currentValue < n && ++delta > maxInt) {
7600 error("overflow");
7601 }
7602 if (currentValue == n) {
7603 // Represent delta as a generalized variable-length integer
7604 for (q = delta, k = base; ;k += base) {
7605 t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
7606 if (q < t) {
7607 break;
7608 }
7609 qMinusT = q - t;
7610 baseMinusT = base - t;
7611 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
7612 q = floor(qMinusT / baseMinusT);
7613 }
7614 output.push(stringFromCharCode(digitToBasic(q, 0)));
7615 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
7616 delta = 0;
7617 ++handledCPCount;
7618 }
7619 }
7620 ++delta;
7621 ++n;
7622 }
7623 return output.join("");
7624 }
7625 /**
7626 * Converts a Punycode string representing a domain name or an email address
7627 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
7628 * it doesn't matter if you call it on a string that has already been
7629 * converted to Unicode.
7630 * @memberOf punycode
7631 * @param {String} input The Punycoded domain name or email address to
7632 * convert to Unicode.
7633 * @returns {String} The Unicode representation of the given Punycode
7634 * string.
7635 */ function toUnicode(input) {
7636 return mapDomain(input, (function(string) {
7637 return regexPunycode.test(string) ? decode$2(string.slice(4).toLowerCase()) : string;
7638 }));
7639 }
7640 /**
7641 * Converts a Unicode string representing a domain name or an email address to
7642 * Punycode. Only the non-ASCII parts of the domain name will be converted,
7643 * i.e. it doesn't matter if you call it with a domain that's already in
7644 * ASCII.
7645 * @memberOf punycode
7646 * @param {String} input The domain name or email address to convert, as a
7647 * Unicode string.
7648 * @returns {String} The Punycode representation of the given domain name or
7649 * email address.
7650 */ function toASCII(input) {
7651 return mapDomain(input, (function(string) {
7652 return regexNonASCII.test(string) ? "xn--" + encode$2(string) : string;
7653 }));
7654 }
7655 var version = "1.4.1";
7656 /**
7657 * An object of methods to convert from JavaScript's internal character
7658 * representation (UCS-2) to Unicode code points, and back.
7659 * @see <https://mathiasbynens.be/notes/javascript-encoding>
7660 * @memberOf punycode
7661 * @type Object
7662 */ var ucs2 = {
7663 decode: ucs2decode,
7664 encode: ucs2encode
7665 };
7666 var punycode = {
7667 version: version,
7668 ucs2: ucs2,
7669 toASCII: toASCII,
7670 toUnicode: toUnicode,
7671 encode: encode$2,
7672 decode: decode$2
7673 };
7674 var punycode$1 = Object.freeze({
7675 __proto__: null,
7676 decode: decode$2,
7677 encode: encode$2,
7678 toUnicode: toUnicode,
7679 toASCII: toASCII,
7680 version: version,
7681 ucs2: ucs2,
7682 default: punycode
7683 });
7684 // markdown-it default options
7685 var _default = {
7686 options: {
7687 html: false,
7688 // Enable HTML tags in source
7689 xhtmlOut: false,
7690 // Use '/' to close single tags (<br />)
7691 breaks: false,
7692 // Convert '\n' in paragraphs into <br>
7693 langPrefix: "language-",
7694 // CSS language prefix for fenced blocks
7695 linkify: false,
7696 // autoconvert URL-like texts to links
7697 // Enable some language-neutral replacements + quotes beautification
7698 typographer: false,
7699 // Double + single quotes replacement pairs, when typographer enabled,
7700 // and smartquotes on. Could be either a String or an Array.
7701 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
7702 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
7703 quotes: "\u201c\u201d\u2018\u2019",
7704 /* “”‘’ */
7705 // Highlighter function. Should return escaped HTML,
7706 // or '' if the source string is not changed and should be escaped externaly.
7707 // If result starts with <pre... internal wrapper is skipped.
7708 // function (/*str, lang*/) { return ''; }
7709 highlight: null,
7710 maxNesting: 100
7711 },
7712 components: {
7713 core: {},
7714 block: {},
7715 inline: {}
7716 }
7717 };
7718 // "Zero" preset, with nothing enabled. Useful for manual configuring of simple
7719 var zero = {
7720 options: {
7721 html: false,
7722 // Enable HTML tags in source
7723 xhtmlOut: false,
7724 // Use '/' to close single tags (<br />)
7725 breaks: false,
7726 // Convert '\n' in paragraphs into <br>
7727 langPrefix: "language-",
7728 // CSS language prefix for fenced blocks
7729 linkify: false,
7730 // autoconvert URL-like texts to links
7731 // Enable some language-neutral replacements + quotes beautification
7732 typographer: false,
7733 // Double + single quotes replacement pairs, when typographer enabled,
7734 // and smartquotes on. Could be either a String or an Array.
7735 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
7736 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
7737 quotes: "\u201c\u201d\u2018\u2019",
7738 /* “”‘’ */
7739 // Highlighter function. Should return escaped HTML,
7740 // or '' if the source string is not changed and should be escaped externaly.
7741 // If result starts with <pre... internal wrapper is skipped.
7742 // function (/*str, lang*/) { return ''; }
7743 highlight: null,
7744 maxNesting: 20
7745 },
7746 components: {
7747 core: {
7748 rules: [ "normalize", "block", "inline" ]
7749 },
7750 block: {
7751 rules: [ "paragraph" ]
7752 },
7753 inline: {
7754 rules: [ "text" ],
7755 rules2: [ "balance_pairs", "text_collapse" ]
7756 }
7757 }
7758 };
7759 // Commonmark default options
7760 var commonmark = {
7761 options: {
7762 html: true,
7763 // Enable HTML tags in source
7764 xhtmlOut: true,
7765 // Use '/' to close single tags (<br />)
7766 breaks: false,
7767 // Convert '\n' in paragraphs into <br>
7768 langPrefix: "language-",
7769 // CSS language prefix for fenced blocks
7770 linkify: false,
7771 // autoconvert URL-like texts to links
7772 // Enable some language-neutral replacements + quotes beautification
7773 typographer: false,
7774 // Double + single quotes replacement pairs, when typographer enabled,
7775 // and smartquotes on. Could be either a String or an Array.
7776 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
7777 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
7778 quotes: "\u201c\u201d\u2018\u2019",
7779 /* “”‘’ */
7780 // Highlighter function. Should return escaped HTML,
7781 // or '' if the source string is not changed and should be escaped externaly.
7782 // If result starts with <pre... internal wrapper is skipped.
7783 // function (/*str, lang*/) { return ''; }
7784 highlight: null,
7785 maxNesting: 20
7786 },
7787 components: {
7788 core: {
7789 rules: [ "normalize", "block", "inline" ]
7790 },
7791 block: {
7792 rules: [ "blockquote", "code", "fence", "heading", "hr", "html_block", "lheading", "list", "reference", "paragraph" ]
7793 },
7794 inline: {
7795 rules: [ "autolink", "backticks", "emphasis", "entity", "escape", "html_inline", "image", "link", "newline", "text" ],
7796 rules2: [ "balance_pairs", "emphasis", "text_collapse" ]
7797 }
7798 }
7799 };
7800 var punycode$2 = getAugmentedNamespace(punycode$1);
7801 var config = {
7802 default: _default,
7803 zero: zero,
7804 commonmark: commonmark
7805 };
7806 ////////////////////////////////////////////////////////////////////////////////
7807
7808 // This validator can prohibit more than really needed to prevent XSS. It's a
7809 // tradeoff to keep code simple and to be secure by default.
7810
7811 // If you need different setup - override validator method as you wish. Or
7812 // replace it with dummy function and use external sanitizer.
7813
7814 var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
7815 var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
7816 function validateLink(url) {
7817 // url should be normalized at this point, and existing entities are decoded
7818 var str = url.trim().toLowerCase();
7819 return BAD_PROTO_RE.test(str) ? GOOD_DATA_RE.test(str) ? true : false : true;
7820 }
7821 ////////////////////////////////////////////////////////////////////////////////
7822 var RECODE_HOSTNAME_FOR = [ "http:", "https:", "mailto:" ];
7823 function normalizeLink(url) {
7824 var parsed = mdurl.parse(url, true);
7825 if (parsed.hostname) {
7826 // Encode hostnames in urls like:
7827 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
7828 // We don't encode unknown schemas, because it's likely that we encode
7829 // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
7830 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
7831 try {
7832 parsed.hostname = punycode$2.toASCII(parsed.hostname);
7833 } catch (er) {}
7834 }
7835 }
7836 return mdurl.encode(mdurl.format(parsed));
7837 }
7838 function normalizeLinkText(url) {
7839 var parsed = mdurl.parse(url, true);
7840 if (parsed.hostname) {
7841 // Encode hostnames in urls like:
7842 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
7843 // We don't encode unknown schemas, because it's likely that we encode
7844 // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
7845 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
7846 try {
7847 parsed.hostname = punycode$2.toUnicode(parsed.hostname);
7848 } catch (er) {}
7849 }
7850 }
7851 // add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720
7852 return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + "%");
7853 }
7854 /**
7855 * class MarkdownIt
7856 *
7857 * Main parser/renderer class.
7858 *
7859 * ##### Usage
7860 *
7861 * ```javascript
7862 * // node.js, "classic" way:
7863 * var MarkdownIt = require('markdown-it'),
7864 * md = new MarkdownIt();
7865 * var result = md.render('# markdown-it rulezz!');
7866 *
7867 * // node.js, the same, but with sugar:
7868 * var md = require('markdown-it')();
7869 * var result = md.render('# markdown-it rulezz!');
7870 *
7871 * // browser without AMD, added to "window" on script load
7872 * // Note, there are no dash.
7873 * var md = window.markdownit();
7874 * var result = md.render('# markdown-it rulezz!');
7875 * ```
7876 *
7877 * Single line rendering, without paragraph wrap:
7878 *
7879 * ```javascript
7880 * var md = require('markdown-it')();
7881 * var result = md.renderInline('__markdown-it__ rulezz!');
7882 * ```
7883 **/
7884 /**
7885 * new MarkdownIt([presetName, options])
7886 * - presetName (String): optional, `commonmark` / `zero`
7887 * - options (Object)
7888 *
7889 * Creates parser instanse with given config. Can be called without `new`.
7890 *
7891 * ##### presetName
7892 *
7893 * MarkdownIt provides named presets as a convenience to quickly
7894 * enable/disable active syntax rules and options for common use cases.
7895 *
7896 * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
7897 * configures parser to strict [CommonMark](http://commonmark.org/) mode.
7898 * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
7899 * similar to GFM, used when no preset name given. Enables all available rules,
7900 * but still without html, typographer & autolinker.
7901 * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
7902 * all rules disabled. Useful to quickly setup your config via `.enable()`.
7903 * For example, when you need only `bold` and `italic` markup and nothing else.
7904 *
7905 * ##### options:
7906 *
7907 * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
7908 * That's not safe! You may need external sanitizer to protect output from XSS.
7909 * It's better to extend features via plugins, instead of enabling HTML.
7910 * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
7911 * (`<br />`). This is needed only for full CommonMark compatibility. In real
7912 * world you will need HTML output.
7913 * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
7914 * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
7915 * Can be useful for external highlighters.
7916 * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
7917 * - __typographer__ - `false`. Set `true` to enable [some language-neutral
7918 * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
7919 * quotes beautification (smartquotes).
7920 * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
7921 * pairs, when typographer enabled and smartquotes on. For example, you can
7922 * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
7923 * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
7924 * - __highlight__ - `null`. Highlighter function for fenced code blocks.
7925 * Highlighter `function (str, lang)` should return escaped HTML. It can also
7926 * return empty string if the source was not changed and should be escaped
7927 * externaly. If result starts with <pre... internal wrapper is skipped.
7928 *
7929 * ##### Example
7930 *
7931 * ```javascript
7932 * // commonmark mode
7933 * var md = require('markdown-it')('commonmark');
7934 *
7935 * // default mode
7936 * var md = require('markdown-it')();
7937 *
7938 * // enable everything
7939 * var md = require('markdown-it')({
7940 * html: true,
7941 * linkify: true,
7942 * typographer: true
7943 * });
7944 * ```
7945 *
7946 * ##### Syntax highlighting
7947 *
7948 * ```js
7949 * var hljs = require('highlight.js') // https://highlightjs.org/
7950 *
7951 * var md = require('markdown-it')({
7952 * highlight: function (str, lang) {
7953 * if (lang && hljs.getLanguage(lang)) {
7954 * try {
7955 * return hljs.highlight(lang, str, true).value;
7956 * } catch (__) {}
7957 * }
7958 *
7959 * return ''; // use external default escaping
7960 * }
7961 * });
7962 * ```
7963 *
7964 * Or with full wrapper override (if you need assign class to `<pre>`):
7965 *
7966 * ```javascript
7967 * var hljs = require('highlight.js') // https://highlightjs.org/
7968 *
7969 * // Actual default values
7970 * var md = require('markdown-it')({
7971 * highlight: function (str, lang) {
7972 * if (lang && hljs.getLanguage(lang)) {
7973 * try {
7974 * return '<pre class="hljs"><code>' +
7975 * hljs.highlight(lang, str, true).value +
7976 * '</code></pre>';
7977 * } catch (__) {}
7978 * }
7979 *
7980 * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
7981 * }
7982 * });
7983 * ```
7984 *
7985 **/ function MarkdownIt(presetName, options) {
7986 if (!(this instanceof MarkdownIt)) {
7987 return new MarkdownIt(presetName, options);
7988 }
7989 if (!options) {
7990 if (!utils.isString(presetName)) {
7991 options = presetName || {};
7992 presetName = "default";
7993 }
7994 }
7995 /**
7996 * MarkdownIt#inline -> ParserInline
7997 *
7998 * Instance of [[ParserInline]]. You may need it to add new rules when
7999 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
8000 * [[MarkdownIt.enable]].
8001 **/ this.inline = new parser_inline;
8002 /**
8003 * MarkdownIt#block -> ParserBlock
8004 *
8005 * Instance of [[ParserBlock]]. You may need it to add new rules when
8006 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
8007 * [[MarkdownIt.enable]].
8008 **/ this.block = new parser_block;
8009 /**
8010 * MarkdownIt#core -> Core
8011 *
8012 * Instance of [[Core]] chain executor. You may need it to add new rules when
8013 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
8014 * [[MarkdownIt.enable]].
8015 **/ this.core = new parser_core;
8016 /**
8017 * MarkdownIt#renderer -> Renderer
8018 *
8019 * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
8020 * rules for new token types, generated by plugins.
8021 *
8022 * ##### Example
8023 *
8024 * ```javascript
8025 * var md = require('markdown-it')();
8026 *
8027 * function myToken(tokens, idx, options, env, self) {
8028 * //...
8029 * return result;
8030 * };
8031 *
8032 * md.renderer.rules['my_token'] = myToken
8033 * ```
8034 *
8035 * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
8036 **/ this.renderer = new renderer;
8037 /**
8038 * MarkdownIt#linkify -> LinkifyIt
8039 *
8040 * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
8041 * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
8042 * rule.
8043 **/ this.linkify = new linkifyIt;
8044 /**
8045 * MarkdownIt#validateLink(url) -> Boolean
8046 *
8047 * Link validation function. CommonMark allows too much in links. By default
8048 * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
8049 * except some embedded image types.
8050 *
8051 * You can change this behaviour:
8052 *
8053 * ```javascript
8054 * var md = require('markdown-it')();
8055 * // enable everything
8056 * md.validateLink = function () { return true; }
8057 * ```
8058 **/ this.validateLink = validateLink;
8059 /**
8060 * MarkdownIt#normalizeLink(url) -> String
8061 *
8062 * Function used to encode link url to a machine-readable format,
8063 * which includes url-encoding, punycode, etc.
8064 **/ this.normalizeLink = normalizeLink;
8065 /**
8066 * MarkdownIt#normalizeLinkText(url) -> String
8067 *
8068 * Function used to decode link url to a human-readable format`
8069 **/ this.normalizeLinkText = normalizeLinkText;
8070 // Expose utils & helpers for easy acces from plugins
8071 /**
8072 * MarkdownIt#utils -> utils
8073 *
8074 * Assorted utility functions, useful to write plugins. See details
8075 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
8076 **/ this.utils = utils;
8077 /**
8078 * MarkdownIt#helpers -> helpers
8079 *
8080 * Link components parser functions, useful to write plugins. See details
8081 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
8082 **/ this.helpers = utils.assign({}, helpers);
8083 this.options = {};
8084 this.configure(presetName);
8085 if (options) {
8086 this.set(options);
8087 }
8088 }
8089 /** chainable
8090 * MarkdownIt.set(options)
8091 *
8092 * Set parser options (in the same format as in constructor). Probably, you
8093 * will never need it, but you can change options after constructor call.
8094 *
8095 * ##### Example
8096 *
8097 * ```javascript
8098 * var md = require('markdown-it')()
8099 * .set({ html: true, breaks: true })
8100 * .set({ typographer, true });
8101 * ```
8102 *
8103 * __Note:__ To achieve the best possible performance, don't modify a
8104 * `markdown-it` instance options on the fly. If you need multiple configurations
8105 * it's best to create multiple instances and initialize each with separate
8106 * config.
8107 **/ MarkdownIt.prototype.set = function(options) {
8108 utils.assign(this.options, options);
8109 return this;
8110 };
8111 /** chainable, internal
8112 * MarkdownIt.configure(presets)
8113 *
8114 * Batch load of all options and compenent settings. This is internal method,
8115 * and you probably will not need it. But if you will - see available presets
8116 * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
8117 *
8118 * We strongly recommend to use presets instead of direct config loads. That
8119 * will give better compatibility with next versions.
8120 **/ MarkdownIt.prototype.configure = function(presets) {
8121 var self = this, presetName;
8122 if (utils.isString(presets)) {
8123 presetName = presets;
8124 presets = config[presetName];
8125 if (!presets) {
8126 throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name');
8127 }
8128 }
8129 if (!presets) {
8130 throw new Error("Wrong `markdown-it` preset, can't be empty");
8131 }
8132 if (presets.options) {
8133 self.set(presets.options);
8134 }
8135 if (presets.components) {
8136 Object.keys(presets.components).forEach((function(name) {
8137 if (presets.components[name].rules) {
8138 self[name].ruler.enableOnly(presets.components[name].rules);
8139 }
8140 if (presets.components[name].rules2) {
8141 self[name].ruler2.enableOnly(presets.components[name].rules2);
8142 }
8143 }));
8144 }
8145 return this;
8146 };
8147 /** chainable
8148 * MarkdownIt.enable(list, ignoreInvalid)
8149 * - list (String|Array): rule name or list of rule names to enable
8150 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
8151 *
8152 * Enable list or rules. It will automatically find appropriate components,
8153 * containing rules with given names. If rule not found, and `ignoreInvalid`
8154 * not set - throws exception.
8155 *
8156 * ##### Example
8157 *
8158 * ```javascript
8159 * var md = require('markdown-it')()
8160 * .enable(['sub', 'sup'])
8161 * .disable('smartquotes');
8162 * ```
8163 **/ MarkdownIt.prototype.enable = function(list, ignoreInvalid) {
8164 var result = [];
8165 if (!Array.isArray(list)) {
8166 list = [ list ];
8167 }
8168 [ "core", "block", "inline" ].forEach((function(chain) {
8169 result = result.concat(this[chain].ruler.enable(list, true));
8170 }), this);
8171 result = result.concat(this.inline.ruler2.enable(list, true));
8172 var missed = list.filter((function(name) {
8173 return result.indexOf(name) < 0;
8174 }));
8175 if (missed.length && !ignoreInvalid) {
8176 throw new Error("MarkdownIt. Failed to enable unknown rule(s): " + missed);
8177 }
8178 return this;
8179 };
8180 /** chainable
8181 * MarkdownIt.disable(list, ignoreInvalid)
8182 * - list (String|Array): rule name or list of rule names to disable.
8183 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
8184 *
8185 * The same as [[MarkdownIt.enable]], but turn specified rules off.
8186 **/ MarkdownIt.prototype.disable = function(list, ignoreInvalid) {
8187 var result = [];
8188 if (!Array.isArray(list)) {
8189 list = [ list ];
8190 }
8191 [ "core", "block", "inline" ].forEach((function(chain) {
8192 result = result.concat(this[chain].ruler.disable(list, true));
8193 }), this);
8194 result = result.concat(this.inline.ruler2.disable(list, true));
8195 var missed = list.filter((function(name) {
8196 return result.indexOf(name) < 0;
8197 }));
8198 if (missed.length && !ignoreInvalid) {
8199 throw new Error("MarkdownIt. Failed to disable unknown rule(s): " + missed);
8200 }
8201 return this;
8202 };
8203 /** chainable
8204 * MarkdownIt.use(plugin, params)
8205 *
8206 * Load specified plugin with given params into current parser instance.
8207 * It's just a sugar to call `plugin(md, params)` with curring.
8208 *
8209 * ##### Example
8210 *
8211 * ```javascript
8212 * var iterator = require('markdown-it-for-inline');
8213 * var md = require('markdown-it')()
8214 * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
8215 * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
8216 * });
8217 * ```
8218 **/ MarkdownIt.prototype.use = function(plugin /*, params, ... */) {
8219 var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
8220 plugin.apply(plugin, args);
8221 return this;
8222 };
8223 /** internal
8224 * MarkdownIt.parse(src, env) -> Array
8225 * - src (String): source string
8226 * - env (Object): environment sandbox
8227 *
8228 * Parse input string and return list of block tokens (special token type
8229 * "inline" will contain list of inline tokens). You should not call this
8230 * method directly, until you write custom renderer (for example, to produce
8231 * AST).
8232 *
8233 * `env` is used to pass data between "distributed" rules and return additional
8234 * metadata like reference info, needed for the renderer. It also can be used to
8235 * inject data in specific cases. Usually, you will be ok to pass `{}`,
8236 * and then pass updated object to renderer.
8237 **/ MarkdownIt.prototype.parse = function(src, env) {
8238 if (typeof src !== "string") {
8239 throw new Error("Input data should be a String");
8240 }
8241 var state = new this.core.State(src, this, env);
8242 this.core.process(state);
8243 return state.tokens;
8244 };
8245 /**
8246 * MarkdownIt.render(src [, env]) -> String
8247 * - src (String): source string
8248 * - env (Object): environment sandbox
8249 *
8250 * Render markdown string into html. It does all magic for you :).
8251 *
8252 * `env` can be used to inject additional metadata (`{}` by default).
8253 * But you will not need it with high probability. See also comment
8254 * in [[MarkdownIt.parse]].
8255 **/ MarkdownIt.prototype.render = function(src, env) {
8256 env = env || {};
8257 return this.renderer.render(this.parse(src, env), this.options, env);
8258 };
8259 /** internal
8260 * MarkdownIt.parseInline(src, env) -> Array
8261 * - src (String): source string
8262 * - env (Object): environment sandbox
8263 *
8264 * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
8265 * block tokens list with the single `inline` element, containing parsed inline
8266 * tokens in `children` property. Also updates `env` object.
8267 **/ MarkdownIt.prototype.parseInline = function(src, env) {
8268 var state = new this.core.State(src, this, env);
8269 state.inlineMode = true;
8270 this.core.process(state);
8271 return state.tokens;
8272 };
8273 /**
8274 * MarkdownIt.renderInline(src [, env]) -> String
8275 * - src (String): source string
8276 * - env (Object): environment sandbox
8277 *
8278 * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
8279 * will NOT be wrapped into `<p>` tags.
8280 **/ MarkdownIt.prototype.renderInline = function(src, env) {
8281 env = env || {};
8282 return this.renderer.render(this.parseInline(src, env), this.options, env);
8283 };
8284 var lib = MarkdownIt;
8285 var markdownIt = lib;
8286 return markdownIt;
8287}));