source: node_modules/remarkable/dist/cjs/index.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 168.2 KB
RevLine 
[d24f17c]1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5// List of valid entities
6//
7// Generate with ./support/entities.js script
8//
9
10/*eslint quotes:0*/
11var entities = {
12 "Aacute":"\u00C1",
13 "aacute":"\u00E1",
14 "Abreve":"\u0102",
15 "abreve":"\u0103",
16 "ac":"\u223E",
17 "acd":"\u223F",
18 "acE":"\u223E\u0333",
19 "Acirc":"\u00C2",
20 "acirc":"\u00E2",
21 "acute":"\u00B4",
22 "Acy":"\u0410",
23 "acy":"\u0430",
24 "AElig":"\u00C6",
25 "aelig":"\u00E6",
26 "af":"\u2061",
27 "Afr":"\uD835\uDD04",
28 "afr":"\uD835\uDD1E",
29 "Agrave":"\u00C0",
30 "agrave":"\u00E0",
31 "alefsym":"\u2135",
32 "aleph":"\u2135",
33 "Alpha":"\u0391",
34 "alpha":"\u03B1",
35 "Amacr":"\u0100",
36 "amacr":"\u0101",
37 "amalg":"\u2A3F",
38 "AMP":"\u0026",
39 "amp":"\u0026",
40 "And":"\u2A53",
41 "and":"\u2227",
42 "andand":"\u2A55",
43 "andd":"\u2A5C",
44 "andslope":"\u2A58",
45 "andv":"\u2A5A",
46 "ang":"\u2220",
47 "ange":"\u29A4",
48 "angle":"\u2220",
49 "angmsd":"\u2221",
50 "angmsdaa":"\u29A8",
51 "angmsdab":"\u29A9",
52 "angmsdac":"\u29AA",
53 "angmsdad":"\u29AB",
54 "angmsdae":"\u29AC",
55 "angmsdaf":"\u29AD",
56 "angmsdag":"\u29AE",
57 "angmsdah":"\u29AF",
58 "angrt":"\u221F",
59 "angrtvb":"\u22BE",
60 "angrtvbd":"\u299D",
61 "angsph":"\u2222",
62 "angst":"\u00C5",
63 "angzarr":"\u237C",
64 "Aogon":"\u0104",
65 "aogon":"\u0105",
66 "Aopf":"\uD835\uDD38",
67 "aopf":"\uD835\uDD52",
68 "ap":"\u2248",
69 "apacir":"\u2A6F",
70 "apE":"\u2A70",
71 "ape":"\u224A",
72 "apid":"\u224B",
73 "apos":"\u0027",
74 "ApplyFunction":"\u2061",
75 "approx":"\u2248",
76 "approxeq":"\u224A",
77 "Aring":"\u00C5",
78 "aring":"\u00E5",
79 "Ascr":"\uD835\uDC9C",
80 "ascr":"\uD835\uDCB6",
81 "Assign":"\u2254",
82 "ast":"\u002A",
83 "asymp":"\u2248",
84 "asympeq":"\u224D",
85 "Atilde":"\u00C3",
86 "atilde":"\u00E3",
87 "Auml":"\u00C4",
88 "auml":"\u00E4",
89 "awconint":"\u2233",
90 "awint":"\u2A11",
91 "backcong":"\u224C",
92 "backepsilon":"\u03F6",
93 "backprime":"\u2035",
94 "backsim":"\u223D",
95 "backsimeq":"\u22CD",
96 "Backslash":"\u2216",
97 "Barv":"\u2AE7",
98 "barvee":"\u22BD",
99 "Barwed":"\u2306",
100 "barwed":"\u2305",
101 "barwedge":"\u2305",
102 "bbrk":"\u23B5",
103 "bbrktbrk":"\u23B6",
104 "bcong":"\u224C",
105 "Bcy":"\u0411",
106 "bcy":"\u0431",
107 "bdquo":"\u201E",
108 "becaus":"\u2235",
109 "Because":"\u2235",
110 "because":"\u2235",
111 "bemptyv":"\u29B0",
112 "bepsi":"\u03F6",
113 "bernou":"\u212C",
114 "Bernoullis":"\u212C",
115 "Beta":"\u0392",
116 "beta":"\u03B2",
117 "beth":"\u2136",
118 "between":"\u226C",
119 "Bfr":"\uD835\uDD05",
120 "bfr":"\uD835\uDD1F",
121 "bigcap":"\u22C2",
122 "bigcirc":"\u25EF",
123 "bigcup":"\u22C3",
124 "bigodot":"\u2A00",
125 "bigoplus":"\u2A01",
126 "bigotimes":"\u2A02",
127 "bigsqcup":"\u2A06",
128 "bigstar":"\u2605",
129 "bigtriangledown":"\u25BD",
130 "bigtriangleup":"\u25B3",
131 "biguplus":"\u2A04",
132 "bigvee":"\u22C1",
133 "bigwedge":"\u22C0",
134 "bkarow":"\u290D",
135 "blacklozenge":"\u29EB",
136 "blacksquare":"\u25AA",
137 "blacktriangle":"\u25B4",
138 "blacktriangledown":"\u25BE",
139 "blacktriangleleft":"\u25C2",
140 "blacktriangleright":"\u25B8",
141 "blank":"\u2423",
142 "blk12":"\u2592",
143 "blk14":"\u2591",
144 "blk34":"\u2593",
145 "block":"\u2588",
146 "bne":"\u003D\u20E5",
147 "bnequiv":"\u2261\u20E5",
148 "bNot":"\u2AED",
149 "bnot":"\u2310",
150 "Bopf":"\uD835\uDD39",
151 "bopf":"\uD835\uDD53",
152 "bot":"\u22A5",
153 "bottom":"\u22A5",
154 "bowtie":"\u22C8",
155 "boxbox":"\u29C9",
156 "boxDL":"\u2557",
157 "boxDl":"\u2556",
158 "boxdL":"\u2555",
159 "boxdl":"\u2510",
160 "boxDR":"\u2554",
161 "boxDr":"\u2553",
162 "boxdR":"\u2552",
163 "boxdr":"\u250C",
164 "boxH":"\u2550",
165 "boxh":"\u2500",
166 "boxHD":"\u2566",
167 "boxHd":"\u2564",
168 "boxhD":"\u2565",
169 "boxhd":"\u252C",
170 "boxHU":"\u2569",
171 "boxHu":"\u2567",
172 "boxhU":"\u2568",
173 "boxhu":"\u2534",
174 "boxminus":"\u229F",
175 "boxplus":"\u229E",
176 "boxtimes":"\u22A0",
177 "boxUL":"\u255D",
178 "boxUl":"\u255C",
179 "boxuL":"\u255B",
180 "boxul":"\u2518",
181 "boxUR":"\u255A",
182 "boxUr":"\u2559",
183 "boxuR":"\u2558",
184 "boxur":"\u2514",
185 "boxV":"\u2551",
186 "boxv":"\u2502",
187 "boxVH":"\u256C",
188 "boxVh":"\u256B",
189 "boxvH":"\u256A",
190 "boxvh":"\u253C",
191 "boxVL":"\u2563",
192 "boxVl":"\u2562",
193 "boxvL":"\u2561",
194 "boxvl":"\u2524",
195 "boxVR":"\u2560",
196 "boxVr":"\u255F",
197 "boxvR":"\u255E",
198 "boxvr":"\u251C",
199 "bprime":"\u2035",
200 "Breve":"\u02D8",
201 "breve":"\u02D8",
202 "brvbar":"\u00A6",
203 "Bscr":"\u212C",
204 "bscr":"\uD835\uDCB7",
205 "bsemi":"\u204F",
206 "bsim":"\u223D",
207 "bsime":"\u22CD",
208 "bsol":"\u005C",
209 "bsolb":"\u29C5",
210 "bsolhsub":"\u27C8",
211 "bull":"\u2022",
212 "bullet":"\u2022",
213 "bump":"\u224E",
214 "bumpE":"\u2AAE",
215 "bumpe":"\u224F",
216 "Bumpeq":"\u224E",
217 "bumpeq":"\u224F",
218 "Cacute":"\u0106",
219 "cacute":"\u0107",
220 "Cap":"\u22D2",
221 "cap":"\u2229",
222 "capand":"\u2A44",
223 "capbrcup":"\u2A49",
224 "capcap":"\u2A4B",
225 "capcup":"\u2A47",
226 "capdot":"\u2A40",
227 "CapitalDifferentialD":"\u2145",
228 "caps":"\u2229\uFE00",
229 "caret":"\u2041",
230 "caron":"\u02C7",
231 "Cayleys":"\u212D",
232 "ccaps":"\u2A4D",
233 "Ccaron":"\u010C",
234 "ccaron":"\u010D",
235 "Ccedil":"\u00C7",
236 "ccedil":"\u00E7",
237 "Ccirc":"\u0108",
238 "ccirc":"\u0109",
239 "Cconint":"\u2230",
240 "ccups":"\u2A4C",
241 "ccupssm":"\u2A50",
242 "Cdot":"\u010A",
243 "cdot":"\u010B",
244 "cedil":"\u00B8",
245 "Cedilla":"\u00B8",
246 "cemptyv":"\u29B2",
247 "cent":"\u00A2",
248 "CenterDot":"\u00B7",
249 "centerdot":"\u00B7",
250 "Cfr":"\u212D",
251 "cfr":"\uD835\uDD20",
252 "CHcy":"\u0427",
253 "chcy":"\u0447",
254 "check":"\u2713",
255 "checkmark":"\u2713",
256 "Chi":"\u03A7",
257 "chi":"\u03C7",
258 "cir":"\u25CB",
259 "circ":"\u02C6",
260 "circeq":"\u2257",
261 "circlearrowleft":"\u21BA",
262 "circlearrowright":"\u21BB",
263 "circledast":"\u229B",
264 "circledcirc":"\u229A",
265 "circleddash":"\u229D",
266 "CircleDot":"\u2299",
267 "circledR":"\u00AE",
268 "circledS":"\u24C8",
269 "CircleMinus":"\u2296",
270 "CirclePlus":"\u2295",
271 "CircleTimes":"\u2297",
272 "cirE":"\u29C3",
273 "cire":"\u2257",
274 "cirfnint":"\u2A10",
275 "cirmid":"\u2AEF",
276 "cirscir":"\u29C2",
277 "ClockwiseContourIntegral":"\u2232",
278 "CloseCurlyDoubleQuote":"\u201D",
279 "CloseCurlyQuote":"\u2019",
280 "clubs":"\u2663",
281 "clubsuit":"\u2663",
282 "Colon":"\u2237",
283 "colon":"\u003A",
284 "Colone":"\u2A74",
285 "colone":"\u2254",
286 "coloneq":"\u2254",
287 "comma":"\u002C",
288 "commat":"\u0040",
289 "comp":"\u2201",
290 "compfn":"\u2218",
291 "complement":"\u2201",
292 "complexes":"\u2102",
293 "cong":"\u2245",
294 "congdot":"\u2A6D",
295 "Congruent":"\u2261",
296 "Conint":"\u222F",
297 "conint":"\u222E",
298 "ContourIntegral":"\u222E",
299 "Copf":"\u2102",
300 "copf":"\uD835\uDD54",
301 "coprod":"\u2210",
302 "Coproduct":"\u2210",
303 "COPY":"\u00A9",
304 "copy":"\u00A9",
305 "copysr":"\u2117",
306 "CounterClockwiseContourIntegral":"\u2233",
307 "crarr":"\u21B5",
308 "Cross":"\u2A2F",
309 "cross":"\u2717",
310 "Cscr":"\uD835\uDC9E",
311 "cscr":"\uD835\uDCB8",
312 "csub":"\u2ACF",
313 "csube":"\u2AD1",
314 "csup":"\u2AD0",
315 "csupe":"\u2AD2",
316 "ctdot":"\u22EF",
317 "cudarrl":"\u2938",
318 "cudarrr":"\u2935",
319 "cuepr":"\u22DE",
320 "cuesc":"\u22DF",
321 "cularr":"\u21B6",
322 "cularrp":"\u293D",
323 "Cup":"\u22D3",
324 "cup":"\u222A",
325 "cupbrcap":"\u2A48",
326 "CupCap":"\u224D",
327 "cupcap":"\u2A46",
328 "cupcup":"\u2A4A",
329 "cupdot":"\u228D",
330 "cupor":"\u2A45",
331 "cups":"\u222A\uFE00",
332 "curarr":"\u21B7",
333 "curarrm":"\u293C",
334 "curlyeqprec":"\u22DE",
335 "curlyeqsucc":"\u22DF",
336 "curlyvee":"\u22CE",
337 "curlywedge":"\u22CF",
338 "curren":"\u00A4",
339 "curvearrowleft":"\u21B6",
340 "curvearrowright":"\u21B7",
341 "cuvee":"\u22CE",
342 "cuwed":"\u22CF",
343 "cwconint":"\u2232",
344 "cwint":"\u2231",
345 "cylcty":"\u232D",
346 "Dagger":"\u2021",
347 "dagger":"\u2020",
348 "daleth":"\u2138",
349 "Darr":"\u21A1",
350 "dArr":"\u21D3",
351 "darr":"\u2193",
352 "dash":"\u2010",
353 "Dashv":"\u2AE4",
354 "dashv":"\u22A3",
355 "dbkarow":"\u290F",
356 "dblac":"\u02DD",
357 "Dcaron":"\u010E",
358 "dcaron":"\u010F",
359 "Dcy":"\u0414",
360 "dcy":"\u0434",
361 "DD":"\u2145",
362 "dd":"\u2146",
363 "ddagger":"\u2021",
364 "ddarr":"\u21CA",
365 "DDotrahd":"\u2911",
366 "ddotseq":"\u2A77",
367 "deg":"\u00B0",
368 "Del":"\u2207",
369 "Delta":"\u0394",
370 "delta":"\u03B4",
371 "demptyv":"\u29B1",
372 "dfisht":"\u297F",
373 "Dfr":"\uD835\uDD07",
374 "dfr":"\uD835\uDD21",
375 "dHar":"\u2965",
376 "dharl":"\u21C3",
377 "dharr":"\u21C2",
378 "DiacriticalAcute":"\u00B4",
379 "DiacriticalDot":"\u02D9",
380 "DiacriticalDoubleAcute":"\u02DD",
381 "DiacriticalGrave":"\u0060",
382 "DiacriticalTilde":"\u02DC",
383 "diam":"\u22C4",
384 "Diamond":"\u22C4",
385 "diamond":"\u22C4",
386 "diamondsuit":"\u2666",
387 "diams":"\u2666",
388 "die":"\u00A8",
389 "DifferentialD":"\u2146",
390 "digamma":"\u03DD",
391 "disin":"\u22F2",
392 "div":"\u00F7",
393 "divide":"\u00F7",
394 "divideontimes":"\u22C7",
395 "divonx":"\u22C7",
396 "DJcy":"\u0402",
397 "djcy":"\u0452",
398 "dlcorn":"\u231E",
399 "dlcrop":"\u230D",
400 "dollar":"\u0024",
401 "Dopf":"\uD835\uDD3B",
402 "dopf":"\uD835\uDD55",
403 "Dot":"\u00A8",
404 "dot":"\u02D9",
405 "DotDot":"\u20DC",
406 "doteq":"\u2250",
407 "doteqdot":"\u2251",
408 "DotEqual":"\u2250",
409 "dotminus":"\u2238",
410 "dotplus":"\u2214",
411 "dotsquare":"\u22A1",
412 "doublebarwedge":"\u2306",
413 "DoubleContourIntegral":"\u222F",
414 "DoubleDot":"\u00A8",
415 "DoubleDownArrow":"\u21D3",
416 "DoubleLeftArrow":"\u21D0",
417 "DoubleLeftRightArrow":"\u21D4",
418 "DoubleLeftTee":"\u2AE4",
419 "DoubleLongLeftArrow":"\u27F8",
420 "DoubleLongLeftRightArrow":"\u27FA",
421 "DoubleLongRightArrow":"\u27F9",
422 "DoubleRightArrow":"\u21D2",
423 "DoubleRightTee":"\u22A8",
424 "DoubleUpArrow":"\u21D1",
425 "DoubleUpDownArrow":"\u21D5",
426 "DoubleVerticalBar":"\u2225",
427 "DownArrow":"\u2193",
428 "Downarrow":"\u21D3",
429 "downarrow":"\u2193",
430 "DownArrowBar":"\u2913",
431 "DownArrowUpArrow":"\u21F5",
432 "DownBreve":"\u0311",
433 "downdownarrows":"\u21CA",
434 "downharpoonleft":"\u21C3",
435 "downharpoonright":"\u21C2",
436 "DownLeftRightVector":"\u2950",
437 "DownLeftTeeVector":"\u295E",
438 "DownLeftVector":"\u21BD",
439 "DownLeftVectorBar":"\u2956",
440 "DownRightTeeVector":"\u295F",
441 "DownRightVector":"\u21C1",
442 "DownRightVectorBar":"\u2957",
443 "DownTee":"\u22A4",
444 "DownTeeArrow":"\u21A7",
445 "drbkarow":"\u2910",
446 "drcorn":"\u231F",
447 "drcrop":"\u230C",
448 "Dscr":"\uD835\uDC9F",
449 "dscr":"\uD835\uDCB9",
450 "DScy":"\u0405",
451 "dscy":"\u0455",
452 "dsol":"\u29F6",
453 "Dstrok":"\u0110",
454 "dstrok":"\u0111",
455 "dtdot":"\u22F1",
456 "dtri":"\u25BF",
457 "dtrif":"\u25BE",
458 "duarr":"\u21F5",
459 "duhar":"\u296F",
460 "dwangle":"\u29A6",
461 "DZcy":"\u040F",
462 "dzcy":"\u045F",
463 "dzigrarr":"\u27FF",
464 "Eacute":"\u00C9",
465 "eacute":"\u00E9",
466 "easter":"\u2A6E",
467 "Ecaron":"\u011A",
468 "ecaron":"\u011B",
469 "ecir":"\u2256",
470 "Ecirc":"\u00CA",
471 "ecirc":"\u00EA",
472 "ecolon":"\u2255",
473 "Ecy":"\u042D",
474 "ecy":"\u044D",
475 "eDDot":"\u2A77",
476 "Edot":"\u0116",
477 "eDot":"\u2251",
478 "edot":"\u0117",
479 "ee":"\u2147",
480 "efDot":"\u2252",
481 "Efr":"\uD835\uDD08",
482 "efr":"\uD835\uDD22",
483 "eg":"\u2A9A",
484 "Egrave":"\u00C8",
485 "egrave":"\u00E8",
486 "egs":"\u2A96",
487 "egsdot":"\u2A98",
488 "el":"\u2A99",
489 "Element":"\u2208",
490 "elinters":"\u23E7",
491 "ell":"\u2113",
492 "els":"\u2A95",
493 "elsdot":"\u2A97",
494 "Emacr":"\u0112",
495 "emacr":"\u0113",
496 "empty":"\u2205",
497 "emptyset":"\u2205",
498 "EmptySmallSquare":"\u25FB",
499 "emptyv":"\u2205",
500 "EmptyVerySmallSquare":"\u25AB",
501 "emsp":"\u2003",
502 "emsp13":"\u2004",
503 "emsp14":"\u2005",
504 "ENG":"\u014A",
505 "eng":"\u014B",
506 "ensp":"\u2002",
507 "Eogon":"\u0118",
508 "eogon":"\u0119",
509 "Eopf":"\uD835\uDD3C",
510 "eopf":"\uD835\uDD56",
511 "epar":"\u22D5",
512 "eparsl":"\u29E3",
513 "eplus":"\u2A71",
514 "epsi":"\u03B5",
515 "Epsilon":"\u0395",
516 "epsilon":"\u03B5",
517 "epsiv":"\u03F5",
518 "eqcirc":"\u2256",
519 "eqcolon":"\u2255",
520 "eqsim":"\u2242",
521 "eqslantgtr":"\u2A96",
522 "eqslantless":"\u2A95",
523 "Equal":"\u2A75",
524 "equals":"\u003D",
525 "EqualTilde":"\u2242",
526 "equest":"\u225F",
527 "Equilibrium":"\u21CC",
528 "equiv":"\u2261",
529 "equivDD":"\u2A78",
530 "eqvparsl":"\u29E5",
531 "erarr":"\u2971",
532 "erDot":"\u2253",
533 "Escr":"\u2130",
534 "escr":"\u212F",
535 "esdot":"\u2250",
536 "Esim":"\u2A73",
537 "esim":"\u2242",
538 "Eta":"\u0397",
539 "eta":"\u03B7",
540 "ETH":"\u00D0",
541 "eth":"\u00F0",
542 "Euml":"\u00CB",
543 "euml":"\u00EB",
544 "euro":"\u20AC",
545 "excl":"\u0021",
546 "exist":"\u2203",
547 "Exists":"\u2203",
548 "expectation":"\u2130",
549 "ExponentialE":"\u2147",
550 "exponentiale":"\u2147",
551 "fallingdotseq":"\u2252",
552 "Fcy":"\u0424",
553 "fcy":"\u0444",
554 "female":"\u2640",
555 "ffilig":"\uFB03",
556 "fflig":"\uFB00",
557 "ffllig":"\uFB04",
558 "Ffr":"\uD835\uDD09",
559 "ffr":"\uD835\uDD23",
560 "filig":"\uFB01",
561 "FilledSmallSquare":"\u25FC",
562 "FilledVerySmallSquare":"\u25AA",
563 "fjlig":"\u0066\u006A",
564 "flat":"\u266D",
565 "fllig":"\uFB02",
566 "fltns":"\u25B1",
567 "fnof":"\u0192",
568 "Fopf":"\uD835\uDD3D",
569 "fopf":"\uD835\uDD57",
570 "ForAll":"\u2200",
571 "forall":"\u2200",
572 "fork":"\u22D4",
573 "forkv":"\u2AD9",
574 "Fouriertrf":"\u2131",
575 "fpartint":"\u2A0D",
576 "frac12":"\u00BD",
577 "frac13":"\u2153",
578 "frac14":"\u00BC",
579 "frac15":"\u2155",
580 "frac16":"\u2159",
581 "frac18":"\u215B",
582 "frac23":"\u2154",
583 "frac25":"\u2156",
584 "frac34":"\u00BE",
585 "frac35":"\u2157",
586 "frac38":"\u215C",
587 "frac45":"\u2158",
588 "frac56":"\u215A",
589 "frac58":"\u215D",
590 "frac78":"\u215E",
591 "frasl":"\u2044",
592 "frown":"\u2322",
593 "Fscr":"\u2131",
594 "fscr":"\uD835\uDCBB",
595 "gacute":"\u01F5",
596 "Gamma":"\u0393",
597 "gamma":"\u03B3",
598 "Gammad":"\u03DC",
599 "gammad":"\u03DD",
600 "gap":"\u2A86",
601 "Gbreve":"\u011E",
602 "gbreve":"\u011F",
603 "Gcedil":"\u0122",
604 "Gcirc":"\u011C",
605 "gcirc":"\u011D",
606 "Gcy":"\u0413",
607 "gcy":"\u0433",
608 "Gdot":"\u0120",
609 "gdot":"\u0121",
610 "gE":"\u2267",
611 "ge":"\u2265",
612 "gEl":"\u2A8C",
613 "gel":"\u22DB",
614 "geq":"\u2265",
615 "geqq":"\u2267",
616 "geqslant":"\u2A7E",
617 "ges":"\u2A7E",
618 "gescc":"\u2AA9",
619 "gesdot":"\u2A80",
620 "gesdoto":"\u2A82",
621 "gesdotol":"\u2A84",
622 "gesl":"\u22DB\uFE00",
623 "gesles":"\u2A94",
624 "Gfr":"\uD835\uDD0A",
625 "gfr":"\uD835\uDD24",
626 "Gg":"\u22D9",
627 "gg":"\u226B",
628 "ggg":"\u22D9",
629 "gimel":"\u2137",
630 "GJcy":"\u0403",
631 "gjcy":"\u0453",
632 "gl":"\u2277",
633 "gla":"\u2AA5",
634 "glE":"\u2A92",
635 "glj":"\u2AA4",
636 "gnap":"\u2A8A",
637 "gnapprox":"\u2A8A",
638 "gnE":"\u2269",
639 "gne":"\u2A88",
640 "gneq":"\u2A88",
641 "gneqq":"\u2269",
642 "gnsim":"\u22E7",
643 "Gopf":"\uD835\uDD3E",
644 "gopf":"\uD835\uDD58",
645 "grave":"\u0060",
646 "GreaterEqual":"\u2265",
647 "GreaterEqualLess":"\u22DB",
648 "GreaterFullEqual":"\u2267",
649 "GreaterGreater":"\u2AA2",
650 "GreaterLess":"\u2277",
651 "GreaterSlantEqual":"\u2A7E",
652 "GreaterTilde":"\u2273",
653 "Gscr":"\uD835\uDCA2",
654 "gscr":"\u210A",
655 "gsim":"\u2273",
656 "gsime":"\u2A8E",
657 "gsiml":"\u2A90",
658 "GT":"\u003E",
659 "Gt":"\u226B",
660 "gt":"\u003E",
661 "gtcc":"\u2AA7",
662 "gtcir":"\u2A7A",
663 "gtdot":"\u22D7",
664 "gtlPar":"\u2995",
665 "gtquest":"\u2A7C",
666 "gtrapprox":"\u2A86",
667 "gtrarr":"\u2978",
668 "gtrdot":"\u22D7",
669 "gtreqless":"\u22DB",
670 "gtreqqless":"\u2A8C",
671 "gtrless":"\u2277",
672 "gtrsim":"\u2273",
673 "gvertneqq":"\u2269\uFE00",
674 "gvnE":"\u2269\uFE00",
675 "Hacek":"\u02C7",
676 "hairsp":"\u200A",
677 "half":"\u00BD",
678 "hamilt":"\u210B",
679 "HARDcy":"\u042A",
680 "hardcy":"\u044A",
681 "hArr":"\u21D4",
682 "harr":"\u2194",
683 "harrcir":"\u2948",
684 "harrw":"\u21AD",
685 "Hat":"\u005E",
686 "hbar":"\u210F",
687 "Hcirc":"\u0124",
688 "hcirc":"\u0125",
689 "hearts":"\u2665",
690 "heartsuit":"\u2665",
691 "hellip":"\u2026",
692 "hercon":"\u22B9",
693 "Hfr":"\u210C",
694 "hfr":"\uD835\uDD25",
695 "HilbertSpace":"\u210B",
696 "hksearow":"\u2925",
697 "hkswarow":"\u2926",
698 "hoarr":"\u21FF",
699 "homtht":"\u223B",
700 "hookleftarrow":"\u21A9",
701 "hookrightarrow":"\u21AA",
702 "Hopf":"\u210D",
703 "hopf":"\uD835\uDD59",
704 "horbar":"\u2015",
705 "HorizontalLine":"\u2500",
706 "Hscr":"\u210B",
707 "hscr":"\uD835\uDCBD",
708 "hslash":"\u210F",
709 "Hstrok":"\u0126",
710 "hstrok":"\u0127",
711 "HumpDownHump":"\u224E",
712 "HumpEqual":"\u224F",
713 "hybull":"\u2043",
714 "hyphen":"\u2010",
715 "Iacute":"\u00CD",
716 "iacute":"\u00ED",
717 "ic":"\u2063",
718 "Icirc":"\u00CE",
719 "icirc":"\u00EE",
720 "Icy":"\u0418",
721 "icy":"\u0438",
722 "Idot":"\u0130",
723 "IEcy":"\u0415",
724 "iecy":"\u0435",
725 "iexcl":"\u00A1",
726 "iff":"\u21D4",
727 "Ifr":"\u2111",
728 "ifr":"\uD835\uDD26",
729 "Igrave":"\u00CC",
730 "igrave":"\u00EC",
731 "ii":"\u2148",
732 "iiiint":"\u2A0C",
733 "iiint":"\u222D",
734 "iinfin":"\u29DC",
735 "iiota":"\u2129",
736 "IJlig":"\u0132",
737 "ijlig":"\u0133",
738 "Im":"\u2111",
739 "Imacr":"\u012A",
740 "imacr":"\u012B",
741 "image":"\u2111",
742 "ImaginaryI":"\u2148",
743 "imagline":"\u2110",
744 "imagpart":"\u2111",
745 "imath":"\u0131",
746 "imof":"\u22B7",
747 "imped":"\u01B5",
748 "Implies":"\u21D2",
749 "in":"\u2208",
750 "incare":"\u2105",
751 "infin":"\u221E",
752 "infintie":"\u29DD",
753 "inodot":"\u0131",
754 "Int":"\u222C",
755 "int":"\u222B",
756 "intcal":"\u22BA",
757 "integers":"\u2124",
758 "Integral":"\u222B",
759 "intercal":"\u22BA",
760 "Intersection":"\u22C2",
761 "intlarhk":"\u2A17",
762 "intprod":"\u2A3C",
763 "InvisibleComma":"\u2063",
764 "InvisibleTimes":"\u2062",
765 "IOcy":"\u0401",
766 "iocy":"\u0451",
767 "Iogon":"\u012E",
768 "iogon":"\u012F",
769 "Iopf":"\uD835\uDD40",
770 "iopf":"\uD835\uDD5A",
771 "Iota":"\u0399",
772 "iota":"\u03B9",
773 "iprod":"\u2A3C",
774 "iquest":"\u00BF",
775 "Iscr":"\u2110",
776 "iscr":"\uD835\uDCBE",
777 "isin":"\u2208",
778 "isindot":"\u22F5",
779 "isinE":"\u22F9",
780 "isins":"\u22F4",
781 "isinsv":"\u22F3",
782 "isinv":"\u2208",
783 "it":"\u2062",
784 "Itilde":"\u0128",
785 "itilde":"\u0129",
786 "Iukcy":"\u0406",
787 "iukcy":"\u0456",
788 "Iuml":"\u00CF",
789 "iuml":"\u00EF",
790 "Jcirc":"\u0134",
791 "jcirc":"\u0135",
792 "Jcy":"\u0419",
793 "jcy":"\u0439",
794 "Jfr":"\uD835\uDD0D",
795 "jfr":"\uD835\uDD27",
796 "jmath":"\u0237",
797 "Jopf":"\uD835\uDD41",
798 "jopf":"\uD835\uDD5B",
799 "Jscr":"\uD835\uDCA5",
800 "jscr":"\uD835\uDCBF",
801 "Jsercy":"\u0408",
802 "jsercy":"\u0458",
803 "Jukcy":"\u0404",
804 "jukcy":"\u0454",
805 "Kappa":"\u039A",
806 "kappa":"\u03BA",
807 "kappav":"\u03F0",
808 "Kcedil":"\u0136",
809 "kcedil":"\u0137",
810 "Kcy":"\u041A",
811 "kcy":"\u043A",
812 "Kfr":"\uD835\uDD0E",
813 "kfr":"\uD835\uDD28",
814 "kgreen":"\u0138",
815 "KHcy":"\u0425",
816 "khcy":"\u0445",
817 "KJcy":"\u040C",
818 "kjcy":"\u045C",
819 "Kopf":"\uD835\uDD42",
820 "kopf":"\uD835\uDD5C",
821 "Kscr":"\uD835\uDCA6",
822 "kscr":"\uD835\uDCC0",
823 "lAarr":"\u21DA",
824 "Lacute":"\u0139",
825 "lacute":"\u013A",
826 "laemptyv":"\u29B4",
827 "lagran":"\u2112",
828 "Lambda":"\u039B",
829 "lambda":"\u03BB",
830 "Lang":"\u27EA",
831 "lang":"\u27E8",
832 "langd":"\u2991",
833 "langle":"\u27E8",
834 "lap":"\u2A85",
835 "Laplacetrf":"\u2112",
836 "laquo":"\u00AB",
837 "Larr":"\u219E",
838 "lArr":"\u21D0",
839 "larr":"\u2190",
840 "larrb":"\u21E4",
841 "larrbfs":"\u291F",
842 "larrfs":"\u291D",
843 "larrhk":"\u21A9",
844 "larrlp":"\u21AB",
845 "larrpl":"\u2939",
846 "larrsim":"\u2973",
847 "larrtl":"\u21A2",
848 "lat":"\u2AAB",
849 "lAtail":"\u291B",
850 "latail":"\u2919",
851 "late":"\u2AAD",
852 "lates":"\u2AAD\uFE00",
853 "lBarr":"\u290E",
854 "lbarr":"\u290C",
855 "lbbrk":"\u2772",
856 "lbrace":"\u007B",
857 "lbrack":"\u005B",
858 "lbrke":"\u298B",
859 "lbrksld":"\u298F",
860 "lbrkslu":"\u298D",
861 "Lcaron":"\u013D",
862 "lcaron":"\u013E",
863 "Lcedil":"\u013B",
864 "lcedil":"\u013C",
865 "lceil":"\u2308",
866 "lcub":"\u007B",
867 "Lcy":"\u041B",
868 "lcy":"\u043B",
869 "ldca":"\u2936",
870 "ldquo":"\u201C",
871 "ldquor":"\u201E",
872 "ldrdhar":"\u2967",
873 "ldrushar":"\u294B",
874 "ldsh":"\u21B2",
875 "lE":"\u2266",
876 "le":"\u2264",
877 "LeftAngleBracket":"\u27E8",
878 "LeftArrow":"\u2190",
879 "Leftarrow":"\u21D0",
880 "leftarrow":"\u2190",
881 "LeftArrowBar":"\u21E4",
882 "LeftArrowRightArrow":"\u21C6",
883 "leftarrowtail":"\u21A2",
884 "LeftCeiling":"\u2308",
885 "LeftDoubleBracket":"\u27E6",
886 "LeftDownTeeVector":"\u2961",
887 "LeftDownVector":"\u21C3",
888 "LeftDownVectorBar":"\u2959",
889 "LeftFloor":"\u230A",
890 "leftharpoondown":"\u21BD",
891 "leftharpoonup":"\u21BC",
892 "leftleftarrows":"\u21C7",
893 "LeftRightArrow":"\u2194",
894 "Leftrightarrow":"\u21D4",
895 "leftrightarrow":"\u2194",
896 "leftrightarrows":"\u21C6",
897 "leftrightharpoons":"\u21CB",
898 "leftrightsquigarrow":"\u21AD",
899 "LeftRightVector":"\u294E",
900 "LeftTee":"\u22A3",
901 "LeftTeeArrow":"\u21A4",
902 "LeftTeeVector":"\u295A",
903 "leftthreetimes":"\u22CB",
904 "LeftTriangle":"\u22B2",
905 "LeftTriangleBar":"\u29CF",
906 "LeftTriangleEqual":"\u22B4",
907 "LeftUpDownVector":"\u2951",
908 "LeftUpTeeVector":"\u2960",
909 "LeftUpVector":"\u21BF",
910 "LeftUpVectorBar":"\u2958",
911 "LeftVector":"\u21BC",
912 "LeftVectorBar":"\u2952",
913 "lEg":"\u2A8B",
914 "leg":"\u22DA",
915 "leq":"\u2264",
916 "leqq":"\u2266",
917 "leqslant":"\u2A7D",
918 "les":"\u2A7D",
919 "lescc":"\u2AA8",
920 "lesdot":"\u2A7F",
921 "lesdoto":"\u2A81",
922 "lesdotor":"\u2A83",
923 "lesg":"\u22DA\uFE00",
924 "lesges":"\u2A93",
925 "lessapprox":"\u2A85",
926 "lessdot":"\u22D6",
927 "lesseqgtr":"\u22DA",
928 "lesseqqgtr":"\u2A8B",
929 "LessEqualGreater":"\u22DA",
930 "LessFullEqual":"\u2266",
931 "LessGreater":"\u2276",
932 "lessgtr":"\u2276",
933 "LessLess":"\u2AA1",
934 "lesssim":"\u2272",
935 "LessSlantEqual":"\u2A7D",
936 "LessTilde":"\u2272",
937 "lfisht":"\u297C",
938 "lfloor":"\u230A",
939 "Lfr":"\uD835\uDD0F",
940 "lfr":"\uD835\uDD29",
941 "lg":"\u2276",
942 "lgE":"\u2A91",
943 "lHar":"\u2962",
944 "lhard":"\u21BD",
945 "lharu":"\u21BC",
946 "lharul":"\u296A",
947 "lhblk":"\u2584",
948 "LJcy":"\u0409",
949 "ljcy":"\u0459",
950 "Ll":"\u22D8",
951 "ll":"\u226A",
952 "llarr":"\u21C7",
953 "llcorner":"\u231E",
954 "Lleftarrow":"\u21DA",
955 "llhard":"\u296B",
956 "lltri":"\u25FA",
957 "Lmidot":"\u013F",
958 "lmidot":"\u0140",
959 "lmoust":"\u23B0",
960 "lmoustache":"\u23B0",
961 "lnap":"\u2A89",
962 "lnapprox":"\u2A89",
963 "lnE":"\u2268",
964 "lne":"\u2A87",
965 "lneq":"\u2A87",
966 "lneqq":"\u2268",
967 "lnsim":"\u22E6",
968 "loang":"\u27EC",
969 "loarr":"\u21FD",
970 "lobrk":"\u27E6",
971 "LongLeftArrow":"\u27F5",
972 "Longleftarrow":"\u27F8",
973 "longleftarrow":"\u27F5",
974 "LongLeftRightArrow":"\u27F7",
975 "Longleftrightarrow":"\u27FA",
976 "longleftrightarrow":"\u27F7",
977 "longmapsto":"\u27FC",
978 "LongRightArrow":"\u27F6",
979 "Longrightarrow":"\u27F9",
980 "longrightarrow":"\u27F6",
981 "looparrowleft":"\u21AB",
982 "looparrowright":"\u21AC",
983 "lopar":"\u2985",
984 "Lopf":"\uD835\uDD43",
985 "lopf":"\uD835\uDD5D",
986 "loplus":"\u2A2D",
987 "lotimes":"\u2A34",
988 "lowast":"\u2217",
989 "lowbar":"\u005F",
990 "LowerLeftArrow":"\u2199",
991 "LowerRightArrow":"\u2198",
992 "loz":"\u25CA",
993 "lozenge":"\u25CA",
994 "lozf":"\u29EB",
995 "lpar":"\u0028",
996 "lparlt":"\u2993",
997 "lrarr":"\u21C6",
998 "lrcorner":"\u231F",
999 "lrhar":"\u21CB",
1000 "lrhard":"\u296D",
1001 "lrm":"\u200E",
1002 "lrtri":"\u22BF",
1003 "lsaquo":"\u2039",
1004 "Lscr":"\u2112",
1005 "lscr":"\uD835\uDCC1",
1006 "Lsh":"\u21B0",
1007 "lsh":"\u21B0",
1008 "lsim":"\u2272",
1009 "lsime":"\u2A8D",
1010 "lsimg":"\u2A8F",
1011 "lsqb":"\u005B",
1012 "lsquo":"\u2018",
1013 "lsquor":"\u201A",
1014 "Lstrok":"\u0141",
1015 "lstrok":"\u0142",
1016 "LT":"\u003C",
1017 "Lt":"\u226A",
1018 "lt":"\u003C",
1019 "ltcc":"\u2AA6",
1020 "ltcir":"\u2A79",
1021 "ltdot":"\u22D6",
1022 "lthree":"\u22CB",
1023 "ltimes":"\u22C9",
1024 "ltlarr":"\u2976",
1025 "ltquest":"\u2A7B",
1026 "ltri":"\u25C3",
1027 "ltrie":"\u22B4",
1028 "ltrif":"\u25C2",
1029 "ltrPar":"\u2996",
1030 "lurdshar":"\u294A",
1031 "luruhar":"\u2966",
1032 "lvertneqq":"\u2268\uFE00",
1033 "lvnE":"\u2268\uFE00",
1034 "macr":"\u00AF",
1035 "male":"\u2642",
1036 "malt":"\u2720",
1037 "maltese":"\u2720",
1038 "Map":"\u2905",
1039 "map":"\u21A6",
1040 "mapsto":"\u21A6",
1041 "mapstodown":"\u21A7",
1042 "mapstoleft":"\u21A4",
1043 "mapstoup":"\u21A5",
1044 "marker":"\u25AE",
1045 "mcomma":"\u2A29",
1046 "Mcy":"\u041C",
1047 "mcy":"\u043C",
1048 "mdash":"\u2014",
1049 "mDDot":"\u223A",
1050 "measuredangle":"\u2221",
1051 "MediumSpace":"\u205F",
1052 "Mellintrf":"\u2133",
1053 "Mfr":"\uD835\uDD10",
1054 "mfr":"\uD835\uDD2A",
1055 "mho":"\u2127",
1056 "micro":"\u00B5",
1057 "mid":"\u2223",
1058 "midast":"\u002A",
1059 "midcir":"\u2AF0",
1060 "middot":"\u00B7",
1061 "minus":"\u2212",
1062 "minusb":"\u229F",
1063 "minusd":"\u2238",
1064 "minusdu":"\u2A2A",
1065 "MinusPlus":"\u2213",
1066 "mlcp":"\u2ADB",
1067 "mldr":"\u2026",
1068 "mnplus":"\u2213",
1069 "models":"\u22A7",
1070 "Mopf":"\uD835\uDD44",
1071 "mopf":"\uD835\uDD5E",
1072 "mp":"\u2213",
1073 "Mscr":"\u2133",
1074 "mscr":"\uD835\uDCC2",
1075 "mstpos":"\u223E",
1076 "Mu":"\u039C",
1077 "mu":"\u03BC",
1078 "multimap":"\u22B8",
1079 "mumap":"\u22B8",
1080 "nabla":"\u2207",
1081 "Nacute":"\u0143",
1082 "nacute":"\u0144",
1083 "nang":"\u2220\u20D2",
1084 "nap":"\u2249",
1085 "napE":"\u2A70\u0338",
1086 "napid":"\u224B\u0338",
1087 "napos":"\u0149",
1088 "napprox":"\u2249",
1089 "natur":"\u266E",
1090 "natural":"\u266E",
1091 "naturals":"\u2115",
1092 "nbsp":"\u00A0",
1093 "nbump":"\u224E\u0338",
1094 "nbumpe":"\u224F\u0338",
1095 "ncap":"\u2A43",
1096 "Ncaron":"\u0147",
1097 "ncaron":"\u0148",
1098 "Ncedil":"\u0145",
1099 "ncedil":"\u0146",
1100 "ncong":"\u2247",
1101 "ncongdot":"\u2A6D\u0338",
1102 "ncup":"\u2A42",
1103 "Ncy":"\u041D",
1104 "ncy":"\u043D",
1105 "ndash":"\u2013",
1106 "ne":"\u2260",
1107 "nearhk":"\u2924",
1108 "neArr":"\u21D7",
1109 "nearr":"\u2197",
1110 "nearrow":"\u2197",
1111 "nedot":"\u2250\u0338",
1112 "NegativeMediumSpace":"\u200B",
1113 "NegativeThickSpace":"\u200B",
1114 "NegativeThinSpace":"\u200B",
1115 "NegativeVeryThinSpace":"\u200B",
1116 "nequiv":"\u2262",
1117 "nesear":"\u2928",
1118 "nesim":"\u2242\u0338",
1119 "NestedGreaterGreater":"\u226B",
1120 "NestedLessLess":"\u226A",
1121 "NewLine":"\u000A",
1122 "nexist":"\u2204",
1123 "nexists":"\u2204",
1124 "Nfr":"\uD835\uDD11",
1125 "nfr":"\uD835\uDD2B",
1126 "ngE":"\u2267\u0338",
1127 "nge":"\u2271",
1128 "ngeq":"\u2271",
1129 "ngeqq":"\u2267\u0338",
1130 "ngeqslant":"\u2A7E\u0338",
1131 "nges":"\u2A7E\u0338",
1132 "nGg":"\u22D9\u0338",
1133 "ngsim":"\u2275",
1134 "nGt":"\u226B\u20D2",
1135 "ngt":"\u226F",
1136 "ngtr":"\u226F",
1137 "nGtv":"\u226B\u0338",
1138 "nhArr":"\u21CE",
1139 "nharr":"\u21AE",
1140 "nhpar":"\u2AF2",
1141 "ni":"\u220B",
1142 "nis":"\u22FC",
1143 "nisd":"\u22FA",
1144 "niv":"\u220B",
1145 "NJcy":"\u040A",
1146 "njcy":"\u045A",
1147 "nlArr":"\u21CD",
1148 "nlarr":"\u219A",
1149 "nldr":"\u2025",
1150 "nlE":"\u2266\u0338",
1151 "nle":"\u2270",
1152 "nLeftarrow":"\u21CD",
1153 "nleftarrow":"\u219A",
1154 "nLeftrightarrow":"\u21CE",
1155 "nleftrightarrow":"\u21AE",
1156 "nleq":"\u2270",
1157 "nleqq":"\u2266\u0338",
1158 "nleqslant":"\u2A7D\u0338",
1159 "nles":"\u2A7D\u0338",
1160 "nless":"\u226E",
1161 "nLl":"\u22D8\u0338",
1162 "nlsim":"\u2274",
1163 "nLt":"\u226A\u20D2",
1164 "nlt":"\u226E",
1165 "nltri":"\u22EA",
1166 "nltrie":"\u22EC",
1167 "nLtv":"\u226A\u0338",
1168 "nmid":"\u2224",
1169 "NoBreak":"\u2060",
1170 "NonBreakingSpace":"\u00A0",
1171 "Nopf":"\u2115",
1172 "nopf":"\uD835\uDD5F",
1173 "Not":"\u2AEC",
1174 "not":"\u00AC",
1175 "NotCongruent":"\u2262",
1176 "NotCupCap":"\u226D",
1177 "NotDoubleVerticalBar":"\u2226",
1178 "NotElement":"\u2209",
1179 "NotEqual":"\u2260",
1180 "NotEqualTilde":"\u2242\u0338",
1181 "NotExists":"\u2204",
1182 "NotGreater":"\u226F",
1183 "NotGreaterEqual":"\u2271",
1184 "NotGreaterFullEqual":"\u2267\u0338",
1185 "NotGreaterGreater":"\u226B\u0338",
1186 "NotGreaterLess":"\u2279",
1187 "NotGreaterSlantEqual":"\u2A7E\u0338",
1188 "NotGreaterTilde":"\u2275",
1189 "NotHumpDownHump":"\u224E\u0338",
1190 "NotHumpEqual":"\u224F\u0338",
1191 "notin":"\u2209",
1192 "notindot":"\u22F5\u0338",
1193 "notinE":"\u22F9\u0338",
1194 "notinva":"\u2209",
1195 "notinvb":"\u22F7",
1196 "notinvc":"\u22F6",
1197 "NotLeftTriangle":"\u22EA",
1198 "NotLeftTriangleBar":"\u29CF\u0338",
1199 "NotLeftTriangleEqual":"\u22EC",
1200 "NotLess":"\u226E",
1201 "NotLessEqual":"\u2270",
1202 "NotLessGreater":"\u2278",
1203 "NotLessLess":"\u226A\u0338",
1204 "NotLessSlantEqual":"\u2A7D\u0338",
1205 "NotLessTilde":"\u2274",
1206 "NotNestedGreaterGreater":"\u2AA2\u0338",
1207 "NotNestedLessLess":"\u2AA1\u0338",
1208 "notni":"\u220C",
1209 "notniva":"\u220C",
1210 "notnivb":"\u22FE",
1211 "notnivc":"\u22FD",
1212 "NotPrecedes":"\u2280",
1213 "NotPrecedesEqual":"\u2AAF\u0338",
1214 "NotPrecedesSlantEqual":"\u22E0",
1215 "NotReverseElement":"\u220C",
1216 "NotRightTriangle":"\u22EB",
1217 "NotRightTriangleBar":"\u29D0\u0338",
1218 "NotRightTriangleEqual":"\u22ED",
1219 "NotSquareSubset":"\u228F\u0338",
1220 "NotSquareSubsetEqual":"\u22E2",
1221 "NotSquareSuperset":"\u2290\u0338",
1222 "NotSquareSupersetEqual":"\u22E3",
1223 "NotSubset":"\u2282\u20D2",
1224 "NotSubsetEqual":"\u2288",
1225 "NotSucceeds":"\u2281",
1226 "NotSucceedsEqual":"\u2AB0\u0338",
1227 "NotSucceedsSlantEqual":"\u22E1",
1228 "NotSucceedsTilde":"\u227F\u0338",
1229 "NotSuperset":"\u2283\u20D2",
1230 "NotSupersetEqual":"\u2289",
1231 "NotTilde":"\u2241",
1232 "NotTildeEqual":"\u2244",
1233 "NotTildeFullEqual":"\u2247",
1234 "NotTildeTilde":"\u2249",
1235 "NotVerticalBar":"\u2224",
1236 "npar":"\u2226",
1237 "nparallel":"\u2226",
1238 "nparsl":"\u2AFD\u20E5",
1239 "npart":"\u2202\u0338",
1240 "npolint":"\u2A14",
1241 "npr":"\u2280",
1242 "nprcue":"\u22E0",
1243 "npre":"\u2AAF\u0338",
1244 "nprec":"\u2280",
1245 "npreceq":"\u2AAF\u0338",
1246 "nrArr":"\u21CF",
1247 "nrarr":"\u219B",
1248 "nrarrc":"\u2933\u0338",
1249 "nrarrw":"\u219D\u0338",
1250 "nRightarrow":"\u21CF",
1251 "nrightarrow":"\u219B",
1252 "nrtri":"\u22EB",
1253 "nrtrie":"\u22ED",
1254 "nsc":"\u2281",
1255 "nsccue":"\u22E1",
1256 "nsce":"\u2AB0\u0338",
1257 "Nscr":"\uD835\uDCA9",
1258 "nscr":"\uD835\uDCC3",
1259 "nshortmid":"\u2224",
1260 "nshortparallel":"\u2226",
1261 "nsim":"\u2241",
1262 "nsime":"\u2244",
1263 "nsimeq":"\u2244",
1264 "nsmid":"\u2224",
1265 "nspar":"\u2226",
1266 "nsqsube":"\u22E2",
1267 "nsqsupe":"\u22E3",
1268 "nsub":"\u2284",
1269 "nsubE":"\u2AC5\u0338",
1270 "nsube":"\u2288",
1271 "nsubset":"\u2282\u20D2",
1272 "nsubseteq":"\u2288",
1273 "nsubseteqq":"\u2AC5\u0338",
1274 "nsucc":"\u2281",
1275 "nsucceq":"\u2AB0\u0338",
1276 "nsup":"\u2285",
1277 "nsupE":"\u2AC6\u0338",
1278 "nsupe":"\u2289",
1279 "nsupset":"\u2283\u20D2",
1280 "nsupseteq":"\u2289",
1281 "nsupseteqq":"\u2AC6\u0338",
1282 "ntgl":"\u2279",
1283 "Ntilde":"\u00D1",
1284 "ntilde":"\u00F1",
1285 "ntlg":"\u2278",
1286 "ntriangleleft":"\u22EA",
1287 "ntrianglelefteq":"\u22EC",
1288 "ntriangleright":"\u22EB",
1289 "ntrianglerighteq":"\u22ED",
1290 "Nu":"\u039D",
1291 "nu":"\u03BD",
1292 "num":"\u0023",
1293 "numero":"\u2116",
1294 "numsp":"\u2007",
1295 "nvap":"\u224D\u20D2",
1296 "nVDash":"\u22AF",
1297 "nVdash":"\u22AE",
1298 "nvDash":"\u22AD",
1299 "nvdash":"\u22AC",
1300 "nvge":"\u2265\u20D2",
1301 "nvgt":"\u003E\u20D2",
1302 "nvHarr":"\u2904",
1303 "nvinfin":"\u29DE",
1304 "nvlArr":"\u2902",
1305 "nvle":"\u2264\u20D2",
1306 "nvlt":"\u003C\u20D2",
1307 "nvltrie":"\u22B4\u20D2",
1308 "nvrArr":"\u2903",
1309 "nvrtrie":"\u22B5\u20D2",
1310 "nvsim":"\u223C\u20D2",
1311 "nwarhk":"\u2923",
1312 "nwArr":"\u21D6",
1313 "nwarr":"\u2196",
1314 "nwarrow":"\u2196",
1315 "nwnear":"\u2927",
1316 "Oacute":"\u00D3",
1317 "oacute":"\u00F3",
1318 "oast":"\u229B",
1319 "ocir":"\u229A",
1320 "Ocirc":"\u00D4",
1321 "ocirc":"\u00F4",
1322 "Ocy":"\u041E",
1323 "ocy":"\u043E",
1324 "odash":"\u229D",
1325 "Odblac":"\u0150",
1326 "odblac":"\u0151",
1327 "odiv":"\u2A38",
1328 "odot":"\u2299",
1329 "odsold":"\u29BC",
1330 "OElig":"\u0152",
1331 "oelig":"\u0153",
1332 "ofcir":"\u29BF",
1333 "Ofr":"\uD835\uDD12",
1334 "ofr":"\uD835\uDD2C",
1335 "ogon":"\u02DB",
1336 "Ograve":"\u00D2",
1337 "ograve":"\u00F2",
1338 "ogt":"\u29C1",
1339 "ohbar":"\u29B5",
1340 "ohm":"\u03A9",
1341 "oint":"\u222E",
1342 "olarr":"\u21BA",
1343 "olcir":"\u29BE",
1344 "olcross":"\u29BB",
1345 "oline":"\u203E",
1346 "olt":"\u29C0",
1347 "Omacr":"\u014C",
1348 "omacr":"\u014D",
1349 "Omega":"\u03A9",
1350 "omega":"\u03C9",
1351 "Omicron":"\u039F",
1352 "omicron":"\u03BF",
1353 "omid":"\u29B6",
1354 "ominus":"\u2296",
1355 "Oopf":"\uD835\uDD46",
1356 "oopf":"\uD835\uDD60",
1357 "opar":"\u29B7",
1358 "OpenCurlyDoubleQuote":"\u201C",
1359 "OpenCurlyQuote":"\u2018",
1360 "operp":"\u29B9",
1361 "oplus":"\u2295",
1362 "Or":"\u2A54",
1363 "or":"\u2228",
1364 "orarr":"\u21BB",
1365 "ord":"\u2A5D",
1366 "order":"\u2134",
1367 "orderof":"\u2134",
1368 "ordf":"\u00AA",
1369 "ordm":"\u00BA",
1370 "origof":"\u22B6",
1371 "oror":"\u2A56",
1372 "orslope":"\u2A57",
1373 "orv":"\u2A5B",
1374 "oS":"\u24C8",
1375 "Oscr":"\uD835\uDCAA",
1376 "oscr":"\u2134",
1377 "Oslash":"\u00D8",
1378 "oslash":"\u00F8",
1379 "osol":"\u2298",
1380 "Otilde":"\u00D5",
1381 "otilde":"\u00F5",
1382 "Otimes":"\u2A37",
1383 "otimes":"\u2297",
1384 "otimesas":"\u2A36",
1385 "Ouml":"\u00D6",
1386 "ouml":"\u00F6",
1387 "ovbar":"\u233D",
1388 "OverBar":"\u203E",
1389 "OverBrace":"\u23DE",
1390 "OverBracket":"\u23B4",
1391 "OverParenthesis":"\u23DC",
1392 "par":"\u2225",
1393 "para":"\u00B6",
1394 "parallel":"\u2225",
1395 "parsim":"\u2AF3",
1396 "parsl":"\u2AFD",
1397 "part":"\u2202",
1398 "PartialD":"\u2202",
1399 "Pcy":"\u041F",
1400 "pcy":"\u043F",
1401 "percnt":"\u0025",
1402 "period":"\u002E",
1403 "permil":"\u2030",
1404 "perp":"\u22A5",
1405 "pertenk":"\u2031",
1406 "Pfr":"\uD835\uDD13",
1407 "pfr":"\uD835\uDD2D",
1408 "Phi":"\u03A6",
1409 "phi":"\u03C6",
1410 "phiv":"\u03D5",
1411 "phmmat":"\u2133",
1412 "phone":"\u260E",
1413 "Pi":"\u03A0",
1414 "pi":"\u03C0",
1415 "pitchfork":"\u22D4",
1416 "piv":"\u03D6",
1417 "planck":"\u210F",
1418 "planckh":"\u210E",
1419 "plankv":"\u210F",
1420 "plus":"\u002B",
1421 "plusacir":"\u2A23",
1422 "plusb":"\u229E",
1423 "pluscir":"\u2A22",
1424 "plusdo":"\u2214",
1425 "plusdu":"\u2A25",
1426 "pluse":"\u2A72",
1427 "PlusMinus":"\u00B1",
1428 "plusmn":"\u00B1",
1429 "plussim":"\u2A26",
1430 "plustwo":"\u2A27",
1431 "pm":"\u00B1",
1432 "Poincareplane":"\u210C",
1433 "pointint":"\u2A15",
1434 "Popf":"\u2119",
1435 "popf":"\uD835\uDD61",
1436 "pound":"\u00A3",
1437 "Pr":"\u2ABB",
1438 "pr":"\u227A",
1439 "prap":"\u2AB7",
1440 "prcue":"\u227C",
1441 "prE":"\u2AB3",
1442 "pre":"\u2AAF",
1443 "prec":"\u227A",
1444 "precapprox":"\u2AB7",
1445 "preccurlyeq":"\u227C",
1446 "Precedes":"\u227A",
1447 "PrecedesEqual":"\u2AAF",
1448 "PrecedesSlantEqual":"\u227C",
1449 "PrecedesTilde":"\u227E",
1450 "preceq":"\u2AAF",
1451 "precnapprox":"\u2AB9",
1452 "precneqq":"\u2AB5",
1453 "precnsim":"\u22E8",
1454 "precsim":"\u227E",
1455 "Prime":"\u2033",
1456 "prime":"\u2032",
1457 "primes":"\u2119",
1458 "prnap":"\u2AB9",
1459 "prnE":"\u2AB5",
1460 "prnsim":"\u22E8",
1461 "prod":"\u220F",
1462 "Product":"\u220F",
1463 "profalar":"\u232E",
1464 "profline":"\u2312",
1465 "profsurf":"\u2313",
1466 "prop":"\u221D",
1467 "Proportion":"\u2237",
1468 "Proportional":"\u221D",
1469 "propto":"\u221D",
1470 "prsim":"\u227E",
1471 "prurel":"\u22B0",
1472 "Pscr":"\uD835\uDCAB",
1473 "pscr":"\uD835\uDCC5",
1474 "Psi":"\u03A8",
1475 "psi":"\u03C8",
1476 "puncsp":"\u2008",
1477 "Qfr":"\uD835\uDD14",
1478 "qfr":"\uD835\uDD2E",
1479 "qint":"\u2A0C",
1480 "Qopf":"\u211A",
1481 "qopf":"\uD835\uDD62",
1482 "qprime":"\u2057",
1483 "Qscr":"\uD835\uDCAC",
1484 "qscr":"\uD835\uDCC6",
1485 "quaternions":"\u210D",
1486 "quatint":"\u2A16",
1487 "quest":"\u003F",
1488 "questeq":"\u225F",
1489 "QUOT":"\u0022",
1490 "quot":"\u0022",
1491 "rAarr":"\u21DB",
1492 "race":"\u223D\u0331",
1493 "Racute":"\u0154",
1494 "racute":"\u0155",
1495 "radic":"\u221A",
1496 "raemptyv":"\u29B3",
1497 "Rang":"\u27EB",
1498 "rang":"\u27E9",
1499 "rangd":"\u2992",
1500 "range":"\u29A5",
1501 "rangle":"\u27E9",
1502 "raquo":"\u00BB",
1503 "Rarr":"\u21A0",
1504 "rArr":"\u21D2",
1505 "rarr":"\u2192",
1506 "rarrap":"\u2975",
1507 "rarrb":"\u21E5",
1508 "rarrbfs":"\u2920",
1509 "rarrc":"\u2933",
1510 "rarrfs":"\u291E",
1511 "rarrhk":"\u21AA",
1512 "rarrlp":"\u21AC",
1513 "rarrpl":"\u2945",
1514 "rarrsim":"\u2974",
1515 "Rarrtl":"\u2916",
1516 "rarrtl":"\u21A3",
1517 "rarrw":"\u219D",
1518 "rAtail":"\u291C",
1519 "ratail":"\u291A",
1520 "ratio":"\u2236",
1521 "rationals":"\u211A",
1522 "RBarr":"\u2910",
1523 "rBarr":"\u290F",
1524 "rbarr":"\u290D",
1525 "rbbrk":"\u2773",
1526 "rbrace":"\u007D",
1527 "rbrack":"\u005D",
1528 "rbrke":"\u298C",
1529 "rbrksld":"\u298E",
1530 "rbrkslu":"\u2990",
1531 "Rcaron":"\u0158",
1532 "rcaron":"\u0159",
1533 "Rcedil":"\u0156",
1534 "rcedil":"\u0157",
1535 "rceil":"\u2309",
1536 "rcub":"\u007D",
1537 "Rcy":"\u0420",
1538 "rcy":"\u0440",
1539 "rdca":"\u2937",
1540 "rdldhar":"\u2969",
1541 "rdquo":"\u201D",
1542 "rdquor":"\u201D",
1543 "rdsh":"\u21B3",
1544 "Re":"\u211C",
1545 "real":"\u211C",
1546 "realine":"\u211B",
1547 "realpart":"\u211C",
1548 "reals":"\u211D",
1549 "rect":"\u25AD",
1550 "REG":"\u00AE",
1551 "reg":"\u00AE",
1552 "ReverseElement":"\u220B",
1553 "ReverseEquilibrium":"\u21CB",
1554 "ReverseUpEquilibrium":"\u296F",
1555 "rfisht":"\u297D",
1556 "rfloor":"\u230B",
1557 "Rfr":"\u211C",
1558 "rfr":"\uD835\uDD2F",
1559 "rHar":"\u2964",
1560 "rhard":"\u21C1",
1561 "rharu":"\u21C0",
1562 "rharul":"\u296C",
1563 "Rho":"\u03A1",
1564 "rho":"\u03C1",
1565 "rhov":"\u03F1",
1566 "RightAngleBracket":"\u27E9",
1567 "RightArrow":"\u2192",
1568 "Rightarrow":"\u21D2",
1569 "rightarrow":"\u2192",
1570 "RightArrowBar":"\u21E5",
1571 "RightArrowLeftArrow":"\u21C4",
1572 "rightarrowtail":"\u21A3",
1573 "RightCeiling":"\u2309",
1574 "RightDoubleBracket":"\u27E7",
1575 "RightDownTeeVector":"\u295D",
1576 "RightDownVector":"\u21C2",
1577 "RightDownVectorBar":"\u2955",
1578 "RightFloor":"\u230B",
1579 "rightharpoondown":"\u21C1",
1580 "rightharpoonup":"\u21C0",
1581 "rightleftarrows":"\u21C4",
1582 "rightleftharpoons":"\u21CC",
1583 "rightrightarrows":"\u21C9",
1584 "rightsquigarrow":"\u219D",
1585 "RightTee":"\u22A2",
1586 "RightTeeArrow":"\u21A6",
1587 "RightTeeVector":"\u295B",
1588 "rightthreetimes":"\u22CC",
1589 "RightTriangle":"\u22B3",
1590 "RightTriangleBar":"\u29D0",
1591 "RightTriangleEqual":"\u22B5",
1592 "RightUpDownVector":"\u294F",
1593 "RightUpTeeVector":"\u295C",
1594 "RightUpVector":"\u21BE",
1595 "RightUpVectorBar":"\u2954",
1596 "RightVector":"\u21C0",
1597 "RightVectorBar":"\u2953",
1598 "ring":"\u02DA",
1599 "risingdotseq":"\u2253",
1600 "rlarr":"\u21C4",
1601 "rlhar":"\u21CC",
1602 "rlm":"\u200F",
1603 "rmoust":"\u23B1",
1604 "rmoustache":"\u23B1",
1605 "rnmid":"\u2AEE",
1606 "roang":"\u27ED",
1607 "roarr":"\u21FE",
1608 "robrk":"\u27E7",
1609 "ropar":"\u2986",
1610 "Ropf":"\u211D",
1611 "ropf":"\uD835\uDD63",
1612 "roplus":"\u2A2E",
1613 "rotimes":"\u2A35",
1614 "RoundImplies":"\u2970",
1615 "rpar":"\u0029",
1616 "rpargt":"\u2994",
1617 "rppolint":"\u2A12",
1618 "rrarr":"\u21C9",
1619 "Rrightarrow":"\u21DB",
1620 "rsaquo":"\u203A",
1621 "Rscr":"\u211B",
1622 "rscr":"\uD835\uDCC7",
1623 "Rsh":"\u21B1",
1624 "rsh":"\u21B1",
1625 "rsqb":"\u005D",
1626 "rsquo":"\u2019",
1627 "rsquor":"\u2019",
1628 "rthree":"\u22CC",
1629 "rtimes":"\u22CA",
1630 "rtri":"\u25B9",
1631 "rtrie":"\u22B5",
1632 "rtrif":"\u25B8",
1633 "rtriltri":"\u29CE",
1634 "RuleDelayed":"\u29F4",
1635 "ruluhar":"\u2968",
1636 "rx":"\u211E",
1637 "Sacute":"\u015A",
1638 "sacute":"\u015B",
1639 "sbquo":"\u201A",
1640 "Sc":"\u2ABC",
1641 "sc":"\u227B",
1642 "scap":"\u2AB8",
1643 "Scaron":"\u0160",
1644 "scaron":"\u0161",
1645 "sccue":"\u227D",
1646 "scE":"\u2AB4",
1647 "sce":"\u2AB0",
1648 "Scedil":"\u015E",
1649 "scedil":"\u015F",
1650 "Scirc":"\u015C",
1651 "scirc":"\u015D",
1652 "scnap":"\u2ABA",
1653 "scnE":"\u2AB6",
1654 "scnsim":"\u22E9",
1655 "scpolint":"\u2A13",
1656 "scsim":"\u227F",
1657 "Scy":"\u0421",
1658 "scy":"\u0441",
1659 "sdot":"\u22C5",
1660 "sdotb":"\u22A1",
1661 "sdote":"\u2A66",
1662 "searhk":"\u2925",
1663 "seArr":"\u21D8",
1664 "searr":"\u2198",
1665 "searrow":"\u2198",
1666 "sect":"\u00A7",
1667 "semi":"\u003B",
1668 "seswar":"\u2929",
1669 "setminus":"\u2216",
1670 "setmn":"\u2216",
1671 "sext":"\u2736",
1672 "Sfr":"\uD835\uDD16",
1673 "sfr":"\uD835\uDD30",
1674 "sfrown":"\u2322",
1675 "sharp":"\u266F",
1676 "SHCHcy":"\u0429",
1677 "shchcy":"\u0449",
1678 "SHcy":"\u0428",
1679 "shcy":"\u0448",
1680 "ShortDownArrow":"\u2193",
1681 "ShortLeftArrow":"\u2190",
1682 "shortmid":"\u2223",
1683 "shortparallel":"\u2225",
1684 "ShortRightArrow":"\u2192",
1685 "ShortUpArrow":"\u2191",
1686 "shy":"\u00AD",
1687 "Sigma":"\u03A3",
1688 "sigma":"\u03C3",
1689 "sigmaf":"\u03C2",
1690 "sigmav":"\u03C2",
1691 "sim":"\u223C",
1692 "simdot":"\u2A6A",
1693 "sime":"\u2243",
1694 "simeq":"\u2243",
1695 "simg":"\u2A9E",
1696 "simgE":"\u2AA0",
1697 "siml":"\u2A9D",
1698 "simlE":"\u2A9F",
1699 "simne":"\u2246",
1700 "simplus":"\u2A24",
1701 "simrarr":"\u2972",
1702 "slarr":"\u2190",
1703 "SmallCircle":"\u2218",
1704 "smallsetminus":"\u2216",
1705 "smashp":"\u2A33",
1706 "smeparsl":"\u29E4",
1707 "smid":"\u2223",
1708 "smile":"\u2323",
1709 "smt":"\u2AAA",
1710 "smte":"\u2AAC",
1711 "smtes":"\u2AAC\uFE00",
1712 "SOFTcy":"\u042C",
1713 "softcy":"\u044C",
1714 "sol":"\u002F",
1715 "solb":"\u29C4",
1716 "solbar":"\u233F",
1717 "Sopf":"\uD835\uDD4A",
1718 "sopf":"\uD835\uDD64",
1719 "spades":"\u2660",
1720 "spadesuit":"\u2660",
1721 "spar":"\u2225",
1722 "sqcap":"\u2293",
1723 "sqcaps":"\u2293\uFE00",
1724 "sqcup":"\u2294",
1725 "sqcups":"\u2294\uFE00",
1726 "Sqrt":"\u221A",
1727 "sqsub":"\u228F",
1728 "sqsube":"\u2291",
1729 "sqsubset":"\u228F",
1730 "sqsubseteq":"\u2291",
1731 "sqsup":"\u2290",
1732 "sqsupe":"\u2292",
1733 "sqsupset":"\u2290",
1734 "sqsupseteq":"\u2292",
1735 "squ":"\u25A1",
1736 "Square":"\u25A1",
1737 "square":"\u25A1",
1738 "SquareIntersection":"\u2293",
1739 "SquareSubset":"\u228F",
1740 "SquareSubsetEqual":"\u2291",
1741 "SquareSuperset":"\u2290",
1742 "SquareSupersetEqual":"\u2292",
1743 "SquareUnion":"\u2294",
1744 "squarf":"\u25AA",
1745 "squf":"\u25AA",
1746 "srarr":"\u2192",
1747 "Sscr":"\uD835\uDCAE",
1748 "sscr":"\uD835\uDCC8",
1749 "ssetmn":"\u2216",
1750 "ssmile":"\u2323",
1751 "sstarf":"\u22C6",
1752 "Star":"\u22C6",
1753 "star":"\u2606",
1754 "starf":"\u2605",
1755 "straightepsilon":"\u03F5",
1756 "straightphi":"\u03D5",
1757 "strns":"\u00AF",
1758 "Sub":"\u22D0",
1759 "sub":"\u2282",
1760 "subdot":"\u2ABD",
1761 "subE":"\u2AC5",
1762 "sube":"\u2286",
1763 "subedot":"\u2AC3",
1764 "submult":"\u2AC1",
1765 "subnE":"\u2ACB",
1766 "subne":"\u228A",
1767 "subplus":"\u2ABF",
1768 "subrarr":"\u2979",
1769 "Subset":"\u22D0",
1770 "subset":"\u2282",
1771 "subseteq":"\u2286",
1772 "subseteqq":"\u2AC5",
1773 "SubsetEqual":"\u2286",
1774 "subsetneq":"\u228A",
1775 "subsetneqq":"\u2ACB",
1776 "subsim":"\u2AC7",
1777 "subsub":"\u2AD5",
1778 "subsup":"\u2AD3",
1779 "succ":"\u227B",
1780 "succapprox":"\u2AB8",
1781 "succcurlyeq":"\u227D",
1782 "Succeeds":"\u227B",
1783 "SucceedsEqual":"\u2AB0",
1784 "SucceedsSlantEqual":"\u227D",
1785 "SucceedsTilde":"\u227F",
1786 "succeq":"\u2AB0",
1787 "succnapprox":"\u2ABA",
1788 "succneqq":"\u2AB6",
1789 "succnsim":"\u22E9",
1790 "succsim":"\u227F",
1791 "SuchThat":"\u220B",
1792 "Sum":"\u2211",
1793 "sum":"\u2211",
1794 "sung":"\u266A",
1795 "Sup":"\u22D1",
1796 "sup":"\u2283",
1797 "sup1":"\u00B9",
1798 "sup2":"\u00B2",
1799 "sup3":"\u00B3",
1800 "supdot":"\u2ABE",
1801 "supdsub":"\u2AD8",
1802 "supE":"\u2AC6",
1803 "supe":"\u2287",
1804 "supedot":"\u2AC4",
1805 "Superset":"\u2283",
1806 "SupersetEqual":"\u2287",
1807 "suphsol":"\u27C9",
1808 "suphsub":"\u2AD7",
1809 "suplarr":"\u297B",
1810 "supmult":"\u2AC2",
1811 "supnE":"\u2ACC",
1812 "supne":"\u228B",
1813 "supplus":"\u2AC0",
1814 "Supset":"\u22D1",
1815 "supset":"\u2283",
1816 "supseteq":"\u2287",
1817 "supseteqq":"\u2AC6",
1818 "supsetneq":"\u228B",
1819 "supsetneqq":"\u2ACC",
1820 "supsim":"\u2AC8",
1821 "supsub":"\u2AD4",
1822 "supsup":"\u2AD6",
1823 "swarhk":"\u2926",
1824 "swArr":"\u21D9",
1825 "swarr":"\u2199",
1826 "swarrow":"\u2199",
1827 "swnwar":"\u292A",
1828 "szlig":"\u00DF",
1829 "Tab":"\u0009",
1830 "target":"\u2316",
1831 "Tau":"\u03A4",
1832 "tau":"\u03C4",
1833 "tbrk":"\u23B4",
1834 "Tcaron":"\u0164",
1835 "tcaron":"\u0165",
1836 "Tcedil":"\u0162",
1837 "tcedil":"\u0163",
1838 "Tcy":"\u0422",
1839 "tcy":"\u0442",
1840 "tdot":"\u20DB",
1841 "telrec":"\u2315",
1842 "Tfr":"\uD835\uDD17",
1843 "tfr":"\uD835\uDD31",
1844 "there4":"\u2234",
1845 "Therefore":"\u2234",
1846 "therefore":"\u2234",
1847 "Theta":"\u0398",
1848 "theta":"\u03B8",
1849 "thetasym":"\u03D1",
1850 "thetav":"\u03D1",
1851 "thickapprox":"\u2248",
1852 "thicksim":"\u223C",
1853 "ThickSpace":"\u205F\u200A",
1854 "thinsp":"\u2009",
1855 "ThinSpace":"\u2009",
1856 "thkap":"\u2248",
1857 "thksim":"\u223C",
1858 "THORN":"\u00DE",
1859 "thorn":"\u00FE",
1860 "Tilde":"\u223C",
1861 "tilde":"\u02DC",
1862 "TildeEqual":"\u2243",
1863 "TildeFullEqual":"\u2245",
1864 "TildeTilde":"\u2248",
1865 "times":"\u00D7",
1866 "timesb":"\u22A0",
1867 "timesbar":"\u2A31",
1868 "timesd":"\u2A30",
1869 "tint":"\u222D",
1870 "toea":"\u2928",
1871 "top":"\u22A4",
1872 "topbot":"\u2336",
1873 "topcir":"\u2AF1",
1874 "Topf":"\uD835\uDD4B",
1875 "topf":"\uD835\uDD65",
1876 "topfork":"\u2ADA",
1877 "tosa":"\u2929",
1878 "tprime":"\u2034",
1879 "TRADE":"\u2122",
1880 "trade":"\u2122",
1881 "triangle":"\u25B5",
1882 "triangledown":"\u25BF",
1883 "triangleleft":"\u25C3",
1884 "trianglelefteq":"\u22B4",
1885 "triangleq":"\u225C",
1886 "triangleright":"\u25B9",
1887 "trianglerighteq":"\u22B5",
1888 "tridot":"\u25EC",
1889 "trie":"\u225C",
1890 "triminus":"\u2A3A",
1891 "TripleDot":"\u20DB",
1892 "triplus":"\u2A39",
1893 "trisb":"\u29CD",
1894 "tritime":"\u2A3B",
1895 "trpezium":"\u23E2",
1896 "Tscr":"\uD835\uDCAF",
1897 "tscr":"\uD835\uDCC9",
1898 "TScy":"\u0426",
1899 "tscy":"\u0446",
1900 "TSHcy":"\u040B",
1901 "tshcy":"\u045B",
1902 "Tstrok":"\u0166",
1903 "tstrok":"\u0167",
1904 "twixt":"\u226C",
1905 "twoheadleftarrow":"\u219E",
1906 "twoheadrightarrow":"\u21A0",
1907 "Uacute":"\u00DA",
1908 "uacute":"\u00FA",
1909 "Uarr":"\u219F",
1910 "uArr":"\u21D1",
1911 "uarr":"\u2191",
1912 "Uarrocir":"\u2949",
1913 "Ubrcy":"\u040E",
1914 "ubrcy":"\u045E",
1915 "Ubreve":"\u016C",
1916 "ubreve":"\u016D",
1917 "Ucirc":"\u00DB",
1918 "ucirc":"\u00FB",
1919 "Ucy":"\u0423",
1920 "ucy":"\u0443",
1921 "udarr":"\u21C5",
1922 "Udblac":"\u0170",
1923 "udblac":"\u0171",
1924 "udhar":"\u296E",
1925 "ufisht":"\u297E",
1926 "Ufr":"\uD835\uDD18",
1927 "ufr":"\uD835\uDD32",
1928 "Ugrave":"\u00D9",
1929 "ugrave":"\u00F9",
1930 "uHar":"\u2963",
1931 "uharl":"\u21BF",
1932 "uharr":"\u21BE",
1933 "uhblk":"\u2580",
1934 "ulcorn":"\u231C",
1935 "ulcorner":"\u231C",
1936 "ulcrop":"\u230F",
1937 "ultri":"\u25F8",
1938 "Umacr":"\u016A",
1939 "umacr":"\u016B",
1940 "uml":"\u00A8",
1941 "UnderBar":"\u005F",
1942 "UnderBrace":"\u23DF",
1943 "UnderBracket":"\u23B5",
1944 "UnderParenthesis":"\u23DD",
1945 "Union":"\u22C3",
1946 "UnionPlus":"\u228E",
1947 "Uogon":"\u0172",
1948 "uogon":"\u0173",
1949 "Uopf":"\uD835\uDD4C",
1950 "uopf":"\uD835\uDD66",
1951 "UpArrow":"\u2191",
1952 "Uparrow":"\u21D1",
1953 "uparrow":"\u2191",
1954 "UpArrowBar":"\u2912",
1955 "UpArrowDownArrow":"\u21C5",
1956 "UpDownArrow":"\u2195",
1957 "Updownarrow":"\u21D5",
1958 "updownarrow":"\u2195",
1959 "UpEquilibrium":"\u296E",
1960 "upharpoonleft":"\u21BF",
1961 "upharpoonright":"\u21BE",
1962 "uplus":"\u228E",
1963 "UpperLeftArrow":"\u2196",
1964 "UpperRightArrow":"\u2197",
1965 "Upsi":"\u03D2",
1966 "upsi":"\u03C5",
1967 "upsih":"\u03D2",
1968 "Upsilon":"\u03A5",
1969 "upsilon":"\u03C5",
1970 "UpTee":"\u22A5",
1971 "UpTeeArrow":"\u21A5",
1972 "upuparrows":"\u21C8",
1973 "urcorn":"\u231D",
1974 "urcorner":"\u231D",
1975 "urcrop":"\u230E",
1976 "Uring":"\u016E",
1977 "uring":"\u016F",
1978 "urtri":"\u25F9",
1979 "Uscr":"\uD835\uDCB0",
1980 "uscr":"\uD835\uDCCA",
1981 "utdot":"\u22F0",
1982 "Utilde":"\u0168",
1983 "utilde":"\u0169",
1984 "utri":"\u25B5",
1985 "utrif":"\u25B4",
1986 "uuarr":"\u21C8",
1987 "Uuml":"\u00DC",
1988 "uuml":"\u00FC",
1989 "uwangle":"\u29A7",
1990 "vangrt":"\u299C",
1991 "varepsilon":"\u03F5",
1992 "varkappa":"\u03F0",
1993 "varnothing":"\u2205",
1994 "varphi":"\u03D5",
1995 "varpi":"\u03D6",
1996 "varpropto":"\u221D",
1997 "vArr":"\u21D5",
1998 "varr":"\u2195",
1999 "varrho":"\u03F1",
2000 "varsigma":"\u03C2",
2001 "varsubsetneq":"\u228A\uFE00",
2002 "varsubsetneqq":"\u2ACB\uFE00",
2003 "varsupsetneq":"\u228B\uFE00",
2004 "varsupsetneqq":"\u2ACC\uFE00",
2005 "vartheta":"\u03D1",
2006 "vartriangleleft":"\u22B2",
2007 "vartriangleright":"\u22B3",
2008 "Vbar":"\u2AEB",
2009 "vBar":"\u2AE8",
2010 "vBarv":"\u2AE9",
2011 "Vcy":"\u0412",
2012 "vcy":"\u0432",
2013 "VDash":"\u22AB",
2014 "Vdash":"\u22A9",
2015 "vDash":"\u22A8",
2016 "vdash":"\u22A2",
2017 "Vdashl":"\u2AE6",
2018 "Vee":"\u22C1",
2019 "vee":"\u2228",
2020 "veebar":"\u22BB",
2021 "veeeq":"\u225A",
2022 "vellip":"\u22EE",
2023 "Verbar":"\u2016",
2024 "verbar":"\u007C",
2025 "Vert":"\u2016",
2026 "vert":"\u007C",
2027 "VerticalBar":"\u2223",
2028 "VerticalLine":"\u007C",
2029 "VerticalSeparator":"\u2758",
2030 "VerticalTilde":"\u2240",
2031 "VeryThinSpace":"\u200A",
2032 "Vfr":"\uD835\uDD19",
2033 "vfr":"\uD835\uDD33",
2034 "vltri":"\u22B2",
2035 "vnsub":"\u2282\u20D2",
2036 "vnsup":"\u2283\u20D2",
2037 "Vopf":"\uD835\uDD4D",
2038 "vopf":"\uD835\uDD67",
2039 "vprop":"\u221D",
2040 "vrtri":"\u22B3",
2041 "Vscr":"\uD835\uDCB1",
2042 "vscr":"\uD835\uDCCB",
2043 "vsubnE":"\u2ACB\uFE00",
2044 "vsubne":"\u228A\uFE00",
2045 "vsupnE":"\u2ACC\uFE00",
2046 "vsupne":"\u228B\uFE00",
2047 "Vvdash":"\u22AA",
2048 "vzigzag":"\u299A",
2049 "Wcirc":"\u0174",
2050 "wcirc":"\u0175",
2051 "wedbar":"\u2A5F",
2052 "Wedge":"\u22C0",
2053 "wedge":"\u2227",
2054 "wedgeq":"\u2259",
2055 "weierp":"\u2118",
2056 "Wfr":"\uD835\uDD1A",
2057 "wfr":"\uD835\uDD34",
2058 "Wopf":"\uD835\uDD4E",
2059 "wopf":"\uD835\uDD68",
2060 "wp":"\u2118",
2061 "wr":"\u2240",
2062 "wreath":"\u2240",
2063 "Wscr":"\uD835\uDCB2",
2064 "wscr":"\uD835\uDCCC",
2065 "xcap":"\u22C2",
2066 "xcirc":"\u25EF",
2067 "xcup":"\u22C3",
2068 "xdtri":"\u25BD",
2069 "Xfr":"\uD835\uDD1B",
2070 "xfr":"\uD835\uDD35",
2071 "xhArr":"\u27FA",
2072 "xharr":"\u27F7",
2073 "Xi":"\u039E",
2074 "xi":"\u03BE",
2075 "xlArr":"\u27F8",
2076 "xlarr":"\u27F5",
2077 "xmap":"\u27FC",
2078 "xnis":"\u22FB",
2079 "xodot":"\u2A00",
2080 "Xopf":"\uD835\uDD4F",
2081 "xopf":"\uD835\uDD69",
2082 "xoplus":"\u2A01",
2083 "xotime":"\u2A02",
2084 "xrArr":"\u27F9",
2085 "xrarr":"\u27F6",
2086 "Xscr":"\uD835\uDCB3",
2087 "xscr":"\uD835\uDCCD",
2088 "xsqcup":"\u2A06",
2089 "xuplus":"\u2A04",
2090 "xutri":"\u25B3",
2091 "xvee":"\u22C1",
2092 "xwedge":"\u22C0",
2093 "Yacute":"\u00DD",
2094 "yacute":"\u00FD",
2095 "YAcy":"\u042F",
2096 "yacy":"\u044F",
2097 "Ycirc":"\u0176",
2098 "ycirc":"\u0177",
2099 "Ycy":"\u042B",
2100 "ycy":"\u044B",
2101 "yen":"\u00A5",
2102 "Yfr":"\uD835\uDD1C",
2103 "yfr":"\uD835\uDD36",
2104 "YIcy":"\u0407",
2105 "yicy":"\u0457",
2106 "Yopf":"\uD835\uDD50",
2107 "yopf":"\uD835\uDD6A",
2108 "Yscr":"\uD835\uDCB4",
2109 "yscr":"\uD835\uDCCE",
2110 "YUcy":"\u042E",
2111 "yucy":"\u044E",
2112 "Yuml":"\u0178",
2113 "yuml":"\u00FF",
2114 "Zacute":"\u0179",
2115 "zacute":"\u017A",
2116 "Zcaron":"\u017D",
2117 "zcaron":"\u017E",
2118 "Zcy":"\u0417",
2119 "zcy":"\u0437",
2120 "Zdot":"\u017B",
2121 "zdot":"\u017C",
2122 "zeetrf":"\u2128",
2123 "ZeroWidthSpace":"\u200B",
2124 "Zeta":"\u0396",
2125 "zeta":"\u03B6",
2126 "Zfr":"\u2128",
2127 "zfr":"\uD835\uDD37",
2128 "ZHcy":"\u0416",
2129 "zhcy":"\u0436",
2130 "zigrarr":"\u21DD",
2131 "Zopf":"\u2124",
2132 "zopf":"\uD835\uDD6B",
2133 "Zscr":"\uD835\uDCB5",
2134 "zscr":"\uD835\uDCCF",
2135 "zwj":"\u200D",
2136 "zwnj":"\u200C"
2137};
2138
2139var hasOwn = Object.prototype.hasOwnProperty;
2140
2141function has(object, key) {
2142 return object
2143 ? hasOwn.call(object, key)
2144 : false;
2145}
2146
2147function decodeEntity(name) {
2148 if (has(entities, name)) {
2149 return entities[name]
2150 } else {
2151 return name;
2152 }
2153}
2154
2155/**
2156 * Utility functions
2157 */
2158
2159function typeOf(obj) {
2160 return Object.prototype.toString.call(obj);
2161}
2162
2163function isString(obj) {
2164 return typeOf(obj) === '[object String]';
2165}
2166
2167var hasOwn$1 = Object.prototype.hasOwnProperty;
2168
2169function has$1(object, key) {
2170 return object
2171 ? hasOwn$1.call(object, key)
2172 : false;
2173}
2174
2175// Extend objects
2176//
2177function assign(obj /*from1, from2, from3, ...*/) {
2178 var sources = [].slice.call(arguments, 1);
2179
2180 sources.forEach(function (source) {
2181 if (!source) { return; }
2182
2183 if (typeof source !== 'object') {
2184 throw new TypeError(source + 'must be object');
2185 }
2186
2187 Object.keys(source).forEach(function (key) {
2188 obj[key] = source[key];
2189 });
2190 });
2191
2192 return obj;
2193}
2194
2195////////////////////////////////////////////////////////////////////////////////
2196
2197var UNESCAPE_MD_RE = /\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
2198
2199function unescapeMd(str) {
2200 if (str.indexOf('\\') < 0) { return str; }
2201 return str.replace(UNESCAPE_MD_RE, '$1');
2202}
2203
2204////////////////////////////////////////////////////////////////////////////////
2205
2206function isValidEntityCode(c) {
2207 /*eslint no-bitwise:0*/
2208 // broken sequence
2209 if (c >= 0xD800 && c <= 0xDFFF) { return false; }
2210 // never used
2211 if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }
2212 if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }
2213 // control codes
2214 if (c >= 0x00 && c <= 0x08) { return false; }
2215 if (c === 0x0B) { return false; }
2216 if (c >= 0x0E && c <= 0x1F) { return false; }
2217 if (c >= 0x7F && c <= 0x9F) { return false; }
2218 // out of range
2219 if (c > 0x10FFFF) { return false; }
2220 return true;
2221}
2222
2223function fromCodePoint(c) {
2224 /*eslint no-bitwise:0*/
2225 if (c > 0xffff) {
2226 c -= 0x10000;
2227 var surrogate1 = 0xd800 + (c >> 10),
2228 surrogate2 = 0xdc00 + (c & 0x3ff);
2229
2230 return String.fromCharCode(surrogate1, surrogate2);
2231 }
2232 return String.fromCharCode(c);
2233}
2234
2235var NAMED_ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
2236var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
2237
2238function replaceEntityPattern(match, name) {
2239 var code = 0;
2240 var decoded = decodeEntity(name);
2241
2242 if (name !== decoded) {
2243 return decoded;
2244 } else if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
2245 code = name[1].toLowerCase() === 'x' ?
2246 parseInt(name.slice(2), 16)
2247 :
2248 parseInt(name.slice(1), 10);
2249 if (isValidEntityCode(code)) {
2250 return fromCodePoint(code);
2251 }
2252 }
2253 return match;
2254}
2255
2256function replaceEntities(str) {
2257 if (str.indexOf('&') < 0) { return str; }
2258
2259 return str.replace(NAMED_ENTITY_RE, replaceEntityPattern);
2260}
2261
2262////////////////////////////////////////////////////////////////////////////////
2263
2264var HTML_ESCAPE_TEST_RE = /[&<>"]/;
2265var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
2266var HTML_REPLACEMENTS = {
2267 '&': '&amp;',
2268 '<': '&lt;',
2269 '>': '&gt;',
2270 '"': '&quot;'
2271};
2272
2273function replaceUnsafeChar(ch) {
2274 return HTML_REPLACEMENTS[ch];
2275}
2276
2277function escapeHtml(str) {
2278 if (HTML_ESCAPE_TEST_RE.test(str)) {
2279 return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
2280 }
2281 return str;
2282}
2283
2284var utils = /*#__PURE__*/Object.freeze({
2285 isString: isString,
2286 has: has$1,
2287 assign: assign,
2288 unescapeMd: unescapeMd,
2289 isValidEntityCode: isValidEntityCode,
2290 fromCodePoint: fromCodePoint,
2291 replaceEntities: replaceEntities,
2292 escapeHtml: escapeHtml
2293});
2294
2295/**
2296 * Renderer rules cache
2297 */
2298
2299var rules = {};
2300
2301/**
2302 * Blockquotes
2303 */
2304
2305rules.blockquote_open = function(/* tokens, idx, options, env */) {
2306 return '<blockquote>\n';
2307};
2308
2309rules.blockquote_close = function(tokens, idx /*, options, env */) {
2310 return '</blockquote>' + getBreak(tokens, idx);
2311};
2312
2313/**
2314 * Code
2315 */
2316
2317rules.code = function(tokens, idx /*, options, env */) {
2318 if (tokens[idx].block) {
2319 return '<pre><code>' + escapeHtml(tokens[idx].content) + '</code></pre>' + getBreak(tokens, idx);
2320 }
2321 return '<code>' + escapeHtml(tokens[idx].content) + '</code>';
2322};
2323
2324/**
2325 * Fenced code blocks
2326 */
2327
2328rules.fence = function(tokens, idx, options, env, instance) {
2329 var token = tokens[idx];
2330 var langClass = '';
2331 var langPrefix = options.langPrefix;
2332 var langName = '', fences, fenceName;
2333 var highlighted;
2334
2335 if (token.params) {
2336
2337 //
2338 // ```foo bar
2339 //
2340 // Try custom renderer "foo" first. That will simplify overwrite
2341 // for diagrams, latex, and any other fenced block with custom look
2342 //
2343
2344 fences = token.params.split(/\s+/g);
2345 fenceName = fences.join(' ');
2346
2347 if (has$1(instance.rules.fence_custom, fences[0])) {
2348 return instance.rules.fence_custom[fences[0]](tokens, idx, options, env, instance);
2349 }
2350
2351 langName = escapeHtml(replaceEntities(unescapeMd(fenceName)));
2352 langClass = ' class="' + langPrefix + langName + '"';
2353 }
2354
2355 if (options.highlight) {
2356 highlighted = options.highlight.apply(options.highlight, [ token.content ].concat(fences))
2357 || escapeHtml(token.content);
2358 } else {
2359 highlighted = escapeHtml(token.content);
2360 }
2361
2362 return '<pre><code' + langClass + '>'
2363 + highlighted
2364 + '</code></pre>'
2365 + getBreak(tokens, idx);
2366};
2367
2368rules.fence_custom = {};
2369
2370/**
2371 * Headings
2372 */
2373
2374rules.heading_open = function(tokens, idx /*, options, env */) {
2375 return '<h' + tokens[idx].hLevel + '>';
2376};
2377rules.heading_close = function(tokens, idx /*, options, env */) {
2378 return '</h' + tokens[idx].hLevel + '>\n';
2379};
2380
2381/**
2382 * Horizontal rules
2383 */
2384
2385rules.hr = function(tokens, idx, options /*, env */) {
2386 return (options.xhtmlOut ? '<hr />' : '<hr>') + getBreak(tokens, idx);
2387};
2388
2389/**
2390 * Bullets
2391 */
2392
2393rules.bullet_list_open = function(/* tokens, idx, options, env */) {
2394 return '<ul>\n';
2395};
2396rules.bullet_list_close = function(tokens, idx /*, options, env */) {
2397 return '</ul>' + getBreak(tokens, idx);
2398};
2399
2400/**
2401 * List items
2402 */
2403
2404rules.list_item_open = function(/* tokens, idx, options, env */) {
2405 return '<li>';
2406};
2407rules.list_item_close = function(/* tokens, idx, options, env */) {
2408 return '</li>\n';
2409};
2410
2411/**
2412 * Ordered list items
2413 */
2414
2415rules.ordered_list_open = function(tokens, idx /*, options, env */) {
2416 var token = tokens[idx];
2417 var order = token.order > 1 ? ' start="' + token.order + '"' : '';
2418 return '<ol' + order + '>\n';
2419};
2420rules.ordered_list_close = function(tokens, idx /*, options, env */) {
2421 return '</ol>' + getBreak(tokens, idx);
2422};
2423
2424/**
2425 * Paragraphs
2426 */
2427
2428rules.paragraph_open = function(tokens, idx /*, options, env */) {
2429 return tokens[idx].tight ? '' : '<p>';
2430};
2431rules.paragraph_close = function(tokens, idx /*, options, env */) {
2432 var addBreak = !(tokens[idx].tight && idx && tokens[idx - 1].type === 'inline' && !tokens[idx - 1].content);
2433 return (tokens[idx].tight ? '' : '</p>') + (addBreak ? getBreak(tokens, idx) : '');
2434};
2435
2436/**
2437 * Links
2438 */
2439
2440rules.link_open = function(tokens, idx, options /* env */) {
2441 var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
2442 var target = options.linkTarget ? (' target="' + options.linkTarget + '"') : '';
2443 return '<a href="' + escapeHtml(tokens[idx].href) + '"' + title + target + '>';
2444};
2445rules.link_close = function(/* tokens, idx, options, env */) {
2446 return '</a>';
2447};
2448
2449/**
2450 * Images
2451 */
2452
2453rules.image = function(tokens, idx, options /*, env */) {
2454 var src = ' src="' + escapeHtml(tokens[idx].src) + '"';
2455 var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
2456 var alt = ' alt="' + (tokens[idx].alt ? escapeHtml(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
2457 var suffix = options.xhtmlOut ? ' /' : '';
2458 return '<img' + src + alt + title + suffix + '>';
2459};
2460
2461/**
2462 * Tables
2463 */
2464
2465rules.table_open = function(/* tokens, idx, options, env */) {
2466 return '<table>\n';
2467};
2468rules.table_close = function(/* tokens, idx, options, env */) {
2469 return '</table>\n';
2470};
2471rules.thead_open = function(/* tokens, idx, options, env */) {
2472 return '<thead>\n';
2473};
2474rules.thead_close = function(/* tokens, idx, options, env */) {
2475 return '</thead>\n';
2476};
2477rules.tbody_open = function(/* tokens, idx, options, env */) {
2478 return '<tbody>\n';
2479};
2480rules.tbody_close = function(/* tokens, idx, options, env */) {
2481 return '</tbody>\n';
2482};
2483rules.tr_open = function(/* tokens, idx, options, env */) {
2484 return '<tr>';
2485};
2486rules.tr_close = function(/* tokens, idx, options, env */) {
2487 return '</tr>\n';
2488};
2489rules.th_open = function(tokens, idx /*, options, env */) {
2490 var token = tokens[idx];
2491 return '<th'
2492 + (token.align ? ' style="text-align:' + token.align + '"' : '')
2493 + '>';
2494};
2495rules.th_close = function(/* tokens, idx, options, env */) {
2496 return '</th>';
2497};
2498rules.td_open = function(tokens, idx /*, options, env */) {
2499 var token = tokens[idx];
2500 return '<td'
2501 + (token.align ? ' style="text-align:' + token.align + '"' : '')
2502 + '>';
2503};
2504rules.td_close = function(/* tokens, idx, options, env */) {
2505 return '</td>';
2506};
2507
2508/**
2509 * Bold
2510 */
2511
2512rules.strong_open = function(/* tokens, idx, options, env */) {
2513 return '<strong>';
2514};
2515rules.strong_close = function(/* tokens, idx, options, env */) {
2516 return '</strong>';
2517};
2518
2519/**
2520 * Italicize
2521 */
2522
2523rules.em_open = function(/* tokens, idx, options, env */) {
2524 return '<em>';
2525};
2526rules.em_close = function(/* tokens, idx, options, env */) {
2527 return '</em>';
2528};
2529
2530/**
2531 * Strikethrough
2532 */
2533
2534rules.del_open = function(/* tokens, idx, options, env */) {
2535 return '<del>';
2536};
2537rules.del_close = function(/* tokens, idx, options, env */) {
2538 return '</del>';
2539};
2540
2541/**
2542 * Insert
2543 */
2544
2545rules.ins_open = function(/* tokens, idx, options, env */) {
2546 return '<ins>';
2547};
2548rules.ins_close = function(/* tokens, idx, options, env */) {
2549 return '</ins>';
2550};
2551
2552/**
2553 * Highlight
2554 */
2555
2556rules.mark_open = function(/* tokens, idx, options, env */) {
2557 return '<mark>';
2558};
2559rules.mark_close = function(/* tokens, idx, options, env */) {
2560 return '</mark>';
2561};
2562
2563/**
2564 * Super- and sub-script
2565 */
2566
2567rules.sub = function(tokens, idx /*, options, env */) {
2568 return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
2569};
2570rules.sup = function(tokens, idx /*, options, env */) {
2571 return '<sup>' + escapeHtml(tokens[idx].content) + '</sup>';
2572};
2573
2574/**
2575 * Breaks
2576 */
2577
2578rules.hardbreak = function(tokens, idx, options /*, env */) {
2579 return options.xhtmlOut ? '<br />\n' : '<br>\n';
2580};
2581rules.softbreak = function(tokens, idx, options /*, env */) {
2582 return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
2583};
2584
2585/**
2586 * Text
2587 */
2588
2589rules.text = function(tokens, idx /*, options, env */) {
2590 return escapeHtml(tokens[idx].content);
2591};
2592
2593/**
2594 * Content
2595 */
2596
2597rules.htmlblock = function(tokens, idx /*, options, env */) {
2598 return tokens[idx].content;
2599};
2600rules.htmltag = function(tokens, idx /*, options, env */) {
2601 return tokens[idx].content;
2602};
2603
2604/**
2605 * Abbreviations, initialism
2606 */
2607
2608rules.abbr_open = function(tokens, idx /*, options, env */) {
2609 return '<abbr title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '">';
2610};
2611rules.abbr_close = function(/* tokens, idx, options, env */) {
2612 return '</abbr>';
2613};
2614
2615/**
2616 * Footnotes
2617 */
2618
2619rules.footnote_ref = function(tokens, idx) {
2620 var n = Number(tokens[idx].id + 1).toString();
2621 var id = 'fnref' + n;
2622 if (tokens[idx].subId > 0) {
2623 id += ':' + tokens[idx].subId;
2624 }
2625 return '<sup class="footnote-ref"><a href="#fn' + n + '" id="' + id + '">[' + n + ']</a></sup>';
2626};
2627rules.footnote_block_open = function(tokens, idx, options) {
2628 var hr = options.xhtmlOut
2629 ? '<hr class="footnotes-sep" />\n'
2630 : '<hr class="footnotes-sep">\n';
2631 return hr + '<section class="footnotes">\n<ol class="footnotes-list">\n';
2632};
2633rules.footnote_block_close = function() {
2634 return '</ol>\n</section>\n';
2635};
2636rules.footnote_open = function(tokens, idx) {
2637 var id = Number(tokens[idx].id + 1).toString();
2638 return '<li id="fn' + id + '" class="footnote-item">';
2639};
2640rules.footnote_close = function() {
2641 return '</li>\n';
2642};
2643rules.footnote_anchor = function(tokens, idx) {
2644 var n = Number(tokens[idx].id + 1).toString();
2645 var id = 'fnref' + n;
2646 if (tokens[idx].subId > 0) {
2647 id += ':' + tokens[idx].subId;
2648 }
2649 return ' <a href="#' + id + '" class="footnote-backref">↩</a>';
2650};
2651
2652/**
2653 * Definition lists
2654 */
2655
2656rules.dl_open = function() {
2657 return '<dl>\n';
2658};
2659rules.dt_open = function() {
2660 return '<dt>';
2661};
2662rules.dd_open = function() {
2663 return '<dd>';
2664};
2665rules.dl_close = function() {
2666 return '</dl>\n';
2667};
2668rules.dt_close = function() {
2669 return '</dt>\n';
2670};
2671rules.dd_close = function() {
2672 return '</dd>\n';
2673};
2674
2675/**
2676 * Helper functions
2677 */
2678
2679function nextToken(tokens, idx) {
2680 if (++idx >= tokens.length - 2) {
2681 return idx;
2682 }
2683 if ((tokens[idx].type === 'paragraph_open' && tokens[idx].tight) &&
2684 (tokens[idx + 1].type === 'inline' && tokens[idx + 1].content.length === 0) &&
2685 (tokens[idx + 2].type === 'paragraph_close' && tokens[idx + 2].tight)) {
2686 return nextToken(tokens, idx + 2);
2687 }
2688 return idx;
2689}
2690
2691/**
2692 * Check to see if `\n` is needed before the next token.
2693 *
2694 * @param {Array} `tokens`
2695 * @param {Number} `idx`
2696 * @return {String} Empty string or newline
2697 * @api private
2698 */
2699
2700var getBreak = rules.getBreak = function getBreak(tokens, idx) {
2701 idx = nextToken(tokens, idx);
2702 if (idx < tokens.length && tokens[idx].type === 'list_item_close') {
2703 return '';
2704 }
2705 return '\n';
2706};
2707
2708/**
2709 * Renderer class. Renders HTML and exposes `rules` to allow
2710 * local modifications.
2711 */
2712
2713function Renderer() {
2714 this.rules = assign({}, rules);
2715
2716 // exported helper, for custom rules only
2717 this.getBreak = rules.getBreak;
2718}
2719
2720/**
2721 * Render a string of inline HTML with the given `tokens` and
2722 * `options`.
2723 *
2724 * @param {Array} `tokens`
2725 * @param {Object} `options`
2726 * @param {Object} `env`
2727 * @return {String}
2728 * @api public
2729 */
2730
2731Renderer.prototype.renderInline = function (tokens, options, env) {
2732 var _rules = this.rules;
2733 var len = tokens.length, i = 0;
2734 var result = '';
2735
2736 while (len--) {
2737 result += _rules[tokens[i].type](tokens, i++, options, env, this);
2738 }
2739
2740 return result;
2741};
2742
2743/**
2744 * Render a string of HTML with the given `tokens` and
2745 * `options`.
2746 *
2747 * @param {Array} `tokens`
2748 * @param {Object} `options`
2749 * @param {Object} `env`
2750 * @return {String}
2751 * @api public
2752 */
2753
2754Renderer.prototype.render = function (tokens, options, env) {
2755 var _rules = this.rules;
2756 var len = tokens.length, i = -1;
2757 var result = '';
2758
2759 while (++i < len) {
2760 if (tokens[i].type === 'inline') {
2761 result += this.renderInline(tokens[i].children, options, env);
2762 } else {
2763 result += _rules[tokens[i].type](tokens, i, options, env, this);
2764 }
2765 }
2766 return result;
2767};
2768
2769/**
2770 * Ruler is a helper class for building responsibility chains from
2771 * parse rules. It allows:
2772 *
2773 * - easy stack rules chains
2774 * - getting main chain and named chains content (as arrays of functions)
2775 *
2776 * Helper methods, should not be used directly.
2777 * @api private
2778 */
2779
2780function Ruler() {
2781 // List of added rules. Each element is:
2782 //
2783 // { name: XXX,
2784 // enabled: Boolean,
2785 // fn: Function(),
2786 // alt: [ name2, name3 ] }
2787 //
2788 this.__rules__ = [];
2789
2790 // Cached rule chains.
2791 //
2792 // First level - chain name, '' for default.
2793 // Second level - digital anchor for fast filtering by charcodes.
2794 //
2795 this.__cache__ = null;
2796}
2797
2798/**
2799 * Find the index of a rule by `name`.
2800 *
2801 * @param {String} `name`
2802 * @return {Number} Index of the given `name`
2803 * @api private
2804 */
2805
2806Ruler.prototype.__find__ = function (name) {
2807 var len = this.__rules__.length;
2808 var i = -1;
2809
2810 while (len--) {
2811 if (this.__rules__[++i].name === name) {
2812 return i;
2813 }
2814 }
2815 return -1;
2816};
2817
2818/**
2819 * Build the rules lookup cache
2820 *
2821 * @api private
2822 */
2823
2824Ruler.prototype.__compile__ = function () {
2825 var self = this;
2826 var chains = [ '' ];
2827
2828 // collect unique names
2829 self.__rules__.forEach(function (rule) {
2830 if (!rule.enabled) {
2831 return;
2832 }
2833
2834 rule.alt.forEach(function (altName) {
2835 if (chains.indexOf(altName) < 0) {
2836 chains.push(altName);
2837 }
2838 });
2839 });
2840
2841 self.__cache__ = {};
2842
2843 chains.forEach(function (chain) {
2844 self.__cache__[chain] = [];
2845 self.__rules__.forEach(function (rule) {
2846 if (!rule.enabled) {
2847 return;
2848 }
2849
2850 if (chain && rule.alt.indexOf(chain) < 0) {
2851 return;
2852 }
2853 self.__cache__[chain].push(rule.fn);
2854 });
2855 });
2856};
2857
2858/**
2859 * Ruler public methods
2860 * ------------------------------------------------
2861 */
2862
2863/**
2864 * Replace rule function
2865 *
2866 * @param {String} `name` Rule name
2867 * @param {Function `fn`
2868 * @param {Object} `options`
2869 * @api private
2870 */
2871
2872Ruler.prototype.at = function (name, fn, options) {
2873 var idx = this.__find__(name);
2874 var opt = options || {};
2875
2876 if (idx === -1) {
2877 throw new Error('Parser rule not found: ' + name);
2878 }
2879
2880 this.__rules__[idx].fn = fn;
2881 this.__rules__[idx].alt = opt.alt || [];
2882 this.__cache__ = null;
2883};
2884
2885/**
2886 * Add a rule to the chain before given the `ruleName`.
2887 *
2888 * @param {String} `beforeName`
2889 * @param {String} `ruleName`
2890 * @param {Function} `fn`
2891 * @param {Object} `options`
2892 * @api private
2893 */
2894
2895Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
2896 var idx = this.__find__(beforeName);
2897 var opt = options || {};
2898
2899 if (idx === -1) {
2900 throw new Error('Parser rule not found: ' + beforeName);
2901 }
2902
2903 this.__rules__.splice(idx, 0, {
2904 name: ruleName,
2905 enabled: true,
2906 fn: fn,
2907 alt: opt.alt || []
2908 });
2909
2910 this.__cache__ = null;
2911};
2912
2913/**
2914 * Add a rule to the chain after the given `ruleName`.
2915 *
2916 * @param {String} `afterName`
2917 * @param {String} `ruleName`
2918 * @param {Function} `fn`
2919 * @param {Object} `options`
2920 * @api private
2921 */
2922
2923Ruler.prototype.after = function (afterName, ruleName, fn, options) {
2924 var idx = this.__find__(afterName);
2925 var opt = options || {};
2926
2927 if (idx === -1) {
2928 throw new Error('Parser rule not found: ' + afterName);
2929 }
2930
2931 this.__rules__.splice(idx + 1, 0, {
2932 name: ruleName,
2933 enabled: true,
2934 fn: fn,
2935 alt: opt.alt || []
2936 });
2937
2938 this.__cache__ = null;
2939};
2940
2941/**
2942 * Add a rule to the end of chain.
2943 *
2944 * @param {String} `ruleName`
2945 * @param {Function} `fn`
2946 * @param {Object} `options`
2947 * @return {String}
2948 */
2949
2950Ruler.prototype.push = function (ruleName, fn, options) {
2951 var opt = options || {};
2952
2953 this.__rules__.push({
2954 name: ruleName,
2955 enabled: true,
2956 fn: fn,
2957 alt: opt.alt || []
2958 });
2959
2960 this.__cache__ = null;
2961};
2962
2963/**
2964 * Enable a rule or list of rules.
2965 *
2966 * @param {String|Array} `list` Name or array of rule names to enable
2967 * @param {Boolean} `strict` If `true`, all non listed rules will be disabled.
2968 * @api private
2969 */
2970
2971Ruler.prototype.enable = function (list, strict) {
2972 list = !Array.isArray(list)
2973 ? [ list ]
2974 : list;
2975
2976 // In strict mode disable all existing rules first
2977 if (strict) {
2978 this.__rules__.forEach(function (rule) {
2979 rule.enabled = false;
2980 });
2981 }
2982
2983 // Search by name and enable
2984 list.forEach(function (name) {
2985 var idx = this.__find__(name);
2986 if (idx < 0) {
2987 throw new Error('Rules manager: invalid rule name ' + name);
2988 }
2989 this.__rules__[idx].enabled = true;
2990 }, this);
2991
2992 this.__cache__ = null;
2993};
2994
2995
2996/**
2997 * Disable a rule or list of rules.
2998 *
2999 * @param {String|Array} `list` Name or array of rule names to disable
3000 * @api private
3001 */
3002
3003Ruler.prototype.disable = function (list) {
3004 list = !Array.isArray(list)
3005 ? [ list ]
3006 : list;
3007
3008 // Search by name and disable
3009 list.forEach(function (name) {
3010 var idx = this.__find__(name);
3011 if (idx < 0) {
3012 throw new Error('Rules manager: invalid rule name ' + name);
3013 }
3014 this.__rules__[idx].enabled = false;
3015 }, this);
3016
3017 this.__cache__ = null;
3018};
3019
3020/**
3021 * Get a rules list as an array of functions.
3022 *
3023 * @param {String} `chainName`
3024 * @return {Object}
3025 * @api private
3026 */
3027
3028Ruler.prototype.getRules = function (chainName) {
3029 if (this.__cache__ === null) {
3030 this.__compile__();
3031 }
3032 return this.__cache__[chainName] || [];
3033};
3034
3035function block(state) {
3036
3037 if (state.inlineMode) {
3038 state.tokens.push({
3039 type: 'inline',
3040 content: state.src.replace(/\n/g, ' ').trim(),
3041 level: 0,
3042 lines: [ 0, 1 ],
3043 children: []
3044 });
3045
3046 } else {
3047 state.block.parse(state.src, state.options, state.env, state.tokens);
3048 }
3049}
3050
3051// Inline parser state
3052
3053function StateInline(src, parserInline, options, env, outTokens) {
3054 this.src = src;
3055 this.env = env;
3056 this.options = options;
3057 this.parser = parserInline;
3058 this.tokens = outTokens;
3059 this.pos = 0;
3060 this.posMax = this.src.length;
3061 this.level = 0;
3062 this.pending = '';
3063 this.pendingLevel = 0;
3064
3065 this.cache = []; // Stores { start: end } pairs. Useful for backtrack
3066 // optimization of pairs parse (emphasis, strikes).
3067
3068 // Link parser state vars
3069
3070 this.isInLabel = false; // Set true when seek link label - we should disable
3071 // "paired" rules (emphasis, strikes) to not skip
3072 // tailing `]`
3073
3074 this.linkLevel = 0; // Increment for each nesting link. Used to prevent
3075 // nesting in definitions
3076
3077 this.linkContent = ''; // Temporary storage for link url
3078
3079 this.labelUnmatchedScopes = 0; // Track unpaired `[` for link labels
3080 // (backtrack optimization)
3081}
3082
3083// Flush pending text
3084//
3085StateInline.prototype.pushPending = function () {
3086 this.tokens.push({
3087 type: 'text',
3088 content: this.pending,
3089 level: this.pendingLevel
3090 });
3091 this.pending = '';
3092};
3093
3094// Push new token to "stream".
3095// If pending text exists - flush it as text token
3096//
3097StateInline.prototype.push = function (token) {
3098 if (this.pending) {
3099 this.pushPending();
3100 }
3101
3102 this.tokens.push(token);
3103 this.pendingLevel = this.level;
3104};
3105
3106// Store value to cache.
3107// !!! Implementation has parser-specific optimizations
3108// !!! keys MUST be integer, >= 0; values MUST be integer, > 0
3109//
3110StateInline.prototype.cacheSet = function (key, val) {
3111 for (var i = this.cache.length; i <= key; i++) {
3112 this.cache.push(0);
3113 }
3114
3115 this.cache[key] = val;
3116};
3117
3118// Get cache value
3119//
3120StateInline.prototype.cacheGet = function (key) {
3121 return key < this.cache.length ? this.cache[key] : 0;
3122};
3123
3124/**
3125 * Parse link labels
3126 *
3127 * This function assumes that first character (`[`) already matches;
3128 * returns the end of the label.
3129 *
3130 * @param {Object} state
3131 * @param {Number} start
3132 * @api private
3133 */
3134
3135function parseLinkLabel(state, start) {
3136 var level, found, marker,
3137 labelEnd = -1,
3138 max = state.posMax,
3139 oldPos = state.pos,
3140 oldFlag = state.isInLabel;
3141
3142 if (state.isInLabel) { return -1; }
3143
3144 if (state.labelUnmatchedScopes) {
3145 state.labelUnmatchedScopes--;
3146 return -1;
3147 }
3148
3149 state.pos = start + 1;
3150 state.isInLabel = true;
3151 level = 1;
3152
3153 while (state.pos < max) {
3154 marker = state.src.charCodeAt(state.pos);
3155 if (marker === 0x5B /* [ */) {
3156 level++;
3157 } else if (marker === 0x5D /* ] */) {
3158 level--;
3159 if (level === 0) {
3160 found = true;
3161 break;
3162 }
3163 }
3164
3165 state.parser.skipToken(state);
3166 }
3167
3168 if (found) {
3169 labelEnd = state.pos;
3170 state.labelUnmatchedScopes = 0;
3171 } else {
3172 state.labelUnmatchedScopes = level - 1;
3173 }
3174
3175 // restore old state
3176 state.pos = oldPos;
3177 state.isInLabel = oldFlag;
3178
3179 return labelEnd;
3180}
3181
3182// Parse abbreviation definitions, i.e. `*[abbr]: description`
3183
3184
3185function parseAbbr(str, parserInline, options, env) {
3186 var state, labelEnd, pos, max, label, title;
3187
3188 if (str.charCodeAt(0) !== 0x2A/* * */) { return -1; }
3189 if (str.charCodeAt(1) !== 0x5B/* [ */) { return -1; }
3190
3191 if (str.indexOf(']:') === -1) { return -1; }
3192
3193 state = new StateInline(str, parserInline, options, env, []);
3194 labelEnd = parseLinkLabel(state, 1);
3195
3196 if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return -1; }
3197
3198 max = state.posMax;
3199
3200 // abbr title is always one line, so looking for ending "\n" here
3201 for (pos = labelEnd + 2; pos < max; pos++) {
3202 if (state.src.charCodeAt(pos) === 0x0A) { break; }
3203 }
3204
3205 label = str.slice(2, labelEnd);
3206 title = str.slice(labelEnd + 2, pos).trim();
3207 if (title.length === 0) { return -1; }
3208 if (!env.abbreviations) { env.abbreviations = {}; }
3209 // prepend ':' to avoid conflict with Object.prototype members
3210 if (typeof env.abbreviations[':' + label] === 'undefined') {
3211 env.abbreviations[':' + label] = title;
3212 }
3213
3214 return pos;
3215}
3216
3217function abbr(state) {
3218 var tokens = state.tokens, i, l, content, pos;
3219
3220 if (state.inlineMode) {
3221 return;
3222 }
3223
3224 // Parse inlines
3225 for (i = 1, l = tokens.length - 1; i < l; i++) {
3226 if (tokens[i - 1].type === 'paragraph_open' &&
3227 tokens[i].type === 'inline' &&
3228 tokens[i + 1].type === 'paragraph_close') {
3229
3230 content = tokens[i].content;
3231 while (content.length) {
3232 pos = parseAbbr(content, state.inline, state.options, state.env);
3233 if (pos < 0) { break; }
3234 content = content.slice(pos).trim();
3235 }
3236
3237 tokens[i].content = content;
3238 if (!content.length) {
3239 tokens[i - 1].tight = true;
3240 tokens[i + 1].tight = true;
3241 }
3242 }
3243 }
3244}
3245
3246function normalizeLink(url) {
3247 var normalized = replaceEntities(url);
3248 // We shouldn't care about the result of malformed URIs,
3249 // and should not throw an exception.
3250 try {
3251 normalized = decodeURI(normalized);
3252 } catch (err) {}
3253 return encodeURI(normalized);
3254}
3255
3256/**
3257 * Parse link destination
3258 *
3259 * - on success it returns a string and updates state.pos;
3260 * - on failure it returns null
3261 *
3262 * @param {Object} state
3263 * @param {Number} pos
3264 * @api private
3265 */
3266
3267function parseLinkDestination(state, pos) {
3268 var code, level, link,
3269 start = pos,
3270 max = state.posMax;
3271
3272 if (state.src.charCodeAt(pos) === 0x3C /* < */) {
3273 pos++;
3274 while (pos < max) {
3275 code = state.src.charCodeAt(pos);
3276 if (code === 0x0A /* \n */) { return false; }
3277 if (code === 0x3E /* > */) {
3278 link = normalizeLink(unescapeMd(state.src.slice(start + 1, pos)));
3279 if (!state.parser.validateLink(link)) { return false; }
3280 state.pos = pos + 1;
3281 state.linkContent = link;
3282 return true;
3283 }
3284 if (code === 0x5C /* \ */ && pos + 1 < max) {
3285 pos += 2;
3286 continue;
3287 }
3288
3289 pos++;
3290 }
3291
3292 // no closing '>'
3293 return false;
3294 }
3295
3296 // this should be ... } else { ... branch
3297
3298 level = 0;
3299 while (pos < max) {
3300 code = state.src.charCodeAt(pos);
3301
3302 if (code === 0x20) { break; }
3303
3304 // ascii control chars
3305 if (code < 0x20 || code === 0x7F) { break; }
3306
3307 if (code === 0x5C /* \ */ && pos + 1 < max) {
3308 pos += 2;
3309 continue;
3310 }
3311
3312 if (code === 0x28 /* ( */) {
3313 level++;
3314 if (level > 1) { break; }
3315 }
3316
3317 if (code === 0x29 /* ) */) {
3318 level--;
3319 if (level < 0) { break; }
3320 }
3321
3322 pos++;
3323 }
3324
3325 if (start === pos) { return false; }
3326
3327 link = unescapeMd(state.src.slice(start, pos));
3328 if (!state.parser.validateLink(link)) { return false; }
3329
3330 state.linkContent = link;
3331 state.pos = pos;
3332 return true;
3333}
3334
3335/**
3336 * Parse link title
3337 *
3338 * - on success it returns a string and updates state.pos;
3339 * - on failure it returns null
3340 *
3341 * @param {Object} state
3342 * @param {Number} pos
3343 * @api private
3344 */
3345
3346function parseLinkTitle(state, pos) {
3347 var code,
3348 start = pos,
3349 max = state.posMax,
3350 marker = state.src.charCodeAt(pos);
3351
3352 if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return false; }
3353
3354 pos++;
3355
3356 // if opening marker is "(", switch it to closing marker ")"
3357 if (marker === 0x28) { marker = 0x29; }
3358
3359 while (pos < max) {
3360 code = state.src.charCodeAt(pos);
3361 if (code === marker) {
3362 state.pos = pos + 1;
3363 state.linkContent = unescapeMd(state.src.slice(start + 1, pos));
3364 return true;
3365 }
3366 if (code === 0x5C /* \ */ && pos + 1 < max) {
3367 pos += 2;
3368 continue;
3369 }
3370
3371 pos++;
3372 }
3373
3374 return false;
3375}
3376
3377function normalizeReference(str) {
3378 // use .toUpperCase() instead of .toLowerCase()
3379 // here to avoid a conflict with Object.prototype
3380 // members (most notably, `__proto__`)
3381 return str.trim().replace(/\s+/g, ' ').toUpperCase();
3382}
3383
3384function parseReference(str, parser, options, env) {
3385 var state, labelEnd, pos, max, code, start, href, title, label;
3386
3387 if (str.charCodeAt(0) !== 0x5B/* [ */) { return -1; }
3388
3389 if (str.indexOf(']:') === -1) { return -1; }
3390
3391 state = new StateInline(str, parser, options, env, []);
3392 labelEnd = parseLinkLabel(state, 0);
3393
3394 if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return -1; }
3395
3396 max = state.posMax;
3397
3398 // [label]: destination 'title'
3399 // ^^^ skip optional whitespace here
3400 for (pos = labelEnd + 2; pos < max; pos++) {
3401 code = state.src.charCodeAt(pos);
3402 if (code !== 0x20 && code !== 0x0A) { break; }
3403 }
3404
3405 // [label]: destination 'title'
3406 // ^^^^^^^^^^^ parse this
3407 if (!parseLinkDestination(state, pos)) { return -1; }
3408 href = state.linkContent;
3409 pos = state.pos;
3410
3411 // [label]: destination 'title'
3412 // ^^^ skipping those spaces
3413 start = pos;
3414 for (pos = pos + 1; pos < max; pos++) {
3415 code = state.src.charCodeAt(pos);
3416 if (code !== 0x20 && code !== 0x0A) { break; }
3417 }
3418
3419 // [label]: destination 'title'
3420 // ^^^^^^^ parse this
3421 if (pos < max && start !== pos && parseLinkTitle(state, pos)) {
3422 title = state.linkContent;
3423 pos = state.pos;
3424 } else {
3425 title = '';
3426 pos = start;
3427 }
3428
3429 // ensure that the end of the line is empty
3430 while (pos < max && state.src.charCodeAt(pos) === 0x20/* space */) { pos++; }
3431 if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; }
3432
3433 label = normalizeReference(str.slice(1, labelEnd));
3434 if (typeof env.references[label] === 'undefined') {
3435 env.references[label] = { title: title, href: href };
3436 }
3437
3438 return pos;
3439}
3440
3441
3442function references(state) {
3443 var tokens = state.tokens, i, l, content, pos;
3444
3445 state.env.references = state.env.references || {};
3446
3447 if (state.inlineMode) {
3448 return;
3449 }
3450
3451 // Scan definitions in paragraph inlines
3452 for (i = 1, l = tokens.length - 1; i < l; i++) {
3453 if (tokens[i].type === 'inline' &&
3454 tokens[i - 1].type === 'paragraph_open' &&
3455 tokens[i + 1].type === 'paragraph_close') {
3456
3457 content = tokens[i].content;
3458 while (content.length) {
3459 pos = parseReference(content, state.inline, state.options, state.env);
3460 if (pos < 0) { break; }
3461 content = content.slice(pos).trim();
3462 }
3463
3464 tokens[i].content = content;
3465 if (!content.length) {
3466 tokens[i - 1].tight = true;
3467 tokens[i + 1].tight = true;
3468 }
3469 }
3470 }
3471}
3472
3473function inline(state) {
3474 var tokens = state.tokens, tok, i, l;
3475
3476 // Parse inlines
3477 for (i = 0, l = tokens.length; i < l; i++) {
3478 tok = tokens[i];
3479 if (tok.type === 'inline') {
3480 state.inline.parse(tok.content, state.options, state.env, tok.children);
3481 }
3482 }
3483}
3484
3485function footnote_block(state) {
3486 var i, l, j, t, lastParagraph, list, tokens, current, currentLabel,
3487 level = 0,
3488 insideRef = false,
3489 refTokens = {};
3490
3491 if (!state.env.footnotes) { return; }
3492
3493 state.tokens = state.tokens.filter(function(tok) {
3494 if (tok.type === 'footnote_reference_open') {
3495 insideRef = true;
3496 current = [];
3497 currentLabel = tok.label;
3498 return false;
3499 }
3500 if (tok.type === 'footnote_reference_close') {
3501 insideRef = false;
3502 // prepend ':' to avoid conflict with Object.prototype members
3503 refTokens[':' + currentLabel] = current;
3504 return false;
3505 }
3506 if (insideRef) { current.push(tok); }
3507 return !insideRef;
3508 });
3509
3510 if (!state.env.footnotes.list) { return; }
3511 list = state.env.footnotes.list;
3512
3513 state.tokens.push({
3514 type: 'footnote_block_open',
3515 level: level++
3516 });
3517 for (i = 0, l = list.length; i < l; i++) {
3518 state.tokens.push({
3519 type: 'footnote_open',
3520 id: i,
3521 level: level++
3522 });
3523
3524 if (list[i].tokens) {
3525 tokens = [];
3526 tokens.push({
3527 type: 'paragraph_open',
3528 tight: false,
3529 level: level++
3530 });
3531 tokens.push({
3532 type: 'inline',
3533 content: '',
3534 level: level,
3535 children: list[i].tokens
3536 });
3537 tokens.push({
3538 type: 'paragraph_close',
3539 tight: false,
3540 level: --level
3541 });
3542 } else if (list[i].label) {
3543 tokens = refTokens[':' + list[i].label];
3544 }
3545
3546 state.tokens = state.tokens.concat(tokens);
3547 if (state.tokens[state.tokens.length - 1].type === 'paragraph_close') {
3548 lastParagraph = state.tokens.pop();
3549 } else {
3550 lastParagraph = null;
3551 }
3552
3553 t = list[i].count > 0 ? list[i].count : 1;
3554 for (j = 0; j < t; j++) {
3555 state.tokens.push({
3556 type: 'footnote_anchor',
3557 id: i,
3558 subId: j,
3559 level: level
3560 });
3561 }
3562
3563 if (lastParagraph) {
3564 state.tokens.push(lastParagraph);
3565 }
3566
3567 state.tokens.push({
3568 type: 'footnote_close',
3569 level: --level
3570 });
3571 }
3572 state.tokens.push({
3573 type: 'footnote_block_close',
3574 level: --level
3575 });
3576}
3577
3578// Enclose abbreviations in <abbr> tags
3579//
3580
3581var PUNCT_CHARS = ' \n()[]\'".,!?-';
3582
3583
3584// from Google closure library
3585// http://closure-library.googlecode.com/git-history/docs/local_closure_goog_string_string.js.source.html#line1021
3586function regEscape(s) {
3587 return s.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1');
3588}
3589
3590
3591function abbr2(state) {
3592 var i, j, l, tokens, token, text, nodes, pos, level, reg, m, regText,
3593 blockTokens = state.tokens;
3594
3595 if (!state.env.abbreviations) { return; }
3596 if (!state.env.abbrRegExp) {
3597 regText = '(^|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])'
3598 + '(' + Object.keys(state.env.abbreviations).map(function (x) {
3599 return x.substr(1);
3600 }).sort(function (a, b) {
3601 return b.length - a.length;
3602 }).map(regEscape).join('|') + ')'
3603 + '($|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])';
3604 state.env.abbrRegExp = new RegExp(regText, 'g');
3605 }
3606 reg = state.env.abbrRegExp;
3607
3608 for (j = 0, l = blockTokens.length; j < l; j++) {
3609 if (blockTokens[j].type !== 'inline') { continue; }
3610 tokens = blockTokens[j].children;
3611
3612 // We scan from the end, to keep position when new tags added.
3613 for (i = tokens.length - 1; i >= 0; i--) {
3614 token = tokens[i];
3615 if (token.type !== 'text') { continue; }
3616
3617 pos = 0;
3618 text = token.content;
3619 reg.lastIndex = 0;
3620 level = token.level;
3621 nodes = [];
3622
3623 while ((m = reg.exec(text))) {
3624 if (reg.lastIndex > pos) {
3625 nodes.push({
3626 type: 'text',
3627 content: text.slice(pos, m.index + m[1].length),
3628 level: level
3629 });
3630 }
3631
3632 nodes.push({
3633 type: 'abbr_open',
3634 title: state.env.abbreviations[':' + m[2]],
3635 level: level++
3636 });
3637 nodes.push({
3638 type: 'text',
3639 content: m[2],
3640 level: level
3641 });
3642 nodes.push({
3643 type: 'abbr_close',
3644 level: --level
3645 });
3646 pos = reg.lastIndex - m[3].length;
3647 }
3648
3649 if (!nodes.length) { continue; }
3650
3651 if (pos < text.length) {
3652 nodes.push({
3653 type: 'text',
3654 content: text.slice(pos),
3655 level: level
3656 });
3657 }
3658
3659 // replace current node
3660 blockTokens[j].children = tokens = [].concat(tokens.slice(0, i), nodes, tokens.slice(i + 1));
3661 }
3662 }
3663}
3664
3665// Simple typographical replacements
3666//
3667// TODO:
3668// - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
3669// - miltiplication 2 x 4 -> 2 × 4
3670
3671var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
3672
3673var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;
3674var SCOPED_ABBR = {
3675 'c': '©',
3676 'r': '®',
3677 'p': '§',
3678 'tm': '™'
3679};
3680
3681function replaceScopedAbbr(str) {
3682 if (str.indexOf('(') < 0) { return str; }
3683
3684 return str.replace(SCOPED_ABBR_RE, function(match, name) {
3685 return SCOPED_ABBR[name.toLowerCase()];
3686 });
3687}
3688
3689
3690function replace(state) {
3691 var i, token, text, inlineTokens, blkIdx;
3692
3693 if (!state.options.typographer) { return; }
3694
3695 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
3696
3697 if (state.tokens[blkIdx].type !== 'inline') { continue; }
3698
3699 inlineTokens = state.tokens[blkIdx].children;
3700
3701 for (i = inlineTokens.length - 1; i >= 0; i--) {
3702 token = inlineTokens[i];
3703 if (token.type === 'text') {
3704 text = token.content;
3705
3706 text = replaceScopedAbbr(text);
3707
3708 if (RARE_RE.test(text)) {
3709 text = text
3710 .replace(/\+-/g, '±')
3711 // .., ..., ....... -> …
3712 // but ?..... & !..... -> ?.. & !..
3713 .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
3714 .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
3715 // em-dash
3716 .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
3717 // en-dash
3718 .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
3719 .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
3720 }
3721
3722 token.content = text;
3723 }
3724 }
3725 }
3726}
3727
3728// Convert straight quotation marks to typographic ones
3729//
3730
3731var QUOTE_TEST_RE = /['"]/;
3732var QUOTE_RE = /['"]/g;
3733var PUNCT_RE = /[-\s()\[\]]/;
3734var APOSTROPHE = '’';
3735
3736// This function returns true if the character at `pos`
3737// could be inside a word.
3738function isLetter(str, pos) {
3739 if (pos < 0 || pos >= str.length) { return false; }
3740 return !PUNCT_RE.test(str[pos]);
3741}
3742
3743
3744function replaceAt(str, index, ch) {
3745 return str.substr(0, index) + ch + str.substr(index + 1);
3746}
3747
3748
3749function smartquotes(state) {
3750 /*eslint max-depth:0*/
3751 var i, token, text, t, pos, max, thisLevel, lastSpace, nextSpace, item,
3752 canOpen, canClose, j, isSingle, blkIdx, tokens,
3753 stack;
3754
3755 if (!state.options.typographer) { return; }
3756
3757 stack = [];
3758
3759 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
3760
3761 if (state.tokens[blkIdx].type !== 'inline') { continue; }
3762
3763 tokens = state.tokens[blkIdx].children;
3764 stack.length = 0;
3765
3766 for (i = 0; i < tokens.length; i++) {
3767 token = tokens[i];
3768
3769 if (token.type !== 'text' || QUOTE_TEST_RE.test(token.text)) { continue; }
3770
3771 thisLevel = tokens[i].level;
3772
3773 for (j = stack.length - 1; j >= 0; j--) {
3774 if (stack[j].level <= thisLevel) { break; }
3775 }
3776 stack.length = j + 1;
3777
3778 text = token.content;
3779 pos = 0;
3780 max = text.length;
3781
3782 /*eslint no-labels:0,block-scoped-var:0*/
3783 OUTER:
3784 while (pos < max) {
3785 QUOTE_RE.lastIndex = pos;
3786 t = QUOTE_RE.exec(text);
3787 if (!t) { break; }
3788
3789 lastSpace = !isLetter(text, t.index - 1);
3790 pos = t.index + 1;
3791 isSingle = (t[0] === "'");
3792 nextSpace = !isLetter(text, pos);
3793
3794 if (!nextSpace && !lastSpace) {
3795 // middle of word
3796 if (isSingle) {
3797 token.content = replaceAt(token.content, t.index, APOSTROPHE);
3798 }
3799 continue;
3800 }
3801
3802 canOpen = !nextSpace;
3803 canClose = !lastSpace;
3804
3805 if (canClose) {
3806 // this could be a closing quote, rewind the stack to get a match
3807 for (j = stack.length - 1; j >= 0; j--) {
3808 item = stack[j];
3809 if (stack[j].level < thisLevel) { break; }
3810 if (item.single === isSingle && stack[j].level === thisLevel) {
3811 item = stack[j];
3812 if (isSingle) {
3813 tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, state.options.quotes[2]);
3814 token.content = replaceAt(token.content, t.index, state.options.quotes[3]);
3815 } else {
3816 tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, state.options.quotes[0]);
3817 token.content = replaceAt(token.content, t.index, state.options.quotes[1]);
3818 }
3819 stack.length = j;
3820 continue OUTER;
3821 }
3822 }
3823 }
3824
3825 if (canOpen) {
3826 stack.push({
3827 token: i,
3828 pos: t.index,
3829 single: isSingle,
3830 level: thisLevel
3831 });
3832 } else if (canClose && isSingle) {
3833 token.content = replaceAt(token.content, t.index, APOSTROPHE);
3834 }
3835 }
3836 }
3837 }
3838}
3839
3840/**
3841 * Core parser `rules`
3842 */
3843
3844var _rules = [
3845 [ 'block', block ],
3846 [ 'abbr', abbr ],
3847 [ 'references', references ],
3848 [ 'inline', inline ],
3849 [ 'footnote_tail', footnote_block ],
3850 [ 'abbr2', abbr2 ],
3851 [ 'replacements', replace ],
3852 [ 'smartquotes', smartquotes ],
3853];
3854
3855/**
3856 * Class for top level (`core`) parser rules
3857 *
3858 * @api private
3859 */
3860
3861function Core() {
3862 this.options = {};
3863 this.ruler = new Ruler();
3864 for (var i = 0; i < _rules.length; i++) {
3865 this.ruler.push(_rules[i][0], _rules[i][1]);
3866 }
3867}
3868
3869/**
3870 * Process rules with the given `state`
3871 *
3872 * @param {Object} `state`
3873 * @api private
3874 */
3875
3876Core.prototype.process = function (state) {
3877 var i, l, rules;
3878 rules = this.ruler.getRules('');
3879 for (i = 0, l = rules.length; i < l; i++) {
3880 rules[i](state);
3881 }
3882};
3883
3884// Parser state class
3885
3886function StateBlock(src, parser, options, env, tokens) {
3887 var ch, s, start, pos, len, indent, indent_found;
3888
3889 this.src = src;
3890
3891 // Shortcuts to simplify nested calls
3892 this.parser = parser;
3893
3894 this.options = options;
3895
3896 this.env = env;
3897
3898 //
3899 // Internal state vartiables
3900 //
3901
3902 this.tokens = tokens;
3903
3904 this.bMarks = []; // line begin offsets for fast jumps
3905 this.eMarks = []; // line end offsets for fast jumps
3906 this.tShift = []; // indent for each line
3907
3908 // block parser variables
3909 this.blkIndent = 0; // required block content indent
3910 // (for example, if we are in list)
3911 this.line = 0; // line index in src
3912 this.lineMax = 0; // lines count
3913 this.tight = false; // loose/tight mode for lists
3914 this.parentType = 'root'; // if `list`, block parser stops on two newlines
3915 this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
3916
3917 this.level = 0;
3918
3919 // renderer
3920 this.result = '';
3921
3922 // Create caches
3923 // Generate markers.
3924 s = this.src;
3925 indent = 0;
3926 indent_found = false;
3927
3928 for (start = pos = indent = 0, len = s.length; pos < len; pos++) {
3929 ch = s.charCodeAt(pos);
3930
3931 if (!indent_found) {
3932 if (ch === 0x20/* space */) {
3933 indent++;
3934 continue;
3935 } else {
3936 indent_found = true;
3937 }
3938 }
3939
3940 if (ch === 0x0A || pos === len - 1) {
3941 if (ch !== 0x0A) { pos++; }
3942 this.bMarks.push(start);
3943 this.eMarks.push(pos);
3944 this.tShift.push(indent);
3945
3946 indent_found = false;
3947 indent = 0;
3948 start = pos + 1;
3949 }
3950 }
3951
3952 // Push fake entry to simplify cache bounds checks
3953 this.bMarks.push(s.length);
3954 this.eMarks.push(s.length);
3955 this.tShift.push(0);
3956
3957 this.lineMax = this.bMarks.length - 1; // don't count last fake line
3958}
3959
3960StateBlock.prototype.isEmpty = function isEmpty(line) {
3961 return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
3962};
3963
3964StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
3965 for (var max = this.lineMax; from < max; from++) {
3966 if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
3967 break;
3968 }
3969 }
3970 return from;
3971};
3972
3973// Skip spaces from given position.
3974StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
3975 for (var max = this.src.length; pos < max; pos++) {
3976 if (this.src.charCodeAt(pos) !== 0x20/* space */) { break; }
3977 }
3978 return pos;
3979};
3980
3981// Skip char codes from given position
3982StateBlock.prototype.skipChars = function skipChars(pos, code) {
3983 for (var max = this.src.length; pos < max; pos++) {
3984 if (this.src.charCodeAt(pos) !== code) { break; }
3985 }
3986 return pos;
3987};
3988
3989// Skip char codes reverse from given position - 1
3990StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
3991 if (pos <= min) { return pos; }
3992
3993 while (pos > min) {
3994 if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
3995 }
3996 return pos;
3997};
3998
3999// cut lines range from source.
4000StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
4001 var i, first, last, queue, shift,
4002 line = begin;
4003
4004 if (begin >= end) {
4005 return '';
4006 }
4007
4008 // Opt: don't use push queue for single line;
4009 if (line + 1 === end) {
4010 first = this.bMarks[line] + Math.min(this.tShift[line], indent);
4011 last = keepLastLF ? this.eMarks[line] + 1 : this.eMarks[line];
4012 return this.src.slice(first, last);
4013 }
4014
4015 queue = new Array(end - begin);
4016
4017 for (i = 0; line < end; line++, i++) {
4018 shift = this.tShift[line];
4019 if (shift > indent) { shift = indent; }
4020 if (shift < 0) { shift = 0; }
4021
4022 first = this.bMarks[line] + shift;
4023
4024 if (line + 1 < end || keepLastLF) {
4025 // No need for bounds check because we have fake entry on tail.
4026 last = this.eMarks[line] + 1;
4027 } else {
4028 last = this.eMarks[line];
4029 }
4030
4031 queue[i] = this.src.slice(first, last);
4032 }
4033
4034 return queue.join('');
4035};
4036
4037// Code block (4 spaces padded)
4038
4039function code(state, startLine, endLine/*, silent*/) {
4040 var nextLine, last;
4041
4042 if (state.tShift[startLine] - state.blkIndent < 4) { return false; }
4043
4044 last = nextLine = startLine + 1;
4045
4046 while (nextLine < endLine) {
4047 if (state.isEmpty(nextLine)) {
4048 nextLine++;
4049 continue;
4050 }
4051 if (state.tShift[nextLine] - state.blkIndent >= 4) {
4052 nextLine++;
4053 last = nextLine;
4054 continue;
4055 }
4056 break;
4057 }
4058
4059 state.line = nextLine;
4060 state.tokens.push({
4061 type: 'code',
4062 content: state.getLines(startLine, last, 4 + state.blkIndent, true),
4063 block: true,
4064 lines: [ startLine, state.line ],
4065 level: state.level
4066 });
4067
4068 return true;
4069}
4070
4071// fences (``` lang, ~~~ lang)
4072
4073function fences(state, startLine, endLine, silent) {
4074 var marker, len, params, nextLine, mem,
4075 haveEndMarker = false,
4076 pos = state.bMarks[startLine] + state.tShift[startLine],
4077 max = state.eMarks[startLine];
4078
4079 if (pos + 3 > max) { return false; }
4080
4081 marker = state.src.charCodeAt(pos);
4082
4083 if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
4084 return false;
4085 }
4086
4087 // scan marker length
4088 mem = pos;
4089 pos = state.skipChars(pos, marker);
4090
4091 len = pos - mem;
4092
4093 if (len < 3) { return false; }
4094
4095 params = state.src.slice(pos, max).trim();
4096
4097 if (params.indexOf('`') >= 0) { return false; }
4098
4099 // Since start is found, we can report success here in validation mode
4100 if (silent) { return true; }
4101
4102 // search end of block
4103 nextLine = startLine;
4104
4105 for (;;) {
4106 nextLine++;
4107 if (nextLine >= endLine) {
4108 // unclosed block should be autoclosed by end of document.
4109 // also block seems to be autoclosed by end of parent
4110 break;
4111 }
4112
4113 pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
4114 max = state.eMarks[nextLine];
4115
4116 if (pos < max && state.tShift[nextLine] < state.blkIndent) {
4117 // non-empty line with negative indent should stop the list:
4118 // - ```
4119 // test
4120 break;
4121 }
4122
4123 if (state.src.charCodeAt(pos) !== marker) { continue; }
4124
4125 if (state.tShift[nextLine] - state.blkIndent >= 4) {
4126 // closing fence should be indented less than 4 spaces
4127 continue;
4128 }
4129
4130 pos = state.skipChars(pos, marker);
4131
4132 // closing code fence must be at least as long as the opening one
4133 if (pos - mem < len) { continue; }
4134
4135 // make sure tail has spaces only
4136 pos = state.skipSpaces(pos);
4137
4138 if (pos < max) { continue; }
4139
4140 haveEndMarker = true;
4141 // found!
4142 break;
4143 }
4144
4145 // If a fence has heading spaces, they should be removed from its inner block
4146 len = state.tShift[startLine];
4147
4148 state.line = nextLine + (haveEndMarker ? 1 : 0);
4149 state.tokens.push({
4150 type: 'fence',
4151 params: params,
4152 content: state.getLines(startLine + 1, nextLine, len, true),
4153 lines: [ startLine, state.line ],
4154 level: state.level
4155 });
4156
4157 return true;
4158}
4159
4160// Block quotes
4161
4162function blockquote(state, startLine, endLine, silent) {
4163 var nextLine, lastLineEmpty, oldTShift, oldBMarks, oldIndent, oldParentType, lines,
4164 terminatorRules,
4165 i, l, terminate,
4166 pos = state.bMarks[startLine] + state.tShift[startLine],
4167 max = state.eMarks[startLine];
4168
4169 if (pos > max) { return false; }
4170
4171 // check the block quote marker
4172 if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
4173
4174 if (state.level >= state.options.maxNesting) { return false; }
4175
4176 // we know that it's going to be a valid blockquote,
4177 // so no point trying to find the end of it in silent mode
4178 if (silent) { return true; }
4179
4180 // skip one optional space after '>'
4181 if (state.src.charCodeAt(pos) === 0x20) { pos++; }
4182
4183 oldIndent = state.blkIndent;
4184 state.blkIndent = 0;
4185
4186 oldBMarks = [ state.bMarks[startLine] ];
4187 state.bMarks[startLine] = pos;
4188
4189 // check if we have an empty blockquote
4190 pos = pos < max ? state.skipSpaces(pos) : pos;
4191 lastLineEmpty = pos >= max;
4192
4193 oldTShift = [ state.tShift[startLine] ];
4194 state.tShift[startLine] = pos - state.bMarks[startLine];
4195
4196 terminatorRules = state.parser.ruler.getRules('blockquote');
4197
4198 // Search the end of the block
4199 //
4200 // Block ends with either:
4201 // 1. an empty line outside:
4202 // ```
4203 // > test
4204 //
4205 // ```
4206 // 2. an empty line inside:
4207 // ```
4208 // >
4209 // test
4210 // ```
4211 // 3. another tag
4212 // ```
4213 // > test
4214 // - - -
4215 // ```
4216 for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
4217 pos = state.bMarks[nextLine] + state.tShift[nextLine];
4218 max = state.eMarks[nextLine];
4219
4220 if (pos >= max) {
4221 // Case 1: line is not inside the blockquote, and this line is empty.
4222 break;
4223 }
4224
4225 if (state.src.charCodeAt(pos++) === 0x3E/* > */) {
4226 // This line is inside the blockquote.
4227
4228 // skip one optional space after '>'
4229 if (state.src.charCodeAt(pos) === 0x20) { pos++; }
4230
4231 oldBMarks.push(state.bMarks[nextLine]);
4232 state.bMarks[nextLine] = pos;
4233
4234 pos = pos < max ? state.skipSpaces(pos) : pos;
4235 lastLineEmpty = pos >= max;
4236
4237 oldTShift.push(state.tShift[nextLine]);
4238 state.tShift[nextLine] = pos - state.bMarks[nextLine];
4239 continue;
4240 }
4241
4242 // Case 2: line is not inside the blockquote, and the last line was empty.
4243 if (lastLineEmpty) { break; }
4244
4245 // Case 3: another tag found.
4246 terminate = false;
4247 for (i = 0, l = terminatorRules.length; i < l; i++) {
4248 if (terminatorRules[i](state, nextLine, endLine, true)) {
4249 terminate = true;
4250 break;
4251 }
4252 }
4253 if (terminate) { break; }
4254
4255 oldBMarks.push(state.bMarks[nextLine]);
4256 oldTShift.push(state.tShift[nextLine]);
4257
4258 // A negative number means that this is a paragraph continuation;
4259 //
4260 // Any negative number will do the job here, but it's better for it
4261 // to be large enough to make any bugs obvious.
4262 state.tShift[nextLine] = -1337;
4263 }
4264
4265 oldParentType = state.parentType;
4266 state.parentType = 'blockquote';
4267 state.tokens.push({
4268 type: 'blockquote_open',
4269 lines: lines = [ startLine, 0 ],
4270 level: state.level++
4271 });
4272 state.parser.tokenize(state, startLine, nextLine);
4273 state.tokens.push({
4274 type: 'blockquote_close',
4275 level: --state.level
4276 });
4277 state.parentType = oldParentType;
4278 lines[1] = state.line;
4279
4280 // Restore original tShift; this might not be necessary since the parser
4281 // has already been here, but just to make sure we can do that.
4282 for (i = 0; i < oldTShift.length; i++) {
4283 state.bMarks[i + startLine] = oldBMarks[i];
4284 state.tShift[i + startLine] = oldTShift[i];
4285 }
4286 state.blkIndent = oldIndent;
4287
4288 return true;
4289}
4290
4291// Horizontal rule
4292
4293function hr(state, startLine, endLine, silent) {
4294 var marker, cnt, ch,
4295 pos = state.bMarks[startLine],
4296 max = state.eMarks[startLine];
4297
4298 pos += state.tShift[startLine];
4299
4300 if (pos > max) { return false; }
4301
4302 marker = state.src.charCodeAt(pos++);
4303
4304 // Check hr marker
4305 if (marker !== 0x2A/* * */ &&
4306 marker !== 0x2D/* - */ &&
4307 marker !== 0x5F/* _ */) {
4308 return false;
4309 }
4310
4311 // markers can be mixed with spaces, but there should be at least 3 one
4312
4313 cnt = 1;
4314 while (pos < max) {
4315 ch = state.src.charCodeAt(pos++);
4316 if (ch !== marker && ch !== 0x20/* space */) { return false; }
4317 if (ch === marker) { cnt++; }
4318 }
4319
4320 if (cnt < 3) { return false; }
4321
4322 if (silent) { return true; }
4323
4324 state.line = startLine + 1;
4325 state.tokens.push({
4326 type: 'hr',
4327 lines: [ startLine, state.line ],
4328 level: state.level
4329 });
4330
4331 return true;
4332}
4333
4334// Lists
4335
4336// Search `[-+*][\n ]`, returns next pos arter marker on success
4337// or -1 on fail.
4338function skipBulletListMarker(state, startLine) {
4339 var marker, pos, max;
4340
4341 pos = state.bMarks[startLine] + state.tShift[startLine];
4342 max = state.eMarks[startLine];
4343
4344 if (pos >= max) { return -1; }
4345
4346 marker = state.src.charCodeAt(pos++);
4347 // Check bullet
4348 if (marker !== 0x2A/* * */ &&
4349 marker !== 0x2D/* - */ &&
4350 marker !== 0x2B/* + */) {
4351 return -1;
4352 }
4353
4354 if (pos < max && state.src.charCodeAt(pos) !== 0x20) {
4355 // " 1.test " - is not a list item
4356 return -1;
4357 }
4358
4359 return pos;
4360}
4361
4362// Search `\d+[.)][\n ]`, returns next pos arter marker on success
4363// or -1 on fail.
4364function skipOrderedListMarker(state, startLine) {
4365 var ch,
4366 pos = state.bMarks[startLine] + state.tShift[startLine],
4367 max = state.eMarks[startLine];
4368
4369 if (pos + 1 >= max) { return -1; }
4370
4371 ch = state.src.charCodeAt(pos++);
4372
4373 if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
4374
4375 for (;;) {
4376 // EOL -> fail
4377 if (pos >= max) { return -1; }
4378
4379 ch = state.src.charCodeAt(pos++);
4380
4381 if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
4382 continue;
4383 }
4384
4385 // found valid marker
4386 if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
4387 break;
4388 }
4389
4390 return -1;
4391 }
4392
4393
4394 if (pos < max && state.src.charCodeAt(pos) !== 0x20/* space */) {
4395 // " 1.test " - is not a list item
4396 return -1;
4397 }
4398 return pos;
4399}
4400
4401function markTightParagraphs(state, idx) {
4402 var i, l,
4403 level = state.level + 2;
4404
4405 for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
4406 if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
4407 state.tokens[i + 2].tight = true;
4408 state.tokens[i].tight = true;
4409 i += 2;
4410 }
4411 }
4412}
4413
4414
4415function list(state, startLine, endLine, silent) {
4416 var nextLine,
4417 indent,
4418 oldTShift,
4419 oldIndent,
4420 oldTight,
4421 oldParentType,
4422 start,
4423 posAfterMarker,
4424 max,
4425 indentAfterMarker,
4426 markerValue,
4427 markerCharCode,
4428 isOrdered,
4429 contentStart,
4430 listTokIdx,
4431 prevEmptyEnd,
4432 listLines,
4433 itemLines,
4434 tight = true,
4435 terminatorRules,
4436 i, l, terminate;
4437
4438 // Detect list type and position after marker
4439 if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
4440 isOrdered = true;
4441 } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
4442 isOrdered = false;
4443 } else {
4444 return false;
4445 }
4446
4447 if (state.level >= state.options.maxNesting) { return false; }
4448
4449 // We should terminate list on style change. Remember first one to compare.
4450 markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
4451
4452 // For validation mode we can terminate immediately
4453 if (silent) { return true; }
4454
4455 // Start list
4456 listTokIdx = state.tokens.length;
4457
4458 if (isOrdered) {
4459 start = state.bMarks[startLine] + state.tShift[startLine];
4460 markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
4461
4462 state.tokens.push({
4463 type: 'ordered_list_open',
4464 order: markerValue,
4465 lines: listLines = [ startLine, 0 ],
4466 level: state.level++
4467 });
4468
4469 } else {
4470 state.tokens.push({
4471 type: 'bullet_list_open',
4472 lines: listLines = [ startLine, 0 ],
4473 level: state.level++
4474 });
4475 }
4476
4477 //
4478 // Iterate list items
4479 //
4480
4481 nextLine = startLine;
4482 prevEmptyEnd = false;
4483 terminatorRules = state.parser.ruler.getRules('list');
4484
4485 while (nextLine < endLine) {
4486 contentStart = state.skipSpaces(posAfterMarker);
4487 max = state.eMarks[nextLine];
4488
4489 if (contentStart >= max) {
4490 // trimming space in "- \n 3" case, indent is 1 here
4491 indentAfterMarker = 1;
4492 } else {
4493 indentAfterMarker = contentStart - posAfterMarker;
4494 }
4495
4496 // If we have more than 4 spaces, the indent is 1
4497 // (the rest is just indented code block)
4498 if (indentAfterMarker > 4) { indentAfterMarker = 1; }
4499
4500 // If indent is less than 1, assume that it's one, example:
4501 // "-\n test"
4502 if (indentAfterMarker < 1) { indentAfterMarker = 1; }
4503
4504 // " - test"
4505 // ^^^^^ - calculating total length of this thing
4506 indent = (posAfterMarker - state.bMarks[nextLine]) + indentAfterMarker;
4507
4508 // Run subparser & write tokens
4509 state.tokens.push({
4510 type: 'list_item_open',
4511 lines: itemLines = [ startLine, 0 ],
4512 level: state.level++
4513 });
4514
4515 oldIndent = state.blkIndent;
4516 oldTight = state.tight;
4517 oldTShift = state.tShift[startLine];
4518 oldParentType = state.parentType;
4519 state.tShift[startLine] = contentStart - state.bMarks[startLine];
4520 state.blkIndent = indent;
4521 state.tight = true;
4522 state.parentType = 'list';
4523
4524 state.parser.tokenize(state, startLine, endLine, true);
4525
4526 // If any of list item is tight, mark list as tight
4527 if (!state.tight || prevEmptyEnd) {
4528 tight = false;
4529 }
4530 // Item become loose if finish with empty line,
4531 // but we should filter last element, because it means list finish
4532 prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);
4533
4534 state.blkIndent = oldIndent;
4535 state.tShift[startLine] = oldTShift;
4536 state.tight = oldTight;
4537 state.parentType = oldParentType;
4538
4539 state.tokens.push({
4540 type: 'list_item_close',
4541 level: --state.level
4542 });
4543
4544 nextLine = startLine = state.line;
4545 itemLines[1] = nextLine;
4546 contentStart = state.bMarks[startLine];
4547
4548 if (nextLine >= endLine) { break; }
4549
4550 if (state.isEmpty(nextLine)) {
4551 break;
4552 }
4553
4554 //
4555 // Try to check if list is terminated or continued.
4556 //
4557 if (state.tShift[nextLine] < state.blkIndent) { break; }
4558
4559 // fail if terminating block found
4560 terminate = false;
4561 for (i = 0, l = terminatorRules.length; i < l; i++) {
4562 if (terminatorRules[i](state, nextLine, endLine, true)) {
4563 terminate = true;
4564 break;
4565 }
4566 }
4567 if (terminate) { break; }
4568
4569 // fail if list has another type
4570 if (isOrdered) {
4571 posAfterMarker = skipOrderedListMarker(state, nextLine);
4572 if (posAfterMarker < 0) { break; }
4573 } else {
4574 posAfterMarker = skipBulletListMarker(state, nextLine);
4575 if (posAfterMarker < 0) { break; }
4576 }
4577
4578 if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
4579 }
4580
4581 // Finilize list
4582 state.tokens.push({
4583 type: isOrdered ? 'ordered_list_close' : 'bullet_list_close',
4584 level: --state.level
4585 });
4586 listLines[1] = nextLine;
4587
4588 state.line = nextLine;
4589
4590 // mark paragraphs tight if needed
4591 if (tight) {
4592 markTightParagraphs(state, listTokIdx);
4593 }
4594
4595 return true;
4596}
4597
4598// Process footnote reference list
4599
4600function footnote(state, startLine, endLine, silent) {
4601 var oldBMark, oldTShift, oldParentType, pos, label,
4602 start = state.bMarks[startLine] + state.tShift[startLine],
4603 max = state.eMarks[startLine];
4604
4605 // line should be at least 5 chars - "[^x]:"
4606 if (start + 4 > max) { return false; }
4607
4608 if (state.src.charCodeAt(start) !== 0x5B/* [ */) { return false; }
4609 if (state.src.charCodeAt(start + 1) !== 0x5E/* ^ */) { return false; }
4610 if (state.level >= state.options.maxNesting) { return false; }
4611
4612 for (pos = start + 2; pos < max; pos++) {
4613 if (state.src.charCodeAt(pos) === 0x20) { return false; }
4614 if (state.src.charCodeAt(pos) === 0x5D /* ] */) {
4615 break;
4616 }
4617 }
4618
4619 if (pos === start + 2) { return false; } // no empty footnote labels
4620 if (pos + 1 >= max || state.src.charCodeAt(++pos) !== 0x3A /* : */) { return false; }
4621 if (silent) { return true; }
4622 pos++;
4623
4624 if (!state.env.footnotes) { state.env.footnotes = {}; }
4625 if (!state.env.footnotes.refs) { state.env.footnotes.refs = {}; }
4626 label = state.src.slice(start + 2, pos - 2);
4627 state.env.footnotes.refs[':' + label] = -1;
4628
4629 state.tokens.push({
4630 type: 'footnote_reference_open',
4631 label: label,
4632 level: state.level++
4633 });
4634
4635 oldBMark = state.bMarks[startLine];
4636 oldTShift = state.tShift[startLine];
4637 oldParentType = state.parentType;
4638 state.tShift[startLine] = state.skipSpaces(pos) - pos;
4639 state.bMarks[startLine] = pos;
4640 state.blkIndent += 4;
4641 state.parentType = 'footnote';
4642
4643 if (state.tShift[startLine] < state.blkIndent) {
4644 state.tShift[startLine] += state.blkIndent;
4645 state.bMarks[startLine] -= state.blkIndent;
4646 }
4647
4648 state.parser.tokenize(state, startLine, endLine, true);
4649
4650 state.parentType = oldParentType;
4651 state.blkIndent -= 4;
4652 state.tShift[startLine] = oldTShift;
4653 state.bMarks[startLine] = oldBMark;
4654
4655 state.tokens.push({
4656 type: 'footnote_reference_close',
4657 level: --state.level
4658 });
4659
4660 return true;
4661}
4662
4663// heading (#, ##, ...)
4664
4665function heading(state, startLine, endLine, silent) {
4666 var ch, level, tmp,
4667 pos = state.bMarks[startLine] + state.tShift[startLine],
4668 max = state.eMarks[startLine];
4669
4670 if (pos >= max) { return false; }
4671
4672 ch = state.src.charCodeAt(pos);
4673
4674 if (ch !== 0x23/* # */ || pos >= max) { return false; }
4675
4676 // count heading level
4677 level = 1;
4678 ch = state.src.charCodeAt(++pos);
4679 while (ch === 0x23/* # */ && pos < max && level <= 6) {
4680 level++;
4681 ch = state.src.charCodeAt(++pos);
4682 }
4683
4684 if (level > 6 || (pos < max && ch !== 0x20/* space */)) { return false; }
4685
4686 if (silent) { return true; }
4687
4688 // Let's cut tails like ' ### ' from the end of string
4689
4690 max = state.skipCharsBack(max, 0x20, pos); // space
4691 tmp = state.skipCharsBack(max, 0x23, pos); // #
4692 if (tmp > pos && state.src.charCodeAt(tmp - 1) === 0x20/* space */) {
4693 max = tmp;
4694 }
4695
4696 state.line = startLine + 1;
4697
4698 state.tokens.push({ type: 'heading_open',
4699 hLevel: level,
4700 lines: [ startLine, state.line ],
4701 level: state.level
4702 });
4703
4704 // only if header is not empty
4705 if (pos < max) {
4706 state.tokens.push({
4707 type: 'inline',
4708 content: state.src.slice(pos, max).trim(),
4709 level: state.level + 1,
4710 lines: [ startLine, state.line ],
4711 children: []
4712 });
4713 }
4714 state.tokens.push({ type: 'heading_close', hLevel: level, level: state.level });
4715
4716 return true;
4717}
4718
4719// lheading (---, ===)
4720
4721function lheading(state, startLine, endLine/*, silent*/) {
4722 var marker, pos, max,
4723 next = startLine + 1;
4724
4725 if (next >= endLine) { return false; }
4726 if (state.tShift[next] < state.blkIndent) { return false; }
4727
4728 // Scan next line
4729
4730 if (state.tShift[next] - state.blkIndent > 3) { return false; }
4731
4732 pos = state.bMarks[next] + state.tShift[next];
4733 max = state.eMarks[next];
4734
4735 if (pos >= max) { return false; }
4736
4737 marker = state.src.charCodeAt(pos);
4738
4739 if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; }
4740
4741 pos = state.skipChars(pos, marker);
4742
4743 pos = state.skipSpaces(pos);
4744
4745 if (pos < max) { return false; }
4746
4747 pos = state.bMarks[startLine] + state.tShift[startLine];
4748
4749 state.line = next + 1;
4750 state.tokens.push({
4751 type: 'heading_open',
4752 hLevel: marker === 0x3D/* = */ ? 1 : 2,
4753 lines: [ startLine, state.line ],
4754 level: state.level
4755 });
4756 state.tokens.push({
4757 type: 'inline',
4758 content: state.src.slice(pos, state.eMarks[startLine]).trim(),
4759 level: state.level + 1,
4760 lines: [ startLine, state.line - 1 ],
4761 children: []
4762 });
4763 state.tokens.push({
4764 type: 'heading_close',
4765 hLevel: marker === 0x3D/* = */ ? 1 : 2,
4766 level: state.level
4767 });
4768
4769 return true;
4770}
4771
4772// List of valid html blocks names, accorting to commonmark spec
4773// http://jgm.github.io/CommonMark/spec.html#html-blocks
4774
4775var html_blocks = {};
4776
4777[
4778 'article',
4779 'aside',
4780 'button',
4781 'blockquote',
4782 'body',
4783 'canvas',
4784 'caption',
4785 'col',
4786 'colgroup',
4787 'dd',
4788 'div',
4789 'dl',
4790 'dt',
4791 'embed',
4792 'fieldset',
4793 'figcaption',
4794 'figure',
4795 'footer',
4796 'form',
4797 'h1',
4798 'h2',
4799 'h3',
4800 'h4',
4801 'h5',
4802 'h6',
4803 'header',
4804 'hgroup',
4805 'hr',
4806 'iframe',
4807 'li',
4808 'map',
4809 'object',
4810 'ol',
4811 'output',
4812 'p',
4813 'pre',
4814 'progress',
4815 'script',
4816 'section',
4817 'style',
4818 'table',
4819 'tbody',
4820 'td',
4821 'textarea',
4822 'tfoot',
4823 'th',
4824 'tr',
4825 'thead',
4826 'ul',
4827 'video'
4828].forEach(function (name) { html_blocks[name] = true; });
4829
4830// HTML block
4831
4832
4833var HTML_TAG_OPEN_RE = /^<([a-zA-Z]{1,15})[\s\/>]/;
4834var HTML_TAG_CLOSE_RE = /^<\/([a-zA-Z]{1,15})[\s>]/;
4835
4836function isLetter$1(ch) {
4837 /*eslint no-bitwise:0*/
4838 var lc = ch | 0x20; // to lower case
4839 return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
4840}
4841
4842function htmlblock(state, startLine, endLine, silent) {
4843 var ch, match, nextLine,
4844 pos = state.bMarks[startLine],
4845 max = state.eMarks[startLine],
4846 shift = state.tShift[startLine];
4847
4848 pos += shift;
4849
4850 if (!state.options.html) { return false; }
4851
4852 if (shift > 3 || pos + 2 >= max) { return false; }
4853
4854 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
4855
4856 ch = state.src.charCodeAt(pos + 1);
4857
4858 if (ch === 0x21/* ! */ || ch === 0x3F/* ? */) {
4859 // Directive start / comment start / processing instruction start
4860 if (silent) { return true; }
4861
4862 } else if (ch === 0x2F/* / */ || isLetter$1(ch)) {
4863
4864 // Probably start or end of tag
4865 if (ch === 0x2F/* \ */) {
4866 // closing tag
4867 match = state.src.slice(pos, max).match(HTML_TAG_CLOSE_RE);
4868 if (!match) { return false; }
4869 } else {
4870 // opening tag
4871 match = state.src.slice(pos, max).match(HTML_TAG_OPEN_RE);
4872 if (!match) { return false; }
4873 }
4874 // Make sure tag name is valid
4875 if (html_blocks[match[1].toLowerCase()] !== true) { return false; }
4876 if (silent) { return true; }
4877
4878 } else {
4879 return false;
4880 }
4881
4882 // If we are here - we detected HTML block.
4883 // Let's roll down till empty line (block end).
4884 nextLine = startLine + 1;
4885 while (nextLine < state.lineMax && !state.isEmpty(nextLine)) {
4886 nextLine++;
4887 }
4888
4889 state.line = nextLine;
4890 state.tokens.push({
4891 type: 'htmlblock',
4892 level: state.level,
4893 lines: [ startLine, state.line ],
4894 content: state.getLines(startLine, nextLine, 0, true)
4895 });
4896
4897 return true;
4898}
4899
4900// GFM table, non-standard
4901
4902function getLine(state, line) {
4903 var pos = state.bMarks[line] + state.blkIndent,
4904 max = state.eMarks[line];
4905
4906 return state.src.substr(pos, max - pos);
4907}
4908
4909function table(state, startLine, endLine, silent) {
4910 var ch, lineText, pos, i, nextLine, rows, cell,
4911 aligns, t, tableLines, tbodyLines;
4912
4913 // should have at least three lines
4914 if (startLine + 2 > endLine) { return false; }
4915
4916 nextLine = startLine + 1;
4917
4918 if (state.tShift[nextLine] < state.blkIndent) { return false; }
4919
4920 // first character of the second line should be '|' or '-'
4921
4922 pos = state.bMarks[nextLine] + state.tShift[nextLine];
4923 if (pos >= state.eMarks[nextLine]) { return false; }
4924
4925 ch = state.src.charCodeAt(pos);
4926 if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }
4927
4928 lineText = getLine(state, startLine + 1);
4929 if (!/^[-:| ]+$/.test(lineText)) { return false; }
4930
4931 rows = lineText.split('|');
4932 if (rows <= 2) { return false; }
4933 aligns = [];
4934 for (i = 0; i < rows.length; i++) {
4935 t = rows[i].trim();
4936 if (!t) {
4937 // allow empty columns before and after table, but not in between columns;
4938 // e.g. allow ` |---| `, disallow ` ---||--- `
4939 if (i === 0 || i === rows.length - 1) {
4940 continue;
4941 } else {
4942 return false;
4943 }
4944 }
4945
4946 if (!/^:?-+:?$/.test(t)) { return false; }
4947 if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
4948 aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
4949 } else if (t.charCodeAt(0) === 0x3A/* : */) {
4950 aligns.push('left');
4951 } else {
4952 aligns.push('');
4953 }
4954 }
4955
4956 lineText = getLine(state, startLine).trim();
4957 if (lineText.indexOf('|') === -1) { return false; }
4958 rows = lineText.replace(/^\||\|$/g, '').split('|');
4959 if (aligns.length !== rows.length) { return false; }
4960 if (silent) { return true; }
4961
4962 state.tokens.push({
4963 type: 'table_open',
4964 lines: tableLines = [ startLine, 0 ],
4965 level: state.level++
4966 });
4967 state.tokens.push({
4968 type: 'thead_open',
4969 lines: [ startLine, startLine + 1 ],
4970 level: state.level++
4971 });
4972
4973 state.tokens.push({
4974 type: 'tr_open',
4975 lines: [ startLine, startLine + 1 ],
4976 level: state.level++
4977 });
4978 for (i = 0; i < rows.length; i++) {
4979 state.tokens.push({
4980 type: 'th_open',
4981 align: aligns[i],
4982 lines: [ startLine, startLine + 1 ],
4983 level: state.level++
4984 });
4985 state.tokens.push({
4986 type: 'inline',
4987 content: rows[i].trim(),
4988 lines: [ startLine, startLine + 1 ],
4989 level: state.level,
4990 children: []
4991 });
4992 state.tokens.push({ type: 'th_close', level: --state.level });
4993 }
4994 state.tokens.push({ type: 'tr_close', level: --state.level });
4995 state.tokens.push({ type: 'thead_close', level: --state.level });
4996
4997 state.tokens.push({
4998 type: 'tbody_open',
4999 lines: tbodyLines = [ startLine + 2, 0 ],
5000 level: state.level++
5001 });
5002
5003 for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
5004 if (state.tShift[nextLine] < state.blkIndent) { break; }
5005
5006 lineText = getLine(state, nextLine).trim();
5007 if (lineText.indexOf('|') === -1) { break; }
5008 rows = lineText.replace(/^\||\|$/g, '').split('|');
5009
5010 state.tokens.push({ type: 'tr_open', level: state.level++ });
5011 for (i = 0; i < rows.length; i++) {
5012 state.tokens.push({ type: 'td_open', align: aligns[i], level: state.level++ });
5013 // 0x7c === '|'
5014 cell = rows[i].substring(
5015 rows[i].charCodeAt(0) === 0x7c ? 1 : 0,
5016 rows[i].charCodeAt(rows[i].length - 1) === 0x7c ? rows[i].length - 1 : rows[i].length
5017 ).trim();
5018 state.tokens.push({
5019 type: 'inline',
5020 content: cell,
5021 level: state.level,
5022 children: []
5023 });
5024 state.tokens.push({ type: 'td_close', level: --state.level });
5025 }
5026 state.tokens.push({ type: 'tr_close', level: --state.level });
5027 }
5028 state.tokens.push({ type: 'tbody_close', level: --state.level });
5029 state.tokens.push({ type: 'table_close', level: --state.level });
5030
5031 tableLines[1] = tbodyLines[1] = nextLine;
5032 state.line = nextLine;
5033 return true;
5034}
5035
5036// Definition lists
5037
5038// Search `[:~][\n ]`, returns next pos after marker on success
5039// or -1 on fail.
5040function skipMarker(state, line) {
5041 var pos, marker,
5042 start = state.bMarks[line] + state.tShift[line],
5043 max = state.eMarks[line];
5044
5045 if (start >= max) { return -1; }
5046
5047 // Check bullet
5048 marker = state.src.charCodeAt(start++);
5049 if (marker !== 0x7E/* ~ */ && marker !== 0x3A/* : */) { return -1; }
5050
5051 pos = state.skipSpaces(start);
5052
5053 // require space after ":"
5054 if (start === pos) { return -1; }
5055
5056 // no empty definitions, e.g. " : "
5057 if (pos >= max) { return -1; }
5058
5059 return pos;
5060}
5061
5062function markTightParagraphs$1(state, idx) {
5063 var i, l,
5064 level = state.level + 2;
5065
5066 for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
5067 if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
5068 state.tokens[i + 2].tight = true;
5069 state.tokens[i].tight = true;
5070 i += 2;
5071 }
5072 }
5073}
5074
5075function deflist(state, startLine, endLine, silent) {
5076 var contentStart,
5077 ddLine,
5078 dtLine,
5079 itemLines,
5080 listLines,
5081 listTokIdx,
5082 nextLine,
5083 oldIndent,
5084 oldDDIndent,
5085 oldParentType,
5086 oldTShift,
5087 oldTight,
5088 prevEmptyEnd,
5089 tight;
5090
5091 if (silent) {
5092 // quirk: validation mode validates a dd block only, not a whole deflist
5093 if (state.ddIndent < 0) { return false; }
5094 return skipMarker(state, startLine) >= 0;
5095 }
5096
5097 nextLine = startLine + 1;
5098 if (state.isEmpty(nextLine)) {
5099 if (++nextLine > endLine) { return false; }
5100 }
5101
5102 if (state.tShift[nextLine] < state.blkIndent) { return false; }
5103 contentStart = skipMarker(state, nextLine);
5104 if (contentStart < 0) { return false; }
5105
5106 if (state.level >= state.options.maxNesting) { return false; }
5107
5108 // Start list
5109 listTokIdx = state.tokens.length;
5110
5111 state.tokens.push({
5112 type: 'dl_open',
5113 lines: listLines = [ startLine, 0 ],
5114 level: state.level++
5115 });
5116
5117 //
5118 // Iterate list items
5119 //
5120
5121 dtLine = startLine;
5122 ddLine = nextLine;
5123
5124 // One definition list can contain multiple DTs,
5125 // and one DT can be followed by multiple DDs.
5126 //
5127 // Thus, there is two loops here, and label is
5128 // needed to break out of the second one
5129 //
5130 /*eslint no-labels:0,block-scoped-var:0*/
5131 OUTER:
5132 for (;;) {
5133 tight = true;
5134 prevEmptyEnd = false;
5135
5136 state.tokens.push({
5137 type: 'dt_open',
5138 lines: [ dtLine, dtLine ],
5139 level: state.level++
5140 });
5141 state.tokens.push({
5142 type: 'inline',
5143 content: state.getLines(dtLine, dtLine + 1, state.blkIndent, false).trim(),
5144 level: state.level + 1,
5145 lines: [ dtLine, dtLine ],
5146 children: []
5147 });
5148 state.tokens.push({
5149 type: 'dt_close',
5150 level: --state.level
5151 });
5152
5153 for (;;) {
5154 state.tokens.push({
5155 type: 'dd_open',
5156 lines: itemLines = [ nextLine, 0 ],
5157 level: state.level++
5158 });
5159
5160 oldTight = state.tight;
5161 oldDDIndent = state.ddIndent;
5162 oldIndent = state.blkIndent;
5163 oldTShift = state.tShift[ddLine];
5164 oldParentType = state.parentType;
5165 state.blkIndent = state.ddIndent = state.tShift[ddLine] + 2;
5166 state.tShift[ddLine] = contentStart - state.bMarks[ddLine];
5167 state.tight = true;
5168 state.parentType = 'deflist';
5169
5170 state.parser.tokenize(state, ddLine, endLine, true);
5171
5172 // If any of list item is tight, mark list as tight
5173 if (!state.tight || prevEmptyEnd) {
5174 tight = false;
5175 }
5176 // Item become loose if finish with empty line,
5177 // but we should filter last element, because it means list finish
5178 prevEmptyEnd = (state.line - ddLine) > 1 && state.isEmpty(state.line - 1);
5179
5180 state.tShift[ddLine] = oldTShift;
5181 state.tight = oldTight;
5182 state.parentType = oldParentType;
5183 state.blkIndent = oldIndent;
5184 state.ddIndent = oldDDIndent;
5185
5186 state.tokens.push({
5187 type: 'dd_close',
5188 level: --state.level
5189 });
5190
5191 itemLines[1] = nextLine = state.line;
5192
5193 if (nextLine >= endLine) { break OUTER; }
5194
5195 if (state.tShift[nextLine] < state.blkIndent) { break OUTER; }
5196 contentStart = skipMarker(state, nextLine);
5197 if (contentStart < 0) { break; }
5198
5199 ddLine = nextLine;
5200
5201 // go to the next loop iteration:
5202 // insert DD tag and repeat checking
5203 }
5204
5205 if (nextLine >= endLine) { break; }
5206 dtLine = nextLine;
5207
5208 if (state.isEmpty(dtLine)) { break; }
5209 if (state.tShift[dtLine] < state.blkIndent) { break; }
5210
5211 ddLine = dtLine + 1;
5212 if (ddLine >= endLine) { break; }
5213 if (state.isEmpty(ddLine)) { ddLine++; }
5214 if (ddLine >= endLine) { break; }
5215
5216 if (state.tShift[ddLine] < state.blkIndent) { break; }
5217 contentStart = skipMarker(state, ddLine);
5218 if (contentStart < 0) { break; }
5219
5220 // go to the next loop iteration:
5221 // insert DT and DD tags and repeat checking
5222 }
5223
5224 // Finilize list
5225 state.tokens.push({
5226 type: 'dl_close',
5227 level: --state.level
5228 });
5229 listLines[1] = nextLine;
5230
5231 state.line = nextLine;
5232
5233 // mark paragraphs tight if needed
5234 if (tight) {
5235 markTightParagraphs$1(state, listTokIdx);
5236 }
5237
5238 return true;
5239}
5240
5241// Paragraph
5242
5243function paragraph(state, startLine/*, endLine*/) {
5244 var endLine, content, terminate, i, l,
5245 nextLine = startLine + 1,
5246 terminatorRules;
5247
5248 endLine = state.lineMax;
5249
5250 // jump line-by-line until empty one or EOF
5251 if (nextLine < endLine && !state.isEmpty(nextLine)) {
5252 terminatorRules = state.parser.ruler.getRules('paragraph');
5253
5254 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
5255 // this would be a code block normally, but after paragraph
5256 // it's considered a lazy continuation regardless of what's there
5257 if (state.tShift[nextLine] - state.blkIndent > 3) { continue; }
5258
5259 // Some tags can terminate paragraph without empty line.
5260 terminate = false;
5261 for (i = 0, l = terminatorRules.length; i < l; i++) {
5262 if (terminatorRules[i](state, nextLine, endLine, true)) {
5263 terminate = true;
5264 break;
5265 }
5266 }
5267 if (terminate) { break; }
5268 }
5269 }
5270
5271 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
5272
5273 state.line = nextLine;
5274 if (content.length) {
5275 state.tokens.push({
5276 type: 'paragraph_open',
5277 tight: false,
5278 lines: [ startLine, state.line ],
5279 level: state.level
5280 });
5281 state.tokens.push({
5282 type: 'inline',
5283 content: content,
5284 level: state.level + 1,
5285 lines: [ startLine, state.line ],
5286 children: []
5287 });
5288 state.tokens.push({
5289 type: 'paragraph_close',
5290 tight: false,
5291 level: state.level
5292 });
5293 }
5294
5295 return true;
5296}
5297
5298/**
5299 * Parser rules
5300 */
5301
5302var _rules$1 = [
5303 [ 'code', code ],
5304 [ 'fences', fences, [ 'paragraph', 'blockquote', 'list' ] ],
5305 [ 'blockquote', blockquote, [ 'paragraph', 'blockquote', 'list' ] ],
5306 [ 'hr', hr, [ 'paragraph', 'blockquote', 'list' ] ],
5307 [ 'list', list, [ 'paragraph', 'blockquote' ] ],
5308 [ 'footnote', footnote, [ 'paragraph' ] ],
5309 [ 'heading', heading, [ 'paragraph', 'blockquote' ] ],
5310 [ 'lheading', lheading ],
5311 [ 'htmlblock', htmlblock, [ 'paragraph', 'blockquote' ] ],
5312 [ 'table', table, [ 'paragraph' ] ],
5313 [ 'deflist', deflist, [ 'paragraph' ] ],
5314 [ 'paragraph', paragraph ]
5315];
5316
5317/**
5318 * Block Parser class
5319 *
5320 * @api private
5321 */
5322
5323function ParserBlock() {
5324 this.ruler = new Ruler();
5325 for (var i = 0; i < _rules$1.length; i++) {
5326 this.ruler.push(_rules$1[i][0], _rules$1[i][1], {
5327 alt: (_rules$1[i][2] || []).slice()
5328 });
5329 }
5330}
5331
5332/**
5333 * Generate tokens for the given input range.
5334 *
5335 * @param {Object} `state` Has properties like `src`, `parser`, `options` etc
5336 * @param {Number} `startLine`
5337 * @param {Number} `endLine`
5338 * @api private
5339 */
5340
5341ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
5342 var rules = this.ruler.getRules('');
5343 var len = rules.length;
5344 var line = startLine;
5345 var hasEmptyLines = false;
5346 var ok, i;
5347
5348 while (line < endLine) {
5349 state.line = line = state.skipEmptyLines(line);
5350 if (line >= endLine) {
5351 break;
5352 }
5353
5354 // Termination condition for nested calls.
5355 // Nested calls currently used for blockquotes & lists
5356 if (state.tShift[line] < state.blkIndent) {
5357 break;
5358 }
5359
5360 // Try all possible rules.
5361 // On success, rule should:
5362 //
5363 // - update `state.line`
5364 // - update `state.tokens`
5365 // - return true
5366
5367 for (i = 0; i < len; i++) {
5368 ok = rules[i](state, line, endLine, false);
5369 if (ok) {
5370 break;
5371 }
5372 }
5373
5374 // set state.tight iff we had an empty line before current tag
5375 // i.e. latest empty line should not count
5376 state.tight = !hasEmptyLines;
5377
5378 // paragraph might "eat" one newline after it in nested lists
5379 if (state.isEmpty(state.line - 1)) {
5380 hasEmptyLines = true;
5381 }
5382
5383 line = state.line;
5384
5385 if (line < endLine && state.isEmpty(line)) {
5386 hasEmptyLines = true;
5387 line++;
5388
5389 // two empty lines should stop the parser in list mode
5390 if (line < endLine && state.parentType === 'list' && state.isEmpty(line)) { break; }
5391 state.line = line;
5392 }
5393 }
5394};
5395
5396var TABS_SCAN_RE = /[\n\t]/g;
5397var NEWLINES_RE = /\r[\n\u0085]|[\u2424\u2028\u0085]/g;
5398var SPACES_RE = /\u00a0/g;
5399
5400/**
5401 * Tokenize the given `str`.
5402 *
5403 * @param {String} `str` Source string
5404 * @param {Object} `options`
5405 * @param {Object} `env`
5406 * @param {Array} `outTokens`
5407 * @api private
5408 */
5409
5410ParserBlock.prototype.parse = function (str, options, env, outTokens) {
5411 var state, lineStart = 0, lastTabPos = 0;
5412 if (!str) { return []; }
5413
5414 // Normalize spaces
5415 str = str.replace(SPACES_RE, ' ');
5416
5417 // Normalize newlines
5418 str = str.replace(NEWLINES_RE, '\n');
5419
5420 // Replace tabs with proper number of spaces (1..4)
5421 if (str.indexOf('\t') >= 0) {
5422 str = str.replace(TABS_SCAN_RE, function (match, offset) {
5423 var result;
5424 if (str.charCodeAt(offset) === 0x0A) {
5425 lineStart = offset + 1;
5426 lastTabPos = 0;
5427 return match;
5428 }
5429 result = ' '.slice((offset - lineStart - lastTabPos) % 4);
5430 lastTabPos = offset - lineStart + 1;
5431 return result;
5432 });
5433 }
5434
5435 state = new StateBlock(str, this, options, env, outTokens);
5436 this.tokenize(state, state.line, state.lineMax);
5437};
5438
5439// Skip text characters for text token, place those to pending buffer
5440// and increment current pos
5441
5442// Rule to skip pure text
5443// '{}$%@~+=:' reserved for extentions
5444
5445function isTerminatorChar(ch) {
5446 switch (ch) {
5447 case 0x0A/* \n */:
5448 case 0x5C/* \ */:
5449 case 0x60/* ` */:
5450 case 0x2A/* * */:
5451 case 0x5F/* _ */:
5452 case 0x5E/* ^ */:
5453 case 0x5B/* [ */:
5454 case 0x5D/* ] */:
5455 case 0x21/* ! */:
5456 case 0x26/* & */:
5457 case 0x3C/* < */:
5458 case 0x3E/* > */:
5459 case 0x7B/* { */:
5460 case 0x7D/* } */:
5461 case 0x24/* $ */:
5462 case 0x25/* % */:
5463 case 0x40/* @ */:
5464 case 0x7E/* ~ */:
5465 case 0x2B/* + */:
5466 case 0x3D/* = */:
5467 case 0x3A/* : */:
5468 return true;
5469 default:
5470 return false;
5471 }
5472}
5473
5474function text(state, silent) {
5475 var pos = state.pos;
5476
5477 while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
5478 pos++;
5479 }
5480
5481 if (pos === state.pos) { return false; }
5482
5483 if (!silent) { state.pending += state.src.slice(state.pos, pos); }
5484
5485 state.pos = pos;
5486
5487 return true;
5488}
5489
5490// Proceess '\n'
5491
5492function newline(state, silent) {
5493 var pmax, max, pos = state.pos;
5494
5495 if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
5496
5497 pmax = state.pending.length - 1;
5498 max = state.posMax;
5499
5500 // ' \n' -> hardbreak
5501 // Lookup in pending chars is bad practice! Don't copy to other rules!
5502 // Pending string is stored in concat mode, indexed lookups will cause
5503 // convertion to flat mode.
5504 if (!silent) {
5505 if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
5506 if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
5507 // Strip out all trailing spaces on this line.
5508 for (var i = pmax - 2; i >= 0; i--) {
5509 if (state.pending.charCodeAt(i) !== 0x20) {
5510 state.pending = state.pending.substring(0, i + 1);
5511 break;
5512 }
5513 }
5514 state.push({
5515 type: 'hardbreak',
5516 level: state.level
5517 });
5518 } else {
5519 state.pending = state.pending.slice(0, -1);
5520 state.push({
5521 type: 'softbreak',
5522 level: state.level
5523 });
5524 }
5525
5526 } else {
5527 state.push({
5528 type: 'softbreak',
5529 level: state.level
5530 });
5531 }
5532 }
5533
5534 pos++;
5535
5536 // skip heading spaces for next line
5537 while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; }
5538
5539 state.pos = pos;
5540 return true;
5541}
5542
5543// Proceess escaped chars and hardbreaks
5544
5545var ESCAPED = [];
5546
5547for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
5548
5549'\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
5550 .split('').forEach(function(ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
5551
5552
5553function escape(state, silent) {
5554 var ch, pos = state.pos, max = state.posMax;
5555
5556 if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }
5557
5558 pos++;
5559
5560 if (pos < max) {
5561 ch = state.src.charCodeAt(pos);
5562
5563 if (ch < 256 && ESCAPED[ch] !== 0) {
5564 if (!silent) { state.pending += state.src[pos]; }
5565 state.pos += 2;
5566 return true;
5567 }
5568
5569 if (ch === 0x0A) {
5570 if (!silent) {
5571 state.push({
5572 type: 'hardbreak',
5573 level: state.level
5574 });
5575 }
5576
5577 pos++;
5578 // skip leading whitespaces from next line
5579 while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; }
5580
5581 state.pos = pos;
5582 return true;
5583 }
5584 }
5585
5586 if (!silent) { state.pending += '\\'; }
5587 state.pos++;
5588 return true;
5589}
5590
5591// Parse backticks
5592
5593function backticks(state, silent) {
5594 var start, max, marker, matchStart, matchEnd,
5595 pos = state.pos,
5596 ch = state.src.charCodeAt(pos);
5597
5598 if (ch !== 0x60/* ` */) { return false; }
5599
5600 start = pos;
5601 pos++;
5602 max = state.posMax;
5603
5604 while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
5605
5606 marker = state.src.slice(start, pos);
5607
5608 matchStart = matchEnd = pos;
5609
5610 while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
5611 matchEnd = matchStart + 1;
5612
5613 while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
5614
5615 if (matchEnd - matchStart === marker.length) {
5616 if (!silent) {
5617 state.push({
5618 type: 'code',
5619 content: state.src.slice(pos, matchStart)
5620 .replace(/[ \n]+/g, ' ')
5621 .trim(),
5622 block: false,
5623 level: state.level
5624 });
5625 }
5626 state.pos = matchEnd;
5627 return true;
5628 }
5629 }
5630
5631 if (!silent) { state.pending += marker; }
5632 state.pos += marker.length;
5633 return true;
5634}
5635
5636// Process ~~deleted text~~
5637
5638function del(state, silent) {
5639 var found,
5640 pos,
5641 stack,
5642 max = state.posMax,
5643 start = state.pos,
5644 lastChar,
5645 nextChar;
5646
5647 if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
5648 if (silent) { return false; } // don't run any pairs in validation mode
5649 if (start + 4 >= max) { return false; }
5650 if (state.src.charCodeAt(start + 1) !== 0x7E/* ~ */) { return false; }
5651 if (state.level >= state.options.maxNesting) { return false; }
5652
5653 lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
5654 nextChar = state.src.charCodeAt(start + 2);
5655
5656 if (lastChar === 0x7E/* ~ */) { return false; }
5657 if (nextChar === 0x7E/* ~ */) { return false; }
5658 if (nextChar === 0x20 || nextChar === 0x0A) { return false; }
5659
5660 pos = start + 2;
5661 while (pos < max && state.src.charCodeAt(pos) === 0x7E/* ~ */) { pos++; }
5662 if (pos > start + 3) {
5663 // sequence of 4+ markers taking as literal, same as in a emphasis
5664 state.pos += pos - start;
5665 if (!silent) { state.pending += state.src.slice(start, pos); }
5666 return true;
5667 }
5668
5669 state.pos = start + 2;
5670 stack = 1;
5671
5672 while (state.pos + 1 < max) {
5673 if (state.src.charCodeAt(state.pos) === 0x7E/* ~ */) {
5674 if (state.src.charCodeAt(state.pos + 1) === 0x7E/* ~ */) {
5675 lastChar = state.src.charCodeAt(state.pos - 1);
5676 nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1;
5677 if (nextChar !== 0x7E/* ~ */ && lastChar !== 0x7E/* ~ */) {
5678 if (lastChar !== 0x20 && lastChar !== 0x0A) {
5679 // closing '~~'
5680 stack--;
5681 } else if (nextChar !== 0x20 && nextChar !== 0x0A) {
5682 // opening '~~'
5683 stack++;
5684 } // else {
5685 // // standalone ' ~~ ' indented with spaces
5686 // }
5687 if (stack <= 0) {
5688 found = true;
5689 break;
5690 }
5691 }
5692 }
5693 }
5694
5695 state.parser.skipToken(state);
5696 }
5697
5698 if (!found) {
5699 // parser failed to find ending tag, so it's not valid emphasis
5700 state.pos = start;
5701 return false;
5702 }
5703
5704 // found!
5705 state.posMax = state.pos;
5706 state.pos = start + 2;
5707
5708 if (!silent) {
5709 state.push({ type: 'del_open', level: state.level++ });
5710 state.parser.tokenize(state);
5711 state.push({ type: 'del_close', level: --state.level });
5712 }
5713
5714 state.pos = state.posMax + 2;
5715 state.posMax = max;
5716 return true;
5717}
5718
5719// Process ++inserted text++
5720
5721function ins(state, silent) {
5722 var found,
5723 pos,
5724 stack,
5725 max = state.posMax,
5726 start = state.pos,
5727 lastChar,
5728 nextChar;
5729
5730 if (state.src.charCodeAt(start) !== 0x2B/* + */) { return false; }
5731 if (silent) { return false; } // don't run any pairs in validation mode
5732 if (start + 4 >= max) { return false; }
5733 if (state.src.charCodeAt(start + 1) !== 0x2B/* + */) { return false; }
5734 if (state.level >= state.options.maxNesting) { return false; }
5735
5736 lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
5737 nextChar = state.src.charCodeAt(start + 2);
5738
5739 if (lastChar === 0x2B/* + */) { return false; }
5740 if (nextChar === 0x2B/* + */) { return false; }
5741 if (nextChar === 0x20 || nextChar === 0x0A) { return false; }
5742
5743 pos = start + 2;
5744 while (pos < max && state.src.charCodeAt(pos) === 0x2B/* + */) { pos++; }
5745 if (pos !== start + 2) {
5746 // sequence of 3+ markers taking as literal, same as in a emphasis
5747 state.pos += pos - start;
5748 if (!silent) { state.pending += state.src.slice(start, pos); }
5749 return true;
5750 }
5751
5752 state.pos = start + 2;
5753 stack = 1;
5754
5755 while (state.pos + 1 < max) {
5756 if (state.src.charCodeAt(state.pos) === 0x2B/* + */) {
5757 if (state.src.charCodeAt(state.pos + 1) === 0x2B/* + */) {
5758 lastChar = state.src.charCodeAt(state.pos - 1);
5759 nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1;
5760 if (nextChar !== 0x2B/* + */ && lastChar !== 0x2B/* + */) {
5761 if (lastChar !== 0x20 && lastChar !== 0x0A) {
5762 // closing '++'
5763 stack--;
5764 } else if (nextChar !== 0x20 && nextChar !== 0x0A) {
5765 // opening '++'
5766 stack++;
5767 } // else {
5768 // // standalone ' ++ ' indented with spaces
5769 // }
5770 if (stack <= 0) {
5771 found = true;
5772 break;
5773 }
5774 }
5775 }
5776 }
5777
5778 state.parser.skipToken(state);
5779 }
5780
5781 if (!found) {
5782 // parser failed to find ending tag, so it's not valid emphasis
5783 state.pos = start;
5784 return false;
5785 }
5786
5787 // found!
5788 state.posMax = state.pos;
5789 state.pos = start + 2;
5790
5791 if (!silent) {
5792 state.push({ type: 'ins_open', level: state.level++ });
5793 state.parser.tokenize(state);
5794 state.push({ type: 'ins_close', level: --state.level });
5795 }
5796
5797 state.pos = state.posMax + 2;
5798 state.posMax = max;
5799 return true;
5800}
5801
5802// Process ==highlighted text==
5803
5804function mark(state, silent) {
5805 var found,
5806 pos,
5807 stack,
5808 max = state.posMax,
5809 start = state.pos,
5810 lastChar,
5811 nextChar;
5812
5813 if (state.src.charCodeAt(start) !== 0x3D/* = */) { return false; }
5814 if (silent) { return false; } // don't run any pairs in validation mode
5815 if (start + 4 >= max) { return false; }
5816 if (state.src.charCodeAt(start + 1) !== 0x3D/* = */) { return false; }
5817 if (state.level >= state.options.maxNesting) { return false; }
5818
5819 lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
5820 nextChar = state.src.charCodeAt(start + 2);
5821
5822 if (lastChar === 0x3D/* = */) { return false; }
5823 if (nextChar === 0x3D/* = */) { return false; }
5824 if (nextChar === 0x20 || nextChar === 0x0A) { return false; }
5825
5826 pos = start + 2;
5827 while (pos < max && state.src.charCodeAt(pos) === 0x3D/* = */) { pos++; }
5828 if (pos !== start + 2) {
5829 // sequence of 3+ markers taking as literal, same as in a emphasis
5830 state.pos += pos - start;
5831 if (!silent) { state.pending += state.src.slice(start, pos); }
5832 return true;
5833 }
5834
5835 state.pos = start + 2;
5836 stack = 1;
5837
5838 while (state.pos + 1 < max) {
5839 if (state.src.charCodeAt(state.pos) === 0x3D/* = */) {
5840 if (state.src.charCodeAt(state.pos + 1) === 0x3D/* = */) {
5841 lastChar = state.src.charCodeAt(state.pos - 1);
5842 nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1;
5843 if (nextChar !== 0x3D/* = */ && lastChar !== 0x3D/* = */) {
5844 if (lastChar !== 0x20 && lastChar !== 0x0A) {
5845 // closing '=='
5846 stack--;
5847 } else if (nextChar !== 0x20 && nextChar !== 0x0A) {
5848 // opening '=='
5849 stack++;
5850 } // else {
5851 // // standalone ' == ' indented with spaces
5852 // }
5853 if (stack <= 0) {
5854 found = true;
5855 break;
5856 }
5857 }
5858 }
5859 }
5860
5861 state.parser.skipToken(state);
5862 }
5863
5864 if (!found) {
5865 // parser failed to find ending tag, so it's not valid emphasis
5866 state.pos = start;
5867 return false;
5868 }
5869
5870 // found!
5871 state.posMax = state.pos;
5872 state.pos = start + 2;
5873
5874 if (!silent) {
5875 state.push({ type: 'mark_open', level: state.level++ });
5876 state.parser.tokenize(state);
5877 state.push({ type: 'mark_close', level: --state.level });
5878 }
5879
5880 state.pos = state.posMax + 2;
5881 state.posMax = max;
5882 return true;
5883}
5884
5885// Process *this* and _that_
5886
5887function isAlphaNum(code) {
5888 return (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */) ||
5889 (code >= 0x41 /* A */ && code <= 0x5A /* Z */) ||
5890 (code >= 0x61 /* a */ && code <= 0x7A /* z */);
5891}
5892
5893// parse sequence of emphasis markers,
5894// "start" should point at a valid marker
5895function scanDelims(state, start) {
5896 var pos = start, lastChar, nextChar, count,
5897 can_open = true,
5898 can_close = true,
5899 max = state.posMax,
5900 marker = state.src.charCodeAt(start);
5901
5902 lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
5903
5904 while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; }
5905 if (pos >= max) { can_open = false; }
5906 count = pos - start;
5907
5908 if (count >= 4) {
5909 // sequence of four or more unescaped markers can't start/end an emphasis
5910 can_open = can_close = false;
5911 } else {
5912 nextChar = pos < max ? state.src.charCodeAt(pos) : -1;
5913
5914 // check whitespace conditions
5915 if (nextChar === 0x20 || nextChar === 0x0A) { can_open = false; }
5916 if (lastChar === 0x20 || lastChar === 0x0A) { can_close = false; }
5917
5918 if (marker === 0x5F /* _ */) {
5919 // check if we aren't inside the word
5920 if (isAlphaNum(lastChar)) { can_open = false; }
5921 if (isAlphaNum(nextChar)) { can_close = false; }
5922 }
5923 }
5924
5925 return {
5926 can_open: can_open,
5927 can_close: can_close,
5928 delims: count
5929 };
5930}
5931
5932function emphasis(state, silent) {
5933 var startCount,
5934 count,
5935 found,
5936 oldCount,
5937 newCount,
5938 stack,
5939 res,
5940 max = state.posMax,
5941 start = state.pos,
5942 marker = state.src.charCodeAt(start);
5943
5944 if (marker !== 0x5F/* _ */ && marker !== 0x2A /* * */) { return false; }
5945 if (silent) { return false; } // don't run any pairs in validation mode
5946
5947 res = scanDelims(state, start);
5948 startCount = res.delims;
5949 if (!res.can_open) {
5950 state.pos += startCount;
5951 if (!silent) { state.pending += state.src.slice(start, state.pos); }
5952 return true;
5953 }
5954
5955 if (state.level >= state.options.maxNesting) { return false; }
5956
5957 state.pos = start + startCount;
5958 stack = [ startCount ];
5959
5960 while (state.pos < max) {
5961 if (state.src.charCodeAt(state.pos) === marker) {
5962 res = scanDelims(state, state.pos);
5963 count = res.delims;
5964 if (res.can_close) {
5965 oldCount = stack.pop();
5966 newCount = count;
5967
5968 while (oldCount !== newCount) {
5969 if (newCount < oldCount) {
5970 stack.push(oldCount - newCount);
5971 break;
5972 }
5973
5974 // assert(newCount > oldCount)
5975 newCount -= oldCount;
5976
5977 if (stack.length === 0) { break; }
5978 state.pos += oldCount;
5979 oldCount = stack.pop();
5980 }
5981
5982 if (stack.length === 0) {
5983 startCount = oldCount;
5984 found = true;
5985 break;
5986 }
5987 state.pos += count;
5988 continue;
5989 }
5990
5991 if (res.can_open) { stack.push(count); }
5992 state.pos += count;
5993 continue;
5994 }
5995
5996 state.parser.skipToken(state);
5997 }
5998
5999 if (!found) {
6000 // parser failed to find ending tag, so it's not valid emphasis
6001 state.pos = start;
6002 return false;
6003 }
6004
6005 // found!
6006 state.posMax = state.pos;
6007 state.pos = start + startCount;
6008
6009 if (!silent) {
6010 if (startCount === 2 || startCount === 3) {
6011 state.push({ type: 'strong_open', level: state.level++ });
6012 }
6013 if (startCount === 1 || startCount === 3) {
6014 state.push({ type: 'em_open', level: state.level++ });
6015 }
6016
6017 state.parser.tokenize(state);
6018
6019 if (startCount === 1 || startCount === 3) {
6020 state.push({ type: 'em_close', level: --state.level });
6021 }
6022 if (startCount === 2 || startCount === 3) {
6023 state.push({ type: 'strong_close', level: --state.level });
6024 }
6025 }
6026
6027 state.pos = state.posMax + startCount;
6028 state.posMax = max;
6029 return true;
6030}
6031
6032// Process ~subscript~
6033
6034// same as UNESCAPE_MD_RE plus a space
6035var UNESCAPE_RE = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
6036
6037function sub(state, silent) {
6038 var found,
6039 content,
6040 max = state.posMax,
6041 start = state.pos;
6042
6043 if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
6044 if (silent) { return false; } // don't run any pairs in validation mode
6045 if (start + 2 >= max) { return false; }
6046 if (state.level >= state.options.maxNesting) { return false; }
6047
6048 state.pos = start + 1;
6049
6050 while (state.pos < max) {
6051 if (state.src.charCodeAt(state.pos) === 0x7E/* ~ */) {
6052 found = true;
6053 break;
6054 }
6055
6056 state.parser.skipToken(state);
6057 }
6058
6059 if (!found || start + 1 === state.pos) {
6060 state.pos = start;
6061 return false;
6062 }
6063
6064 content = state.src.slice(start + 1, state.pos);
6065
6066 // don't allow unescaped spaces/newlines inside
6067 if (content.match(/(^|[^\\])(\\\\)*\s/)) {
6068 state.pos = start;
6069 return false;
6070 }
6071
6072 // found!
6073 state.posMax = state.pos;
6074 state.pos = start + 1;
6075
6076 if (!silent) {
6077 state.push({
6078 type: 'sub',
6079 level: state.level,
6080 content: content.replace(UNESCAPE_RE, '$1')
6081 });
6082 }
6083
6084 state.pos = state.posMax + 1;
6085 state.posMax = max;
6086 return true;
6087}
6088
6089// Process ^superscript^
6090
6091// same as UNESCAPE_MD_RE plus a space
6092var UNESCAPE_RE$1 = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
6093
6094function sup(state, silent) {
6095 var found,
6096 content,
6097 max = state.posMax,
6098 start = state.pos;
6099
6100 if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; }
6101 if (silent) { return false; } // don't run any pairs in validation mode
6102 if (start + 2 >= max) { return false; }
6103 if (state.level >= state.options.maxNesting) { return false; }
6104
6105 state.pos = start + 1;
6106
6107 while (state.pos < max) {
6108 if (state.src.charCodeAt(state.pos) === 0x5E/* ^ */) {
6109 found = true;
6110 break;
6111 }
6112
6113 state.parser.skipToken(state);
6114 }
6115
6116 if (!found || start + 1 === state.pos) {
6117 state.pos = start;
6118 return false;
6119 }
6120
6121 content = state.src.slice(start + 1, state.pos);
6122
6123 // don't allow unescaped spaces/newlines inside
6124 if (content.match(/(^|[^\\])(\\\\)*\s/)) {
6125 state.pos = start;
6126 return false;
6127 }
6128
6129 // found!
6130 state.posMax = state.pos;
6131 state.pos = start + 1;
6132
6133 if (!silent) {
6134 state.push({
6135 type: 'sup',
6136 level: state.level,
6137 content: content.replace(UNESCAPE_RE$1, '$1')
6138 });
6139 }
6140
6141 state.pos = state.posMax + 1;
6142 state.posMax = max;
6143 return true;
6144}
6145
6146// Process [links](<to> "stuff")
6147
6148
6149function links(state, silent) {
6150 var labelStart,
6151 labelEnd,
6152 label,
6153 href,
6154 title,
6155 pos,
6156 ref,
6157 code,
6158 isImage = false,
6159 oldPos = state.pos,
6160 max = state.posMax,
6161 start = state.pos,
6162 marker = state.src.charCodeAt(start);
6163
6164 if (marker === 0x21/* ! */) {
6165 isImage = true;
6166 marker = state.src.charCodeAt(++start);
6167 }
6168
6169 if (marker !== 0x5B/* [ */) { return false; }
6170 if (state.level >= state.options.maxNesting) { return false; }
6171
6172 labelStart = start + 1;
6173 labelEnd = parseLinkLabel(state, start);
6174
6175 // parser failed to find ']', so it's not a valid link
6176 if (labelEnd < 0) { return false; }
6177
6178 pos = labelEnd + 1;
6179 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
6180 //
6181 // Inline link
6182 //
6183
6184 // [link]( <href> "title" )
6185 // ^^ skipping these spaces
6186 pos++;
6187 for (; pos < max; pos++) {
6188 code = state.src.charCodeAt(pos);
6189 if (code !== 0x20 && code !== 0x0A) { break; }
6190 }
6191 if (pos >= max) { return false; }
6192
6193 // [link]( <href> "title" )
6194 // ^^^^^^ parsing link destination
6195 start = pos;
6196 if (parseLinkDestination(state, pos)) {
6197 href = state.linkContent;
6198 pos = state.pos;
6199 } else {
6200 href = '';
6201 }
6202
6203 // [link]( <href> "title" )
6204 // ^^ skipping these spaces
6205 start = pos;
6206 for (; pos < max; pos++) {
6207 code = state.src.charCodeAt(pos);
6208 if (code !== 0x20 && code !== 0x0A) { break; }
6209 }
6210
6211 // [link]( <href> "title" )
6212 // ^^^^^^^ parsing link title
6213 if (pos < max && start !== pos && parseLinkTitle(state, pos)) {
6214 title = state.linkContent;
6215 pos = state.pos;
6216
6217 // [link]( <href> "title" )
6218 // ^^ skipping these spaces
6219 for (; pos < max; pos++) {
6220 code = state.src.charCodeAt(pos);
6221 if (code !== 0x20 && code !== 0x0A) { break; }
6222 }
6223 } else {
6224 title = '';
6225 }
6226
6227 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
6228 state.pos = oldPos;
6229 return false;
6230 }
6231 pos++;
6232 } else {
6233 //
6234 // Link reference
6235 //
6236
6237 // do not allow nested reference links
6238 if (state.linkLevel > 0) { return false; }
6239
6240 // [foo] [bar]
6241 // ^^ optional whitespace (can include newlines)
6242 for (; pos < max; pos++) {
6243 code = state.src.charCodeAt(pos);
6244 if (code !== 0x20 && code !== 0x0A) { break; }
6245 }
6246
6247 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
6248 start = pos + 1;
6249 pos = parseLinkLabel(state, pos);
6250 if (pos >= 0) {
6251 label = state.src.slice(start, pos++);
6252 } else {
6253 pos = start - 1;
6254 }
6255 }
6256
6257 // covers label === '' and label === undefined
6258 // (collapsed reference link and shortcut reference link respectively)
6259 if (!label) {
6260 if (typeof label === 'undefined') {
6261 pos = labelEnd + 1;
6262 }
6263 label = state.src.slice(labelStart, labelEnd);
6264 }
6265
6266 ref = state.env.references[normalizeReference(label)];
6267 if (!ref) {
6268 state.pos = oldPos;
6269 return false;
6270 }
6271 href = ref.href;
6272 title = ref.title;
6273 }
6274
6275 //
6276 // We found the end of the link, and know for a fact it's a valid link;
6277 // so all that's left to do is to call tokenizer.
6278 //
6279 if (!silent) {
6280 state.pos = labelStart;
6281 state.posMax = labelEnd;
6282
6283 if (isImage) {
6284 state.push({
6285 type: 'image',
6286 src: href,
6287 title: title,
6288 alt: state.src.substr(labelStart, labelEnd - labelStart),
6289 level: state.level
6290 });
6291 } else {
6292 state.push({
6293 type: 'link_open',
6294 href: href,
6295 title: title,
6296 level: state.level++
6297 });
6298 state.linkLevel++;
6299 state.parser.tokenize(state);
6300 state.linkLevel--;
6301 state.push({ type: 'link_close', level: --state.level });
6302 }
6303 }
6304
6305 state.pos = pos;
6306 state.posMax = max;
6307 return true;
6308}
6309
6310// Process inline footnotes (^[...])
6311
6312
6313function footnote_inline(state, silent) {
6314 var labelStart,
6315 labelEnd,
6316 footnoteId,
6317 oldLength,
6318 max = state.posMax,
6319 start = state.pos;
6320
6321 if (start + 2 >= max) { return false; }
6322 if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; }
6323 if (state.src.charCodeAt(start + 1) !== 0x5B/* [ */) { return false; }
6324 if (state.level >= state.options.maxNesting) { return false; }
6325
6326 labelStart = start + 2;
6327 labelEnd = parseLinkLabel(state, start + 1);
6328
6329 // parser failed to find ']', so it's not a valid note
6330 if (labelEnd < 0) { return false; }
6331
6332 // We found the end of the link, and know for a fact it's a valid link;
6333 // so all that's left to do is to call tokenizer.
6334 //
6335 if (!silent) {
6336 if (!state.env.footnotes) { state.env.footnotes = {}; }
6337 if (!state.env.footnotes.list) { state.env.footnotes.list = []; }
6338 footnoteId = state.env.footnotes.list.length;
6339
6340 state.pos = labelStart;
6341 state.posMax = labelEnd;
6342
6343 state.push({
6344 type: 'footnote_ref',
6345 id: footnoteId,
6346 level: state.level
6347 });
6348 state.linkLevel++;
6349 oldLength = state.tokens.length;
6350 state.parser.tokenize(state);
6351 state.env.footnotes.list[footnoteId] = { tokens: state.tokens.splice(oldLength) };
6352 state.linkLevel--;
6353 }
6354
6355 state.pos = labelEnd + 1;
6356 state.posMax = max;
6357 return true;
6358}
6359
6360// Process footnote references ([^...])
6361
6362function footnote_ref(state, silent) {
6363 var label,
6364 pos,
6365 footnoteId,
6366 footnoteSubId,
6367 max = state.posMax,
6368 start = state.pos;
6369
6370 // should be at least 4 chars - "[^x]"
6371 if (start + 3 > max) { return false; }
6372
6373 if (!state.env.footnotes || !state.env.footnotes.refs) { return false; }
6374 if (state.src.charCodeAt(start) !== 0x5B/* [ */) { return false; }
6375 if (state.src.charCodeAt(start + 1) !== 0x5E/* ^ */) { return false; }
6376 if (state.level >= state.options.maxNesting) { return false; }
6377
6378 for (pos = start + 2; pos < max; pos++) {
6379 if (state.src.charCodeAt(pos) === 0x20) { return false; }
6380 if (state.src.charCodeAt(pos) === 0x0A) { return false; }
6381 if (state.src.charCodeAt(pos) === 0x5D /* ] */) {
6382 break;
6383 }
6384 }
6385
6386 if (pos === start + 2) { return false; } // no empty footnote labels
6387 if (pos >= max) { return false; }
6388 pos++;
6389
6390 label = state.src.slice(start + 2, pos - 1);
6391 if (typeof state.env.footnotes.refs[':' + label] === 'undefined') { return false; }
6392
6393 if (!silent) {
6394 if (!state.env.footnotes.list) { state.env.footnotes.list = []; }
6395
6396 if (state.env.footnotes.refs[':' + label] < 0) {
6397 footnoteId = state.env.footnotes.list.length;
6398 state.env.footnotes.list[footnoteId] = { label: label, count: 0 };
6399 state.env.footnotes.refs[':' + label] = footnoteId;
6400 } else {
6401 footnoteId = state.env.footnotes.refs[':' + label];
6402 }
6403
6404 footnoteSubId = state.env.footnotes.list[footnoteId].count;
6405 state.env.footnotes.list[footnoteId].count++;
6406
6407 state.push({
6408 type: 'footnote_ref',
6409 id: footnoteId,
6410 subId: footnoteSubId,
6411 level: state.level
6412 });
6413 }
6414
6415 state.pos = pos;
6416 state.posMax = max;
6417 return true;
6418}
6419
6420// List of valid url schemas, accorting to commonmark spec
6421// http://jgm.github.io/CommonMark/spec.html#autolinks
6422
6423var url_schemas = [
6424 'coap',
6425 'doi',
6426 'javascript',
6427 'aaa',
6428 'aaas',
6429 'about',
6430 'acap',
6431 'cap',
6432 'cid',
6433 'crid',
6434 'data',
6435 'dav',
6436 'dict',
6437 'dns',
6438 'file',
6439 'ftp',
6440 'geo',
6441 'go',
6442 'gopher',
6443 'h323',
6444 'http',
6445 'https',
6446 'iax',
6447 'icap',
6448 'im',
6449 'imap',
6450 'info',
6451 'ipp',
6452 'iris',
6453 'iris.beep',
6454 'iris.xpc',
6455 'iris.xpcs',
6456 'iris.lwz',
6457 'ldap',
6458 'mailto',
6459 'mid',
6460 'msrp',
6461 'msrps',
6462 'mtqp',
6463 'mupdate',
6464 'news',
6465 'nfs',
6466 'ni',
6467 'nih',
6468 'nntp',
6469 'opaquelocktoken',
6470 'pop',
6471 'pres',
6472 'rtsp',
6473 'service',
6474 'session',
6475 'shttp',
6476 'sieve',
6477 'sip',
6478 'sips',
6479 'sms',
6480 'snmp',
6481 'soap.beep',
6482 'soap.beeps',
6483 'tag',
6484 'tel',
6485 'telnet',
6486 'tftp',
6487 'thismessage',
6488 'tn3270',
6489 'tip',
6490 'tv',
6491 'urn',
6492 'vemmi',
6493 'ws',
6494 'wss',
6495 'xcon',
6496 'xcon-userid',
6497 'xmlrpc.beep',
6498 'xmlrpc.beeps',
6499 'xmpp',
6500 'z39.50r',
6501 'z39.50s',
6502 'adiumxtra',
6503 'afp',
6504 'afs',
6505 'aim',
6506 'apt',
6507 'attachment',
6508 'aw',
6509 'beshare',
6510 'bitcoin',
6511 'bolo',
6512 'callto',
6513 'chrome',
6514 'chrome-extension',
6515 'com-eventbrite-attendee',
6516 'content',
6517 'cvs',
6518 'dlna-playsingle',
6519 'dlna-playcontainer',
6520 'dtn',
6521 'dvb',
6522 'ed2k',
6523 'facetime',
6524 'feed',
6525 'finger',
6526 'fish',
6527 'gg',
6528 'git',
6529 'gizmoproject',
6530 'gtalk',
6531 'hcp',
6532 'icon',
6533 'ipn',
6534 'irc',
6535 'irc6',
6536 'ircs',
6537 'itms',
6538 'jar',
6539 'jms',
6540 'keyparc',
6541 'lastfm',
6542 'ldaps',
6543 'magnet',
6544 'maps',
6545 'market',
6546 'message',
6547 'mms',
6548 'ms-help',
6549 'msnim',
6550 'mumble',
6551 'mvn',
6552 'notes',
6553 'oid',
6554 'palm',
6555 'paparazzi',
6556 'platform',
6557 'proxy',
6558 'psyc',
6559 'query',
6560 'res',
6561 'resource',
6562 'rmi',
6563 'rsync',
6564 'rtmp',
6565 'secondlife',
6566 'sftp',
6567 'sgn',
6568 'skype',
6569 'smb',
6570 'soldat',
6571 'spotify',
6572 'ssh',
6573 'steam',
6574 'svn',
6575 'teamspeak',
6576 'things',
6577 'udp',
6578 'unreal',
6579 'ut2004',
6580 'ventrilo',
6581 'view-source',
6582 'webcal',
6583 'wtai',
6584 'wyciwyg',
6585 'xfire',
6586 'xri',
6587 'ymsgr'
6588];
6589
6590// Process autolinks '<protocol:...>'
6591
6592
6593/*eslint max-len:0*/
6594var 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])?)*)>/;
6595var AUTOLINK_RE = /^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;
6596
6597
6598function autolink(state, silent) {
6599 var tail, linkMatch, emailMatch, url, fullUrl, pos = state.pos;
6600
6601 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
6602
6603 tail = state.src.slice(pos);
6604
6605 if (tail.indexOf('>') < 0) { return false; }
6606
6607 linkMatch = tail.match(AUTOLINK_RE);
6608
6609 if (linkMatch) {
6610 if (url_schemas.indexOf(linkMatch[1].toLowerCase()) < 0) { return false; }
6611
6612 url = linkMatch[0].slice(1, -1);
6613 fullUrl = normalizeLink(url);
6614 if (!state.parser.validateLink(url)) { return false; }
6615
6616 if (!silent) {
6617 state.push({
6618 type: 'link_open',
6619 href: fullUrl,
6620 level: state.level
6621 });
6622 state.push({
6623 type: 'text',
6624 content: url,
6625 level: state.level + 1
6626 });
6627 state.push({ type: 'link_close', level: state.level });
6628 }
6629
6630 state.pos += linkMatch[0].length;
6631 return true;
6632 }
6633
6634 emailMatch = tail.match(EMAIL_RE);
6635
6636 if (emailMatch) {
6637
6638 url = emailMatch[0].slice(1, -1);
6639
6640 fullUrl = normalizeLink('mailto:' + url);
6641 if (!state.parser.validateLink(fullUrl)) { return false; }
6642
6643 if (!silent) {
6644 state.push({
6645 type: 'link_open',
6646 href: fullUrl,
6647 level: state.level
6648 });
6649 state.push({
6650 type: 'text',
6651 content: url,
6652 level: state.level + 1
6653 });
6654 state.push({ type: 'link_close', level: state.level });
6655 }
6656
6657 state.pos += emailMatch[0].length;
6658 return true;
6659 }
6660
6661 return false;
6662}
6663
6664// Regexps to match html elements
6665
6666function replace$1(regex, options) {
6667 regex = regex.source;
6668 options = options || '';
6669
6670 return function self(name, val) {
6671 if (!name) {
6672 return new RegExp(regex, options);
6673 }
6674 val = val.source || val;
6675 regex = regex.replace(name, val);
6676 return self;
6677 };
6678}
6679
6680
6681var attr_name = /[a-zA-Z_:][a-zA-Z0-9:._-]*/;
6682
6683var unquoted = /[^"'=<>`\x00-\x20]+/;
6684var single_quoted = /'[^']*'/;
6685var double_quoted = /"[^"]*"/;
6686
6687/*eslint no-spaced-func:0*/
6688var attr_value = replace$1(/(?:unquoted|single_quoted|double_quoted)/)
6689 ('unquoted', unquoted)
6690 ('single_quoted', single_quoted)
6691 ('double_quoted', double_quoted)
6692 ();
6693
6694var attribute = replace$1(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)
6695 ('attr_name', attr_name)
6696 ('attr_value', attr_value)
6697 ();
6698
6699var open_tag = replace$1(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)
6700 ('attribute', attribute)
6701 ();
6702
6703var close_tag = /<\/[A-Za-z][A-Za-z0-9]*\s*>/;
6704var comment = /<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
6705var processing = /<[?].*?[?]>/;
6706var declaration = /<![A-Z]+\s+[^>]*>/;
6707var cdata = /<!\[CDATA\[[\s\S]*?\]\]>/;
6708
6709var HTML_TAG_RE = replace$1(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)
6710 ('open_tag', open_tag)
6711 ('close_tag', close_tag)
6712 ('comment', comment)
6713 ('processing', processing)
6714 ('declaration', declaration)
6715 ('cdata', cdata)
6716 ();
6717
6718// Process html tags
6719
6720
6721function isLetter$2(ch) {
6722 /*eslint no-bitwise:0*/
6723 var lc = ch | 0x20; // to lower case
6724 return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
6725}
6726
6727
6728function htmltag(state, silent) {
6729 var ch, match, max, pos = state.pos;
6730
6731 if (!state.options.html) { return false; }
6732
6733 // Check start
6734 max = state.posMax;
6735 if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
6736 pos + 2 >= max) {
6737 return false;
6738 }
6739
6740 // Quick fail on second char
6741 ch = state.src.charCodeAt(pos + 1);
6742 if (ch !== 0x21/* ! */ &&
6743 ch !== 0x3F/* ? */ &&
6744 ch !== 0x2F/* / */ &&
6745 !isLetter$2(ch)) {
6746 return false;
6747 }
6748
6749 match = state.src.slice(pos).match(HTML_TAG_RE);
6750 if (!match) { return false; }
6751
6752 if (!silent) {
6753 state.push({
6754 type: 'htmltag',
6755 content: state.src.slice(pos, pos + match[0].length),
6756 level: state.level
6757 });
6758 }
6759 state.pos += match[0].length;
6760 return true;
6761}
6762
6763// Process html entity - &#123;, &#xAF;, &quot;, ...
6764
6765
6766var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i;
6767var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
6768
6769
6770function entity(state, silent) {
6771 var ch, code, match, pos = state.pos, max = state.posMax;
6772
6773 if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }
6774
6775 if (pos + 1 < max) {
6776 ch = state.src.charCodeAt(pos + 1);
6777
6778 if (ch === 0x23 /* # */) {
6779 match = state.src.slice(pos).match(DIGITAL_RE);
6780 if (match) {
6781 if (!silent) {
6782 code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
6783 state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
6784 }
6785 state.pos += match[0].length;
6786 return true;
6787 }
6788 } else {
6789 match = state.src.slice(pos).match(NAMED_RE);
6790 if (match) {
6791 var decoded = decodeEntity(match[1]);
6792 if (match[1] !== decoded) {
6793 if (!silent) { state.pending += decoded; }
6794 state.pos += match[0].length;
6795 return true;
6796 }
6797 }
6798 }
6799 }
6800
6801 if (!silent) { state.pending += '&'; }
6802 state.pos++;
6803 return true;
6804}
6805
6806/**
6807 * Inline Parser `rules`
6808 */
6809
6810var _rules$2 = [
6811 [ 'text', text ],
6812 [ 'newline', newline ],
6813 [ 'escape', escape ],
6814 [ 'backticks', backticks ],
6815 [ 'del', del ],
6816 [ 'ins', ins ],
6817 [ 'mark', mark ],
6818 [ 'emphasis', emphasis ],
6819 [ 'sub', sub ],
6820 [ 'sup', sup ],
6821 [ 'links', links ],
6822 [ 'footnote_inline', footnote_inline ],
6823 [ 'footnote_ref', footnote_ref ],
6824 [ 'autolink', autolink ],
6825 [ 'htmltag', htmltag ],
6826 [ 'entity', entity ]
6827];
6828
6829/**
6830 * Inline Parser class. Note that link validation is stricter
6831 * in Remarkable than what is specified by CommonMark. If you
6832 * want to change this you can use a custom validator.
6833 *
6834 * @api private
6835 */
6836
6837function ParserInline() {
6838 this.ruler = new Ruler();
6839 for (var i = 0; i < _rules$2.length; i++) {
6840 this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
6841 }
6842
6843 // Can be overridden with a custom validator
6844 this.validateLink = validateLink;
6845}
6846
6847/**
6848 * Skip a single token by running all rules in validation mode.
6849 * Returns `true` if any rule reports success.
6850 *
6851 * @param {Object} `state`
6852 * @api privage
6853 */
6854
6855ParserInline.prototype.skipToken = function (state) {
6856 var rules = this.ruler.getRules('');
6857 var len = rules.length;
6858 var pos = state.pos;
6859 var i, cached_pos;
6860
6861 if ((cached_pos = state.cacheGet(pos)) > 0) {
6862 state.pos = cached_pos;
6863 return;
6864 }
6865
6866 for (i = 0; i < len; i++) {
6867 if (rules[i](state, true)) {
6868 state.cacheSet(pos, state.pos);
6869 return;
6870 }
6871 }
6872
6873 state.pos++;
6874 state.cacheSet(pos, state.pos);
6875};
6876
6877/**
6878 * Generate tokens for the given input range.
6879 *
6880 * @param {Object} `state`
6881 * @api private
6882 */
6883
6884ParserInline.prototype.tokenize = function (state) {
6885 var rules = this.ruler.getRules('');
6886 var len = rules.length;
6887 var end = state.posMax;
6888 var ok, i;
6889
6890 while (state.pos < end) {
6891
6892 // Try all possible rules.
6893 // On success, the rule should:
6894 //
6895 // - update `state.pos`
6896 // - update `state.tokens`
6897 // - return true
6898 for (i = 0; i < len; i++) {
6899 ok = rules[i](state, false);
6900
6901 if (ok) {
6902 break;
6903 }
6904 }
6905
6906 if (ok) {
6907 if (state.pos >= end) { break; }
6908 continue;
6909 }
6910
6911 state.pending += state.src[state.pos++];
6912 }
6913
6914 if (state.pending) {
6915 state.pushPending();
6916 }
6917};
6918
6919/**
6920 * Parse the given input string.
6921 *
6922 * @param {String} `str`
6923 * @param {Object} `options`
6924 * @param {Object} `env`
6925 * @param {Array} `outTokens`
6926 * @api private
6927 */
6928
6929ParserInline.prototype.parse = function (str, options, env, outTokens) {
6930 var state = new StateInline(str, this, options, env, outTokens);
6931 this.tokenize(state);
6932};
6933
6934/**
6935 * Validate the given `url` by checking for bad protocols.
6936 *
6937 * @param {String} `url`
6938 * @return {Boolean}
6939 */
6940
6941function validateLink(url) {
6942 var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file', 'data' ];
6943 var str = url.trim().toLowerCase();
6944 // Care about digital entities "javascript&#x3A;alert(1)"
6945 str = replaceEntities(str);
6946 if (str.indexOf(':') !== -1 && BAD_PROTOCOLS.indexOf(str.split(':')[0]) !== -1) {
6947 return false;
6948 }
6949 return true;
6950}
6951
6952// Remarkable default options
6953
6954var defaultConfig = {
6955 options: {
6956 html: false, // Enable HTML tags in source
6957 xhtmlOut: false, // Use '/' to close single tags (<br />)
6958 breaks: false, // Convert '\n' in paragraphs into <br>
6959 langPrefix: 'language-', // CSS language prefix for fenced blocks
6960 linkTarget: '', // set target to open link in
6961
6962 // Enable some language-neutral replacements + quotes beautification
6963 typographer: false,
6964
6965 // Double + single quotes replacement pairs, when typographer enabled,
6966 // and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
6967 quotes: '“”‘’',
6968
6969 // Highlighter function. Should return escaped HTML,
6970 // or '' if input not changed
6971 //
6972 // function (/*str, lang*/) { return ''; }
6973 //
6974 highlight: null,
6975
6976 maxNesting: 20 // Internal protection, recursion limit
6977 },
6978
6979 components: {
6980
6981 core: {
6982 rules: [
6983 'block',
6984 'inline',
6985 'references',
6986 'replacements',
6987 'smartquotes',
6988 'references',
6989 'abbr2',
6990 'footnote_tail'
6991 ]
6992 },
6993
6994 block: {
6995 rules: [
6996 'blockquote',
6997 'code',
6998 'fences',
6999 'footnote',
7000 'heading',
7001 'hr',
7002 'htmlblock',
7003 'lheading',
7004 'list',
7005 'paragraph',
7006 'table'
7007 ]
7008 },
7009
7010 inline: {
7011 rules: [
7012 'autolink',
7013 'backticks',
7014 'del',
7015 'emphasis',
7016 'entity',
7017 'escape',
7018 'footnote_ref',
7019 'htmltag',
7020 'links',
7021 'newline',
7022 'text'
7023 ]
7024 }
7025 }
7026};
7027
7028// Remarkable default options
7029
7030var fullConfig = {
7031 options: {
7032 html: false, // Enable HTML tags in source
7033 xhtmlOut: false, // Use '/' to close single tags (<br />)
7034 breaks: false, // Convert '\n' in paragraphs into <br>
7035 langPrefix: 'language-', // CSS language prefix for fenced blocks
7036 linkTarget: '', // set target to open link in
7037
7038 // Enable some language-neutral replacements + quotes beautification
7039 typographer: false,
7040
7041 // Double + single quotes replacement pairs, when typographer enabled,
7042 // and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
7043 quotes: '“”‘’',
7044
7045 // Highlighter function. Should return escaped HTML,
7046 // or '' if input not changed
7047 //
7048 // function (/*str, lang*/) { return ''; }
7049 //
7050 highlight: null,
7051
7052 maxNesting: 20 // Internal protection, recursion limit
7053 },
7054
7055 components: {
7056 // Don't restrict core/block/inline rules
7057 core: {},
7058 block: {},
7059 inline: {}
7060 }
7061};
7062
7063// Commonmark default options
7064
7065var commonmarkConfig = {
7066 options: {
7067 html: true, // Enable HTML tags in source
7068 xhtmlOut: true, // Use '/' to close single tags (<br />)
7069 breaks: false, // Convert '\n' in paragraphs into <br>
7070 langPrefix: 'language-', // CSS language prefix for fenced blocks
7071 linkTarget: '', // set target to open link in
7072
7073 // Enable some language-neutral replacements + quotes beautification
7074 typographer: false,
7075
7076 // Double + single quotes replacement pairs, when typographer enabled,
7077 // and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
7078 quotes: '“”‘’',
7079
7080 // Highlighter function. Should return escaped HTML,
7081 // or '' if input not changed
7082 //
7083 // function (/*str, lang*/) { return ''; }
7084 //
7085 highlight: null,
7086
7087 maxNesting: 20 // Internal protection, recursion limit
7088 },
7089
7090 components: {
7091
7092 core: {
7093 rules: [
7094 'block',
7095 'inline',
7096 'references',
7097 'abbr2'
7098 ]
7099 },
7100
7101 block: {
7102 rules: [
7103 'blockquote',
7104 'code',
7105 'fences',
7106 'heading',
7107 'hr',
7108 'htmlblock',
7109 'lheading',
7110 'list',
7111 'paragraph'
7112 ]
7113 },
7114
7115 inline: {
7116 rules: [
7117 'autolink',
7118 'backticks',
7119 'emphasis',
7120 'entity',
7121 'escape',
7122 'htmltag',
7123 'links',
7124 'newline',
7125 'text'
7126 ]
7127 }
7128 }
7129};
7130
7131/**
7132 * Preset configs
7133 */
7134
7135var config = {
7136 'default': defaultConfig,
7137 'full': fullConfig,
7138 'commonmark': commonmarkConfig
7139};
7140
7141/**
7142 * The `StateCore` class manages state.
7143 *
7144 * @param {Object} `instance` Remarkable instance
7145 * @param {String} `str` Markdown string
7146 * @param {Object} `env`
7147 */
7148
7149function StateCore(instance, str, env) {
7150 this.src = str;
7151 this.env = env;
7152 this.options = instance.options;
7153 this.tokens = [];
7154 this.inlineMode = false;
7155
7156 this.inline = instance.inline;
7157 this.block = instance.block;
7158 this.renderer = instance.renderer;
7159 this.typographer = instance.typographer;
7160}
7161
7162/**
7163 * The main `Remarkable` class. Create an instance of
7164 * `Remarkable` with a `preset` and/or `options`.
7165 *
7166 * @param {String} `preset` If no preset is given, `default` is used.
7167 * @param {Object} `options`
7168 */
7169
7170function Remarkable(preset, options) {
7171 if (typeof preset !== 'string') {
7172 options = preset;
7173 preset = 'default';
7174 }
7175
7176 if (options && options.linkify != null) {
7177 console.warn(
7178 'linkify option is removed. Use linkify plugin instead:\n\n' +
7179 'import Remarkable from \'remarkable\';\n' +
7180 'import linkify from \'remarkable/linkify\';\n' +
7181 'new Remarkable().use(linkify)\n'
7182 );
7183 }
7184
7185 this.inline = new ParserInline();
7186 this.block = new ParserBlock();
7187 this.core = new Core();
7188 this.renderer = new Renderer();
7189 this.ruler = new Ruler();
7190
7191 this.options = {};
7192 this.configure(config[preset]);
7193 this.set(options || {});
7194}
7195
7196/**
7197 * Set options as an alternative to passing them
7198 * to the constructor.
7199 *
7200 * ```js
7201 * md.set({typographer: true});
7202 * ```
7203 * @param {Object} `options`
7204 * @api public
7205 */
7206
7207Remarkable.prototype.set = function (options) {
7208 assign(this.options, options);
7209};
7210
7211/**
7212 * Batch loader for components rules states, and options
7213 *
7214 * @param {Object} `presets`
7215 */
7216
7217Remarkable.prototype.configure = function (presets) {
7218 var self = this;
7219
7220 if (!presets) { throw new Error('Wrong `remarkable` preset, check name/content'); }
7221 if (presets.options) { self.set(presets.options); }
7222 if (presets.components) {
7223 Object.keys(presets.components).forEach(function (name) {
7224 if (presets.components[name].rules) {
7225 self[name].ruler.enable(presets.components[name].rules, true);
7226 }
7227 });
7228 }
7229};
7230
7231/**
7232 * Use a plugin.
7233 *
7234 * ```js
7235 * var md = new Remarkable();
7236 *
7237 * md.use(plugin1)
7238 * .use(plugin2, opts)
7239 * .use(plugin3);
7240 * ```
7241 *
7242 * @param {Function} `plugin`
7243 * @param {Object} `options`
7244 * @return {Object} `Remarkable` for chaining
7245 */
7246
7247Remarkable.prototype.use = function (plugin, options) {
7248 plugin(this, options);
7249 return this;
7250};
7251
7252
7253/**
7254 * Parse the input `string` and return a tokens array.
7255 * Modifies `env` with definitions data.
7256 *
7257 * @param {String} `string`
7258 * @param {Object} `env`
7259 * @return {Array} Array of tokens
7260 */
7261
7262Remarkable.prototype.parse = function (str, env) {
7263 var state = new StateCore(this, str, env);
7264 this.core.process(state);
7265 return state.tokens;
7266};
7267
7268/**
7269 * The main `.render()` method that does all the magic :)
7270 *
7271 * @param {String} `string`
7272 * @param {Object} `env`
7273 * @return {String} Rendered HTML.
7274 */
7275
7276Remarkable.prototype.render = function (str, env) {
7277 env = env || {};
7278 return this.renderer.render(this.parse(str, env), this.options, env);
7279};
7280
7281/**
7282 * Parse the given content `string` as a single string.
7283 *
7284 * @param {String} `string`
7285 * @param {Object} `env`
7286 * @return {Array} Array of tokens
7287 */
7288
7289Remarkable.prototype.parseInline = function (str, env) {
7290 var state = new StateCore(this, str, env);
7291 state.inlineMode = true;
7292 this.core.process(state);
7293 return state.tokens;
7294};
7295
7296/**
7297 * Render a single content `string`, without wrapping it
7298 * to paragraphs
7299 *
7300 * @param {String} `str`
7301 * @param {Object} `env`
7302 * @return {String}
7303 */
7304
7305Remarkable.prototype.renderInline = function (str, env) {
7306 env = env || {};
7307 return this.renderer.render(this.parseInline(str, env), this.options, env);
7308};
7309
7310exports.Remarkable = Remarkable;
7311exports.utils = utils;
Note: See TracBrowser for help on using the repository browser.