1 | // List of valid entities
|
---|
2 | //
|
---|
3 | // Generate with ./support/entities.js script
|
---|
4 | //
|
---|
5 |
|
---|
6 | /*eslint quotes:0*/
|
---|
7 | var entities = {
|
---|
8 | "Aacute":"\u00C1",
|
---|
9 | "aacute":"\u00E1",
|
---|
10 | "Abreve":"\u0102",
|
---|
11 | "abreve":"\u0103",
|
---|
12 | "ac":"\u223E",
|
---|
13 | "acd":"\u223F",
|
---|
14 | "acE":"\u223E\u0333",
|
---|
15 | "Acirc":"\u00C2",
|
---|
16 | "acirc":"\u00E2",
|
---|
17 | "acute":"\u00B4",
|
---|
18 | "Acy":"\u0410",
|
---|
19 | "acy":"\u0430",
|
---|
20 | "AElig":"\u00C6",
|
---|
21 | "aelig":"\u00E6",
|
---|
22 | "af":"\u2061",
|
---|
23 | "Afr":"\uD835\uDD04",
|
---|
24 | "afr":"\uD835\uDD1E",
|
---|
25 | "Agrave":"\u00C0",
|
---|
26 | "agrave":"\u00E0",
|
---|
27 | "alefsym":"\u2135",
|
---|
28 | "aleph":"\u2135",
|
---|
29 | "Alpha":"\u0391",
|
---|
30 | "alpha":"\u03B1",
|
---|
31 | "Amacr":"\u0100",
|
---|
32 | "amacr":"\u0101",
|
---|
33 | "amalg":"\u2A3F",
|
---|
34 | "AMP":"\u0026",
|
---|
35 | "amp":"\u0026",
|
---|
36 | "And":"\u2A53",
|
---|
37 | "and":"\u2227",
|
---|
38 | "andand":"\u2A55",
|
---|
39 | "andd":"\u2A5C",
|
---|
40 | "andslope":"\u2A58",
|
---|
41 | "andv":"\u2A5A",
|
---|
42 | "ang":"\u2220",
|
---|
43 | "ange":"\u29A4",
|
---|
44 | "angle":"\u2220",
|
---|
45 | "angmsd":"\u2221",
|
---|
46 | "angmsdaa":"\u29A8",
|
---|
47 | "angmsdab":"\u29A9",
|
---|
48 | "angmsdac":"\u29AA",
|
---|
49 | "angmsdad":"\u29AB",
|
---|
50 | "angmsdae":"\u29AC",
|
---|
51 | "angmsdaf":"\u29AD",
|
---|
52 | "angmsdag":"\u29AE",
|
---|
53 | "angmsdah":"\u29AF",
|
---|
54 | "angrt":"\u221F",
|
---|
55 | "angrtvb":"\u22BE",
|
---|
56 | "angrtvbd":"\u299D",
|
---|
57 | "angsph":"\u2222",
|
---|
58 | "angst":"\u00C5",
|
---|
59 | "angzarr":"\u237C",
|
---|
60 | "Aogon":"\u0104",
|
---|
61 | "aogon":"\u0105",
|
---|
62 | "Aopf":"\uD835\uDD38",
|
---|
63 | "aopf":"\uD835\uDD52",
|
---|
64 | "ap":"\u2248",
|
---|
65 | "apacir":"\u2A6F",
|
---|
66 | "apE":"\u2A70",
|
---|
67 | "ape":"\u224A",
|
---|
68 | "apid":"\u224B",
|
---|
69 | "apos":"\u0027",
|
---|
70 | "ApplyFunction":"\u2061",
|
---|
71 | "approx":"\u2248",
|
---|
72 | "approxeq":"\u224A",
|
---|
73 | "Aring":"\u00C5",
|
---|
74 | "aring":"\u00E5",
|
---|
75 | "Ascr":"\uD835\uDC9C",
|
---|
76 | "ascr":"\uD835\uDCB6",
|
---|
77 | "Assign":"\u2254",
|
---|
78 | "ast":"\u002A",
|
---|
79 | "asymp":"\u2248",
|
---|
80 | "asympeq":"\u224D",
|
---|
81 | "Atilde":"\u00C3",
|
---|
82 | "atilde":"\u00E3",
|
---|
83 | "Auml":"\u00C4",
|
---|
84 | "auml":"\u00E4",
|
---|
85 | "awconint":"\u2233",
|
---|
86 | "awint":"\u2A11",
|
---|
87 | "backcong":"\u224C",
|
---|
88 | "backepsilon":"\u03F6",
|
---|
89 | "backprime":"\u2035",
|
---|
90 | "backsim":"\u223D",
|
---|
91 | "backsimeq":"\u22CD",
|
---|
92 | "Backslash":"\u2216",
|
---|
93 | "Barv":"\u2AE7",
|
---|
94 | "barvee":"\u22BD",
|
---|
95 | "Barwed":"\u2306",
|
---|
96 | "barwed":"\u2305",
|
---|
97 | "barwedge":"\u2305",
|
---|
98 | "bbrk":"\u23B5",
|
---|
99 | "bbrktbrk":"\u23B6",
|
---|
100 | "bcong":"\u224C",
|
---|
101 | "Bcy":"\u0411",
|
---|
102 | "bcy":"\u0431",
|
---|
103 | "bdquo":"\u201E",
|
---|
104 | "becaus":"\u2235",
|
---|
105 | "Because":"\u2235",
|
---|
106 | "because":"\u2235",
|
---|
107 | "bemptyv":"\u29B0",
|
---|
108 | "bepsi":"\u03F6",
|
---|
109 | "bernou":"\u212C",
|
---|
110 | "Bernoullis":"\u212C",
|
---|
111 | "Beta":"\u0392",
|
---|
112 | "beta":"\u03B2",
|
---|
113 | "beth":"\u2136",
|
---|
114 | "between":"\u226C",
|
---|
115 | "Bfr":"\uD835\uDD05",
|
---|
116 | "bfr":"\uD835\uDD1F",
|
---|
117 | "bigcap":"\u22C2",
|
---|
118 | "bigcirc":"\u25EF",
|
---|
119 | "bigcup":"\u22C3",
|
---|
120 | "bigodot":"\u2A00",
|
---|
121 | "bigoplus":"\u2A01",
|
---|
122 | "bigotimes":"\u2A02",
|
---|
123 | "bigsqcup":"\u2A06",
|
---|
124 | "bigstar":"\u2605",
|
---|
125 | "bigtriangledown":"\u25BD",
|
---|
126 | "bigtriangleup":"\u25B3",
|
---|
127 | "biguplus":"\u2A04",
|
---|
128 | "bigvee":"\u22C1",
|
---|
129 | "bigwedge":"\u22C0",
|
---|
130 | "bkarow":"\u290D",
|
---|
131 | "blacklozenge":"\u29EB",
|
---|
132 | "blacksquare":"\u25AA",
|
---|
133 | "blacktriangle":"\u25B4",
|
---|
134 | "blacktriangledown":"\u25BE",
|
---|
135 | "blacktriangleleft":"\u25C2",
|
---|
136 | "blacktriangleright":"\u25B8",
|
---|
137 | "blank":"\u2423",
|
---|
138 | "blk12":"\u2592",
|
---|
139 | "blk14":"\u2591",
|
---|
140 | "blk34":"\u2593",
|
---|
141 | "block":"\u2588",
|
---|
142 | "bne":"\u003D\u20E5",
|
---|
143 | "bnequiv":"\u2261\u20E5",
|
---|
144 | "bNot":"\u2AED",
|
---|
145 | "bnot":"\u2310",
|
---|
146 | "Bopf":"\uD835\uDD39",
|
---|
147 | "bopf":"\uD835\uDD53",
|
---|
148 | "bot":"\u22A5",
|
---|
149 | "bottom":"\u22A5",
|
---|
150 | "bowtie":"\u22C8",
|
---|
151 | "boxbox":"\u29C9",
|
---|
152 | "boxDL":"\u2557",
|
---|
153 | "boxDl":"\u2556",
|
---|
154 | "boxdL":"\u2555",
|
---|
155 | "boxdl":"\u2510",
|
---|
156 | "boxDR":"\u2554",
|
---|
157 | "boxDr":"\u2553",
|
---|
158 | "boxdR":"\u2552",
|
---|
159 | "boxdr":"\u250C",
|
---|
160 | "boxH":"\u2550",
|
---|
161 | "boxh":"\u2500",
|
---|
162 | "boxHD":"\u2566",
|
---|
163 | "boxHd":"\u2564",
|
---|
164 | "boxhD":"\u2565",
|
---|
165 | "boxhd":"\u252C",
|
---|
166 | "boxHU":"\u2569",
|
---|
167 | "boxHu":"\u2567",
|
---|
168 | "boxhU":"\u2568",
|
---|
169 | "boxhu":"\u2534",
|
---|
170 | "boxminus":"\u229F",
|
---|
171 | "boxplus":"\u229E",
|
---|
172 | "boxtimes":"\u22A0",
|
---|
173 | "boxUL":"\u255D",
|
---|
174 | "boxUl":"\u255C",
|
---|
175 | "boxuL":"\u255B",
|
---|
176 | "boxul":"\u2518",
|
---|
177 | "boxUR":"\u255A",
|
---|
178 | "boxUr":"\u2559",
|
---|
179 | "boxuR":"\u2558",
|
---|
180 | "boxur":"\u2514",
|
---|
181 | "boxV":"\u2551",
|
---|
182 | "boxv":"\u2502",
|
---|
183 | "boxVH":"\u256C",
|
---|
184 | "boxVh":"\u256B",
|
---|
185 | "boxvH":"\u256A",
|
---|
186 | "boxvh":"\u253C",
|
---|
187 | "boxVL":"\u2563",
|
---|
188 | "boxVl":"\u2562",
|
---|
189 | "boxvL":"\u2561",
|
---|
190 | "boxvl":"\u2524",
|
---|
191 | "boxVR":"\u2560",
|
---|
192 | "boxVr":"\u255F",
|
---|
193 | "boxvR":"\u255E",
|
---|
194 | "boxvr":"\u251C",
|
---|
195 | "bprime":"\u2035",
|
---|
196 | "Breve":"\u02D8",
|
---|
197 | "breve":"\u02D8",
|
---|
198 | "brvbar":"\u00A6",
|
---|
199 | "Bscr":"\u212C",
|
---|
200 | "bscr":"\uD835\uDCB7",
|
---|
201 | "bsemi":"\u204F",
|
---|
202 | "bsim":"\u223D",
|
---|
203 | "bsime":"\u22CD",
|
---|
204 | "bsol":"\u005C",
|
---|
205 | "bsolb":"\u29C5",
|
---|
206 | "bsolhsub":"\u27C8",
|
---|
207 | "bull":"\u2022",
|
---|
208 | "bullet":"\u2022",
|
---|
209 | "bump":"\u224E",
|
---|
210 | "bumpE":"\u2AAE",
|
---|
211 | "bumpe":"\u224F",
|
---|
212 | "Bumpeq":"\u224E",
|
---|
213 | "bumpeq":"\u224F",
|
---|
214 | "Cacute":"\u0106",
|
---|
215 | "cacute":"\u0107",
|
---|
216 | "Cap":"\u22D2",
|
---|
217 | "cap":"\u2229",
|
---|
218 | "capand":"\u2A44",
|
---|
219 | "capbrcup":"\u2A49",
|
---|
220 | "capcap":"\u2A4B",
|
---|
221 | "capcup":"\u2A47",
|
---|
222 | "capdot":"\u2A40",
|
---|
223 | "CapitalDifferentialD":"\u2145",
|
---|
224 | "caps":"\u2229\uFE00",
|
---|
225 | "caret":"\u2041",
|
---|
226 | "caron":"\u02C7",
|
---|
227 | "Cayleys":"\u212D",
|
---|
228 | "ccaps":"\u2A4D",
|
---|
229 | "Ccaron":"\u010C",
|
---|
230 | "ccaron":"\u010D",
|
---|
231 | "Ccedil":"\u00C7",
|
---|
232 | "ccedil":"\u00E7",
|
---|
233 | "Ccirc":"\u0108",
|
---|
234 | "ccirc":"\u0109",
|
---|
235 | "Cconint":"\u2230",
|
---|
236 | "ccups":"\u2A4C",
|
---|
237 | "ccupssm":"\u2A50",
|
---|
238 | "Cdot":"\u010A",
|
---|
239 | "cdot":"\u010B",
|
---|
240 | "cedil":"\u00B8",
|
---|
241 | "Cedilla":"\u00B8",
|
---|
242 | "cemptyv":"\u29B2",
|
---|
243 | "cent":"\u00A2",
|
---|
244 | "CenterDot":"\u00B7",
|
---|
245 | "centerdot":"\u00B7",
|
---|
246 | "Cfr":"\u212D",
|
---|
247 | "cfr":"\uD835\uDD20",
|
---|
248 | "CHcy":"\u0427",
|
---|
249 | "chcy":"\u0447",
|
---|
250 | "check":"\u2713",
|
---|
251 | "checkmark":"\u2713",
|
---|
252 | "Chi":"\u03A7",
|
---|
253 | "chi":"\u03C7",
|
---|
254 | "cir":"\u25CB",
|
---|
255 | "circ":"\u02C6",
|
---|
256 | "circeq":"\u2257",
|
---|
257 | "circlearrowleft":"\u21BA",
|
---|
258 | "circlearrowright":"\u21BB",
|
---|
259 | "circledast":"\u229B",
|
---|
260 | "circledcirc":"\u229A",
|
---|
261 | "circleddash":"\u229D",
|
---|
262 | "CircleDot":"\u2299",
|
---|
263 | "circledR":"\u00AE",
|
---|
264 | "circledS":"\u24C8",
|
---|
265 | "CircleMinus":"\u2296",
|
---|
266 | "CirclePlus":"\u2295",
|
---|
267 | "CircleTimes":"\u2297",
|
---|
268 | "cirE":"\u29C3",
|
---|
269 | "cire":"\u2257",
|
---|
270 | "cirfnint":"\u2A10",
|
---|
271 | "cirmid":"\u2AEF",
|
---|
272 | "cirscir":"\u29C2",
|
---|
273 | "ClockwiseContourIntegral":"\u2232",
|
---|
274 | "CloseCurlyDoubleQuote":"\u201D",
|
---|
275 | "CloseCurlyQuote":"\u2019",
|
---|
276 | "clubs":"\u2663",
|
---|
277 | "clubsuit":"\u2663",
|
---|
278 | "Colon":"\u2237",
|
---|
279 | "colon":"\u003A",
|
---|
280 | "Colone":"\u2A74",
|
---|
281 | "colone":"\u2254",
|
---|
282 | "coloneq":"\u2254",
|
---|
283 | "comma":"\u002C",
|
---|
284 | "commat":"\u0040",
|
---|
285 | "comp":"\u2201",
|
---|
286 | "compfn":"\u2218",
|
---|
287 | "complement":"\u2201",
|
---|
288 | "complexes":"\u2102",
|
---|
289 | "cong":"\u2245",
|
---|
290 | "congdot":"\u2A6D",
|
---|
291 | "Congruent":"\u2261",
|
---|
292 | "Conint":"\u222F",
|
---|
293 | "conint":"\u222E",
|
---|
294 | "ContourIntegral":"\u222E",
|
---|
295 | "Copf":"\u2102",
|
---|
296 | "copf":"\uD835\uDD54",
|
---|
297 | "coprod":"\u2210",
|
---|
298 | "Coproduct":"\u2210",
|
---|
299 | "COPY":"\u00A9",
|
---|
300 | "copy":"\u00A9",
|
---|
301 | "copysr":"\u2117",
|
---|
302 | "CounterClockwiseContourIntegral":"\u2233",
|
---|
303 | "crarr":"\u21B5",
|
---|
304 | "Cross":"\u2A2F",
|
---|
305 | "cross":"\u2717",
|
---|
306 | "Cscr":"\uD835\uDC9E",
|
---|
307 | "cscr":"\uD835\uDCB8",
|
---|
308 | "csub":"\u2ACF",
|
---|
309 | "csube":"\u2AD1",
|
---|
310 | "csup":"\u2AD0",
|
---|
311 | "csupe":"\u2AD2",
|
---|
312 | "ctdot":"\u22EF",
|
---|
313 | "cudarrl":"\u2938",
|
---|
314 | "cudarrr":"\u2935",
|
---|
315 | "cuepr":"\u22DE",
|
---|
316 | "cuesc":"\u22DF",
|
---|
317 | "cularr":"\u21B6",
|
---|
318 | "cularrp":"\u293D",
|
---|
319 | "Cup":"\u22D3",
|
---|
320 | "cup":"\u222A",
|
---|
321 | "cupbrcap":"\u2A48",
|
---|
322 | "CupCap":"\u224D",
|
---|
323 | "cupcap":"\u2A46",
|
---|
324 | "cupcup":"\u2A4A",
|
---|
325 | "cupdot":"\u228D",
|
---|
326 | "cupor":"\u2A45",
|
---|
327 | "cups":"\u222A\uFE00",
|
---|
328 | "curarr":"\u21B7",
|
---|
329 | "curarrm":"\u293C",
|
---|
330 | "curlyeqprec":"\u22DE",
|
---|
331 | "curlyeqsucc":"\u22DF",
|
---|
332 | "curlyvee":"\u22CE",
|
---|
333 | "curlywedge":"\u22CF",
|
---|
334 | "curren":"\u00A4",
|
---|
335 | "curvearrowleft":"\u21B6",
|
---|
336 | "curvearrowright":"\u21B7",
|
---|
337 | "cuvee":"\u22CE",
|
---|
338 | "cuwed":"\u22CF",
|
---|
339 | "cwconint":"\u2232",
|
---|
340 | "cwint":"\u2231",
|
---|
341 | "cylcty":"\u232D",
|
---|
342 | "Dagger":"\u2021",
|
---|
343 | "dagger":"\u2020",
|
---|
344 | "daleth":"\u2138",
|
---|
345 | "Darr":"\u21A1",
|
---|
346 | "dArr":"\u21D3",
|
---|
347 | "darr":"\u2193",
|
---|
348 | "dash":"\u2010",
|
---|
349 | "Dashv":"\u2AE4",
|
---|
350 | "dashv":"\u22A3",
|
---|
351 | "dbkarow":"\u290F",
|
---|
352 | "dblac":"\u02DD",
|
---|
353 | "Dcaron":"\u010E",
|
---|
354 | "dcaron":"\u010F",
|
---|
355 | "Dcy":"\u0414",
|
---|
356 | "dcy":"\u0434",
|
---|
357 | "DD":"\u2145",
|
---|
358 | "dd":"\u2146",
|
---|
359 | "ddagger":"\u2021",
|
---|
360 | "ddarr":"\u21CA",
|
---|
361 | "DDotrahd":"\u2911",
|
---|
362 | "ddotseq":"\u2A77",
|
---|
363 | "deg":"\u00B0",
|
---|
364 | "Del":"\u2207",
|
---|
365 | "Delta":"\u0394",
|
---|
366 | "delta":"\u03B4",
|
---|
367 | "demptyv":"\u29B1",
|
---|
368 | "dfisht":"\u297F",
|
---|
369 | "Dfr":"\uD835\uDD07",
|
---|
370 | "dfr":"\uD835\uDD21",
|
---|
371 | "dHar":"\u2965",
|
---|
372 | "dharl":"\u21C3",
|
---|
373 | "dharr":"\u21C2",
|
---|
374 | "DiacriticalAcute":"\u00B4",
|
---|
375 | "DiacriticalDot":"\u02D9",
|
---|
376 | "DiacriticalDoubleAcute":"\u02DD",
|
---|
377 | "DiacriticalGrave":"\u0060",
|
---|
378 | "DiacriticalTilde":"\u02DC",
|
---|
379 | "diam":"\u22C4",
|
---|
380 | "Diamond":"\u22C4",
|
---|
381 | "diamond":"\u22C4",
|
---|
382 | "diamondsuit":"\u2666",
|
---|
383 | "diams":"\u2666",
|
---|
384 | "die":"\u00A8",
|
---|
385 | "DifferentialD":"\u2146",
|
---|
386 | "digamma":"\u03DD",
|
---|
387 | "disin":"\u22F2",
|
---|
388 | "div":"\u00F7",
|
---|
389 | "divide":"\u00F7",
|
---|
390 | "divideontimes":"\u22C7",
|
---|
391 | "divonx":"\u22C7",
|
---|
392 | "DJcy":"\u0402",
|
---|
393 | "djcy":"\u0452",
|
---|
394 | "dlcorn":"\u231E",
|
---|
395 | "dlcrop":"\u230D",
|
---|
396 | "dollar":"\u0024",
|
---|
397 | "Dopf":"\uD835\uDD3B",
|
---|
398 | "dopf":"\uD835\uDD55",
|
---|
399 | "Dot":"\u00A8",
|
---|
400 | "dot":"\u02D9",
|
---|
401 | "DotDot":"\u20DC",
|
---|
402 | "doteq":"\u2250",
|
---|
403 | "doteqdot":"\u2251",
|
---|
404 | "DotEqual":"\u2250",
|
---|
405 | "dotminus":"\u2238",
|
---|
406 | "dotplus":"\u2214",
|
---|
407 | "dotsquare":"\u22A1",
|
---|
408 | "doublebarwedge":"\u2306",
|
---|
409 | "DoubleContourIntegral":"\u222F",
|
---|
410 | "DoubleDot":"\u00A8",
|
---|
411 | "DoubleDownArrow":"\u21D3",
|
---|
412 | "DoubleLeftArrow":"\u21D0",
|
---|
413 | "DoubleLeftRightArrow":"\u21D4",
|
---|
414 | "DoubleLeftTee":"\u2AE4",
|
---|
415 | "DoubleLongLeftArrow":"\u27F8",
|
---|
416 | "DoubleLongLeftRightArrow":"\u27FA",
|
---|
417 | "DoubleLongRightArrow":"\u27F9",
|
---|
418 | "DoubleRightArrow":"\u21D2",
|
---|
419 | "DoubleRightTee":"\u22A8",
|
---|
420 | "DoubleUpArrow":"\u21D1",
|
---|
421 | "DoubleUpDownArrow":"\u21D5",
|
---|
422 | "DoubleVerticalBar":"\u2225",
|
---|
423 | "DownArrow":"\u2193",
|
---|
424 | "Downarrow":"\u21D3",
|
---|
425 | "downarrow":"\u2193",
|
---|
426 | "DownArrowBar":"\u2913",
|
---|
427 | "DownArrowUpArrow":"\u21F5",
|
---|
428 | "DownBreve":"\u0311",
|
---|
429 | "downdownarrows":"\u21CA",
|
---|
430 | "downharpoonleft":"\u21C3",
|
---|
431 | "downharpoonright":"\u21C2",
|
---|
432 | "DownLeftRightVector":"\u2950",
|
---|
433 | "DownLeftTeeVector":"\u295E",
|
---|
434 | "DownLeftVector":"\u21BD",
|
---|
435 | "DownLeftVectorBar":"\u2956",
|
---|
436 | "DownRightTeeVector":"\u295F",
|
---|
437 | "DownRightVector":"\u21C1",
|
---|
438 | "DownRightVectorBar":"\u2957",
|
---|
439 | "DownTee":"\u22A4",
|
---|
440 | "DownTeeArrow":"\u21A7",
|
---|
441 | "drbkarow":"\u2910",
|
---|
442 | "drcorn":"\u231F",
|
---|
443 | "drcrop":"\u230C",
|
---|
444 | "Dscr":"\uD835\uDC9F",
|
---|
445 | "dscr":"\uD835\uDCB9",
|
---|
446 | "DScy":"\u0405",
|
---|
447 | "dscy":"\u0455",
|
---|
448 | "dsol":"\u29F6",
|
---|
449 | "Dstrok":"\u0110",
|
---|
450 | "dstrok":"\u0111",
|
---|
451 | "dtdot":"\u22F1",
|
---|
452 | "dtri":"\u25BF",
|
---|
453 | "dtrif":"\u25BE",
|
---|
454 | "duarr":"\u21F5",
|
---|
455 | "duhar":"\u296F",
|
---|
456 | "dwangle":"\u29A6",
|
---|
457 | "DZcy":"\u040F",
|
---|
458 | "dzcy":"\u045F",
|
---|
459 | "dzigrarr":"\u27FF",
|
---|
460 | "Eacute":"\u00C9",
|
---|
461 | "eacute":"\u00E9",
|
---|
462 | "easter":"\u2A6E",
|
---|
463 | "Ecaron":"\u011A",
|
---|
464 | "ecaron":"\u011B",
|
---|
465 | "ecir":"\u2256",
|
---|
466 | "Ecirc":"\u00CA",
|
---|
467 | "ecirc":"\u00EA",
|
---|
468 | "ecolon":"\u2255",
|
---|
469 | "Ecy":"\u042D",
|
---|
470 | "ecy":"\u044D",
|
---|
471 | "eDDot":"\u2A77",
|
---|
472 | "Edot":"\u0116",
|
---|
473 | "eDot":"\u2251",
|
---|
474 | "edot":"\u0117",
|
---|
475 | "ee":"\u2147",
|
---|
476 | "efDot":"\u2252",
|
---|
477 | "Efr":"\uD835\uDD08",
|
---|
478 | "efr":"\uD835\uDD22",
|
---|
479 | "eg":"\u2A9A",
|
---|
480 | "Egrave":"\u00C8",
|
---|
481 | "egrave":"\u00E8",
|
---|
482 | "egs":"\u2A96",
|
---|
483 | "egsdot":"\u2A98",
|
---|
484 | "el":"\u2A99",
|
---|
485 | "Element":"\u2208",
|
---|
486 | "elinters":"\u23E7",
|
---|
487 | "ell":"\u2113",
|
---|
488 | "els":"\u2A95",
|
---|
489 | "elsdot":"\u2A97",
|
---|
490 | "Emacr":"\u0112",
|
---|
491 | "emacr":"\u0113",
|
---|
492 | "empty":"\u2205",
|
---|
493 | "emptyset":"\u2205",
|
---|
494 | "EmptySmallSquare":"\u25FB",
|
---|
495 | "emptyv":"\u2205",
|
---|
496 | "EmptyVerySmallSquare":"\u25AB",
|
---|
497 | "emsp":"\u2003",
|
---|
498 | "emsp13":"\u2004",
|
---|
499 | "emsp14":"\u2005",
|
---|
500 | "ENG":"\u014A",
|
---|
501 | "eng":"\u014B",
|
---|
502 | "ensp":"\u2002",
|
---|
503 | "Eogon":"\u0118",
|
---|
504 | "eogon":"\u0119",
|
---|
505 | "Eopf":"\uD835\uDD3C",
|
---|
506 | "eopf":"\uD835\uDD56",
|
---|
507 | "epar":"\u22D5",
|
---|
508 | "eparsl":"\u29E3",
|
---|
509 | "eplus":"\u2A71",
|
---|
510 | "epsi":"\u03B5",
|
---|
511 | "Epsilon":"\u0395",
|
---|
512 | "epsilon":"\u03B5",
|
---|
513 | "epsiv":"\u03F5",
|
---|
514 | "eqcirc":"\u2256",
|
---|
515 | "eqcolon":"\u2255",
|
---|
516 | "eqsim":"\u2242",
|
---|
517 | "eqslantgtr":"\u2A96",
|
---|
518 | "eqslantless":"\u2A95",
|
---|
519 | "Equal":"\u2A75",
|
---|
520 | "equals":"\u003D",
|
---|
521 | "EqualTilde":"\u2242",
|
---|
522 | "equest":"\u225F",
|
---|
523 | "Equilibrium":"\u21CC",
|
---|
524 | "equiv":"\u2261",
|
---|
525 | "equivDD":"\u2A78",
|
---|
526 | "eqvparsl":"\u29E5",
|
---|
527 | "erarr":"\u2971",
|
---|
528 | "erDot":"\u2253",
|
---|
529 | "Escr":"\u2130",
|
---|
530 | "escr":"\u212F",
|
---|
531 | "esdot":"\u2250",
|
---|
532 | "Esim":"\u2A73",
|
---|
533 | "esim":"\u2242",
|
---|
534 | "Eta":"\u0397",
|
---|
535 | "eta":"\u03B7",
|
---|
536 | "ETH":"\u00D0",
|
---|
537 | "eth":"\u00F0",
|
---|
538 | "Euml":"\u00CB",
|
---|
539 | "euml":"\u00EB",
|
---|
540 | "euro":"\u20AC",
|
---|
541 | "excl":"\u0021",
|
---|
542 | "exist":"\u2203",
|
---|
543 | "Exists":"\u2203",
|
---|
544 | "expectation":"\u2130",
|
---|
545 | "ExponentialE":"\u2147",
|
---|
546 | "exponentiale":"\u2147",
|
---|
547 | "fallingdotseq":"\u2252",
|
---|
548 | "Fcy":"\u0424",
|
---|
549 | "fcy":"\u0444",
|
---|
550 | "female":"\u2640",
|
---|
551 | "ffilig":"\uFB03",
|
---|
552 | "fflig":"\uFB00",
|
---|
553 | "ffllig":"\uFB04",
|
---|
554 | "Ffr":"\uD835\uDD09",
|
---|
555 | "ffr":"\uD835\uDD23",
|
---|
556 | "filig":"\uFB01",
|
---|
557 | "FilledSmallSquare":"\u25FC",
|
---|
558 | "FilledVerySmallSquare":"\u25AA",
|
---|
559 | "fjlig":"\u0066\u006A",
|
---|
560 | "flat":"\u266D",
|
---|
561 | "fllig":"\uFB02",
|
---|
562 | "fltns":"\u25B1",
|
---|
563 | "fnof":"\u0192",
|
---|
564 | "Fopf":"\uD835\uDD3D",
|
---|
565 | "fopf":"\uD835\uDD57",
|
---|
566 | "ForAll":"\u2200",
|
---|
567 | "forall":"\u2200",
|
---|
568 | "fork":"\u22D4",
|
---|
569 | "forkv":"\u2AD9",
|
---|
570 | "Fouriertrf":"\u2131",
|
---|
571 | "fpartint":"\u2A0D",
|
---|
572 | "frac12":"\u00BD",
|
---|
573 | "frac13":"\u2153",
|
---|
574 | "frac14":"\u00BC",
|
---|
575 | "frac15":"\u2155",
|
---|
576 | "frac16":"\u2159",
|
---|
577 | "frac18":"\u215B",
|
---|
578 | "frac23":"\u2154",
|
---|
579 | "frac25":"\u2156",
|
---|
580 | "frac34":"\u00BE",
|
---|
581 | "frac35":"\u2157",
|
---|
582 | "frac38":"\u215C",
|
---|
583 | "frac45":"\u2158",
|
---|
584 | "frac56":"\u215A",
|
---|
585 | "frac58":"\u215D",
|
---|
586 | "frac78":"\u215E",
|
---|
587 | "frasl":"\u2044",
|
---|
588 | "frown":"\u2322",
|
---|
589 | "Fscr":"\u2131",
|
---|
590 | "fscr":"\uD835\uDCBB",
|
---|
591 | "gacute":"\u01F5",
|
---|
592 | "Gamma":"\u0393",
|
---|
593 | "gamma":"\u03B3",
|
---|
594 | "Gammad":"\u03DC",
|
---|
595 | "gammad":"\u03DD",
|
---|
596 | "gap":"\u2A86",
|
---|
597 | "Gbreve":"\u011E",
|
---|
598 | "gbreve":"\u011F",
|
---|
599 | "Gcedil":"\u0122",
|
---|
600 | "Gcirc":"\u011C",
|
---|
601 | "gcirc":"\u011D",
|
---|
602 | "Gcy":"\u0413",
|
---|
603 | "gcy":"\u0433",
|
---|
604 | "Gdot":"\u0120",
|
---|
605 | "gdot":"\u0121",
|
---|
606 | "gE":"\u2267",
|
---|
607 | "ge":"\u2265",
|
---|
608 | "gEl":"\u2A8C",
|
---|
609 | "gel":"\u22DB",
|
---|
610 | "geq":"\u2265",
|
---|
611 | "geqq":"\u2267",
|
---|
612 | "geqslant":"\u2A7E",
|
---|
613 | "ges":"\u2A7E",
|
---|
614 | "gescc":"\u2AA9",
|
---|
615 | "gesdot":"\u2A80",
|
---|
616 | "gesdoto":"\u2A82",
|
---|
617 | "gesdotol":"\u2A84",
|
---|
618 | "gesl":"\u22DB\uFE00",
|
---|
619 | "gesles":"\u2A94",
|
---|
620 | "Gfr":"\uD835\uDD0A",
|
---|
621 | "gfr":"\uD835\uDD24",
|
---|
622 | "Gg":"\u22D9",
|
---|
623 | "gg":"\u226B",
|
---|
624 | "ggg":"\u22D9",
|
---|
625 | "gimel":"\u2137",
|
---|
626 | "GJcy":"\u0403",
|
---|
627 | "gjcy":"\u0453",
|
---|
628 | "gl":"\u2277",
|
---|
629 | "gla":"\u2AA5",
|
---|
630 | "glE":"\u2A92",
|
---|
631 | "glj":"\u2AA4",
|
---|
632 | "gnap":"\u2A8A",
|
---|
633 | "gnapprox":"\u2A8A",
|
---|
634 | "gnE":"\u2269",
|
---|
635 | "gne":"\u2A88",
|
---|
636 | "gneq":"\u2A88",
|
---|
637 | "gneqq":"\u2269",
|
---|
638 | "gnsim":"\u22E7",
|
---|
639 | "Gopf":"\uD835\uDD3E",
|
---|
640 | "gopf":"\uD835\uDD58",
|
---|
641 | "grave":"\u0060",
|
---|
642 | "GreaterEqual":"\u2265",
|
---|
643 | "GreaterEqualLess":"\u22DB",
|
---|
644 | "GreaterFullEqual":"\u2267",
|
---|
645 | "GreaterGreater":"\u2AA2",
|
---|
646 | "GreaterLess":"\u2277",
|
---|
647 | "GreaterSlantEqual":"\u2A7E",
|
---|
648 | "GreaterTilde":"\u2273",
|
---|
649 | "Gscr":"\uD835\uDCA2",
|
---|
650 | "gscr":"\u210A",
|
---|
651 | "gsim":"\u2273",
|
---|
652 | "gsime":"\u2A8E",
|
---|
653 | "gsiml":"\u2A90",
|
---|
654 | "GT":"\u003E",
|
---|
655 | "Gt":"\u226B",
|
---|
656 | "gt":"\u003E",
|
---|
657 | "gtcc":"\u2AA7",
|
---|
658 | "gtcir":"\u2A7A",
|
---|
659 | "gtdot":"\u22D7",
|
---|
660 | "gtlPar":"\u2995",
|
---|
661 | "gtquest":"\u2A7C",
|
---|
662 | "gtrapprox":"\u2A86",
|
---|
663 | "gtrarr":"\u2978",
|
---|
664 | "gtrdot":"\u22D7",
|
---|
665 | "gtreqless":"\u22DB",
|
---|
666 | "gtreqqless":"\u2A8C",
|
---|
667 | "gtrless":"\u2277",
|
---|
668 | "gtrsim":"\u2273",
|
---|
669 | "gvertneqq":"\u2269\uFE00",
|
---|
670 | "gvnE":"\u2269\uFE00",
|
---|
671 | "Hacek":"\u02C7",
|
---|
672 | "hairsp":"\u200A",
|
---|
673 | "half":"\u00BD",
|
---|
674 | "hamilt":"\u210B",
|
---|
675 | "HARDcy":"\u042A",
|
---|
676 | "hardcy":"\u044A",
|
---|
677 | "hArr":"\u21D4",
|
---|
678 | "harr":"\u2194",
|
---|
679 | "harrcir":"\u2948",
|
---|
680 | "harrw":"\u21AD",
|
---|
681 | "Hat":"\u005E",
|
---|
682 | "hbar":"\u210F",
|
---|
683 | "Hcirc":"\u0124",
|
---|
684 | "hcirc":"\u0125",
|
---|
685 | "hearts":"\u2665",
|
---|
686 | "heartsuit":"\u2665",
|
---|
687 | "hellip":"\u2026",
|
---|
688 | "hercon":"\u22B9",
|
---|
689 | "Hfr":"\u210C",
|
---|
690 | "hfr":"\uD835\uDD25",
|
---|
691 | "HilbertSpace":"\u210B",
|
---|
692 | "hksearow":"\u2925",
|
---|
693 | "hkswarow":"\u2926",
|
---|
694 | "hoarr":"\u21FF",
|
---|
695 | "homtht":"\u223B",
|
---|
696 | "hookleftarrow":"\u21A9",
|
---|
697 | "hookrightarrow":"\u21AA",
|
---|
698 | "Hopf":"\u210D",
|
---|
699 | "hopf":"\uD835\uDD59",
|
---|
700 | "horbar":"\u2015",
|
---|
701 | "HorizontalLine":"\u2500",
|
---|
702 | "Hscr":"\u210B",
|
---|
703 | "hscr":"\uD835\uDCBD",
|
---|
704 | "hslash":"\u210F",
|
---|
705 | "Hstrok":"\u0126",
|
---|
706 | "hstrok":"\u0127",
|
---|
707 | "HumpDownHump":"\u224E",
|
---|
708 | "HumpEqual":"\u224F",
|
---|
709 | "hybull":"\u2043",
|
---|
710 | "hyphen":"\u2010",
|
---|
711 | "Iacute":"\u00CD",
|
---|
712 | "iacute":"\u00ED",
|
---|
713 | "ic":"\u2063",
|
---|
714 | "Icirc":"\u00CE",
|
---|
715 | "icirc":"\u00EE",
|
---|
716 | "Icy":"\u0418",
|
---|
717 | "icy":"\u0438",
|
---|
718 | "Idot":"\u0130",
|
---|
719 | "IEcy":"\u0415",
|
---|
720 | "iecy":"\u0435",
|
---|
721 | "iexcl":"\u00A1",
|
---|
722 | "iff":"\u21D4",
|
---|
723 | "Ifr":"\u2111",
|
---|
724 | "ifr":"\uD835\uDD26",
|
---|
725 | "Igrave":"\u00CC",
|
---|
726 | "igrave":"\u00EC",
|
---|
727 | "ii":"\u2148",
|
---|
728 | "iiiint":"\u2A0C",
|
---|
729 | "iiint":"\u222D",
|
---|
730 | "iinfin":"\u29DC",
|
---|
731 | "iiota":"\u2129",
|
---|
732 | "IJlig":"\u0132",
|
---|
733 | "ijlig":"\u0133",
|
---|
734 | "Im":"\u2111",
|
---|
735 | "Imacr":"\u012A",
|
---|
736 | "imacr":"\u012B",
|
---|
737 | "image":"\u2111",
|
---|
738 | "ImaginaryI":"\u2148",
|
---|
739 | "imagline":"\u2110",
|
---|
740 | "imagpart":"\u2111",
|
---|
741 | "imath":"\u0131",
|
---|
742 | "imof":"\u22B7",
|
---|
743 | "imped":"\u01B5",
|
---|
744 | "Implies":"\u21D2",
|
---|
745 | "in":"\u2208",
|
---|
746 | "incare":"\u2105",
|
---|
747 | "infin":"\u221E",
|
---|
748 | "infintie":"\u29DD",
|
---|
749 | "inodot":"\u0131",
|
---|
750 | "Int":"\u222C",
|
---|
751 | "int":"\u222B",
|
---|
752 | "intcal":"\u22BA",
|
---|
753 | "integers":"\u2124",
|
---|
754 | "Integral":"\u222B",
|
---|
755 | "intercal":"\u22BA",
|
---|
756 | "Intersection":"\u22C2",
|
---|
757 | "intlarhk":"\u2A17",
|
---|
758 | "intprod":"\u2A3C",
|
---|
759 | "InvisibleComma":"\u2063",
|
---|
760 | "InvisibleTimes":"\u2062",
|
---|
761 | "IOcy":"\u0401",
|
---|
762 | "iocy":"\u0451",
|
---|
763 | "Iogon":"\u012E",
|
---|
764 | "iogon":"\u012F",
|
---|
765 | "Iopf":"\uD835\uDD40",
|
---|
766 | "iopf":"\uD835\uDD5A",
|
---|
767 | "Iota":"\u0399",
|
---|
768 | "iota":"\u03B9",
|
---|
769 | "iprod":"\u2A3C",
|
---|
770 | "iquest":"\u00BF",
|
---|
771 | "Iscr":"\u2110",
|
---|
772 | "iscr":"\uD835\uDCBE",
|
---|
773 | "isin":"\u2208",
|
---|
774 | "isindot":"\u22F5",
|
---|
775 | "isinE":"\u22F9",
|
---|
776 | "isins":"\u22F4",
|
---|
777 | "isinsv":"\u22F3",
|
---|
778 | "isinv":"\u2208",
|
---|
779 | "it":"\u2062",
|
---|
780 | "Itilde":"\u0128",
|
---|
781 | "itilde":"\u0129",
|
---|
782 | "Iukcy":"\u0406",
|
---|
783 | "iukcy":"\u0456",
|
---|
784 | "Iuml":"\u00CF",
|
---|
785 | "iuml":"\u00EF",
|
---|
786 | "Jcirc":"\u0134",
|
---|
787 | "jcirc":"\u0135",
|
---|
788 | "Jcy":"\u0419",
|
---|
789 | "jcy":"\u0439",
|
---|
790 | "Jfr":"\uD835\uDD0D",
|
---|
791 | "jfr":"\uD835\uDD27",
|
---|
792 | "jmath":"\u0237",
|
---|
793 | "Jopf":"\uD835\uDD41",
|
---|
794 | "jopf":"\uD835\uDD5B",
|
---|
795 | "Jscr":"\uD835\uDCA5",
|
---|
796 | "jscr":"\uD835\uDCBF",
|
---|
797 | "Jsercy":"\u0408",
|
---|
798 | "jsercy":"\u0458",
|
---|
799 | "Jukcy":"\u0404",
|
---|
800 | "jukcy":"\u0454",
|
---|
801 | "Kappa":"\u039A",
|
---|
802 | "kappa":"\u03BA",
|
---|
803 | "kappav":"\u03F0",
|
---|
804 | "Kcedil":"\u0136",
|
---|
805 | "kcedil":"\u0137",
|
---|
806 | "Kcy":"\u041A",
|
---|
807 | "kcy":"\u043A",
|
---|
808 | "Kfr":"\uD835\uDD0E",
|
---|
809 | "kfr":"\uD835\uDD28",
|
---|
810 | "kgreen":"\u0138",
|
---|
811 | "KHcy":"\u0425",
|
---|
812 | "khcy":"\u0445",
|
---|
813 | "KJcy":"\u040C",
|
---|
814 | "kjcy":"\u045C",
|
---|
815 | "Kopf":"\uD835\uDD42",
|
---|
816 | "kopf":"\uD835\uDD5C",
|
---|
817 | "Kscr":"\uD835\uDCA6",
|
---|
818 | "kscr":"\uD835\uDCC0",
|
---|
819 | "lAarr":"\u21DA",
|
---|
820 | "Lacute":"\u0139",
|
---|
821 | "lacute":"\u013A",
|
---|
822 | "laemptyv":"\u29B4",
|
---|
823 | "lagran":"\u2112",
|
---|
824 | "Lambda":"\u039B",
|
---|
825 | "lambda":"\u03BB",
|
---|
826 | "Lang":"\u27EA",
|
---|
827 | "lang":"\u27E8",
|
---|
828 | "langd":"\u2991",
|
---|
829 | "langle":"\u27E8",
|
---|
830 | "lap":"\u2A85",
|
---|
831 | "Laplacetrf":"\u2112",
|
---|
832 | "laquo":"\u00AB",
|
---|
833 | "Larr":"\u219E",
|
---|
834 | "lArr":"\u21D0",
|
---|
835 | "larr":"\u2190",
|
---|
836 | "larrb":"\u21E4",
|
---|
837 | "larrbfs":"\u291F",
|
---|
838 | "larrfs":"\u291D",
|
---|
839 | "larrhk":"\u21A9",
|
---|
840 | "larrlp":"\u21AB",
|
---|
841 | "larrpl":"\u2939",
|
---|
842 | "larrsim":"\u2973",
|
---|
843 | "larrtl":"\u21A2",
|
---|
844 | "lat":"\u2AAB",
|
---|
845 | "lAtail":"\u291B",
|
---|
846 | "latail":"\u2919",
|
---|
847 | "late":"\u2AAD",
|
---|
848 | "lates":"\u2AAD\uFE00",
|
---|
849 | "lBarr":"\u290E",
|
---|
850 | "lbarr":"\u290C",
|
---|
851 | "lbbrk":"\u2772",
|
---|
852 | "lbrace":"\u007B",
|
---|
853 | "lbrack":"\u005B",
|
---|
854 | "lbrke":"\u298B",
|
---|
855 | "lbrksld":"\u298F",
|
---|
856 | "lbrkslu":"\u298D",
|
---|
857 | "Lcaron":"\u013D",
|
---|
858 | "lcaron":"\u013E",
|
---|
859 | "Lcedil":"\u013B",
|
---|
860 | "lcedil":"\u013C",
|
---|
861 | "lceil":"\u2308",
|
---|
862 | "lcub":"\u007B",
|
---|
863 | "Lcy":"\u041B",
|
---|
864 | "lcy":"\u043B",
|
---|
865 | "ldca":"\u2936",
|
---|
866 | "ldquo":"\u201C",
|
---|
867 | "ldquor":"\u201E",
|
---|
868 | "ldrdhar":"\u2967",
|
---|
869 | "ldrushar":"\u294B",
|
---|
870 | "ldsh":"\u21B2",
|
---|
871 | "lE":"\u2266",
|
---|
872 | "le":"\u2264",
|
---|
873 | "LeftAngleBracket":"\u27E8",
|
---|
874 | "LeftArrow":"\u2190",
|
---|
875 | "Leftarrow":"\u21D0",
|
---|
876 | "leftarrow":"\u2190",
|
---|
877 | "LeftArrowBar":"\u21E4",
|
---|
878 | "LeftArrowRightArrow":"\u21C6",
|
---|
879 | "leftarrowtail":"\u21A2",
|
---|
880 | "LeftCeiling":"\u2308",
|
---|
881 | "LeftDoubleBracket":"\u27E6",
|
---|
882 | "LeftDownTeeVector":"\u2961",
|
---|
883 | "LeftDownVector":"\u21C3",
|
---|
884 | "LeftDownVectorBar":"\u2959",
|
---|
885 | "LeftFloor":"\u230A",
|
---|
886 | "leftharpoondown":"\u21BD",
|
---|
887 | "leftharpoonup":"\u21BC",
|
---|
888 | "leftleftarrows":"\u21C7",
|
---|
889 | "LeftRightArrow":"\u2194",
|
---|
890 | "Leftrightarrow":"\u21D4",
|
---|
891 | "leftrightarrow":"\u2194",
|
---|
892 | "leftrightarrows":"\u21C6",
|
---|
893 | "leftrightharpoons":"\u21CB",
|
---|
894 | "leftrightsquigarrow":"\u21AD",
|
---|
895 | "LeftRightVector":"\u294E",
|
---|
896 | "LeftTee":"\u22A3",
|
---|
897 | "LeftTeeArrow":"\u21A4",
|
---|
898 | "LeftTeeVector":"\u295A",
|
---|
899 | "leftthreetimes":"\u22CB",
|
---|
900 | "LeftTriangle":"\u22B2",
|
---|
901 | "LeftTriangleBar":"\u29CF",
|
---|
902 | "LeftTriangleEqual":"\u22B4",
|
---|
903 | "LeftUpDownVector":"\u2951",
|
---|
904 | "LeftUpTeeVector":"\u2960",
|
---|
905 | "LeftUpVector":"\u21BF",
|
---|
906 | "LeftUpVectorBar":"\u2958",
|
---|
907 | "LeftVector":"\u21BC",
|
---|
908 | "LeftVectorBar":"\u2952",
|
---|
909 | "lEg":"\u2A8B",
|
---|
910 | "leg":"\u22DA",
|
---|
911 | "leq":"\u2264",
|
---|
912 | "leqq":"\u2266",
|
---|
913 | "leqslant":"\u2A7D",
|
---|
914 | "les":"\u2A7D",
|
---|
915 | "lescc":"\u2AA8",
|
---|
916 | "lesdot":"\u2A7F",
|
---|
917 | "lesdoto":"\u2A81",
|
---|
918 | "lesdotor":"\u2A83",
|
---|
919 | "lesg":"\u22DA\uFE00",
|
---|
920 | "lesges":"\u2A93",
|
---|
921 | "lessapprox":"\u2A85",
|
---|
922 | "lessdot":"\u22D6",
|
---|
923 | "lesseqgtr":"\u22DA",
|
---|
924 | "lesseqqgtr":"\u2A8B",
|
---|
925 | "LessEqualGreater":"\u22DA",
|
---|
926 | "LessFullEqual":"\u2266",
|
---|
927 | "LessGreater":"\u2276",
|
---|
928 | "lessgtr":"\u2276",
|
---|
929 | "LessLess":"\u2AA1",
|
---|
930 | "lesssim":"\u2272",
|
---|
931 | "LessSlantEqual":"\u2A7D",
|
---|
932 | "LessTilde":"\u2272",
|
---|
933 | "lfisht":"\u297C",
|
---|
934 | "lfloor":"\u230A",
|
---|
935 | "Lfr":"\uD835\uDD0F",
|
---|
936 | "lfr":"\uD835\uDD29",
|
---|
937 | "lg":"\u2276",
|
---|
938 | "lgE":"\u2A91",
|
---|
939 | "lHar":"\u2962",
|
---|
940 | "lhard":"\u21BD",
|
---|
941 | "lharu":"\u21BC",
|
---|
942 | "lharul":"\u296A",
|
---|
943 | "lhblk":"\u2584",
|
---|
944 | "LJcy":"\u0409",
|
---|
945 | "ljcy":"\u0459",
|
---|
946 | "Ll":"\u22D8",
|
---|
947 | "ll":"\u226A",
|
---|
948 | "llarr":"\u21C7",
|
---|
949 | "llcorner":"\u231E",
|
---|
950 | "Lleftarrow":"\u21DA",
|
---|
951 | "llhard":"\u296B",
|
---|
952 | "lltri":"\u25FA",
|
---|
953 | "Lmidot":"\u013F",
|
---|
954 | "lmidot":"\u0140",
|
---|
955 | "lmoust":"\u23B0",
|
---|
956 | "lmoustache":"\u23B0",
|
---|
957 | "lnap":"\u2A89",
|
---|
958 | "lnapprox":"\u2A89",
|
---|
959 | "lnE":"\u2268",
|
---|
960 | "lne":"\u2A87",
|
---|
961 | "lneq":"\u2A87",
|
---|
962 | "lneqq":"\u2268",
|
---|
963 | "lnsim":"\u22E6",
|
---|
964 | "loang":"\u27EC",
|
---|
965 | "loarr":"\u21FD",
|
---|
966 | "lobrk":"\u27E6",
|
---|
967 | "LongLeftArrow":"\u27F5",
|
---|
968 | "Longleftarrow":"\u27F8",
|
---|
969 | "longleftarrow":"\u27F5",
|
---|
970 | "LongLeftRightArrow":"\u27F7",
|
---|
971 | "Longleftrightarrow":"\u27FA",
|
---|
972 | "longleftrightarrow":"\u27F7",
|
---|
973 | "longmapsto":"\u27FC",
|
---|
974 | "LongRightArrow":"\u27F6",
|
---|
975 | "Longrightarrow":"\u27F9",
|
---|
976 | "longrightarrow":"\u27F6",
|
---|
977 | "looparrowleft":"\u21AB",
|
---|
978 | "looparrowright":"\u21AC",
|
---|
979 | "lopar":"\u2985",
|
---|
980 | "Lopf":"\uD835\uDD43",
|
---|
981 | "lopf":"\uD835\uDD5D",
|
---|
982 | "loplus":"\u2A2D",
|
---|
983 | "lotimes":"\u2A34",
|
---|
984 | "lowast":"\u2217",
|
---|
985 | "lowbar":"\u005F",
|
---|
986 | "LowerLeftArrow":"\u2199",
|
---|
987 | "LowerRightArrow":"\u2198",
|
---|
988 | "loz":"\u25CA",
|
---|
989 | "lozenge":"\u25CA",
|
---|
990 | "lozf":"\u29EB",
|
---|
991 | "lpar":"\u0028",
|
---|
992 | "lparlt":"\u2993",
|
---|
993 | "lrarr":"\u21C6",
|
---|
994 | "lrcorner":"\u231F",
|
---|
995 | "lrhar":"\u21CB",
|
---|
996 | "lrhard":"\u296D",
|
---|
997 | "lrm":"\u200E",
|
---|
998 | "lrtri":"\u22BF",
|
---|
999 | "lsaquo":"\u2039",
|
---|
1000 | "Lscr":"\u2112",
|
---|
1001 | "lscr":"\uD835\uDCC1",
|
---|
1002 | "Lsh":"\u21B0",
|
---|
1003 | "lsh":"\u21B0",
|
---|
1004 | "lsim":"\u2272",
|
---|
1005 | "lsime":"\u2A8D",
|
---|
1006 | "lsimg":"\u2A8F",
|
---|
1007 | "lsqb":"\u005B",
|
---|
1008 | "lsquo":"\u2018",
|
---|
1009 | "lsquor":"\u201A",
|
---|
1010 | "Lstrok":"\u0141",
|
---|
1011 | "lstrok":"\u0142",
|
---|
1012 | "LT":"\u003C",
|
---|
1013 | "Lt":"\u226A",
|
---|
1014 | "lt":"\u003C",
|
---|
1015 | "ltcc":"\u2AA6",
|
---|
1016 | "ltcir":"\u2A79",
|
---|
1017 | "ltdot":"\u22D6",
|
---|
1018 | "lthree":"\u22CB",
|
---|
1019 | "ltimes":"\u22C9",
|
---|
1020 | "ltlarr":"\u2976",
|
---|
1021 | "ltquest":"\u2A7B",
|
---|
1022 | "ltri":"\u25C3",
|
---|
1023 | "ltrie":"\u22B4",
|
---|
1024 | "ltrif":"\u25C2",
|
---|
1025 | "ltrPar":"\u2996",
|
---|
1026 | "lurdshar":"\u294A",
|
---|
1027 | "luruhar":"\u2966",
|
---|
1028 | "lvertneqq":"\u2268\uFE00",
|
---|
1029 | "lvnE":"\u2268\uFE00",
|
---|
1030 | "macr":"\u00AF",
|
---|
1031 | "male":"\u2642",
|
---|
1032 | "malt":"\u2720",
|
---|
1033 | "maltese":"\u2720",
|
---|
1034 | "Map":"\u2905",
|
---|
1035 | "map":"\u21A6",
|
---|
1036 | "mapsto":"\u21A6",
|
---|
1037 | "mapstodown":"\u21A7",
|
---|
1038 | "mapstoleft":"\u21A4",
|
---|
1039 | "mapstoup":"\u21A5",
|
---|
1040 | "marker":"\u25AE",
|
---|
1041 | "mcomma":"\u2A29",
|
---|
1042 | "Mcy":"\u041C",
|
---|
1043 | "mcy":"\u043C",
|
---|
1044 | "mdash":"\u2014",
|
---|
1045 | "mDDot":"\u223A",
|
---|
1046 | "measuredangle":"\u2221",
|
---|
1047 | "MediumSpace":"\u205F",
|
---|
1048 | "Mellintrf":"\u2133",
|
---|
1049 | "Mfr":"\uD835\uDD10",
|
---|
1050 | "mfr":"\uD835\uDD2A",
|
---|
1051 | "mho":"\u2127",
|
---|
1052 | "micro":"\u00B5",
|
---|
1053 | "mid":"\u2223",
|
---|
1054 | "midast":"\u002A",
|
---|
1055 | "midcir":"\u2AF0",
|
---|
1056 | "middot":"\u00B7",
|
---|
1057 | "minus":"\u2212",
|
---|
1058 | "minusb":"\u229F",
|
---|
1059 | "minusd":"\u2238",
|
---|
1060 | "minusdu":"\u2A2A",
|
---|
1061 | "MinusPlus":"\u2213",
|
---|
1062 | "mlcp":"\u2ADB",
|
---|
1063 | "mldr":"\u2026",
|
---|
1064 | "mnplus":"\u2213",
|
---|
1065 | "models":"\u22A7",
|
---|
1066 | "Mopf":"\uD835\uDD44",
|
---|
1067 | "mopf":"\uD835\uDD5E",
|
---|
1068 | "mp":"\u2213",
|
---|
1069 | "Mscr":"\u2133",
|
---|
1070 | "mscr":"\uD835\uDCC2",
|
---|
1071 | "mstpos":"\u223E",
|
---|
1072 | "Mu":"\u039C",
|
---|
1073 | "mu":"\u03BC",
|
---|
1074 | "multimap":"\u22B8",
|
---|
1075 | "mumap":"\u22B8",
|
---|
1076 | "nabla":"\u2207",
|
---|
1077 | "Nacute":"\u0143",
|
---|
1078 | "nacute":"\u0144",
|
---|
1079 | "nang":"\u2220\u20D2",
|
---|
1080 | "nap":"\u2249",
|
---|
1081 | "napE":"\u2A70\u0338",
|
---|
1082 | "napid":"\u224B\u0338",
|
---|
1083 | "napos":"\u0149",
|
---|
1084 | "napprox":"\u2249",
|
---|
1085 | "natur":"\u266E",
|
---|
1086 | "natural":"\u266E",
|
---|
1087 | "naturals":"\u2115",
|
---|
1088 | "nbsp":"\u00A0",
|
---|
1089 | "nbump":"\u224E\u0338",
|
---|
1090 | "nbumpe":"\u224F\u0338",
|
---|
1091 | "ncap":"\u2A43",
|
---|
1092 | "Ncaron":"\u0147",
|
---|
1093 | "ncaron":"\u0148",
|
---|
1094 | "Ncedil":"\u0145",
|
---|
1095 | "ncedil":"\u0146",
|
---|
1096 | "ncong":"\u2247",
|
---|
1097 | "ncongdot":"\u2A6D\u0338",
|
---|
1098 | "ncup":"\u2A42",
|
---|
1099 | "Ncy":"\u041D",
|
---|
1100 | "ncy":"\u043D",
|
---|
1101 | "ndash":"\u2013",
|
---|
1102 | "ne":"\u2260",
|
---|
1103 | "nearhk":"\u2924",
|
---|
1104 | "neArr":"\u21D7",
|
---|
1105 | "nearr":"\u2197",
|
---|
1106 | "nearrow":"\u2197",
|
---|
1107 | "nedot":"\u2250\u0338",
|
---|
1108 | "NegativeMediumSpace":"\u200B",
|
---|
1109 | "NegativeThickSpace":"\u200B",
|
---|
1110 | "NegativeThinSpace":"\u200B",
|
---|
1111 | "NegativeVeryThinSpace":"\u200B",
|
---|
1112 | "nequiv":"\u2262",
|
---|
1113 | "nesear":"\u2928",
|
---|
1114 | "nesim":"\u2242\u0338",
|
---|
1115 | "NestedGreaterGreater":"\u226B",
|
---|
1116 | "NestedLessLess":"\u226A",
|
---|
1117 | "NewLine":"\u000A",
|
---|
1118 | "nexist":"\u2204",
|
---|
1119 | "nexists":"\u2204",
|
---|
1120 | "Nfr":"\uD835\uDD11",
|
---|
1121 | "nfr":"\uD835\uDD2B",
|
---|
1122 | "ngE":"\u2267\u0338",
|
---|
1123 | "nge":"\u2271",
|
---|
1124 | "ngeq":"\u2271",
|
---|
1125 | "ngeqq":"\u2267\u0338",
|
---|
1126 | "ngeqslant":"\u2A7E\u0338",
|
---|
1127 | "nges":"\u2A7E\u0338",
|
---|
1128 | "nGg":"\u22D9\u0338",
|
---|
1129 | "ngsim":"\u2275",
|
---|
1130 | "nGt":"\u226B\u20D2",
|
---|
1131 | "ngt":"\u226F",
|
---|
1132 | "ngtr":"\u226F",
|
---|
1133 | "nGtv":"\u226B\u0338",
|
---|
1134 | "nhArr":"\u21CE",
|
---|
1135 | "nharr":"\u21AE",
|
---|
1136 | "nhpar":"\u2AF2",
|
---|
1137 | "ni":"\u220B",
|
---|
1138 | "nis":"\u22FC",
|
---|
1139 | "nisd":"\u22FA",
|
---|
1140 | "niv":"\u220B",
|
---|
1141 | "NJcy":"\u040A",
|
---|
1142 | "njcy":"\u045A",
|
---|
1143 | "nlArr":"\u21CD",
|
---|
1144 | "nlarr":"\u219A",
|
---|
1145 | "nldr":"\u2025",
|
---|
1146 | "nlE":"\u2266\u0338",
|
---|
1147 | "nle":"\u2270",
|
---|
1148 | "nLeftarrow":"\u21CD",
|
---|
1149 | "nleftarrow":"\u219A",
|
---|
1150 | "nLeftrightarrow":"\u21CE",
|
---|
1151 | "nleftrightarrow":"\u21AE",
|
---|
1152 | "nleq":"\u2270",
|
---|
1153 | "nleqq":"\u2266\u0338",
|
---|
1154 | "nleqslant":"\u2A7D\u0338",
|
---|
1155 | "nles":"\u2A7D\u0338",
|
---|
1156 | "nless":"\u226E",
|
---|
1157 | "nLl":"\u22D8\u0338",
|
---|
1158 | "nlsim":"\u2274",
|
---|
1159 | "nLt":"\u226A\u20D2",
|
---|
1160 | "nlt":"\u226E",
|
---|
1161 | "nltri":"\u22EA",
|
---|
1162 | "nltrie":"\u22EC",
|
---|
1163 | "nLtv":"\u226A\u0338",
|
---|
1164 | "nmid":"\u2224",
|
---|
1165 | "NoBreak":"\u2060",
|
---|
1166 | "NonBreakingSpace":"\u00A0",
|
---|
1167 | "Nopf":"\u2115",
|
---|
1168 | "nopf":"\uD835\uDD5F",
|
---|
1169 | "Not":"\u2AEC",
|
---|
1170 | "not":"\u00AC",
|
---|
1171 | "NotCongruent":"\u2262",
|
---|
1172 | "NotCupCap":"\u226D",
|
---|
1173 | "NotDoubleVerticalBar":"\u2226",
|
---|
1174 | "NotElement":"\u2209",
|
---|
1175 | "NotEqual":"\u2260",
|
---|
1176 | "NotEqualTilde":"\u2242\u0338",
|
---|
1177 | "NotExists":"\u2204",
|
---|
1178 | "NotGreater":"\u226F",
|
---|
1179 | "NotGreaterEqual":"\u2271",
|
---|
1180 | "NotGreaterFullEqual":"\u2267\u0338",
|
---|
1181 | "NotGreaterGreater":"\u226B\u0338",
|
---|
1182 | "NotGreaterLess":"\u2279",
|
---|
1183 | "NotGreaterSlantEqual":"\u2A7E\u0338",
|
---|
1184 | "NotGreaterTilde":"\u2275",
|
---|
1185 | "NotHumpDownHump":"\u224E\u0338",
|
---|
1186 | "NotHumpEqual":"\u224F\u0338",
|
---|
1187 | "notin":"\u2209",
|
---|
1188 | "notindot":"\u22F5\u0338",
|
---|
1189 | "notinE":"\u22F9\u0338",
|
---|
1190 | "notinva":"\u2209",
|
---|
1191 | "notinvb":"\u22F7",
|
---|
1192 | "notinvc":"\u22F6",
|
---|
1193 | "NotLeftTriangle":"\u22EA",
|
---|
1194 | "NotLeftTriangleBar":"\u29CF\u0338",
|
---|
1195 | "NotLeftTriangleEqual":"\u22EC",
|
---|
1196 | "NotLess":"\u226E",
|
---|
1197 | "NotLessEqual":"\u2270",
|
---|
1198 | "NotLessGreater":"\u2278",
|
---|
1199 | "NotLessLess":"\u226A\u0338",
|
---|
1200 | "NotLessSlantEqual":"\u2A7D\u0338",
|
---|
1201 | "NotLessTilde":"\u2274",
|
---|
1202 | "NotNestedGreaterGreater":"\u2AA2\u0338",
|
---|
1203 | "NotNestedLessLess":"\u2AA1\u0338",
|
---|
1204 | "notni":"\u220C",
|
---|
1205 | "notniva":"\u220C",
|
---|
1206 | "notnivb":"\u22FE",
|
---|
1207 | "notnivc":"\u22FD",
|
---|
1208 | "NotPrecedes":"\u2280",
|
---|
1209 | "NotPrecedesEqual":"\u2AAF\u0338",
|
---|
1210 | "NotPrecedesSlantEqual":"\u22E0",
|
---|
1211 | "NotReverseElement":"\u220C",
|
---|
1212 | "NotRightTriangle":"\u22EB",
|
---|
1213 | "NotRightTriangleBar":"\u29D0\u0338",
|
---|
1214 | "NotRightTriangleEqual":"\u22ED",
|
---|
1215 | "NotSquareSubset":"\u228F\u0338",
|
---|
1216 | "NotSquareSubsetEqual":"\u22E2",
|
---|
1217 | "NotSquareSuperset":"\u2290\u0338",
|
---|
1218 | "NotSquareSupersetEqual":"\u22E3",
|
---|
1219 | "NotSubset":"\u2282\u20D2",
|
---|
1220 | "NotSubsetEqual":"\u2288",
|
---|
1221 | "NotSucceeds":"\u2281",
|
---|
1222 | "NotSucceedsEqual":"\u2AB0\u0338",
|
---|
1223 | "NotSucceedsSlantEqual":"\u22E1",
|
---|
1224 | "NotSucceedsTilde":"\u227F\u0338",
|
---|
1225 | "NotSuperset":"\u2283\u20D2",
|
---|
1226 | "NotSupersetEqual":"\u2289",
|
---|
1227 | "NotTilde":"\u2241",
|
---|
1228 | "NotTildeEqual":"\u2244",
|
---|
1229 | "NotTildeFullEqual":"\u2247",
|
---|
1230 | "NotTildeTilde":"\u2249",
|
---|
1231 | "NotVerticalBar":"\u2224",
|
---|
1232 | "npar":"\u2226",
|
---|
1233 | "nparallel":"\u2226",
|
---|
1234 | "nparsl":"\u2AFD\u20E5",
|
---|
1235 | "npart":"\u2202\u0338",
|
---|
1236 | "npolint":"\u2A14",
|
---|
1237 | "npr":"\u2280",
|
---|
1238 | "nprcue":"\u22E0",
|
---|
1239 | "npre":"\u2AAF\u0338",
|
---|
1240 | "nprec":"\u2280",
|
---|
1241 | "npreceq":"\u2AAF\u0338",
|
---|
1242 | "nrArr":"\u21CF",
|
---|
1243 | "nrarr":"\u219B",
|
---|
1244 | "nrarrc":"\u2933\u0338",
|
---|
1245 | "nrarrw":"\u219D\u0338",
|
---|
1246 | "nRightarrow":"\u21CF",
|
---|
1247 | "nrightarrow":"\u219B",
|
---|
1248 | "nrtri":"\u22EB",
|
---|
1249 | "nrtrie":"\u22ED",
|
---|
1250 | "nsc":"\u2281",
|
---|
1251 | "nsccue":"\u22E1",
|
---|
1252 | "nsce":"\u2AB0\u0338",
|
---|
1253 | "Nscr":"\uD835\uDCA9",
|
---|
1254 | "nscr":"\uD835\uDCC3",
|
---|
1255 | "nshortmid":"\u2224",
|
---|
1256 | "nshortparallel":"\u2226",
|
---|
1257 | "nsim":"\u2241",
|
---|
1258 | "nsime":"\u2244",
|
---|
1259 | "nsimeq":"\u2244",
|
---|
1260 | "nsmid":"\u2224",
|
---|
1261 | "nspar":"\u2226",
|
---|
1262 | "nsqsube":"\u22E2",
|
---|
1263 | "nsqsupe":"\u22E3",
|
---|
1264 | "nsub":"\u2284",
|
---|
1265 | "nsubE":"\u2AC5\u0338",
|
---|
1266 | "nsube":"\u2288",
|
---|
1267 | "nsubset":"\u2282\u20D2",
|
---|
1268 | "nsubseteq":"\u2288",
|
---|
1269 | "nsubseteqq":"\u2AC5\u0338",
|
---|
1270 | "nsucc":"\u2281",
|
---|
1271 | "nsucceq":"\u2AB0\u0338",
|
---|
1272 | "nsup":"\u2285",
|
---|
1273 | "nsupE":"\u2AC6\u0338",
|
---|
1274 | "nsupe":"\u2289",
|
---|
1275 | "nsupset":"\u2283\u20D2",
|
---|
1276 | "nsupseteq":"\u2289",
|
---|
1277 | "nsupseteqq":"\u2AC6\u0338",
|
---|
1278 | "ntgl":"\u2279",
|
---|
1279 | "Ntilde":"\u00D1",
|
---|
1280 | "ntilde":"\u00F1",
|
---|
1281 | "ntlg":"\u2278",
|
---|
1282 | "ntriangleleft":"\u22EA",
|
---|
1283 | "ntrianglelefteq":"\u22EC",
|
---|
1284 | "ntriangleright":"\u22EB",
|
---|
1285 | "ntrianglerighteq":"\u22ED",
|
---|
1286 | "Nu":"\u039D",
|
---|
1287 | "nu":"\u03BD",
|
---|
1288 | "num":"\u0023",
|
---|
1289 | "numero":"\u2116",
|
---|
1290 | "numsp":"\u2007",
|
---|
1291 | "nvap":"\u224D\u20D2",
|
---|
1292 | "nVDash":"\u22AF",
|
---|
1293 | "nVdash":"\u22AE",
|
---|
1294 | "nvDash":"\u22AD",
|
---|
1295 | "nvdash":"\u22AC",
|
---|
1296 | "nvge":"\u2265\u20D2",
|
---|
1297 | "nvgt":"\u003E\u20D2",
|
---|
1298 | "nvHarr":"\u2904",
|
---|
1299 | "nvinfin":"\u29DE",
|
---|
1300 | "nvlArr":"\u2902",
|
---|
1301 | "nvle":"\u2264\u20D2",
|
---|
1302 | "nvlt":"\u003C\u20D2",
|
---|
1303 | "nvltrie":"\u22B4\u20D2",
|
---|
1304 | "nvrArr":"\u2903",
|
---|
1305 | "nvrtrie":"\u22B5\u20D2",
|
---|
1306 | "nvsim":"\u223C\u20D2",
|
---|
1307 | "nwarhk":"\u2923",
|
---|
1308 | "nwArr":"\u21D6",
|
---|
1309 | "nwarr":"\u2196",
|
---|
1310 | "nwarrow":"\u2196",
|
---|
1311 | "nwnear":"\u2927",
|
---|
1312 | "Oacute":"\u00D3",
|
---|
1313 | "oacute":"\u00F3",
|
---|
1314 | "oast":"\u229B",
|
---|
1315 | "ocir":"\u229A",
|
---|
1316 | "Ocirc":"\u00D4",
|
---|
1317 | "ocirc":"\u00F4",
|
---|
1318 | "Ocy":"\u041E",
|
---|
1319 | "ocy":"\u043E",
|
---|
1320 | "odash":"\u229D",
|
---|
1321 | "Odblac":"\u0150",
|
---|
1322 | "odblac":"\u0151",
|
---|
1323 | "odiv":"\u2A38",
|
---|
1324 | "odot":"\u2299",
|
---|
1325 | "odsold":"\u29BC",
|
---|
1326 | "OElig":"\u0152",
|
---|
1327 | "oelig":"\u0153",
|
---|
1328 | "ofcir":"\u29BF",
|
---|
1329 | "Ofr":"\uD835\uDD12",
|
---|
1330 | "ofr":"\uD835\uDD2C",
|
---|
1331 | "ogon":"\u02DB",
|
---|
1332 | "Ograve":"\u00D2",
|
---|
1333 | "ograve":"\u00F2",
|
---|
1334 | "ogt":"\u29C1",
|
---|
1335 | "ohbar":"\u29B5",
|
---|
1336 | "ohm":"\u03A9",
|
---|
1337 | "oint":"\u222E",
|
---|
1338 | "olarr":"\u21BA",
|
---|
1339 | "olcir":"\u29BE",
|
---|
1340 | "olcross":"\u29BB",
|
---|
1341 | "oline":"\u203E",
|
---|
1342 | "olt":"\u29C0",
|
---|
1343 | "Omacr":"\u014C",
|
---|
1344 | "omacr":"\u014D",
|
---|
1345 | "Omega":"\u03A9",
|
---|
1346 | "omega":"\u03C9",
|
---|
1347 | "Omicron":"\u039F",
|
---|
1348 | "omicron":"\u03BF",
|
---|
1349 | "omid":"\u29B6",
|
---|
1350 | "ominus":"\u2296",
|
---|
1351 | "Oopf":"\uD835\uDD46",
|
---|
1352 | "oopf":"\uD835\uDD60",
|
---|
1353 | "opar":"\u29B7",
|
---|
1354 | "OpenCurlyDoubleQuote":"\u201C",
|
---|
1355 | "OpenCurlyQuote":"\u2018",
|
---|
1356 | "operp":"\u29B9",
|
---|
1357 | "oplus":"\u2295",
|
---|
1358 | "Or":"\u2A54",
|
---|
1359 | "or":"\u2228",
|
---|
1360 | "orarr":"\u21BB",
|
---|
1361 | "ord":"\u2A5D",
|
---|
1362 | "order":"\u2134",
|
---|
1363 | "orderof":"\u2134",
|
---|
1364 | "ordf":"\u00AA",
|
---|
1365 | "ordm":"\u00BA",
|
---|
1366 | "origof":"\u22B6",
|
---|
1367 | "oror":"\u2A56",
|
---|
1368 | "orslope":"\u2A57",
|
---|
1369 | "orv":"\u2A5B",
|
---|
1370 | "oS":"\u24C8",
|
---|
1371 | "Oscr":"\uD835\uDCAA",
|
---|
1372 | "oscr":"\u2134",
|
---|
1373 | "Oslash":"\u00D8",
|
---|
1374 | "oslash":"\u00F8",
|
---|
1375 | "osol":"\u2298",
|
---|
1376 | "Otilde":"\u00D5",
|
---|
1377 | "otilde":"\u00F5",
|
---|
1378 | "Otimes":"\u2A37",
|
---|
1379 | "otimes":"\u2297",
|
---|
1380 | "otimesas":"\u2A36",
|
---|
1381 | "Ouml":"\u00D6",
|
---|
1382 | "ouml":"\u00F6",
|
---|
1383 | "ovbar":"\u233D",
|
---|
1384 | "OverBar":"\u203E",
|
---|
1385 | "OverBrace":"\u23DE",
|
---|
1386 | "OverBracket":"\u23B4",
|
---|
1387 | "OverParenthesis":"\u23DC",
|
---|
1388 | "par":"\u2225",
|
---|
1389 | "para":"\u00B6",
|
---|
1390 | "parallel":"\u2225",
|
---|
1391 | "parsim":"\u2AF3",
|
---|
1392 | "parsl":"\u2AFD",
|
---|
1393 | "part":"\u2202",
|
---|
1394 | "PartialD":"\u2202",
|
---|
1395 | "Pcy":"\u041F",
|
---|
1396 | "pcy":"\u043F",
|
---|
1397 | "percnt":"\u0025",
|
---|
1398 | "period":"\u002E",
|
---|
1399 | "permil":"\u2030",
|
---|
1400 | "perp":"\u22A5",
|
---|
1401 | "pertenk":"\u2031",
|
---|
1402 | "Pfr":"\uD835\uDD13",
|
---|
1403 | "pfr":"\uD835\uDD2D",
|
---|
1404 | "Phi":"\u03A6",
|
---|
1405 | "phi":"\u03C6",
|
---|
1406 | "phiv":"\u03D5",
|
---|
1407 | "phmmat":"\u2133",
|
---|
1408 | "phone":"\u260E",
|
---|
1409 | "Pi":"\u03A0",
|
---|
1410 | "pi":"\u03C0",
|
---|
1411 | "pitchfork":"\u22D4",
|
---|
1412 | "piv":"\u03D6",
|
---|
1413 | "planck":"\u210F",
|
---|
1414 | "planckh":"\u210E",
|
---|
1415 | "plankv":"\u210F",
|
---|
1416 | "plus":"\u002B",
|
---|
1417 | "plusacir":"\u2A23",
|
---|
1418 | "plusb":"\u229E",
|
---|
1419 | "pluscir":"\u2A22",
|
---|
1420 | "plusdo":"\u2214",
|
---|
1421 | "plusdu":"\u2A25",
|
---|
1422 | "pluse":"\u2A72",
|
---|
1423 | "PlusMinus":"\u00B1",
|
---|
1424 | "plusmn":"\u00B1",
|
---|
1425 | "plussim":"\u2A26",
|
---|
1426 | "plustwo":"\u2A27",
|
---|
1427 | "pm":"\u00B1",
|
---|
1428 | "Poincareplane":"\u210C",
|
---|
1429 | "pointint":"\u2A15",
|
---|
1430 | "Popf":"\u2119",
|
---|
1431 | "popf":"\uD835\uDD61",
|
---|
1432 | "pound":"\u00A3",
|
---|
1433 | "Pr":"\u2ABB",
|
---|
1434 | "pr":"\u227A",
|
---|
1435 | "prap":"\u2AB7",
|
---|
1436 | "prcue":"\u227C",
|
---|
1437 | "prE":"\u2AB3",
|
---|
1438 | "pre":"\u2AAF",
|
---|
1439 | "prec":"\u227A",
|
---|
1440 | "precapprox":"\u2AB7",
|
---|
1441 | "preccurlyeq":"\u227C",
|
---|
1442 | "Precedes":"\u227A",
|
---|
1443 | "PrecedesEqual":"\u2AAF",
|
---|
1444 | "PrecedesSlantEqual":"\u227C",
|
---|
1445 | "PrecedesTilde":"\u227E",
|
---|
1446 | "preceq":"\u2AAF",
|
---|
1447 | "precnapprox":"\u2AB9",
|
---|
1448 | "precneqq":"\u2AB5",
|
---|
1449 | "precnsim":"\u22E8",
|
---|
1450 | "precsim":"\u227E",
|
---|
1451 | "Prime":"\u2033",
|
---|
1452 | "prime":"\u2032",
|
---|
1453 | "primes":"\u2119",
|
---|
1454 | "prnap":"\u2AB9",
|
---|
1455 | "prnE":"\u2AB5",
|
---|
1456 | "prnsim":"\u22E8",
|
---|
1457 | "prod":"\u220F",
|
---|
1458 | "Product":"\u220F",
|
---|
1459 | "profalar":"\u232E",
|
---|
1460 | "profline":"\u2312",
|
---|
1461 | "profsurf":"\u2313",
|
---|
1462 | "prop":"\u221D",
|
---|
1463 | "Proportion":"\u2237",
|
---|
1464 | "Proportional":"\u221D",
|
---|
1465 | "propto":"\u221D",
|
---|
1466 | "prsim":"\u227E",
|
---|
1467 | "prurel":"\u22B0",
|
---|
1468 | "Pscr":"\uD835\uDCAB",
|
---|
1469 | "pscr":"\uD835\uDCC5",
|
---|
1470 | "Psi":"\u03A8",
|
---|
1471 | "psi":"\u03C8",
|
---|
1472 | "puncsp":"\u2008",
|
---|
1473 | "Qfr":"\uD835\uDD14",
|
---|
1474 | "qfr":"\uD835\uDD2E",
|
---|
1475 | "qint":"\u2A0C",
|
---|
1476 | "Qopf":"\u211A",
|
---|
1477 | "qopf":"\uD835\uDD62",
|
---|
1478 | "qprime":"\u2057",
|
---|
1479 | "Qscr":"\uD835\uDCAC",
|
---|
1480 | "qscr":"\uD835\uDCC6",
|
---|
1481 | "quaternions":"\u210D",
|
---|
1482 | "quatint":"\u2A16",
|
---|
1483 | "quest":"\u003F",
|
---|
1484 | "questeq":"\u225F",
|
---|
1485 | "QUOT":"\u0022",
|
---|
1486 | "quot":"\u0022",
|
---|
1487 | "rAarr":"\u21DB",
|
---|
1488 | "race":"\u223D\u0331",
|
---|
1489 | "Racute":"\u0154",
|
---|
1490 | "racute":"\u0155",
|
---|
1491 | "radic":"\u221A",
|
---|
1492 | "raemptyv":"\u29B3",
|
---|
1493 | "Rang":"\u27EB",
|
---|
1494 | "rang":"\u27E9",
|
---|
1495 | "rangd":"\u2992",
|
---|
1496 | "range":"\u29A5",
|
---|
1497 | "rangle":"\u27E9",
|
---|
1498 | "raquo":"\u00BB",
|
---|
1499 | "Rarr":"\u21A0",
|
---|
1500 | "rArr":"\u21D2",
|
---|
1501 | "rarr":"\u2192",
|
---|
1502 | "rarrap":"\u2975",
|
---|
1503 | "rarrb":"\u21E5",
|
---|
1504 | "rarrbfs":"\u2920",
|
---|
1505 | "rarrc":"\u2933",
|
---|
1506 | "rarrfs":"\u291E",
|
---|
1507 | "rarrhk":"\u21AA",
|
---|
1508 | "rarrlp":"\u21AC",
|
---|
1509 | "rarrpl":"\u2945",
|
---|
1510 | "rarrsim":"\u2974",
|
---|
1511 | "Rarrtl":"\u2916",
|
---|
1512 | "rarrtl":"\u21A3",
|
---|
1513 | "rarrw":"\u219D",
|
---|
1514 | "rAtail":"\u291C",
|
---|
1515 | "ratail":"\u291A",
|
---|
1516 | "ratio":"\u2236",
|
---|
1517 | "rationals":"\u211A",
|
---|
1518 | "RBarr":"\u2910",
|
---|
1519 | "rBarr":"\u290F",
|
---|
1520 | "rbarr":"\u290D",
|
---|
1521 | "rbbrk":"\u2773",
|
---|
1522 | "rbrace":"\u007D",
|
---|
1523 | "rbrack":"\u005D",
|
---|
1524 | "rbrke":"\u298C",
|
---|
1525 | "rbrksld":"\u298E",
|
---|
1526 | "rbrkslu":"\u2990",
|
---|
1527 | "Rcaron":"\u0158",
|
---|
1528 | "rcaron":"\u0159",
|
---|
1529 | "Rcedil":"\u0156",
|
---|
1530 | "rcedil":"\u0157",
|
---|
1531 | "rceil":"\u2309",
|
---|
1532 | "rcub":"\u007D",
|
---|
1533 | "Rcy":"\u0420",
|
---|
1534 | "rcy":"\u0440",
|
---|
1535 | "rdca":"\u2937",
|
---|
1536 | "rdldhar":"\u2969",
|
---|
1537 | "rdquo":"\u201D",
|
---|
1538 | "rdquor":"\u201D",
|
---|
1539 | "rdsh":"\u21B3",
|
---|
1540 | "Re":"\u211C",
|
---|
1541 | "real":"\u211C",
|
---|
1542 | "realine":"\u211B",
|
---|
1543 | "realpart":"\u211C",
|
---|
1544 | "reals":"\u211D",
|
---|
1545 | "rect":"\u25AD",
|
---|
1546 | "REG":"\u00AE",
|
---|
1547 | "reg":"\u00AE",
|
---|
1548 | "ReverseElement":"\u220B",
|
---|
1549 | "ReverseEquilibrium":"\u21CB",
|
---|
1550 | "ReverseUpEquilibrium":"\u296F",
|
---|
1551 | "rfisht":"\u297D",
|
---|
1552 | "rfloor":"\u230B",
|
---|
1553 | "Rfr":"\u211C",
|
---|
1554 | "rfr":"\uD835\uDD2F",
|
---|
1555 | "rHar":"\u2964",
|
---|
1556 | "rhard":"\u21C1",
|
---|
1557 | "rharu":"\u21C0",
|
---|
1558 | "rharul":"\u296C",
|
---|
1559 | "Rho":"\u03A1",
|
---|
1560 | "rho":"\u03C1",
|
---|
1561 | "rhov":"\u03F1",
|
---|
1562 | "RightAngleBracket":"\u27E9",
|
---|
1563 | "RightArrow":"\u2192",
|
---|
1564 | "Rightarrow":"\u21D2",
|
---|
1565 | "rightarrow":"\u2192",
|
---|
1566 | "RightArrowBar":"\u21E5",
|
---|
1567 | "RightArrowLeftArrow":"\u21C4",
|
---|
1568 | "rightarrowtail":"\u21A3",
|
---|
1569 | "RightCeiling":"\u2309",
|
---|
1570 | "RightDoubleBracket":"\u27E7",
|
---|
1571 | "RightDownTeeVector":"\u295D",
|
---|
1572 | "RightDownVector":"\u21C2",
|
---|
1573 | "RightDownVectorBar":"\u2955",
|
---|
1574 | "RightFloor":"\u230B",
|
---|
1575 | "rightharpoondown":"\u21C1",
|
---|
1576 | "rightharpoonup":"\u21C0",
|
---|
1577 | "rightleftarrows":"\u21C4",
|
---|
1578 | "rightleftharpoons":"\u21CC",
|
---|
1579 | "rightrightarrows":"\u21C9",
|
---|
1580 | "rightsquigarrow":"\u219D",
|
---|
1581 | "RightTee":"\u22A2",
|
---|
1582 | "RightTeeArrow":"\u21A6",
|
---|
1583 | "RightTeeVector":"\u295B",
|
---|
1584 | "rightthreetimes":"\u22CC",
|
---|
1585 | "RightTriangle":"\u22B3",
|
---|
1586 | "RightTriangleBar":"\u29D0",
|
---|
1587 | "RightTriangleEqual":"\u22B5",
|
---|
1588 | "RightUpDownVector":"\u294F",
|
---|
1589 | "RightUpTeeVector":"\u295C",
|
---|
1590 | "RightUpVector":"\u21BE",
|
---|
1591 | "RightUpVectorBar":"\u2954",
|
---|
1592 | "RightVector":"\u21C0",
|
---|
1593 | "RightVectorBar":"\u2953",
|
---|
1594 | "ring":"\u02DA",
|
---|
1595 | "risingdotseq":"\u2253",
|
---|
1596 | "rlarr":"\u21C4",
|
---|
1597 | "rlhar":"\u21CC",
|
---|
1598 | "rlm":"\u200F",
|
---|
1599 | "rmoust":"\u23B1",
|
---|
1600 | "rmoustache":"\u23B1",
|
---|
1601 | "rnmid":"\u2AEE",
|
---|
1602 | "roang":"\u27ED",
|
---|
1603 | "roarr":"\u21FE",
|
---|
1604 | "robrk":"\u27E7",
|
---|
1605 | "ropar":"\u2986",
|
---|
1606 | "Ropf":"\u211D",
|
---|
1607 | "ropf":"\uD835\uDD63",
|
---|
1608 | "roplus":"\u2A2E",
|
---|
1609 | "rotimes":"\u2A35",
|
---|
1610 | "RoundImplies":"\u2970",
|
---|
1611 | "rpar":"\u0029",
|
---|
1612 | "rpargt":"\u2994",
|
---|
1613 | "rppolint":"\u2A12",
|
---|
1614 | "rrarr":"\u21C9",
|
---|
1615 | "Rrightarrow":"\u21DB",
|
---|
1616 | "rsaquo":"\u203A",
|
---|
1617 | "Rscr":"\u211B",
|
---|
1618 | "rscr":"\uD835\uDCC7",
|
---|
1619 | "Rsh":"\u21B1",
|
---|
1620 | "rsh":"\u21B1",
|
---|
1621 | "rsqb":"\u005D",
|
---|
1622 | "rsquo":"\u2019",
|
---|
1623 | "rsquor":"\u2019",
|
---|
1624 | "rthree":"\u22CC",
|
---|
1625 | "rtimes":"\u22CA",
|
---|
1626 | "rtri":"\u25B9",
|
---|
1627 | "rtrie":"\u22B5",
|
---|
1628 | "rtrif":"\u25B8",
|
---|
1629 | "rtriltri":"\u29CE",
|
---|
1630 | "RuleDelayed":"\u29F4",
|
---|
1631 | "ruluhar":"\u2968",
|
---|
1632 | "rx":"\u211E",
|
---|
1633 | "Sacute":"\u015A",
|
---|
1634 | "sacute":"\u015B",
|
---|
1635 | "sbquo":"\u201A",
|
---|
1636 | "Sc":"\u2ABC",
|
---|
1637 | "sc":"\u227B",
|
---|
1638 | "scap":"\u2AB8",
|
---|
1639 | "Scaron":"\u0160",
|
---|
1640 | "scaron":"\u0161",
|
---|
1641 | "sccue":"\u227D",
|
---|
1642 | "scE":"\u2AB4",
|
---|
1643 | "sce":"\u2AB0",
|
---|
1644 | "Scedil":"\u015E",
|
---|
1645 | "scedil":"\u015F",
|
---|
1646 | "Scirc":"\u015C",
|
---|
1647 | "scirc":"\u015D",
|
---|
1648 | "scnap":"\u2ABA",
|
---|
1649 | "scnE":"\u2AB6",
|
---|
1650 | "scnsim":"\u22E9",
|
---|
1651 | "scpolint":"\u2A13",
|
---|
1652 | "scsim":"\u227F",
|
---|
1653 | "Scy":"\u0421",
|
---|
1654 | "scy":"\u0441",
|
---|
1655 | "sdot":"\u22C5",
|
---|
1656 | "sdotb":"\u22A1",
|
---|
1657 | "sdote":"\u2A66",
|
---|
1658 | "searhk":"\u2925",
|
---|
1659 | "seArr":"\u21D8",
|
---|
1660 | "searr":"\u2198",
|
---|
1661 | "searrow":"\u2198",
|
---|
1662 | "sect":"\u00A7",
|
---|
1663 | "semi":"\u003B",
|
---|
1664 | "seswar":"\u2929",
|
---|
1665 | "setminus":"\u2216",
|
---|
1666 | "setmn":"\u2216",
|
---|
1667 | "sext":"\u2736",
|
---|
1668 | "Sfr":"\uD835\uDD16",
|
---|
1669 | "sfr":"\uD835\uDD30",
|
---|
1670 | "sfrown":"\u2322",
|
---|
1671 | "sharp":"\u266F",
|
---|
1672 | "SHCHcy":"\u0429",
|
---|
1673 | "shchcy":"\u0449",
|
---|
1674 | "SHcy":"\u0428",
|
---|
1675 | "shcy":"\u0448",
|
---|
1676 | "ShortDownArrow":"\u2193",
|
---|
1677 | "ShortLeftArrow":"\u2190",
|
---|
1678 | "shortmid":"\u2223",
|
---|
1679 | "shortparallel":"\u2225",
|
---|
1680 | "ShortRightArrow":"\u2192",
|
---|
1681 | "ShortUpArrow":"\u2191",
|
---|
1682 | "shy":"\u00AD",
|
---|
1683 | "Sigma":"\u03A3",
|
---|
1684 | "sigma":"\u03C3",
|
---|
1685 | "sigmaf":"\u03C2",
|
---|
1686 | "sigmav":"\u03C2",
|
---|
1687 | "sim":"\u223C",
|
---|
1688 | "simdot":"\u2A6A",
|
---|
1689 | "sime":"\u2243",
|
---|
1690 | "simeq":"\u2243",
|
---|
1691 | "simg":"\u2A9E",
|
---|
1692 | "simgE":"\u2AA0",
|
---|
1693 | "siml":"\u2A9D",
|
---|
1694 | "simlE":"\u2A9F",
|
---|
1695 | "simne":"\u2246",
|
---|
1696 | "simplus":"\u2A24",
|
---|
1697 | "simrarr":"\u2972",
|
---|
1698 | "slarr":"\u2190",
|
---|
1699 | "SmallCircle":"\u2218",
|
---|
1700 | "smallsetminus":"\u2216",
|
---|
1701 | "smashp":"\u2A33",
|
---|
1702 | "smeparsl":"\u29E4",
|
---|
1703 | "smid":"\u2223",
|
---|
1704 | "smile":"\u2323",
|
---|
1705 | "smt":"\u2AAA",
|
---|
1706 | "smte":"\u2AAC",
|
---|
1707 | "smtes":"\u2AAC\uFE00",
|
---|
1708 | "SOFTcy":"\u042C",
|
---|
1709 | "softcy":"\u044C",
|
---|
1710 | "sol":"\u002F",
|
---|
1711 | "solb":"\u29C4",
|
---|
1712 | "solbar":"\u233F",
|
---|
1713 | "Sopf":"\uD835\uDD4A",
|
---|
1714 | "sopf":"\uD835\uDD64",
|
---|
1715 | "spades":"\u2660",
|
---|
1716 | "spadesuit":"\u2660",
|
---|
1717 | "spar":"\u2225",
|
---|
1718 | "sqcap":"\u2293",
|
---|
1719 | "sqcaps":"\u2293\uFE00",
|
---|
1720 | "sqcup":"\u2294",
|
---|
1721 | "sqcups":"\u2294\uFE00",
|
---|
1722 | "Sqrt":"\u221A",
|
---|
1723 | "sqsub":"\u228F",
|
---|
1724 | "sqsube":"\u2291",
|
---|
1725 | "sqsubset":"\u228F",
|
---|
1726 | "sqsubseteq":"\u2291",
|
---|
1727 | "sqsup":"\u2290",
|
---|
1728 | "sqsupe":"\u2292",
|
---|
1729 | "sqsupset":"\u2290",
|
---|
1730 | "sqsupseteq":"\u2292",
|
---|
1731 | "squ":"\u25A1",
|
---|
1732 | "Square":"\u25A1",
|
---|
1733 | "square":"\u25A1",
|
---|
1734 | "SquareIntersection":"\u2293",
|
---|
1735 | "SquareSubset":"\u228F",
|
---|
1736 | "SquareSubsetEqual":"\u2291",
|
---|
1737 | "SquareSuperset":"\u2290",
|
---|
1738 | "SquareSupersetEqual":"\u2292",
|
---|
1739 | "SquareUnion":"\u2294",
|
---|
1740 | "squarf":"\u25AA",
|
---|
1741 | "squf":"\u25AA",
|
---|
1742 | "srarr":"\u2192",
|
---|
1743 | "Sscr":"\uD835\uDCAE",
|
---|
1744 | "sscr":"\uD835\uDCC8",
|
---|
1745 | "ssetmn":"\u2216",
|
---|
1746 | "ssmile":"\u2323",
|
---|
1747 | "sstarf":"\u22C6",
|
---|
1748 | "Star":"\u22C6",
|
---|
1749 | "star":"\u2606",
|
---|
1750 | "starf":"\u2605",
|
---|
1751 | "straightepsilon":"\u03F5",
|
---|
1752 | "straightphi":"\u03D5",
|
---|
1753 | "strns":"\u00AF",
|
---|
1754 | "Sub":"\u22D0",
|
---|
1755 | "sub":"\u2282",
|
---|
1756 | "subdot":"\u2ABD",
|
---|
1757 | "subE":"\u2AC5",
|
---|
1758 | "sube":"\u2286",
|
---|
1759 | "subedot":"\u2AC3",
|
---|
1760 | "submult":"\u2AC1",
|
---|
1761 | "subnE":"\u2ACB",
|
---|
1762 | "subne":"\u228A",
|
---|
1763 | "subplus":"\u2ABF",
|
---|
1764 | "subrarr":"\u2979",
|
---|
1765 | "Subset":"\u22D0",
|
---|
1766 | "subset":"\u2282",
|
---|
1767 | "subseteq":"\u2286",
|
---|
1768 | "subseteqq":"\u2AC5",
|
---|
1769 | "SubsetEqual":"\u2286",
|
---|
1770 | "subsetneq":"\u228A",
|
---|
1771 | "subsetneqq":"\u2ACB",
|
---|
1772 | "subsim":"\u2AC7",
|
---|
1773 | "subsub":"\u2AD5",
|
---|
1774 | "subsup":"\u2AD3",
|
---|
1775 | "succ":"\u227B",
|
---|
1776 | "succapprox":"\u2AB8",
|
---|
1777 | "succcurlyeq":"\u227D",
|
---|
1778 | "Succeeds":"\u227B",
|
---|
1779 | "SucceedsEqual":"\u2AB0",
|
---|
1780 | "SucceedsSlantEqual":"\u227D",
|
---|
1781 | "SucceedsTilde":"\u227F",
|
---|
1782 | "succeq":"\u2AB0",
|
---|
1783 | "succnapprox":"\u2ABA",
|
---|
1784 | "succneqq":"\u2AB6",
|
---|
1785 | "succnsim":"\u22E9",
|
---|
1786 | "succsim":"\u227F",
|
---|
1787 | "SuchThat":"\u220B",
|
---|
1788 | "Sum":"\u2211",
|
---|
1789 | "sum":"\u2211",
|
---|
1790 | "sung":"\u266A",
|
---|
1791 | "Sup":"\u22D1",
|
---|
1792 | "sup":"\u2283",
|
---|
1793 | "sup1":"\u00B9",
|
---|
1794 | "sup2":"\u00B2",
|
---|
1795 | "sup3":"\u00B3",
|
---|
1796 | "supdot":"\u2ABE",
|
---|
1797 | "supdsub":"\u2AD8",
|
---|
1798 | "supE":"\u2AC6",
|
---|
1799 | "supe":"\u2287",
|
---|
1800 | "supedot":"\u2AC4",
|
---|
1801 | "Superset":"\u2283",
|
---|
1802 | "SupersetEqual":"\u2287",
|
---|
1803 | "suphsol":"\u27C9",
|
---|
1804 | "suphsub":"\u2AD7",
|
---|
1805 | "suplarr":"\u297B",
|
---|
1806 | "supmult":"\u2AC2",
|
---|
1807 | "supnE":"\u2ACC",
|
---|
1808 | "supne":"\u228B",
|
---|
1809 | "supplus":"\u2AC0",
|
---|
1810 | "Supset":"\u22D1",
|
---|
1811 | "supset":"\u2283",
|
---|
1812 | "supseteq":"\u2287",
|
---|
1813 | "supseteqq":"\u2AC6",
|
---|
1814 | "supsetneq":"\u228B",
|
---|
1815 | "supsetneqq":"\u2ACC",
|
---|
1816 | "supsim":"\u2AC8",
|
---|
1817 | "supsub":"\u2AD4",
|
---|
1818 | "supsup":"\u2AD6",
|
---|
1819 | "swarhk":"\u2926",
|
---|
1820 | "swArr":"\u21D9",
|
---|
1821 | "swarr":"\u2199",
|
---|
1822 | "swarrow":"\u2199",
|
---|
1823 | "swnwar":"\u292A",
|
---|
1824 | "szlig":"\u00DF",
|
---|
1825 | "Tab":"\u0009",
|
---|
1826 | "target":"\u2316",
|
---|
1827 | "Tau":"\u03A4",
|
---|
1828 | "tau":"\u03C4",
|
---|
1829 | "tbrk":"\u23B4",
|
---|
1830 | "Tcaron":"\u0164",
|
---|
1831 | "tcaron":"\u0165",
|
---|
1832 | "Tcedil":"\u0162",
|
---|
1833 | "tcedil":"\u0163",
|
---|
1834 | "Tcy":"\u0422",
|
---|
1835 | "tcy":"\u0442",
|
---|
1836 | "tdot":"\u20DB",
|
---|
1837 | "telrec":"\u2315",
|
---|
1838 | "Tfr":"\uD835\uDD17",
|
---|
1839 | "tfr":"\uD835\uDD31",
|
---|
1840 | "there4":"\u2234",
|
---|
1841 | "Therefore":"\u2234",
|
---|
1842 | "therefore":"\u2234",
|
---|
1843 | "Theta":"\u0398",
|
---|
1844 | "theta":"\u03B8",
|
---|
1845 | "thetasym":"\u03D1",
|
---|
1846 | "thetav":"\u03D1",
|
---|
1847 | "thickapprox":"\u2248",
|
---|
1848 | "thicksim":"\u223C",
|
---|
1849 | "ThickSpace":"\u205F\u200A",
|
---|
1850 | "thinsp":"\u2009",
|
---|
1851 | "ThinSpace":"\u2009",
|
---|
1852 | "thkap":"\u2248",
|
---|
1853 | "thksim":"\u223C",
|
---|
1854 | "THORN":"\u00DE",
|
---|
1855 | "thorn":"\u00FE",
|
---|
1856 | "Tilde":"\u223C",
|
---|
1857 | "tilde":"\u02DC",
|
---|
1858 | "TildeEqual":"\u2243",
|
---|
1859 | "TildeFullEqual":"\u2245",
|
---|
1860 | "TildeTilde":"\u2248",
|
---|
1861 | "times":"\u00D7",
|
---|
1862 | "timesb":"\u22A0",
|
---|
1863 | "timesbar":"\u2A31",
|
---|
1864 | "timesd":"\u2A30",
|
---|
1865 | "tint":"\u222D",
|
---|
1866 | "toea":"\u2928",
|
---|
1867 | "top":"\u22A4",
|
---|
1868 | "topbot":"\u2336",
|
---|
1869 | "topcir":"\u2AF1",
|
---|
1870 | "Topf":"\uD835\uDD4B",
|
---|
1871 | "topf":"\uD835\uDD65",
|
---|
1872 | "topfork":"\u2ADA",
|
---|
1873 | "tosa":"\u2929",
|
---|
1874 | "tprime":"\u2034",
|
---|
1875 | "TRADE":"\u2122",
|
---|
1876 | "trade":"\u2122",
|
---|
1877 | "triangle":"\u25B5",
|
---|
1878 | "triangledown":"\u25BF",
|
---|
1879 | "triangleleft":"\u25C3",
|
---|
1880 | "trianglelefteq":"\u22B4",
|
---|
1881 | "triangleq":"\u225C",
|
---|
1882 | "triangleright":"\u25B9",
|
---|
1883 | "trianglerighteq":"\u22B5",
|
---|
1884 | "tridot":"\u25EC",
|
---|
1885 | "trie":"\u225C",
|
---|
1886 | "triminus":"\u2A3A",
|
---|
1887 | "TripleDot":"\u20DB",
|
---|
1888 | "triplus":"\u2A39",
|
---|
1889 | "trisb":"\u29CD",
|
---|
1890 | "tritime":"\u2A3B",
|
---|
1891 | "trpezium":"\u23E2",
|
---|
1892 | "Tscr":"\uD835\uDCAF",
|
---|
1893 | "tscr":"\uD835\uDCC9",
|
---|
1894 | "TScy":"\u0426",
|
---|
1895 | "tscy":"\u0446",
|
---|
1896 | "TSHcy":"\u040B",
|
---|
1897 | "tshcy":"\u045B",
|
---|
1898 | "Tstrok":"\u0166",
|
---|
1899 | "tstrok":"\u0167",
|
---|
1900 | "twixt":"\u226C",
|
---|
1901 | "twoheadleftarrow":"\u219E",
|
---|
1902 | "twoheadrightarrow":"\u21A0",
|
---|
1903 | "Uacute":"\u00DA",
|
---|
1904 | "uacute":"\u00FA",
|
---|
1905 | "Uarr":"\u219F",
|
---|
1906 | "uArr":"\u21D1",
|
---|
1907 | "uarr":"\u2191",
|
---|
1908 | "Uarrocir":"\u2949",
|
---|
1909 | "Ubrcy":"\u040E",
|
---|
1910 | "ubrcy":"\u045E",
|
---|
1911 | "Ubreve":"\u016C",
|
---|
1912 | "ubreve":"\u016D",
|
---|
1913 | "Ucirc":"\u00DB",
|
---|
1914 | "ucirc":"\u00FB",
|
---|
1915 | "Ucy":"\u0423",
|
---|
1916 | "ucy":"\u0443",
|
---|
1917 | "udarr":"\u21C5",
|
---|
1918 | "Udblac":"\u0170",
|
---|
1919 | "udblac":"\u0171",
|
---|
1920 | "udhar":"\u296E",
|
---|
1921 | "ufisht":"\u297E",
|
---|
1922 | "Ufr":"\uD835\uDD18",
|
---|
1923 | "ufr":"\uD835\uDD32",
|
---|
1924 | "Ugrave":"\u00D9",
|
---|
1925 | "ugrave":"\u00F9",
|
---|
1926 | "uHar":"\u2963",
|
---|
1927 | "uharl":"\u21BF",
|
---|
1928 | "uharr":"\u21BE",
|
---|
1929 | "uhblk":"\u2580",
|
---|
1930 | "ulcorn":"\u231C",
|
---|
1931 | "ulcorner":"\u231C",
|
---|
1932 | "ulcrop":"\u230F",
|
---|
1933 | "ultri":"\u25F8",
|
---|
1934 | "Umacr":"\u016A",
|
---|
1935 | "umacr":"\u016B",
|
---|
1936 | "uml":"\u00A8",
|
---|
1937 | "UnderBar":"\u005F",
|
---|
1938 | "UnderBrace":"\u23DF",
|
---|
1939 | "UnderBracket":"\u23B5",
|
---|
1940 | "UnderParenthesis":"\u23DD",
|
---|
1941 | "Union":"\u22C3",
|
---|
1942 | "UnionPlus":"\u228E",
|
---|
1943 | "Uogon":"\u0172",
|
---|
1944 | "uogon":"\u0173",
|
---|
1945 | "Uopf":"\uD835\uDD4C",
|
---|
1946 | "uopf":"\uD835\uDD66",
|
---|
1947 | "UpArrow":"\u2191",
|
---|
1948 | "Uparrow":"\u21D1",
|
---|
1949 | "uparrow":"\u2191",
|
---|
1950 | "UpArrowBar":"\u2912",
|
---|
1951 | "UpArrowDownArrow":"\u21C5",
|
---|
1952 | "UpDownArrow":"\u2195",
|
---|
1953 | "Updownarrow":"\u21D5",
|
---|
1954 | "updownarrow":"\u2195",
|
---|
1955 | "UpEquilibrium":"\u296E",
|
---|
1956 | "upharpoonleft":"\u21BF",
|
---|
1957 | "upharpoonright":"\u21BE",
|
---|
1958 | "uplus":"\u228E",
|
---|
1959 | "UpperLeftArrow":"\u2196",
|
---|
1960 | "UpperRightArrow":"\u2197",
|
---|
1961 | "Upsi":"\u03D2",
|
---|
1962 | "upsi":"\u03C5",
|
---|
1963 | "upsih":"\u03D2",
|
---|
1964 | "Upsilon":"\u03A5",
|
---|
1965 | "upsilon":"\u03C5",
|
---|
1966 | "UpTee":"\u22A5",
|
---|
1967 | "UpTeeArrow":"\u21A5",
|
---|
1968 | "upuparrows":"\u21C8",
|
---|
1969 | "urcorn":"\u231D",
|
---|
1970 | "urcorner":"\u231D",
|
---|
1971 | "urcrop":"\u230E",
|
---|
1972 | "Uring":"\u016E",
|
---|
1973 | "uring":"\u016F",
|
---|
1974 | "urtri":"\u25F9",
|
---|
1975 | "Uscr":"\uD835\uDCB0",
|
---|
1976 | "uscr":"\uD835\uDCCA",
|
---|
1977 | "utdot":"\u22F0",
|
---|
1978 | "Utilde":"\u0168",
|
---|
1979 | "utilde":"\u0169",
|
---|
1980 | "utri":"\u25B5",
|
---|
1981 | "utrif":"\u25B4",
|
---|
1982 | "uuarr":"\u21C8",
|
---|
1983 | "Uuml":"\u00DC",
|
---|
1984 | "uuml":"\u00FC",
|
---|
1985 | "uwangle":"\u29A7",
|
---|
1986 | "vangrt":"\u299C",
|
---|
1987 | "varepsilon":"\u03F5",
|
---|
1988 | "varkappa":"\u03F0",
|
---|
1989 | "varnothing":"\u2205",
|
---|
1990 | "varphi":"\u03D5",
|
---|
1991 | "varpi":"\u03D6",
|
---|
1992 | "varpropto":"\u221D",
|
---|
1993 | "vArr":"\u21D5",
|
---|
1994 | "varr":"\u2195",
|
---|
1995 | "varrho":"\u03F1",
|
---|
1996 | "varsigma":"\u03C2",
|
---|
1997 | "varsubsetneq":"\u228A\uFE00",
|
---|
1998 | "varsubsetneqq":"\u2ACB\uFE00",
|
---|
1999 | "varsupsetneq":"\u228B\uFE00",
|
---|
2000 | "varsupsetneqq":"\u2ACC\uFE00",
|
---|
2001 | "vartheta":"\u03D1",
|
---|
2002 | "vartriangleleft":"\u22B2",
|
---|
2003 | "vartriangleright":"\u22B3",
|
---|
2004 | "Vbar":"\u2AEB",
|
---|
2005 | "vBar":"\u2AE8",
|
---|
2006 | "vBarv":"\u2AE9",
|
---|
2007 | "Vcy":"\u0412",
|
---|
2008 | "vcy":"\u0432",
|
---|
2009 | "VDash":"\u22AB",
|
---|
2010 | "Vdash":"\u22A9",
|
---|
2011 | "vDash":"\u22A8",
|
---|
2012 | "vdash":"\u22A2",
|
---|
2013 | "Vdashl":"\u2AE6",
|
---|
2014 | "Vee":"\u22C1",
|
---|
2015 | "vee":"\u2228",
|
---|
2016 | "veebar":"\u22BB",
|
---|
2017 | "veeeq":"\u225A",
|
---|
2018 | "vellip":"\u22EE",
|
---|
2019 | "Verbar":"\u2016",
|
---|
2020 | "verbar":"\u007C",
|
---|
2021 | "Vert":"\u2016",
|
---|
2022 | "vert":"\u007C",
|
---|
2023 | "VerticalBar":"\u2223",
|
---|
2024 | "VerticalLine":"\u007C",
|
---|
2025 | "VerticalSeparator":"\u2758",
|
---|
2026 | "VerticalTilde":"\u2240",
|
---|
2027 | "VeryThinSpace":"\u200A",
|
---|
2028 | "Vfr":"\uD835\uDD19",
|
---|
2029 | "vfr":"\uD835\uDD33",
|
---|
2030 | "vltri":"\u22B2",
|
---|
2031 | "vnsub":"\u2282\u20D2",
|
---|
2032 | "vnsup":"\u2283\u20D2",
|
---|
2033 | "Vopf":"\uD835\uDD4D",
|
---|
2034 | "vopf":"\uD835\uDD67",
|
---|
2035 | "vprop":"\u221D",
|
---|
2036 | "vrtri":"\u22B3",
|
---|
2037 | "Vscr":"\uD835\uDCB1",
|
---|
2038 | "vscr":"\uD835\uDCCB",
|
---|
2039 | "vsubnE":"\u2ACB\uFE00",
|
---|
2040 | "vsubne":"\u228A\uFE00",
|
---|
2041 | "vsupnE":"\u2ACC\uFE00",
|
---|
2042 | "vsupne":"\u228B\uFE00",
|
---|
2043 | "Vvdash":"\u22AA",
|
---|
2044 | "vzigzag":"\u299A",
|
---|
2045 | "Wcirc":"\u0174",
|
---|
2046 | "wcirc":"\u0175",
|
---|
2047 | "wedbar":"\u2A5F",
|
---|
2048 | "Wedge":"\u22C0",
|
---|
2049 | "wedge":"\u2227",
|
---|
2050 | "wedgeq":"\u2259",
|
---|
2051 | "weierp":"\u2118",
|
---|
2052 | "Wfr":"\uD835\uDD1A",
|
---|
2053 | "wfr":"\uD835\uDD34",
|
---|
2054 | "Wopf":"\uD835\uDD4E",
|
---|
2055 | "wopf":"\uD835\uDD68",
|
---|
2056 | "wp":"\u2118",
|
---|
2057 | "wr":"\u2240",
|
---|
2058 | "wreath":"\u2240",
|
---|
2059 | "Wscr":"\uD835\uDCB2",
|
---|
2060 | "wscr":"\uD835\uDCCC",
|
---|
2061 | "xcap":"\u22C2",
|
---|
2062 | "xcirc":"\u25EF",
|
---|
2063 | "xcup":"\u22C3",
|
---|
2064 | "xdtri":"\u25BD",
|
---|
2065 | "Xfr":"\uD835\uDD1B",
|
---|
2066 | "xfr":"\uD835\uDD35",
|
---|
2067 | "xhArr":"\u27FA",
|
---|
2068 | "xharr":"\u27F7",
|
---|
2069 | "Xi":"\u039E",
|
---|
2070 | "xi":"\u03BE",
|
---|
2071 | "xlArr":"\u27F8",
|
---|
2072 | "xlarr":"\u27F5",
|
---|
2073 | "xmap":"\u27FC",
|
---|
2074 | "xnis":"\u22FB",
|
---|
2075 | "xodot":"\u2A00",
|
---|
2076 | "Xopf":"\uD835\uDD4F",
|
---|
2077 | "xopf":"\uD835\uDD69",
|
---|
2078 | "xoplus":"\u2A01",
|
---|
2079 | "xotime":"\u2A02",
|
---|
2080 | "xrArr":"\u27F9",
|
---|
2081 | "xrarr":"\u27F6",
|
---|
2082 | "Xscr":"\uD835\uDCB3",
|
---|
2083 | "xscr":"\uD835\uDCCD",
|
---|
2084 | "xsqcup":"\u2A06",
|
---|
2085 | "xuplus":"\u2A04",
|
---|
2086 | "xutri":"\u25B3",
|
---|
2087 | "xvee":"\u22C1",
|
---|
2088 | "xwedge":"\u22C0",
|
---|
2089 | "Yacute":"\u00DD",
|
---|
2090 | "yacute":"\u00FD",
|
---|
2091 | "YAcy":"\u042F",
|
---|
2092 | "yacy":"\u044F",
|
---|
2093 | "Ycirc":"\u0176",
|
---|
2094 | "ycirc":"\u0177",
|
---|
2095 | "Ycy":"\u042B",
|
---|
2096 | "ycy":"\u044B",
|
---|
2097 | "yen":"\u00A5",
|
---|
2098 | "Yfr":"\uD835\uDD1C",
|
---|
2099 | "yfr":"\uD835\uDD36",
|
---|
2100 | "YIcy":"\u0407",
|
---|
2101 | "yicy":"\u0457",
|
---|
2102 | "Yopf":"\uD835\uDD50",
|
---|
2103 | "yopf":"\uD835\uDD6A",
|
---|
2104 | "Yscr":"\uD835\uDCB4",
|
---|
2105 | "yscr":"\uD835\uDCCE",
|
---|
2106 | "YUcy":"\u042E",
|
---|
2107 | "yucy":"\u044E",
|
---|
2108 | "Yuml":"\u0178",
|
---|
2109 | "yuml":"\u00FF",
|
---|
2110 | "Zacute":"\u0179",
|
---|
2111 | "zacute":"\u017A",
|
---|
2112 | "Zcaron":"\u017D",
|
---|
2113 | "zcaron":"\u017E",
|
---|
2114 | "Zcy":"\u0417",
|
---|
2115 | "zcy":"\u0437",
|
---|
2116 | "Zdot":"\u017B",
|
---|
2117 | "zdot":"\u017C",
|
---|
2118 | "zeetrf":"\u2128",
|
---|
2119 | "ZeroWidthSpace":"\u200B",
|
---|
2120 | "Zeta":"\u0396",
|
---|
2121 | "zeta":"\u03B6",
|
---|
2122 | "Zfr":"\u2128",
|
---|
2123 | "zfr":"\uD835\uDD37",
|
---|
2124 | "ZHcy":"\u0416",
|
---|
2125 | "zhcy":"\u0436",
|
---|
2126 | "zigrarr":"\u21DD",
|
---|
2127 | "Zopf":"\u2124",
|
---|
2128 | "zopf":"\uD835\uDD6B",
|
---|
2129 | "Zscr":"\uD835\uDCB5",
|
---|
2130 | "zscr":"\uD835\uDCCF",
|
---|
2131 | "zwj":"\u200D",
|
---|
2132 | "zwnj":"\u200C"
|
---|
2133 | };
|
---|
2134 |
|
---|
2135 | var hasOwn = Object.prototype.hasOwnProperty;
|
---|
2136 |
|
---|
2137 | function has(object, key) {
|
---|
2138 | return object
|
---|
2139 | ? hasOwn.call(object, key)
|
---|
2140 | : false;
|
---|
2141 | }
|
---|
2142 |
|
---|
2143 | function decodeEntity(name) {
|
---|
2144 | if (has(entities, name)) {
|
---|
2145 | return entities[name]
|
---|
2146 | } else {
|
---|
2147 | return name;
|
---|
2148 | }
|
---|
2149 | }
|
---|
2150 |
|
---|
2151 | /**
|
---|
2152 | * Utility functions
|
---|
2153 | */
|
---|
2154 |
|
---|
2155 | function typeOf(obj) {
|
---|
2156 | return Object.prototype.toString.call(obj);
|
---|
2157 | }
|
---|
2158 |
|
---|
2159 | function isString(obj) {
|
---|
2160 | return typeOf(obj) === '[object String]';
|
---|
2161 | }
|
---|
2162 |
|
---|
2163 | var hasOwn$1 = Object.prototype.hasOwnProperty;
|
---|
2164 |
|
---|
2165 | function has$1(object, key) {
|
---|
2166 | return object
|
---|
2167 | ? hasOwn$1.call(object, key)
|
---|
2168 | : false;
|
---|
2169 | }
|
---|
2170 |
|
---|
2171 | // Extend objects
|
---|
2172 | //
|
---|
2173 | function assign(obj /*from1, from2, from3, ...*/) {
|
---|
2174 | var sources = [].slice.call(arguments, 1);
|
---|
2175 |
|
---|
2176 | sources.forEach(function (source) {
|
---|
2177 | if (!source) { return; }
|
---|
2178 |
|
---|
2179 | if (typeof source !== 'object') {
|
---|
2180 | throw new TypeError(source + 'must be object');
|
---|
2181 | }
|
---|
2182 |
|
---|
2183 | Object.keys(source).forEach(function (key) {
|
---|
2184 | obj[key] = source[key];
|
---|
2185 | });
|
---|
2186 | });
|
---|
2187 |
|
---|
2188 | return obj;
|
---|
2189 | }
|
---|
2190 |
|
---|
2191 | ////////////////////////////////////////////////////////////////////////////////
|
---|
2192 |
|
---|
2193 | var UNESCAPE_MD_RE = /\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
|
---|
2194 |
|
---|
2195 | function unescapeMd(str) {
|
---|
2196 | if (str.indexOf('\\') < 0) { return str; }
|
---|
2197 | return str.replace(UNESCAPE_MD_RE, '$1');
|
---|
2198 | }
|
---|
2199 |
|
---|
2200 | ////////////////////////////////////////////////////////////////////////////////
|
---|
2201 |
|
---|
2202 | function isValidEntityCode(c) {
|
---|
2203 | /*eslint no-bitwise:0*/
|
---|
2204 | // broken sequence
|
---|
2205 | if (c >= 0xD800 && c <= 0xDFFF) { return false; }
|
---|
2206 | // never used
|
---|
2207 | if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }
|
---|
2208 | if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }
|
---|
2209 | // control codes
|
---|
2210 | if (c >= 0x00 && c <= 0x08) { return false; }
|
---|
2211 | if (c === 0x0B) { return false; }
|
---|
2212 | if (c >= 0x0E && c <= 0x1F) { return false; }
|
---|
2213 | if (c >= 0x7F && c <= 0x9F) { return false; }
|
---|
2214 | // out of range
|
---|
2215 | if (c > 0x10FFFF) { return false; }
|
---|
2216 | return true;
|
---|
2217 | }
|
---|
2218 |
|
---|
2219 | function fromCodePoint(c) {
|
---|
2220 | /*eslint no-bitwise:0*/
|
---|
2221 | if (c > 0xffff) {
|
---|
2222 | c -= 0x10000;
|
---|
2223 | var surrogate1 = 0xd800 + (c >> 10),
|
---|
2224 | surrogate2 = 0xdc00 + (c & 0x3ff);
|
---|
2225 |
|
---|
2226 | return String.fromCharCode(surrogate1, surrogate2);
|
---|
2227 | }
|
---|
2228 | return String.fromCharCode(c);
|
---|
2229 | }
|
---|
2230 |
|
---|
2231 | var NAMED_ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
|
---|
2232 | var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
|
---|
2233 |
|
---|
2234 | function replaceEntityPattern(match, name) {
|
---|
2235 | var code = 0;
|
---|
2236 | var decoded = decodeEntity(name);
|
---|
2237 |
|
---|
2238 | if (name !== decoded) {
|
---|
2239 | return decoded;
|
---|
2240 | } else if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
|
---|
2241 | code = name[1].toLowerCase() === 'x' ?
|
---|
2242 | parseInt(name.slice(2), 16)
|
---|
2243 | :
|
---|
2244 | parseInt(name.slice(1), 10);
|
---|
2245 | if (isValidEntityCode(code)) {
|
---|
2246 | return fromCodePoint(code);
|
---|
2247 | }
|
---|
2248 | }
|
---|
2249 | return match;
|
---|
2250 | }
|
---|
2251 |
|
---|
2252 | function replaceEntities(str) {
|
---|
2253 | if (str.indexOf('&') < 0) { return str; }
|
---|
2254 |
|
---|
2255 | return str.replace(NAMED_ENTITY_RE, replaceEntityPattern);
|
---|
2256 | }
|
---|
2257 |
|
---|
2258 | ////////////////////////////////////////////////////////////////////////////////
|
---|
2259 |
|
---|
2260 | var HTML_ESCAPE_TEST_RE = /[&<>"]/;
|
---|
2261 | var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
|
---|
2262 | var HTML_REPLACEMENTS = {
|
---|
2263 | '&': '&',
|
---|
2264 | '<': '<',
|
---|
2265 | '>': '>',
|
---|
2266 | '"': '"'
|
---|
2267 | };
|
---|
2268 |
|
---|
2269 | function replaceUnsafeChar(ch) {
|
---|
2270 | return HTML_REPLACEMENTS[ch];
|
---|
2271 | }
|
---|
2272 |
|
---|
2273 | function escapeHtml(str) {
|
---|
2274 | if (HTML_ESCAPE_TEST_RE.test(str)) {
|
---|
2275 | return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
|
---|
2276 | }
|
---|
2277 | return str;
|
---|
2278 | }
|
---|
2279 |
|
---|
2280 | var utils = /*#__PURE__*/Object.freeze({
|
---|
2281 | isString: isString,
|
---|
2282 | has: has$1,
|
---|
2283 | assign: assign,
|
---|
2284 | unescapeMd: unescapeMd,
|
---|
2285 | isValidEntityCode: isValidEntityCode,
|
---|
2286 | fromCodePoint: fromCodePoint,
|
---|
2287 | replaceEntities: replaceEntities,
|
---|
2288 | escapeHtml: escapeHtml
|
---|
2289 | });
|
---|
2290 |
|
---|
2291 | /**
|
---|
2292 | * Renderer rules cache
|
---|
2293 | */
|
---|
2294 |
|
---|
2295 | var rules = {};
|
---|
2296 |
|
---|
2297 | /**
|
---|
2298 | * Blockquotes
|
---|
2299 | */
|
---|
2300 |
|
---|
2301 | rules.blockquote_open = function(/* tokens, idx, options, env */) {
|
---|
2302 | return '<blockquote>\n';
|
---|
2303 | };
|
---|
2304 |
|
---|
2305 | rules.blockquote_close = function(tokens, idx /*, options, env */) {
|
---|
2306 | return '</blockquote>' + getBreak(tokens, idx);
|
---|
2307 | };
|
---|
2308 |
|
---|
2309 | /**
|
---|
2310 | * Code
|
---|
2311 | */
|
---|
2312 |
|
---|
2313 | rules.code = function(tokens, idx /*, options, env */) {
|
---|
2314 | if (tokens[idx].block) {
|
---|
2315 | return '<pre><code>' + escapeHtml(tokens[idx].content) + '</code></pre>' + getBreak(tokens, idx);
|
---|
2316 | }
|
---|
2317 | return '<code>' + escapeHtml(tokens[idx].content) + '</code>';
|
---|
2318 | };
|
---|
2319 |
|
---|
2320 | /**
|
---|
2321 | * Fenced code blocks
|
---|
2322 | */
|
---|
2323 |
|
---|
2324 | rules.fence = function(tokens, idx, options, env, instance) {
|
---|
2325 | var token = tokens[idx];
|
---|
2326 | var langClass = '';
|
---|
2327 | var langPrefix = options.langPrefix;
|
---|
2328 | var langName = '', fences, fenceName;
|
---|
2329 | var highlighted;
|
---|
2330 |
|
---|
2331 | if (token.params) {
|
---|
2332 |
|
---|
2333 | //
|
---|
2334 | // ```foo bar
|
---|
2335 | //
|
---|
2336 | // Try custom renderer "foo" first. That will simplify overwrite
|
---|
2337 | // for diagrams, latex, and any other fenced block with custom look
|
---|
2338 | //
|
---|
2339 |
|
---|
2340 | fences = token.params.split(/\s+/g);
|
---|
2341 | fenceName = fences.join(' ');
|
---|
2342 |
|
---|
2343 | if (has$1(instance.rules.fence_custom, fences[0])) {
|
---|
2344 | return instance.rules.fence_custom[fences[0]](tokens, idx, options, env, instance);
|
---|
2345 | }
|
---|
2346 |
|
---|
2347 | langName = escapeHtml(replaceEntities(unescapeMd(fenceName)));
|
---|
2348 | langClass = ' class="' + langPrefix + langName + '"';
|
---|
2349 | }
|
---|
2350 |
|
---|
2351 | if (options.highlight) {
|
---|
2352 | highlighted = options.highlight.apply(options.highlight, [ token.content ].concat(fences))
|
---|
2353 | || escapeHtml(token.content);
|
---|
2354 | } else {
|
---|
2355 | highlighted = escapeHtml(token.content);
|
---|
2356 | }
|
---|
2357 |
|
---|
2358 | return '<pre><code' + langClass + '>'
|
---|
2359 | + highlighted
|
---|
2360 | + '</code></pre>'
|
---|
2361 | + getBreak(tokens, idx);
|
---|
2362 | };
|
---|
2363 |
|
---|
2364 | rules.fence_custom = {};
|
---|
2365 |
|
---|
2366 | /**
|
---|
2367 | * Headings
|
---|
2368 | */
|
---|
2369 |
|
---|
2370 | rules.heading_open = function(tokens, idx /*, options, env */) {
|
---|
2371 | return '<h' + tokens[idx].hLevel + '>';
|
---|
2372 | };
|
---|
2373 | rules.heading_close = function(tokens, idx /*, options, env */) {
|
---|
2374 | return '</h' + tokens[idx].hLevel + '>\n';
|
---|
2375 | };
|
---|
2376 |
|
---|
2377 | /**
|
---|
2378 | * Horizontal rules
|
---|
2379 | */
|
---|
2380 |
|
---|
2381 | rules.hr = function(tokens, idx, options /*, env */) {
|
---|
2382 | return (options.xhtmlOut ? '<hr />' : '<hr>') + getBreak(tokens, idx);
|
---|
2383 | };
|
---|
2384 |
|
---|
2385 | /**
|
---|
2386 | * Bullets
|
---|
2387 | */
|
---|
2388 |
|
---|
2389 | rules.bullet_list_open = function(/* tokens, idx, options, env */) {
|
---|
2390 | return '<ul>\n';
|
---|
2391 | };
|
---|
2392 | rules.bullet_list_close = function(tokens, idx /*, options, env */) {
|
---|
2393 | return '</ul>' + getBreak(tokens, idx);
|
---|
2394 | };
|
---|
2395 |
|
---|
2396 | /**
|
---|
2397 | * List items
|
---|
2398 | */
|
---|
2399 |
|
---|
2400 | rules.list_item_open = function(/* tokens, idx, options, env */) {
|
---|
2401 | return '<li>';
|
---|
2402 | };
|
---|
2403 | rules.list_item_close = function(/* tokens, idx, options, env */) {
|
---|
2404 | return '</li>\n';
|
---|
2405 | };
|
---|
2406 |
|
---|
2407 | /**
|
---|
2408 | * Ordered list items
|
---|
2409 | */
|
---|
2410 |
|
---|
2411 | rules.ordered_list_open = function(tokens, idx /*, options, env */) {
|
---|
2412 | var token = tokens[idx];
|
---|
2413 | var order = token.order > 1 ? ' start="' + token.order + '"' : '';
|
---|
2414 | return '<ol' + order + '>\n';
|
---|
2415 | };
|
---|
2416 | rules.ordered_list_close = function(tokens, idx /*, options, env */) {
|
---|
2417 | return '</ol>' + getBreak(tokens, idx);
|
---|
2418 | };
|
---|
2419 |
|
---|
2420 | /**
|
---|
2421 | * Paragraphs
|
---|
2422 | */
|
---|
2423 |
|
---|
2424 | rules.paragraph_open = function(tokens, idx /*, options, env */) {
|
---|
2425 | return tokens[idx].tight ? '' : '<p>';
|
---|
2426 | };
|
---|
2427 | rules.paragraph_close = function(tokens, idx /*, options, env */) {
|
---|
2428 | var addBreak = !(tokens[idx].tight && idx && tokens[idx - 1].type === 'inline' && !tokens[idx - 1].content);
|
---|
2429 | return (tokens[idx].tight ? '' : '</p>') + (addBreak ? getBreak(tokens, idx) : '');
|
---|
2430 | };
|
---|
2431 |
|
---|
2432 | /**
|
---|
2433 | * Links
|
---|
2434 | */
|
---|
2435 |
|
---|
2436 | rules.link_open = function(tokens, idx, options /* env */) {
|
---|
2437 | var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
|
---|
2438 | var target = options.linkTarget ? (' target="' + options.linkTarget + '"') : '';
|
---|
2439 | return '<a href="' + escapeHtml(tokens[idx].href) + '"' + title + target + '>';
|
---|
2440 | };
|
---|
2441 | rules.link_close = function(/* tokens, idx, options, env */) {
|
---|
2442 | return '</a>';
|
---|
2443 | };
|
---|
2444 |
|
---|
2445 | /**
|
---|
2446 | * Images
|
---|
2447 | */
|
---|
2448 |
|
---|
2449 | rules.image = function(tokens, idx, options /*, env */) {
|
---|
2450 | var src = ' src="' + escapeHtml(tokens[idx].src) + '"';
|
---|
2451 | var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
|
---|
2452 | var alt = ' alt="' + (tokens[idx].alt ? escapeHtml(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
|
---|
2453 | var suffix = options.xhtmlOut ? ' /' : '';
|
---|
2454 | return '<img' + src + alt + title + suffix + '>';
|
---|
2455 | };
|
---|
2456 |
|
---|
2457 | /**
|
---|
2458 | * Tables
|
---|
2459 | */
|
---|
2460 |
|
---|
2461 | rules.table_open = function(/* tokens, idx, options, env */) {
|
---|
2462 | return '<table>\n';
|
---|
2463 | };
|
---|
2464 | rules.table_close = function(/* tokens, idx, options, env */) {
|
---|
2465 | return '</table>\n';
|
---|
2466 | };
|
---|
2467 | rules.thead_open = function(/* tokens, idx, options, env */) {
|
---|
2468 | return '<thead>\n';
|
---|
2469 | };
|
---|
2470 | rules.thead_close = function(/* tokens, idx, options, env */) {
|
---|
2471 | return '</thead>\n';
|
---|
2472 | };
|
---|
2473 | rules.tbody_open = function(/* tokens, idx, options, env */) {
|
---|
2474 | return '<tbody>\n';
|
---|
2475 | };
|
---|
2476 | rules.tbody_close = function(/* tokens, idx, options, env */) {
|
---|
2477 | return '</tbody>\n';
|
---|
2478 | };
|
---|
2479 | rules.tr_open = function(/* tokens, idx, options, env */) {
|
---|
2480 | return '<tr>';
|
---|
2481 | };
|
---|
2482 | rules.tr_close = function(/* tokens, idx, options, env */) {
|
---|
2483 | return '</tr>\n';
|
---|
2484 | };
|
---|
2485 | rules.th_open = function(tokens, idx /*, options, env */) {
|
---|
2486 | var token = tokens[idx];
|
---|
2487 | return '<th'
|
---|
2488 | + (token.align ? ' style="text-align:' + token.align + '"' : '')
|
---|
2489 | + '>';
|
---|
2490 | };
|
---|
2491 | rules.th_close = function(/* tokens, idx, options, env */) {
|
---|
2492 | return '</th>';
|
---|
2493 | };
|
---|
2494 | rules.td_open = function(tokens, idx /*, options, env */) {
|
---|
2495 | var token = tokens[idx];
|
---|
2496 | return '<td'
|
---|
2497 | + (token.align ? ' style="text-align:' + token.align + '"' : '')
|
---|
2498 | + '>';
|
---|
2499 | };
|
---|
2500 | rules.td_close = function(/* tokens, idx, options, env */) {
|
---|
2501 | return '</td>';
|
---|
2502 | };
|
---|
2503 |
|
---|
2504 | /**
|
---|
2505 | * Bold
|
---|
2506 | */
|
---|
2507 |
|
---|
2508 | rules.strong_open = function(/* tokens, idx, options, env */) {
|
---|
2509 | return '<strong>';
|
---|
2510 | };
|
---|
2511 | rules.strong_close = function(/* tokens, idx, options, env */) {
|
---|
2512 | return '</strong>';
|
---|
2513 | };
|
---|
2514 |
|
---|
2515 | /**
|
---|
2516 | * Italicize
|
---|
2517 | */
|
---|
2518 |
|
---|
2519 | rules.em_open = function(/* tokens, idx, options, env */) {
|
---|
2520 | return '<em>';
|
---|
2521 | };
|
---|
2522 | rules.em_close = function(/* tokens, idx, options, env */) {
|
---|
2523 | return '</em>';
|
---|
2524 | };
|
---|
2525 |
|
---|
2526 | /**
|
---|
2527 | * Strikethrough
|
---|
2528 | */
|
---|
2529 |
|
---|
2530 | rules.del_open = function(/* tokens, idx, options, env */) {
|
---|
2531 | return '<del>';
|
---|
2532 | };
|
---|
2533 | rules.del_close = function(/* tokens, idx, options, env */) {
|
---|
2534 | return '</del>';
|
---|
2535 | };
|
---|
2536 |
|
---|
2537 | /**
|
---|
2538 | * Insert
|
---|
2539 | */
|
---|
2540 |
|
---|
2541 | rules.ins_open = function(/* tokens, idx, options, env */) {
|
---|
2542 | return '<ins>';
|
---|
2543 | };
|
---|
2544 | rules.ins_close = function(/* tokens, idx, options, env */) {
|
---|
2545 | return '</ins>';
|
---|
2546 | };
|
---|
2547 |
|
---|
2548 | /**
|
---|
2549 | * Highlight
|
---|
2550 | */
|
---|
2551 |
|
---|
2552 | rules.mark_open = function(/* tokens, idx, options, env */) {
|
---|
2553 | return '<mark>';
|
---|
2554 | };
|
---|
2555 | rules.mark_close = function(/* tokens, idx, options, env */) {
|
---|
2556 | return '</mark>';
|
---|
2557 | };
|
---|
2558 |
|
---|
2559 | /**
|
---|
2560 | * Super- and sub-script
|
---|
2561 | */
|
---|
2562 |
|
---|
2563 | rules.sub = function(tokens, idx /*, options, env */) {
|
---|
2564 | return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
|
---|
2565 | };
|
---|
2566 | rules.sup = function(tokens, idx /*, options, env */) {
|
---|
2567 | return '<sup>' + escapeHtml(tokens[idx].content) + '</sup>';
|
---|
2568 | };
|
---|
2569 |
|
---|
2570 | /**
|
---|
2571 | * Breaks
|
---|
2572 | */
|
---|
2573 |
|
---|
2574 | rules.hardbreak = function(tokens, idx, options /*, env */) {
|
---|
2575 | return options.xhtmlOut ? '<br />\n' : '<br>\n';
|
---|
2576 | };
|
---|
2577 | rules.softbreak = function(tokens, idx, options /*, env */) {
|
---|
2578 | return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
|
---|
2579 | };
|
---|
2580 |
|
---|
2581 | /**
|
---|
2582 | * Text
|
---|
2583 | */
|
---|
2584 |
|
---|
2585 | rules.text = function(tokens, idx /*, options, env */) {
|
---|
2586 | return escapeHtml(tokens[idx].content);
|
---|
2587 | };
|
---|
2588 |
|
---|
2589 | /**
|
---|
2590 | * Content
|
---|
2591 | */
|
---|
2592 |
|
---|
2593 | rules.htmlblock = function(tokens, idx /*, options, env */) {
|
---|
2594 | return tokens[idx].content;
|
---|
2595 | };
|
---|
2596 | rules.htmltag = function(tokens, idx /*, options, env */) {
|
---|
2597 | return tokens[idx].content;
|
---|
2598 | };
|
---|
2599 |
|
---|
2600 | /**
|
---|
2601 | * Abbreviations, initialism
|
---|
2602 | */
|
---|
2603 |
|
---|
2604 | rules.abbr_open = function(tokens, idx /*, options, env */) {
|
---|
2605 | return '<abbr title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '">';
|
---|
2606 | };
|
---|
2607 | rules.abbr_close = function(/* tokens, idx, options, env */) {
|
---|
2608 | return '</abbr>';
|
---|
2609 | };
|
---|
2610 |
|
---|
2611 | /**
|
---|
2612 | * Footnotes
|
---|
2613 | */
|
---|
2614 |
|
---|
2615 | rules.footnote_ref = function(tokens, idx) {
|
---|
2616 | var n = Number(tokens[idx].id + 1).toString();
|
---|
2617 | var id = 'fnref' + n;
|
---|
2618 | if (tokens[idx].subId > 0) {
|
---|
2619 | id += ':' + tokens[idx].subId;
|
---|
2620 | }
|
---|
2621 | return '<sup class="footnote-ref"><a href="#fn' + n + '" id="' + id + '">[' + n + ']</a></sup>';
|
---|
2622 | };
|
---|
2623 | rules.footnote_block_open = function(tokens, idx, options) {
|
---|
2624 | var hr = options.xhtmlOut
|
---|
2625 | ? '<hr class="footnotes-sep" />\n'
|
---|
2626 | : '<hr class="footnotes-sep">\n';
|
---|
2627 | return hr + '<section class="footnotes">\n<ol class="footnotes-list">\n';
|
---|
2628 | };
|
---|
2629 | rules.footnote_block_close = function() {
|
---|
2630 | return '</ol>\n</section>\n';
|
---|
2631 | };
|
---|
2632 | rules.footnote_open = function(tokens, idx) {
|
---|
2633 | var id = Number(tokens[idx].id + 1).toString();
|
---|
2634 | return '<li id="fn' + id + '" class="footnote-item">';
|
---|
2635 | };
|
---|
2636 | rules.footnote_close = function() {
|
---|
2637 | return '</li>\n';
|
---|
2638 | };
|
---|
2639 | rules.footnote_anchor = function(tokens, idx) {
|
---|
2640 | var n = Number(tokens[idx].id + 1).toString();
|
---|
2641 | var id = 'fnref' + n;
|
---|
2642 | if (tokens[idx].subId > 0) {
|
---|
2643 | id += ':' + tokens[idx].subId;
|
---|
2644 | }
|
---|
2645 | return ' <a href="#' + id + '" class="footnote-backref">↩</a>';
|
---|
2646 | };
|
---|
2647 |
|
---|
2648 | /**
|
---|
2649 | * Definition lists
|
---|
2650 | */
|
---|
2651 |
|
---|
2652 | rules.dl_open = function() {
|
---|
2653 | return '<dl>\n';
|
---|
2654 | };
|
---|
2655 | rules.dt_open = function() {
|
---|
2656 | return '<dt>';
|
---|
2657 | };
|
---|
2658 | rules.dd_open = function() {
|
---|
2659 | return '<dd>';
|
---|
2660 | };
|
---|
2661 | rules.dl_close = function() {
|
---|
2662 | return '</dl>\n';
|
---|
2663 | };
|
---|
2664 | rules.dt_close = function() {
|
---|
2665 | return '</dt>\n';
|
---|
2666 | };
|
---|
2667 | rules.dd_close = function() {
|
---|
2668 | return '</dd>\n';
|
---|
2669 | };
|
---|
2670 |
|
---|
2671 | /**
|
---|
2672 | * Helper functions
|
---|
2673 | */
|
---|
2674 |
|
---|
2675 | function nextToken(tokens, idx) {
|
---|
2676 | if (++idx >= tokens.length - 2) {
|
---|
2677 | return idx;
|
---|
2678 | }
|
---|
2679 | if ((tokens[idx].type === 'paragraph_open' && tokens[idx].tight) &&
|
---|
2680 | (tokens[idx + 1].type === 'inline' && tokens[idx + 1].content.length === 0) &&
|
---|
2681 | (tokens[idx + 2].type === 'paragraph_close' && tokens[idx + 2].tight)) {
|
---|
2682 | return nextToken(tokens, idx + 2);
|
---|
2683 | }
|
---|
2684 | return idx;
|
---|
2685 | }
|
---|
2686 |
|
---|
2687 | /**
|
---|
2688 | * Check to see if `\n` is needed before the next token.
|
---|
2689 | *
|
---|
2690 | * @param {Array} `tokens`
|
---|
2691 | * @param {Number} `idx`
|
---|
2692 | * @return {String} Empty string or newline
|
---|
2693 | * @api private
|
---|
2694 | */
|
---|
2695 |
|
---|
2696 | var getBreak = rules.getBreak = function getBreak(tokens, idx) {
|
---|
2697 | idx = nextToken(tokens, idx);
|
---|
2698 | if (idx < tokens.length && tokens[idx].type === 'list_item_close') {
|
---|
2699 | return '';
|
---|
2700 | }
|
---|
2701 | return '\n';
|
---|
2702 | };
|
---|
2703 |
|
---|
2704 | /**
|
---|
2705 | * Renderer class. Renders HTML and exposes `rules` to allow
|
---|
2706 | * local modifications.
|
---|
2707 | */
|
---|
2708 |
|
---|
2709 | function Renderer() {
|
---|
2710 | this.rules = assign({}, rules);
|
---|
2711 |
|
---|
2712 | // exported helper, for custom rules only
|
---|
2713 | this.getBreak = rules.getBreak;
|
---|
2714 | }
|
---|
2715 |
|
---|
2716 | /**
|
---|
2717 | * Render a string of inline HTML with the given `tokens` and
|
---|
2718 | * `options`.
|
---|
2719 | *
|
---|
2720 | * @param {Array} `tokens`
|
---|
2721 | * @param {Object} `options`
|
---|
2722 | * @param {Object} `env`
|
---|
2723 | * @return {String}
|
---|
2724 | * @api public
|
---|
2725 | */
|
---|
2726 |
|
---|
2727 | Renderer.prototype.renderInline = function (tokens, options, env) {
|
---|
2728 | var _rules = this.rules;
|
---|
2729 | var len = tokens.length, i = 0;
|
---|
2730 | var result = '';
|
---|
2731 |
|
---|
2732 | while (len--) {
|
---|
2733 | result += _rules[tokens[i].type](tokens, i++, options, env, this);
|
---|
2734 | }
|
---|
2735 |
|
---|
2736 | return result;
|
---|
2737 | };
|
---|
2738 |
|
---|
2739 | /**
|
---|
2740 | * Render a string of HTML with the given `tokens` and
|
---|
2741 | * `options`.
|
---|
2742 | *
|
---|
2743 | * @param {Array} `tokens`
|
---|
2744 | * @param {Object} `options`
|
---|
2745 | * @param {Object} `env`
|
---|
2746 | * @return {String}
|
---|
2747 | * @api public
|
---|
2748 | */
|
---|
2749 |
|
---|
2750 | Renderer.prototype.render = function (tokens, options, env) {
|
---|
2751 | var _rules = this.rules;
|
---|
2752 | var len = tokens.length, i = -1;
|
---|
2753 | var result = '';
|
---|
2754 |
|
---|
2755 | while (++i < len) {
|
---|
2756 | if (tokens[i].type === 'inline') {
|
---|
2757 | result += this.renderInline(tokens[i].children, options, env);
|
---|
2758 | } else {
|
---|
2759 | result += _rules[tokens[i].type](tokens, i, options, env, this);
|
---|
2760 | }
|
---|
2761 | }
|
---|
2762 | return result;
|
---|
2763 | };
|
---|
2764 |
|
---|
2765 | /**
|
---|
2766 | * Ruler is a helper class for building responsibility chains from
|
---|
2767 | * parse rules. It allows:
|
---|
2768 | *
|
---|
2769 | * - easy stack rules chains
|
---|
2770 | * - getting main chain and named chains content (as arrays of functions)
|
---|
2771 | *
|
---|
2772 | * Helper methods, should not be used directly.
|
---|
2773 | * @api private
|
---|
2774 | */
|
---|
2775 |
|
---|
2776 | function Ruler() {
|
---|
2777 | // List of added rules. Each element is:
|
---|
2778 | //
|
---|
2779 | // { name: XXX,
|
---|
2780 | // enabled: Boolean,
|
---|
2781 | // fn: Function(),
|
---|
2782 | // alt: [ name2, name3 ] }
|
---|
2783 | //
|
---|
2784 | this.__rules__ = [];
|
---|
2785 |
|
---|
2786 | // Cached rule chains.
|
---|
2787 | //
|
---|
2788 | // First level - chain name, '' for default.
|
---|
2789 | // Second level - digital anchor for fast filtering by charcodes.
|
---|
2790 | //
|
---|
2791 | this.__cache__ = null;
|
---|
2792 | }
|
---|
2793 |
|
---|
2794 | /**
|
---|
2795 | * Find the index of a rule by `name`.
|
---|
2796 | *
|
---|
2797 | * @param {String} `name`
|
---|
2798 | * @return {Number} Index of the given `name`
|
---|
2799 | * @api private
|
---|
2800 | */
|
---|
2801 |
|
---|
2802 | Ruler.prototype.__find__ = function (name) {
|
---|
2803 | var len = this.__rules__.length;
|
---|
2804 | var i = -1;
|
---|
2805 |
|
---|
2806 | while (len--) {
|
---|
2807 | if (this.__rules__[++i].name === name) {
|
---|
2808 | return i;
|
---|
2809 | }
|
---|
2810 | }
|
---|
2811 | return -1;
|
---|
2812 | };
|
---|
2813 |
|
---|
2814 | /**
|
---|
2815 | * Build the rules lookup cache
|
---|
2816 | *
|
---|
2817 | * @api private
|
---|
2818 | */
|
---|
2819 |
|
---|
2820 | Ruler.prototype.__compile__ = function () {
|
---|
2821 | var self = this;
|
---|
2822 | var chains = [ '' ];
|
---|
2823 |
|
---|
2824 | // collect unique names
|
---|
2825 | self.__rules__.forEach(function (rule) {
|
---|
2826 | if (!rule.enabled) {
|
---|
2827 | return;
|
---|
2828 | }
|
---|
2829 |
|
---|
2830 | rule.alt.forEach(function (altName) {
|
---|
2831 | if (chains.indexOf(altName) < 0) {
|
---|
2832 | chains.push(altName);
|
---|
2833 | }
|
---|
2834 | });
|
---|
2835 | });
|
---|
2836 |
|
---|
2837 | self.__cache__ = {};
|
---|
2838 |
|
---|
2839 | chains.forEach(function (chain) {
|
---|
2840 | self.__cache__[chain] = [];
|
---|
2841 | self.__rules__.forEach(function (rule) {
|
---|
2842 | if (!rule.enabled) {
|
---|
2843 | return;
|
---|
2844 | }
|
---|
2845 |
|
---|
2846 | if (chain && rule.alt.indexOf(chain) < 0) {
|
---|
2847 | return;
|
---|
2848 | }
|
---|
2849 | self.__cache__[chain].push(rule.fn);
|
---|
2850 | });
|
---|
2851 | });
|
---|
2852 | };
|
---|
2853 |
|
---|
2854 | /**
|
---|
2855 | * Ruler public methods
|
---|
2856 | * ------------------------------------------------
|
---|
2857 | */
|
---|
2858 |
|
---|
2859 | /**
|
---|
2860 | * Replace rule function
|
---|
2861 | *
|
---|
2862 | * @param {String} `name` Rule name
|
---|
2863 | * @param {Function `fn`
|
---|
2864 | * @param {Object} `options`
|
---|
2865 | * @api private
|
---|
2866 | */
|
---|
2867 |
|
---|
2868 | Ruler.prototype.at = function (name, fn, options) {
|
---|
2869 | var idx = this.__find__(name);
|
---|
2870 | var opt = options || {};
|
---|
2871 |
|
---|
2872 | if (idx === -1) {
|
---|
2873 | throw new Error('Parser rule not found: ' + name);
|
---|
2874 | }
|
---|
2875 |
|
---|
2876 | this.__rules__[idx].fn = fn;
|
---|
2877 | this.__rules__[idx].alt = opt.alt || [];
|
---|
2878 | this.__cache__ = null;
|
---|
2879 | };
|
---|
2880 |
|
---|
2881 | /**
|
---|
2882 | * Add a rule to the chain before given the `ruleName`.
|
---|
2883 | *
|
---|
2884 | * @param {String} `beforeName`
|
---|
2885 | * @param {String} `ruleName`
|
---|
2886 | * @param {Function} `fn`
|
---|
2887 | * @param {Object} `options`
|
---|
2888 | * @api private
|
---|
2889 | */
|
---|
2890 |
|
---|
2891 | Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
|
---|
2892 | var idx = this.__find__(beforeName);
|
---|
2893 | var opt = options || {};
|
---|
2894 |
|
---|
2895 | if (idx === -1) {
|
---|
2896 | throw new Error('Parser rule not found: ' + beforeName);
|
---|
2897 | }
|
---|
2898 |
|
---|
2899 | this.__rules__.splice(idx, 0, {
|
---|
2900 | name: ruleName,
|
---|
2901 | enabled: true,
|
---|
2902 | fn: fn,
|
---|
2903 | alt: opt.alt || []
|
---|
2904 | });
|
---|
2905 |
|
---|
2906 | this.__cache__ = null;
|
---|
2907 | };
|
---|
2908 |
|
---|
2909 | /**
|
---|
2910 | * Add a rule to the chain after the given `ruleName`.
|
---|
2911 | *
|
---|
2912 | * @param {String} `afterName`
|
---|
2913 | * @param {String} `ruleName`
|
---|
2914 | * @param {Function} `fn`
|
---|
2915 | * @param {Object} `options`
|
---|
2916 | * @api private
|
---|
2917 | */
|
---|
2918 |
|
---|
2919 | Ruler.prototype.after = function (afterName, ruleName, fn, options) {
|
---|
2920 | var idx = this.__find__(afterName);
|
---|
2921 | var opt = options || {};
|
---|
2922 |
|
---|
2923 | if (idx === -1) {
|
---|
2924 | throw new Error('Parser rule not found: ' + afterName);
|
---|
2925 | }
|
---|
2926 |
|
---|
2927 | this.__rules__.splice(idx + 1, 0, {
|
---|
2928 | name: ruleName,
|
---|
2929 | enabled: true,
|
---|
2930 | fn: fn,
|
---|
2931 | alt: opt.alt || []
|
---|
2932 | });
|
---|
2933 |
|
---|
2934 | this.__cache__ = null;
|
---|
2935 | };
|
---|
2936 |
|
---|
2937 | /**
|
---|
2938 | * Add a rule to the end of chain.
|
---|
2939 | *
|
---|
2940 | * @param {String} `ruleName`
|
---|
2941 | * @param {Function} `fn`
|
---|
2942 | * @param {Object} `options`
|
---|
2943 | * @return {String}
|
---|
2944 | */
|
---|
2945 |
|
---|
2946 | Ruler.prototype.push = function (ruleName, fn, options) {
|
---|
2947 | var opt = options || {};
|
---|
2948 |
|
---|
2949 | this.__rules__.push({
|
---|
2950 | name: ruleName,
|
---|
2951 | enabled: true,
|
---|
2952 | fn: fn,
|
---|
2953 | alt: opt.alt || []
|
---|
2954 | });
|
---|
2955 |
|
---|
2956 | this.__cache__ = null;
|
---|
2957 | };
|
---|
2958 |
|
---|
2959 | /**
|
---|
2960 | * Enable a rule or list of rules.
|
---|
2961 | *
|
---|
2962 | * @param {String|Array} `list` Name or array of rule names to enable
|
---|
2963 | * @param {Boolean} `strict` If `true`, all non listed rules will be disabled.
|
---|
2964 | * @api private
|
---|
2965 | */
|
---|
2966 |
|
---|
2967 | Ruler.prototype.enable = function (list, strict) {
|
---|
2968 | list = !Array.isArray(list)
|
---|
2969 | ? [ list ]
|
---|
2970 | : list;
|
---|
2971 |
|
---|
2972 | // In strict mode disable all existing rules first
|
---|
2973 | if (strict) {
|
---|
2974 | this.__rules__.forEach(function (rule) {
|
---|
2975 | rule.enabled = false;
|
---|
2976 | });
|
---|
2977 | }
|
---|
2978 |
|
---|
2979 | // Search by name and enable
|
---|
2980 | list.forEach(function (name) {
|
---|
2981 | var idx = this.__find__(name);
|
---|
2982 | if (idx < 0) {
|
---|
2983 | throw new Error('Rules manager: invalid rule name ' + name);
|
---|
2984 | }
|
---|
2985 | this.__rules__[idx].enabled = true;
|
---|
2986 | }, this);
|
---|
2987 |
|
---|
2988 | this.__cache__ = null;
|
---|
2989 | };
|
---|
2990 |
|
---|
2991 |
|
---|
2992 | /**
|
---|
2993 | * Disable a rule or list of rules.
|
---|
2994 | *
|
---|
2995 | * @param {String|Array} `list` Name or array of rule names to disable
|
---|
2996 | * @api private
|
---|
2997 | */
|
---|
2998 |
|
---|
2999 | Ruler.prototype.disable = function (list) {
|
---|
3000 | list = !Array.isArray(list)
|
---|
3001 | ? [ list ]
|
---|
3002 | : list;
|
---|
3003 |
|
---|
3004 | // Search by name and disable
|
---|
3005 | list.forEach(function (name) {
|
---|
3006 | var idx = this.__find__(name);
|
---|
3007 | if (idx < 0) {
|
---|
3008 | throw new Error('Rules manager: invalid rule name ' + name);
|
---|
3009 | }
|
---|
3010 | this.__rules__[idx].enabled = false;
|
---|
3011 | }, this);
|
---|
3012 |
|
---|
3013 | this.__cache__ = null;
|
---|
3014 | };
|
---|
3015 |
|
---|
3016 | /**
|
---|
3017 | * Get a rules list as an array of functions.
|
---|
3018 | *
|
---|
3019 | * @param {String} `chainName`
|
---|
3020 | * @return {Object}
|
---|
3021 | * @api private
|
---|
3022 | */
|
---|
3023 |
|
---|
3024 | Ruler.prototype.getRules = function (chainName) {
|
---|
3025 | if (this.__cache__ === null) {
|
---|
3026 | this.__compile__();
|
---|
3027 | }
|
---|
3028 | return this.__cache__[chainName] || [];
|
---|
3029 | };
|
---|
3030 |
|
---|
3031 | function block(state) {
|
---|
3032 |
|
---|
3033 | if (state.inlineMode) {
|
---|
3034 | state.tokens.push({
|
---|
3035 | type: 'inline',
|
---|
3036 | content: state.src.replace(/\n/g, ' ').trim(),
|
---|
3037 | level: 0,
|
---|
3038 | lines: [ 0, 1 ],
|
---|
3039 | children: []
|
---|
3040 | });
|
---|
3041 |
|
---|
3042 | } else {
|
---|
3043 | state.block.parse(state.src, state.options, state.env, state.tokens);
|
---|
3044 | }
|
---|
3045 | }
|
---|
3046 |
|
---|
3047 | // Inline parser state
|
---|
3048 |
|
---|
3049 | function StateInline(src, parserInline, options, env, outTokens) {
|
---|
3050 | this.src = src;
|
---|
3051 | this.env = env;
|
---|
3052 | this.options = options;
|
---|
3053 | this.parser = parserInline;
|
---|
3054 | this.tokens = outTokens;
|
---|
3055 | this.pos = 0;
|
---|
3056 | this.posMax = this.src.length;
|
---|
3057 | this.level = 0;
|
---|
3058 | this.pending = '';
|
---|
3059 | this.pendingLevel = 0;
|
---|
3060 |
|
---|
3061 | this.cache = []; // Stores { start: end } pairs. Useful for backtrack
|
---|
3062 | // optimization of pairs parse (emphasis, strikes).
|
---|
3063 |
|
---|
3064 | // Link parser state vars
|
---|
3065 |
|
---|
3066 | this.isInLabel = false; // Set true when seek link label - we should disable
|
---|
3067 | // "paired" rules (emphasis, strikes) to not skip
|
---|
3068 | // tailing `]`
|
---|
3069 |
|
---|
3070 | this.linkLevel = 0; // Increment for each nesting link. Used to prevent
|
---|
3071 | // nesting in definitions
|
---|
3072 |
|
---|
3073 | this.linkContent = ''; // Temporary storage for link url
|
---|
3074 |
|
---|
3075 | this.labelUnmatchedScopes = 0; // Track unpaired `[` for link labels
|
---|
3076 | // (backtrack optimization)
|
---|
3077 | }
|
---|
3078 |
|
---|
3079 | // Flush pending text
|
---|
3080 | //
|
---|
3081 | StateInline.prototype.pushPending = function () {
|
---|
3082 | this.tokens.push({
|
---|
3083 | type: 'text',
|
---|
3084 | content: this.pending,
|
---|
3085 | level: this.pendingLevel
|
---|
3086 | });
|
---|
3087 | this.pending = '';
|
---|
3088 | };
|
---|
3089 |
|
---|
3090 | // Push new token to "stream".
|
---|
3091 | // If pending text exists - flush it as text token
|
---|
3092 | //
|
---|
3093 | StateInline.prototype.push = function (token) {
|
---|
3094 | if (this.pending) {
|
---|
3095 | this.pushPending();
|
---|
3096 | }
|
---|
3097 |
|
---|
3098 | this.tokens.push(token);
|
---|
3099 | this.pendingLevel = this.level;
|
---|
3100 | };
|
---|
3101 |
|
---|
3102 | // Store value to cache.
|
---|
3103 | // !!! Implementation has parser-specific optimizations
|
---|
3104 | // !!! keys MUST be integer, >= 0; values MUST be integer, > 0
|
---|
3105 | //
|
---|
3106 | StateInline.prototype.cacheSet = function (key, val) {
|
---|
3107 | for (var i = this.cache.length; i <= key; i++) {
|
---|
3108 | this.cache.push(0);
|
---|
3109 | }
|
---|
3110 |
|
---|
3111 | this.cache[key] = val;
|
---|
3112 | };
|
---|
3113 |
|
---|
3114 | // Get cache value
|
---|
3115 | //
|
---|
3116 | StateInline.prototype.cacheGet = function (key) {
|
---|
3117 | return key < this.cache.length ? this.cache[key] : 0;
|
---|
3118 | };
|
---|
3119 |
|
---|
3120 | /**
|
---|
3121 | * Parse link labels
|
---|
3122 | *
|
---|
3123 | * This function assumes that first character (`[`) already matches;
|
---|
3124 | * returns the end of the label.
|
---|
3125 | *
|
---|
3126 | * @param {Object} state
|
---|
3127 | * @param {Number} start
|
---|
3128 | * @api private
|
---|
3129 | */
|
---|
3130 |
|
---|
3131 | function parseLinkLabel(state, start) {
|
---|
3132 | var level, found, marker,
|
---|
3133 | labelEnd = -1,
|
---|
3134 | max = state.posMax,
|
---|
3135 | oldPos = state.pos,
|
---|
3136 | oldFlag = state.isInLabel;
|
---|
3137 |
|
---|
3138 | if (state.isInLabel) { return -1; }
|
---|
3139 |
|
---|
3140 | if (state.labelUnmatchedScopes) {
|
---|
3141 | state.labelUnmatchedScopes--;
|
---|
3142 | return -1;
|
---|
3143 | }
|
---|
3144 |
|
---|
3145 | state.pos = start + 1;
|
---|
3146 | state.isInLabel = true;
|
---|
3147 | level = 1;
|
---|
3148 |
|
---|
3149 | while (state.pos < max) {
|
---|
3150 | marker = state.src.charCodeAt(state.pos);
|
---|
3151 | if (marker === 0x5B /* [ */) {
|
---|
3152 | level++;
|
---|
3153 | } else if (marker === 0x5D /* ] */) {
|
---|
3154 | level--;
|
---|
3155 | if (level === 0) {
|
---|
3156 | found = true;
|
---|
3157 | break;
|
---|
3158 | }
|
---|
3159 | }
|
---|
3160 |
|
---|
3161 | state.parser.skipToken(state);
|
---|
3162 | }
|
---|
3163 |
|
---|
3164 | if (found) {
|
---|
3165 | labelEnd = state.pos;
|
---|
3166 | state.labelUnmatchedScopes = 0;
|
---|
3167 | } else {
|
---|
3168 | state.labelUnmatchedScopes = level - 1;
|
---|
3169 | }
|
---|
3170 |
|
---|
3171 | // restore old state
|
---|
3172 | state.pos = oldPos;
|
---|
3173 | state.isInLabel = oldFlag;
|
---|
3174 |
|
---|
3175 | return labelEnd;
|
---|
3176 | }
|
---|
3177 |
|
---|
3178 | // Parse abbreviation definitions, i.e. `*[abbr]: description`
|
---|
3179 |
|
---|
3180 |
|
---|
3181 | function parseAbbr(str, parserInline, options, env) {
|
---|
3182 | var state, labelEnd, pos, max, label, title;
|
---|
3183 |
|
---|
3184 | if (str.charCodeAt(0) !== 0x2A/* * */) { return -1; }
|
---|
3185 | if (str.charCodeAt(1) !== 0x5B/* [ */) { return -1; }
|
---|
3186 |
|
---|
3187 | if (str.indexOf(']:') === -1) { return -1; }
|
---|
3188 |
|
---|
3189 | state = new StateInline(str, parserInline, options, env, []);
|
---|
3190 | labelEnd = parseLinkLabel(state, 1);
|
---|
3191 |
|
---|
3192 | if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return -1; }
|
---|
3193 |
|
---|
3194 | max = state.posMax;
|
---|
3195 |
|
---|
3196 | // abbr title is always one line, so looking for ending "\n" here
|
---|
3197 | for (pos = labelEnd + 2; pos < max; pos++) {
|
---|
3198 | if (state.src.charCodeAt(pos) === 0x0A) { break; }
|
---|
3199 | }
|
---|
3200 |
|
---|
3201 | label = str.slice(2, labelEnd);
|
---|
3202 | title = str.slice(labelEnd + 2, pos).trim();
|
---|
3203 | if (title.length === 0) { return -1; }
|
---|
3204 | if (!env.abbreviations) { env.abbreviations = {}; }
|
---|
3205 | // prepend ':' to avoid conflict with Object.prototype members
|
---|
3206 | if (typeof env.abbreviations[':' + label] === 'undefined') {
|
---|
3207 | env.abbreviations[':' + label] = title;
|
---|
3208 | }
|
---|
3209 |
|
---|
3210 | return pos;
|
---|
3211 | }
|
---|
3212 |
|
---|
3213 | function abbr(state) {
|
---|
3214 | var tokens = state.tokens, i, l, content, pos;
|
---|
3215 |
|
---|
3216 | if (state.inlineMode) {
|
---|
3217 | return;
|
---|
3218 | }
|
---|
3219 |
|
---|
3220 | // Parse inlines
|
---|
3221 | for (i = 1, l = tokens.length - 1; i < l; i++) {
|
---|
3222 | if (tokens[i - 1].type === 'paragraph_open' &&
|
---|
3223 | tokens[i].type === 'inline' &&
|
---|
3224 | tokens[i + 1].type === 'paragraph_close') {
|
---|
3225 |
|
---|
3226 | content = tokens[i].content;
|
---|
3227 | while (content.length) {
|
---|
3228 | pos = parseAbbr(content, state.inline, state.options, state.env);
|
---|
3229 | if (pos < 0) { break; }
|
---|
3230 | content = content.slice(pos).trim();
|
---|
3231 | }
|
---|
3232 |
|
---|
3233 | tokens[i].content = content;
|
---|
3234 | if (!content.length) {
|
---|
3235 | tokens[i - 1].tight = true;
|
---|
3236 | tokens[i + 1].tight = true;
|
---|
3237 | }
|
---|
3238 | }
|
---|
3239 | }
|
---|
3240 | }
|
---|
3241 |
|
---|
3242 | function normalizeLink(url) {
|
---|
3243 | var normalized = replaceEntities(url);
|
---|
3244 | // We shouldn't care about the result of malformed URIs,
|
---|
3245 | // and should not throw an exception.
|
---|
3246 | try {
|
---|
3247 | normalized = decodeURI(normalized);
|
---|
3248 | } catch (err) {}
|
---|
3249 | return encodeURI(normalized);
|
---|
3250 | }
|
---|
3251 |
|
---|
3252 | /**
|
---|
3253 | * Parse link destination
|
---|
3254 | *
|
---|
3255 | * - on success it returns a string and updates state.pos;
|
---|
3256 | * - on failure it returns null
|
---|
3257 | *
|
---|
3258 | * @param {Object} state
|
---|
3259 | * @param {Number} pos
|
---|
3260 | * @api private
|
---|
3261 | */
|
---|
3262 |
|
---|
3263 | function parseLinkDestination(state, pos) {
|
---|
3264 | var code, level, link,
|
---|
3265 | start = pos,
|
---|
3266 | max = state.posMax;
|
---|
3267 |
|
---|
3268 | if (state.src.charCodeAt(pos) === 0x3C /* < */) {
|
---|
3269 | pos++;
|
---|
3270 | while (pos < max) {
|
---|
3271 | code = state.src.charCodeAt(pos);
|
---|
3272 | if (code === 0x0A /* \n */) { return false; }
|
---|
3273 | if (code === 0x3E /* > */) {
|
---|
3274 | link = normalizeLink(unescapeMd(state.src.slice(start + 1, pos)));
|
---|
3275 | if (!state.parser.validateLink(link)) { return false; }
|
---|
3276 | state.pos = pos + 1;
|
---|
3277 | state.linkContent = link;
|
---|
3278 | return true;
|
---|
3279 | }
|
---|
3280 | if (code === 0x5C /* \ */ && pos + 1 < max) {
|
---|
3281 | pos += 2;
|
---|
3282 | continue;
|
---|
3283 | }
|
---|
3284 |
|
---|
3285 | pos++;
|
---|
3286 | }
|
---|
3287 |
|
---|
3288 | // no closing '>'
|
---|
3289 | return false;
|
---|
3290 | }
|
---|
3291 |
|
---|
3292 | // this should be ... } else { ... branch
|
---|
3293 |
|
---|
3294 | level = 0;
|
---|
3295 | while (pos < max) {
|
---|
3296 | code = state.src.charCodeAt(pos);
|
---|
3297 |
|
---|
3298 | if (code === 0x20) { break; }
|
---|
3299 |
|
---|
3300 | // ascii control chars
|
---|
3301 | if (code < 0x20 || code === 0x7F) { break; }
|
---|
3302 |
|
---|
3303 | if (code === 0x5C /* \ */ && pos + 1 < max) {
|
---|
3304 | pos += 2;
|
---|
3305 | continue;
|
---|
3306 | }
|
---|
3307 |
|
---|
3308 | if (code === 0x28 /* ( */) {
|
---|
3309 | level++;
|
---|
3310 | if (level > 1) { break; }
|
---|
3311 | }
|
---|
3312 |
|
---|
3313 | if (code === 0x29 /* ) */) {
|
---|
3314 | level--;
|
---|
3315 | if (level < 0) { break; }
|
---|
3316 | }
|
---|
3317 |
|
---|
3318 | pos++;
|
---|
3319 | }
|
---|
3320 |
|
---|
3321 | if (start === pos) { return false; }
|
---|
3322 |
|
---|
3323 | link = unescapeMd(state.src.slice(start, pos));
|
---|
3324 | if (!state.parser.validateLink(link)) { return false; }
|
---|
3325 |
|
---|
3326 | state.linkContent = link;
|
---|
3327 | state.pos = pos;
|
---|
3328 | return true;
|
---|
3329 | }
|
---|
3330 |
|
---|
3331 | /**
|
---|
3332 | * Parse link title
|
---|
3333 | *
|
---|
3334 | * - on success it returns a string and updates state.pos;
|
---|
3335 | * - on failure it returns null
|
---|
3336 | *
|
---|
3337 | * @param {Object} state
|
---|
3338 | * @param {Number} pos
|
---|
3339 | * @api private
|
---|
3340 | */
|
---|
3341 |
|
---|
3342 | function parseLinkTitle(state, pos) {
|
---|
3343 | var code,
|
---|
3344 | start = pos,
|
---|
3345 | max = state.posMax,
|
---|
3346 | marker = state.src.charCodeAt(pos);
|
---|
3347 |
|
---|
3348 | if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return false; }
|
---|
3349 |
|
---|
3350 | pos++;
|
---|
3351 |
|
---|
3352 | // if opening marker is "(", switch it to closing marker ")"
|
---|
3353 | if (marker === 0x28) { marker = 0x29; }
|
---|
3354 |
|
---|
3355 | while (pos < max) {
|
---|
3356 | code = state.src.charCodeAt(pos);
|
---|
3357 | if (code === marker) {
|
---|
3358 | state.pos = pos + 1;
|
---|
3359 | state.linkContent = unescapeMd(state.src.slice(start + 1, pos));
|
---|
3360 | return true;
|
---|
3361 | }
|
---|
3362 | if (code === 0x5C /* \ */ && pos + 1 < max) {
|
---|
3363 | pos += 2;
|
---|
3364 | continue;
|
---|
3365 | }
|
---|
3366 |
|
---|
3367 | pos++;
|
---|
3368 | }
|
---|
3369 |
|
---|
3370 | return false;
|
---|
3371 | }
|
---|
3372 |
|
---|
3373 | function normalizeReference(str) {
|
---|
3374 | // use .toUpperCase() instead of .toLowerCase()
|
---|
3375 | // here to avoid a conflict with Object.prototype
|
---|
3376 | // members (most notably, `__proto__`)
|
---|
3377 | return str.trim().replace(/\s+/g, ' ').toUpperCase();
|
---|
3378 | }
|
---|
3379 |
|
---|
3380 | function parseReference(str, parser, options, env) {
|
---|
3381 | var state, labelEnd, pos, max, code, start, href, title, label;
|
---|
3382 |
|
---|
3383 | if (str.charCodeAt(0) !== 0x5B/* [ */) { return -1; }
|
---|
3384 |
|
---|
3385 | if (str.indexOf(']:') === -1) { return -1; }
|
---|
3386 |
|
---|
3387 | state = new StateInline(str, parser, options, env, []);
|
---|
3388 | labelEnd = parseLinkLabel(state, 0);
|
---|
3389 |
|
---|
3390 | if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return -1; }
|
---|
3391 |
|
---|
3392 | max = state.posMax;
|
---|
3393 |
|
---|
3394 | // [label]: destination 'title'
|
---|
3395 | // ^^^ skip optional whitespace here
|
---|
3396 | for (pos = labelEnd + 2; pos < max; pos++) {
|
---|
3397 | code = state.src.charCodeAt(pos);
|
---|
3398 | if (code !== 0x20 && code !== 0x0A) { break; }
|
---|
3399 | }
|
---|
3400 |
|
---|
3401 | // [label]: destination 'title'
|
---|
3402 | // ^^^^^^^^^^^ parse this
|
---|
3403 | if (!parseLinkDestination(state, pos)) { return -1; }
|
---|
3404 | href = state.linkContent;
|
---|
3405 | pos = state.pos;
|
---|
3406 |
|
---|
3407 | // [label]: destination 'title'
|
---|
3408 | // ^^^ skipping those spaces
|
---|
3409 | start = pos;
|
---|
3410 | for (pos = pos + 1; pos < max; pos++) {
|
---|
3411 | code = state.src.charCodeAt(pos);
|
---|
3412 | if (code !== 0x20 && code !== 0x0A) { break; }
|
---|
3413 | }
|
---|
3414 |
|
---|
3415 | // [label]: destination 'title'
|
---|
3416 | // ^^^^^^^ parse this
|
---|
3417 | if (pos < max && start !== pos && parseLinkTitle(state, pos)) {
|
---|
3418 | title = state.linkContent;
|
---|
3419 | pos = state.pos;
|
---|
3420 | } else {
|
---|
3421 | title = '';
|
---|
3422 | pos = start;
|
---|
3423 | }
|
---|
3424 |
|
---|
3425 | // ensure that the end of the line is empty
|
---|
3426 | while (pos < max && state.src.charCodeAt(pos) === 0x20/* space */) { pos++; }
|
---|
3427 | if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; }
|
---|
3428 |
|
---|
3429 | label = normalizeReference(str.slice(1, labelEnd));
|
---|
3430 | if (typeof env.references[label] === 'undefined') {
|
---|
3431 | env.references[label] = { title: title, href: href };
|
---|
3432 | }
|
---|
3433 |
|
---|
3434 | return pos;
|
---|
3435 | }
|
---|
3436 |
|
---|
3437 |
|
---|
3438 | function references(state) {
|
---|
3439 | var tokens = state.tokens, i, l, content, pos;
|
---|
3440 |
|
---|
3441 | state.env.references = state.env.references || {};
|
---|
3442 |
|
---|
3443 | if (state.inlineMode) {
|
---|
3444 | return;
|
---|
3445 | }
|
---|
3446 |
|
---|
3447 | // Scan definitions in paragraph inlines
|
---|
3448 | for (i = 1, l = tokens.length - 1; i < l; i++) {
|
---|
3449 | if (tokens[i].type === 'inline' &&
|
---|
3450 | tokens[i - 1].type === 'paragraph_open' &&
|
---|
3451 | tokens[i + 1].type === 'paragraph_close') {
|
---|
3452 |
|
---|
3453 | content = tokens[i].content;
|
---|
3454 | while (content.length) {
|
---|
3455 | pos = parseReference(content, state.inline, state.options, state.env);
|
---|
3456 | if (pos < 0) { break; }
|
---|
3457 | content = content.slice(pos).trim();
|
---|
3458 | }
|
---|
3459 |
|
---|
3460 | tokens[i].content = content;
|
---|
3461 | if (!content.length) {
|
---|
3462 | tokens[i - 1].tight = true;
|
---|
3463 | tokens[i + 1].tight = true;
|
---|
3464 | }
|
---|
3465 | }
|
---|
3466 | }
|
---|
3467 | }
|
---|
3468 |
|
---|
3469 | function inline(state) {
|
---|
3470 | var tokens = state.tokens, tok, i, l;
|
---|
3471 |
|
---|
3472 | // Parse inlines
|
---|
3473 | for (i = 0, l = tokens.length; i < l; i++) {
|
---|
3474 | tok = tokens[i];
|
---|
3475 | if (tok.type === 'inline') {
|
---|
3476 | state.inline.parse(tok.content, state.options, state.env, tok.children);
|
---|
3477 | }
|
---|
3478 | }
|
---|
3479 | }
|
---|
3480 |
|
---|
3481 | function footnote_block(state) {
|
---|
3482 | var i, l, j, t, lastParagraph, list, tokens, current, currentLabel,
|
---|
3483 | level = 0,
|
---|
3484 | insideRef = false,
|
---|
3485 | refTokens = {};
|
---|
3486 |
|
---|
3487 | if (!state.env.footnotes) { return; }
|
---|
3488 |
|
---|
3489 | state.tokens = state.tokens.filter(function(tok) {
|
---|
3490 | if (tok.type === 'footnote_reference_open') {
|
---|
3491 | insideRef = true;
|
---|
3492 | current = [];
|
---|
3493 | currentLabel = tok.label;
|
---|
3494 | return false;
|
---|
3495 | }
|
---|
3496 | if (tok.type === 'footnote_reference_close') {
|
---|
3497 | insideRef = false;
|
---|
3498 | // prepend ':' to avoid conflict with Object.prototype members
|
---|
3499 | refTokens[':' + currentLabel] = current;
|
---|
3500 | return false;
|
---|
3501 | }
|
---|
3502 | if (insideRef) { current.push(tok); }
|
---|
3503 | return !insideRef;
|
---|
3504 | });
|
---|
3505 |
|
---|
3506 | if (!state.env.footnotes.list) { return; }
|
---|
3507 | list = state.env.footnotes.list;
|
---|
3508 |
|
---|
3509 | state.tokens.push({
|
---|
3510 | type: 'footnote_block_open',
|
---|
3511 | level: level++
|
---|
3512 | });
|
---|
3513 | for (i = 0, l = list.length; i < l; i++) {
|
---|
3514 | state.tokens.push({
|
---|
3515 | type: 'footnote_open',
|
---|
3516 | id: i,
|
---|
3517 | level: level++
|
---|
3518 | });
|
---|
3519 |
|
---|
3520 | if (list[i].tokens) {
|
---|
3521 | tokens = [];
|
---|
3522 | tokens.push({
|
---|
3523 | type: 'paragraph_open',
|
---|
3524 | tight: false,
|
---|
3525 | level: level++
|
---|
3526 | });
|
---|
3527 | tokens.push({
|
---|
3528 | type: 'inline',
|
---|
3529 | content: '',
|
---|
3530 | level: level,
|
---|
3531 | children: list[i].tokens
|
---|
3532 | });
|
---|
3533 | tokens.push({
|
---|
3534 | type: 'paragraph_close',
|
---|
3535 | tight: false,
|
---|
3536 | level: --level
|
---|
3537 | });
|
---|
3538 | } else if (list[i].label) {
|
---|
3539 | tokens = refTokens[':' + list[i].label];
|
---|
3540 | }
|
---|
3541 |
|
---|
3542 | state.tokens = state.tokens.concat(tokens);
|
---|
3543 | if (state.tokens[state.tokens.length - 1].type === 'paragraph_close') {
|
---|
3544 | lastParagraph = state.tokens.pop();
|
---|
3545 | } else {
|
---|
3546 | lastParagraph = null;
|
---|
3547 | }
|
---|
3548 |
|
---|
3549 | t = list[i].count > 0 ? list[i].count : 1;
|
---|
3550 | for (j = 0; j < t; j++) {
|
---|
3551 | state.tokens.push({
|
---|
3552 | type: 'footnote_anchor',
|
---|
3553 | id: i,
|
---|
3554 | subId: j,
|
---|
3555 | level: level
|
---|
3556 | });
|
---|
3557 | }
|
---|
3558 |
|
---|
3559 | if (lastParagraph) {
|
---|
3560 | state.tokens.push(lastParagraph);
|
---|
3561 | }
|
---|
3562 |
|
---|
3563 | state.tokens.push({
|
---|
3564 | type: 'footnote_close',
|
---|
3565 | level: --level
|
---|
3566 | });
|
---|
3567 | }
|
---|
3568 | state.tokens.push({
|
---|
3569 | type: 'footnote_block_close',
|
---|
3570 | level: --level
|
---|
3571 | });
|
---|
3572 | }
|
---|
3573 |
|
---|
3574 | // Enclose abbreviations in <abbr> tags
|
---|
3575 | //
|
---|
3576 |
|
---|
3577 | var PUNCT_CHARS = ' \n()[]\'".,!?-';
|
---|
3578 |
|
---|
3579 |
|
---|
3580 | // from Google closure library
|
---|
3581 | // http://closure-library.googlecode.com/git-history/docs/local_closure_goog_string_string.js.source.html#line1021
|
---|
3582 | function regEscape(s) {
|
---|
3583 | return s.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1');
|
---|
3584 | }
|
---|
3585 |
|
---|
3586 |
|
---|
3587 | function abbr2(state) {
|
---|
3588 | var i, j, l, tokens, token, text, nodes, pos, level, reg, m, regText,
|
---|
3589 | blockTokens = state.tokens;
|
---|
3590 |
|
---|
3591 | if (!state.env.abbreviations) { return; }
|
---|
3592 | if (!state.env.abbrRegExp) {
|
---|
3593 | regText = '(^|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])'
|
---|
3594 | + '(' + Object.keys(state.env.abbreviations).map(function (x) {
|
---|
3595 | return x.substr(1);
|
---|
3596 | }).sort(function (a, b) {
|
---|
3597 | return b.length - a.length;
|
---|
3598 | }).map(regEscape).join('|') + ')'
|
---|
3599 | + '($|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])';
|
---|
3600 | state.env.abbrRegExp = new RegExp(regText, 'g');
|
---|
3601 | }
|
---|
3602 | reg = state.env.abbrRegExp;
|
---|
3603 |
|
---|
3604 | for (j = 0, l = blockTokens.length; j < l; j++) {
|
---|
3605 | if (blockTokens[j].type !== 'inline') { continue; }
|
---|
3606 | tokens = blockTokens[j].children;
|
---|
3607 |
|
---|
3608 | // We scan from the end, to keep position when new tags added.
|
---|
3609 | for (i = tokens.length - 1; i >= 0; i--) {
|
---|
3610 | token = tokens[i];
|
---|
3611 | if (token.type !== 'text') { continue; }
|
---|
3612 |
|
---|
3613 | pos = 0;
|
---|
3614 | text = token.content;
|
---|
3615 | reg.lastIndex = 0;
|
---|
3616 | level = token.level;
|
---|
3617 | nodes = [];
|
---|
3618 |
|
---|
3619 | while ((m = reg.exec(text))) {
|
---|
3620 | if (reg.lastIndex > pos) {
|
---|
3621 | nodes.push({
|
---|
3622 | type: 'text',
|
---|
3623 | content: text.slice(pos, m.index + m[1].length),
|
---|
3624 | level: level
|
---|
3625 | });
|
---|
3626 | }
|
---|
3627 |
|
---|
3628 | nodes.push({
|
---|
3629 | type: 'abbr_open',
|
---|
3630 | title: state.env.abbreviations[':' + m[2]],
|
---|
3631 | level: level++
|
---|
3632 | });
|
---|
3633 | nodes.push({
|
---|
3634 | type: 'text',
|
---|
3635 | content: m[2],
|
---|
3636 | level: level
|
---|
3637 | });
|
---|
3638 | nodes.push({
|
---|
3639 | type: 'abbr_close',
|
---|
3640 | level: --level
|
---|
3641 | });
|
---|
3642 | pos = reg.lastIndex - m[3].length;
|
---|
3643 | }
|
---|
3644 |
|
---|
3645 | if (!nodes.length) { continue; }
|
---|
3646 |
|
---|
3647 | if (pos < text.length) {
|
---|
3648 | nodes.push({
|
---|
3649 | type: 'text',
|
---|
3650 | content: text.slice(pos),
|
---|
3651 | level: level
|
---|
3652 | });
|
---|
3653 | }
|
---|
3654 |
|
---|
3655 | // replace current node
|
---|
3656 | blockTokens[j].children = tokens = [].concat(tokens.slice(0, i), nodes, tokens.slice(i + 1));
|
---|
3657 | }
|
---|
3658 | }
|
---|
3659 | }
|
---|
3660 |
|
---|
3661 | // Simple typographical replacements
|
---|
3662 | //
|
---|
3663 | // TODO:
|
---|
3664 | // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
|
---|
3665 | // - miltiplication 2 x 4 -> 2 × 4
|
---|
3666 |
|
---|
3667 | var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
|
---|
3668 |
|
---|
3669 | var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;
|
---|
3670 | var SCOPED_ABBR = {
|
---|
3671 | 'c': '©',
|
---|
3672 | 'r': '®',
|
---|
3673 | 'p': '§',
|
---|
3674 | 'tm': '™'
|
---|
3675 | };
|
---|
3676 |
|
---|
3677 | function replaceScopedAbbr(str) {
|
---|
3678 | if (str.indexOf('(') < 0) { return str; }
|
---|
3679 |
|
---|
3680 | return str.replace(SCOPED_ABBR_RE, function(match, name) {
|
---|
3681 | return SCOPED_ABBR[name.toLowerCase()];
|
---|
3682 | });
|
---|
3683 | }
|
---|
3684 |
|
---|
3685 |
|
---|
3686 | function replace(state) {
|
---|
3687 | var i, token, text, inlineTokens, blkIdx;
|
---|
3688 |
|
---|
3689 | if (!state.options.typographer) { return; }
|
---|
3690 |
|
---|
3691 | for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
|
---|
3692 |
|
---|
3693 | if (state.tokens[blkIdx].type !== 'inline') { continue; }
|
---|
3694 |
|
---|
3695 | inlineTokens = state.tokens[blkIdx].children;
|
---|
3696 |
|
---|
3697 | for (i = inlineTokens.length - 1; i >= 0; i--) {
|
---|
3698 | token = inlineTokens[i];
|
---|
3699 | if (token.type === 'text') {
|
---|
3700 | text = token.content;
|
---|
3701 |
|
---|
3702 | text = replaceScopedAbbr(text);
|
---|
3703 |
|
---|
3704 | if (RARE_RE.test(text)) {
|
---|
3705 | text = text
|
---|
3706 | .replace(/\+-/g, '±')
|
---|
3707 | // .., ..., ....... -> …
|
---|
3708 | // but ?..... & !..... -> ?.. & !..
|
---|
3709 | .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
|
---|
3710 | .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
|
---|
3711 | // em-dash
|
---|
3712 | .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
|
---|
3713 | // en-dash
|
---|
3714 | .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
|
---|
3715 | .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
|
---|
3716 | }
|
---|
3717 |
|
---|
3718 | token.content = text;
|
---|
3719 | }
|
---|
3720 | }
|
---|
3721 | }
|
---|
3722 | }
|
---|
3723 |
|
---|
3724 | // Convert straight quotation marks to typographic ones
|
---|
3725 | //
|
---|
3726 |
|
---|
3727 | var QUOTE_TEST_RE = /['"]/;
|
---|
3728 | var QUOTE_RE = /['"]/g;
|
---|
3729 | var PUNCT_RE = /[-\s()\[\]]/;
|
---|
3730 | var APOSTROPHE = '’';
|
---|
3731 |
|
---|
3732 | // This function returns true if the character at `pos`
|
---|
3733 | // could be inside a word.
|
---|
3734 | function isLetter(str, pos) {
|
---|
3735 | if (pos < 0 || pos >= str.length) { return false; }
|
---|
3736 | return !PUNCT_RE.test(str[pos]);
|
---|
3737 | }
|
---|
3738 |
|
---|
3739 |
|
---|
3740 | function replaceAt(str, index, ch) {
|
---|
3741 | return str.substr(0, index) + ch + str.substr(index + 1);
|
---|
3742 | }
|
---|
3743 |
|
---|
3744 |
|
---|
3745 | function smartquotes(state) {
|
---|
3746 | /*eslint max-depth:0*/
|
---|
3747 | var i, token, text, t, pos, max, thisLevel, lastSpace, nextSpace, item,
|
---|
3748 | canOpen, canClose, j, isSingle, blkIdx, tokens,
|
---|
3749 | stack;
|
---|
3750 |
|
---|
3751 | if (!state.options.typographer) { return; }
|
---|
3752 |
|
---|
3753 | stack = [];
|
---|
3754 |
|
---|
3755 | for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
|
---|
3756 |
|
---|
3757 | if (state.tokens[blkIdx].type !== 'inline') { continue; }
|
---|
3758 |
|
---|
3759 | tokens = state.tokens[blkIdx].children;
|
---|
3760 | stack.length = 0;
|
---|
3761 |
|
---|
3762 | for (i = 0; i < tokens.length; i++) {
|
---|
3763 | token = tokens[i];
|
---|
3764 |
|
---|
3765 | if (token.type !== 'text' || QUOTE_TEST_RE.test(token.text)) { continue; }
|
---|
3766 |
|
---|
3767 | thisLevel = tokens[i].level;
|
---|
3768 |
|
---|
3769 | for (j = stack.length - 1; j >= 0; j--) {
|
---|
3770 | if (stack[j].level <= thisLevel) { break; }
|
---|
3771 | }
|
---|
3772 | stack.length = j + 1;
|
---|
3773 |
|
---|
3774 | text = token.content;
|
---|
3775 | pos = 0;
|
---|
3776 | max = text.length;
|
---|
3777 |
|
---|
3778 | /*eslint no-labels:0,block-scoped-var:0*/
|
---|
3779 | OUTER:
|
---|
3780 | while (pos < max) {
|
---|
3781 | QUOTE_RE.lastIndex = pos;
|
---|
3782 | t = QUOTE_RE.exec(text);
|
---|
3783 | if (!t) { break; }
|
---|
3784 |
|
---|
3785 | lastSpace = !isLetter(text, t.index - 1);
|
---|
3786 | pos = t.index + 1;
|
---|
3787 | isSingle = (t[0] === "'");
|
---|
3788 | nextSpace = !isLetter(text, pos);
|
---|
3789 |
|
---|
3790 | if (!nextSpace && !lastSpace) {
|
---|
3791 | // middle of word
|
---|
3792 | if (isSingle) {
|
---|
3793 | token.content = replaceAt(token.content, t.index, APOSTROPHE);
|
---|
3794 | }
|
---|
3795 | continue;
|
---|
3796 | }
|
---|
3797 |
|
---|
3798 | canOpen = !nextSpace;
|
---|
3799 | canClose = !lastSpace;
|
---|
3800 |
|
---|
3801 | if (canClose) {
|
---|
3802 | // this could be a closing quote, rewind the stack to get a match
|
---|
3803 | for (j = stack.length - 1; j >= 0; j--) {
|
---|
3804 | item = stack[j];
|
---|
3805 | if (stack[j].level < thisLevel) { break; }
|
---|
3806 | if (item.single === isSingle && stack[j].level === thisLevel) {
|
---|
3807 | item = stack[j];
|
---|
3808 | if (isSingle) {
|
---|
3809 | tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, state.options.quotes[2]);
|
---|
3810 | token.content = replaceAt(token.content, t.index, state.options.quotes[3]);
|
---|
3811 | } else {
|
---|
3812 | tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, state.options.quotes[0]);
|
---|
3813 | token.content = replaceAt(token.content, t.index, state.options.quotes[1]);
|
---|
3814 | }
|
---|
3815 | stack.length = j;
|
---|
3816 | continue OUTER;
|
---|
3817 | }
|
---|
3818 | }
|
---|
3819 | }
|
---|
3820 |
|
---|
3821 | if (canOpen) {
|
---|
3822 | stack.push({
|
---|
3823 | token: i,
|
---|
3824 | pos: t.index,
|
---|
3825 | single: isSingle,
|
---|
3826 | level: thisLevel
|
---|
3827 | });
|
---|
3828 | } else if (canClose && isSingle) {
|
---|
3829 | token.content = replaceAt(token.content, t.index, APOSTROPHE);
|
---|
3830 | }
|
---|
3831 | }
|
---|
3832 | }
|
---|
3833 | }
|
---|
3834 | }
|
---|
3835 |
|
---|
3836 | /**
|
---|
3837 | * Core parser `rules`
|
---|
3838 | */
|
---|
3839 |
|
---|
3840 | var _rules = [
|
---|
3841 | [ 'block', block ],
|
---|
3842 | [ 'abbr', abbr ],
|
---|
3843 | [ 'references', references ],
|
---|
3844 | [ 'inline', inline ],
|
---|
3845 | [ 'footnote_tail', footnote_block ],
|
---|
3846 | [ 'abbr2', abbr2 ],
|
---|
3847 | [ 'replacements', replace ],
|
---|
3848 | [ 'smartquotes', smartquotes ],
|
---|
3849 | ];
|
---|
3850 |
|
---|
3851 | /**
|
---|
3852 | * Class for top level (`core`) parser rules
|
---|
3853 | *
|
---|
3854 | * @api private
|
---|
3855 | */
|
---|
3856 |
|
---|
3857 | function Core() {
|
---|
3858 | this.options = {};
|
---|
3859 | this.ruler = new Ruler();
|
---|
3860 | for (var i = 0; i < _rules.length; i++) {
|
---|
3861 | this.ruler.push(_rules[i][0], _rules[i][1]);
|
---|
3862 | }
|
---|
3863 | }
|
---|
3864 |
|
---|
3865 | /**
|
---|
3866 | * Process rules with the given `state`
|
---|
3867 | *
|
---|
3868 | * @param {Object} `state`
|
---|
3869 | * @api private
|
---|
3870 | */
|
---|
3871 |
|
---|
3872 | Core.prototype.process = function (state) {
|
---|
3873 | var i, l, rules;
|
---|
3874 | rules = this.ruler.getRules('');
|
---|
3875 | for (i = 0, l = rules.length; i < l; i++) {
|
---|
3876 | rules[i](state);
|
---|
3877 | }
|
---|
3878 | };
|
---|
3879 |
|
---|
3880 | // Parser state class
|
---|
3881 |
|
---|
3882 | function StateBlock(src, parser, options, env, tokens) {
|
---|
3883 | var ch, s, start, pos, len, indent, indent_found;
|
---|
3884 |
|
---|
3885 | this.src = src;
|
---|
3886 |
|
---|
3887 | // Shortcuts to simplify nested calls
|
---|
3888 | this.parser = parser;
|
---|
3889 |
|
---|
3890 | this.options = options;
|
---|
3891 |
|
---|
3892 | this.env = env;
|
---|
3893 |
|
---|
3894 | //
|
---|
3895 | // Internal state vartiables
|
---|
3896 | //
|
---|
3897 |
|
---|
3898 | this.tokens = tokens;
|
---|
3899 |
|
---|
3900 | this.bMarks = []; // line begin offsets for fast jumps
|
---|
3901 | this.eMarks = []; // line end offsets for fast jumps
|
---|
3902 | this.tShift = []; // indent for each line
|
---|
3903 |
|
---|
3904 | // block parser variables
|
---|
3905 | this.blkIndent = 0; // required block content indent
|
---|
3906 | // (for example, if we are in list)
|
---|
3907 | this.line = 0; // line index in src
|
---|
3908 | this.lineMax = 0; // lines count
|
---|
3909 | this.tight = false; // loose/tight mode for lists
|
---|
3910 | this.parentType = 'root'; // if `list`, block parser stops on two newlines
|
---|
3911 | this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
|
---|
3912 |
|
---|
3913 | this.level = 0;
|
---|
3914 |
|
---|
3915 | // renderer
|
---|
3916 | this.result = '';
|
---|
3917 |
|
---|
3918 | // Create caches
|
---|
3919 | // Generate markers.
|
---|
3920 | s = this.src;
|
---|
3921 | indent = 0;
|
---|
3922 | indent_found = false;
|
---|
3923 |
|
---|
3924 | for (start = pos = indent = 0, len = s.length; pos < len; pos++) {
|
---|
3925 | ch = s.charCodeAt(pos);
|
---|
3926 |
|
---|
3927 | if (!indent_found) {
|
---|
3928 | if (ch === 0x20/* space */) {
|
---|
3929 | indent++;
|
---|
3930 | continue;
|
---|
3931 | } else {
|
---|
3932 | indent_found = true;
|
---|
3933 | }
|
---|
3934 | }
|
---|
3935 |
|
---|
3936 | if (ch === 0x0A || pos === len - 1) {
|
---|
3937 | if (ch !== 0x0A) { pos++; }
|
---|
3938 | this.bMarks.push(start);
|
---|
3939 | this.eMarks.push(pos);
|
---|
3940 | this.tShift.push(indent);
|
---|
3941 |
|
---|
3942 | indent_found = false;
|
---|
3943 | indent = 0;
|
---|
3944 | start = pos + 1;
|
---|
3945 | }
|
---|
3946 | }
|
---|
3947 |
|
---|
3948 | // Push fake entry to simplify cache bounds checks
|
---|
3949 | this.bMarks.push(s.length);
|
---|
3950 | this.eMarks.push(s.length);
|
---|
3951 | this.tShift.push(0);
|
---|
3952 |
|
---|
3953 | this.lineMax = this.bMarks.length - 1; // don't count last fake line
|
---|
3954 | }
|
---|
3955 |
|
---|
3956 | StateBlock.prototype.isEmpty = function isEmpty(line) {
|
---|
3957 | return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
|
---|
3958 | };
|
---|
3959 |
|
---|
3960 | StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
|
---|
3961 | for (var max = this.lineMax; from < max; from++) {
|
---|
3962 | if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
|
---|
3963 | break;
|
---|
3964 | }
|
---|
3965 | }
|
---|
3966 | return from;
|
---|
3967 | };
|
---|
3968 |
|
---|
3969 | // Skip spaces from given position.
|
---|
3970 | StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
|
---|
3971 | for (var max = this.src.length; pos < max; pos++) {
|
---|
3972 | if (this.src.charCodeAt(pos) !== 0x20/* space */) { break; }
|
---|
3973 | }
|
---|
3974 | return pos;
|
---|
3975 | };
|
---|
3976 |
|
---|
3977 | // Skip char codes from given position
|
---|
3978 | StateBlock.prototype.skipChars = function skipChars(pos, code) {
|
---|
3979 | for (var max = this.src.length; pos < max; pos++) {
|
---|
3980 | if (this.src.charCodeAt(pos) !== code) { break; }
|
---|
3981 | }
|
---|
3982 | return pos;
|
---|
3983 | };
|
---|
3984 |
|
---|
3985 | // Skip char codes reverse from given position - 1
|
---|
3986 | StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
|
---|
3987 | if (pos <= min) { return pos; }
|
---|
3988 |
|
---|
3989 | while (pos > min) {
|
---|
3990 | if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
|
---|
3991 | }
|
---|
3992 | return pos;
|
---|
3993 | };
|
---|
3994 |
|
---|
3995 | // cut lines range from source.
|
---|
3996 | StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
|
---|
3997 | var i, first, last, queue, shift,
|
---|
3998 | line = begin;
|
---|
3999 |
|
---|
4000 | if (begin >= end) {
|
---|
4001 | return '';
|
---|
4002 | }
|
---|
4003 |
|
---|
4004 | // Opt: don't use push queue for single line;
|
---|
4005 | if (line + 1 === end) {
|
---|
4006 | first = this.bMarks[line] + Math.min(this.tShift[line], indent);
|
---|
4007 | last = keepLastLF ? this.eMarks[line] + 1 : this.eMarks[line];
|
---|
4008 | return this.src.slice(first, last);
|
---|
4009 | }
|
---|
4010 |
|
---|
4011 | queue = new Array(end - begin);
|
---|
4012 |
|
---|
4013 | for (i = 0; line < end; line++, i++) {
|
---|
4014 | shift = this.tShift[line];
|
---|
4015 | if (shift > indent) { shift = indent; }
|
---|
4016 | if (shift < 0) { shift = 0; }
|
---|
4017 |
|
---|
4018 | first = this.bMarks[line] + shift;
|
---|
4019 |
|
---|
4020 | if (line + 1 < end || keepLastLF) {
|
---|
4021 | // No need for bounds check because we have fake entry on tail.
|
---|
4022 | last = this.eMarks[line] + 1;
|
---|
4023 | } else {
|
---|
4024 | last = this.eMarks[line];
|
---|
4025 | }
|
---|
4026 |
|
---|
4027 | queue[i] = this.src.slice(first, last);
|
---|
4028 | }
|
---|
4029 |
|
---|
4030 | return queue.join('');
|
---|
4031 | };
|
---|
4032 |
|
---|
4033 | // Code block (4 spaces padded)
|
---|
4034 |
|
---|
4035 | function code(state, startLine, endLine/*, silent*/) {
|
---|
4036 | var nextLine, last;
|
---|
4037 |
|
---|
4038 | if (state.tShift[startLine] - state.blkIndent < 4) { return false; }
|
---|
4039 |
|
---|
4040 | last = nextLine = startLine + 1;
|
---|
4041 |
|
---|
4042 | while (nextLine < endLine) {
|
---|
4043 | if (state.isEmpty(nextLine)) {
|
---|
4044 | nextLine++;
|
---|
4045 | continue;
|
---|
4046 | }
|
---|
4047 | if (state.tShift[nextLine] - state.blkIndent >= 4) {
|
---|
4048 | nextLine++;
|
---|
4049 | last = nextLine;
|
---|
4050 | continue;
|
---|
4051 | }
|
---|
4052 | break;
|
---|
4053 | }
|
---|
4054 |
|
---|
4055 | state.line = nextLine;
|
---|
4056 | state.tokens.push({
|
---|
4057 | type: 'code',
|
---|
4058 | content: state.getLines(startLine, last, 4 + state.blkIndent, true),
|
---|
4059 | block: true,
|
---|
4060 | lines: [ startLine, state.line ],
|
---|
4061 | level: state.level
|
---|
4062 | });
|
---|
4063 |
|
---|
4064 | return true;
|
---|
4065 | }
|
---|
4066 |
|
---|
4067 | // fences (``` lang, ~~~ lang)
|
---|
4068 |
|
---|
4069 | function fences(state, startLine, endLine, silent) {
|
---|
4070 | var marker, len, params, nextLine, mem,
|
---|
4071 | haveEndMarker = false,
|
---|
4072 | pos = state.bMarks[startLine] + state.tShift[startLine],
|
---|
4073 | max = state.eMarks[startLine];
|
---|
4074 |
|
---|
4075 | if (pos + 3 > max) { return false; }
|
---|
4076 |
|
---|
4077 | marker = state.src.charCodeAt(pos);
|
---|
4078 |
|
---|
4079 | if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
|
---|
4080 | return false;
|
---|
4081 | }
|
---|
4082 |
|
---|
4083 | // scan marker length
|
---|
4084 | mem = pos;
|
---|
4085 | pos = state.skipChars(pos, marker);
|
---|
4086 |
|
---|
4087 | len = pos - mem;
|
---|
4088 |
|
---|
4089 | if (len < 3) { return false; }
|
---|
4090 |
|
---|
4091 | params = state.src.slice(pos, max).trim();
|
---|
4092 |
|
---|
4093 | if (params.indexOf('`') >= 0) { return false; }
|
---|
4094 |
|
---|
4095 | // Since start is found, we can report success here in validation mode
|
---|
4096 | if (silent) { return true; }
|
---|
4097 |
|
---|
4098 | // search end of block
|
---|
4099 | nextLine = startLine;
|
---|
4100 |
|
---|
4101 | for (;;) {
|
---|
4102 | nextLine++;
|
---|
4103 | if (nextLine >= endLine) {
|
---|
4104 | // unclosed block should be autoclosed by end of document.
|
---|
4105 | // also block seems to be autoclosed by end of parent
|
---|
4106 | break;
|
---|
4107 | }
|
---|
4108 |
|
---|
4109 | pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
|
---|
4110 | max = state.eMarks[nextLine];
|
---|
4111 |
|
---|
4112 | if (pos < max && state.tShift[nextLine] < state.blkIndent) {
|
---|
4113 | // non-empty line with negative indent should stop the list:
|
---|
4114 | // - ```
|
---|
4115 | // test
|
---|
4116 | break;
|
---|
4117 | }
|
---|
4118 |
|
---|
4119 | if (state.src.charCodeAt(pos) !== marker) { continue; }
|
---|
4120 |
|
---|
4121 | if (state.tShift[nextLine] - state.blkIndent >= 4) {
|
---|
4122 | // closing fence should be indented less than 4 spaces
|
---|
4123 | continue;
|
---|
4124 | }
|
---|
4125 |
|
---|
4126 | pos = state.skipChars(pos, marker);
|
---|
4127 |
|
---|
4128 | // closing code fence must be at least as long as the opening one
|
---|
4129 | if (pos - mem < len) { continue; }
|
---|
4130 |
|
---|
4131 | // make sure tail has spaces only
|
---|
4132 | pos = state.skipSpaces(pos);
|
---|
4133 |
|
---|
4134 | if (pos < max) { continue; }
|
---|
4135 |
|
---|
4136 | haveEndMarker = true;
|
---|
4137 | // found!
|
---|
4138 | break;
|
---|
4139 | }
|
---|
4140 |
|
---|
4141 | // If a fence has heading spaces, they should be removed from its inner block
|
---|
4142 | len = state.tShift[startLine];
|
---|
4143 |
|
---|
4144 | state.line = nextLine + (haveEndMarker ? 1 : 0);
|
---|
4145 | state.tokens.push({
|
---|
4146 | type: 'fence',
|
---|
4147 | params: params,
|
---|
4148 | content: state.getLines(startLine + 1, nextLine, len, true),
|
---|
4149 | lines: [ startLine, state.line ],
|
---|
4150 | level: state.level
|
---|
4151 | });
|
---|
4152 |
|
---|
4153 | return true;
|
---|
4154 | }
|
---|
4155 |
|
---|
4156 | // Block quotes
|
---|
4157 |
|
---|
4158 | function blockquote(state, startLine, endLine, silent) {
|
---|
4159 | var nextLine, lastLineEmpty, oldTShift, oldBMarks, oldIndent, oldParentType, lines,
|
---|
4160 | terminatorRules,
|
---|
4161 | i, l, terminate,
|
---|
4162 | pos = state.bMarks[startLine] + state.tShift[startLine],
|
---|
4163 | max = state.eMarks[startLine];
|
---|
4164 |
|
---|
4165 | if (pos > max) { return false; }
|
---|
4166 |
|
---|
4167 | // check the block quote marker
|
---|
4168 | if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
|
---|
4169 |
|
---|
4170 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
4171 |
|
---|
4172 | // we know that it's going to be a valid blockquote,
|
---|
4173 | // so no point trying to find the end of it in silent mode
|
---|
4174 | if (silent) { return true; }
|
---|
4175 |
|
---|
4176 | // skip one optional space after '>'
|
---|
4177 | if (state.src.charCodeAt(pos) === 0x20) { pos++; }
|
---|
4178 |
|
---|
4179 | oldIndent = state.blkIndent;
|
---|
4180 | state.blkIndent = 0;
|
---|
4181 |
|
---|
4182 | oldBMarks = [ state.bMarks[startLine] ];
|
---|
4183 | state.bMarks[startLine] = pos;
|
---|
4184 |
|
---|
4185 | // check if we have an empty blockquote
|
---|
4186 | pos = pos < max ? state.skipSpaces(pos) : pos;
|
---|
4187 | lastLineEmpty = pos >= max;
|
---|
4188 |
|
---|
4189 | oldTShift = [ state.tShift[startLine] ];
|
---|
4190 | state.tShift[startLine] = pos - state.bMarks[startLine];
|
---|
4191 |
|
---|
4192 | terminatorRules = state.parser.ruler.getRules('blockquote');
|
---|
4193 |
|
---|
4194 | // Search the end of the block
|
---|
4195 | //
|
---|
4196 | // Block ends with either:
|
---|
4197 | // 1. an empty line outside:
|
---|
4198 | // ```
|
---|
4199 | // > test
|
---|
4200 | //
|
---|
4201 | // ```
|
---|
4202 | // 2. an empty line inside:
|
---|
4203 | // ```
|
---|
4204 | // >
|
---|
4205 | // test
|
---|
4206 | // ```
|
---|
4207 | // 3. another tag
|
---|
4208 | // ```
|
---|
4209 | // > test
|
---|
4210 | // - - -
|
---|
4211 | // ```
|
---|
4212 | for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
|
---|
4213 | pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
---|
4214 | max = state.eMarks[nextLine];
|
---|
4215 |
|
---|
4216 | if (pos >= max) {
|
---|
4217 | // Case 1: line is not inside the blockquote, and this line is empty.
|
---|
4218 | break;
|
---|
4219 | }
|
---|
4220 |
|
---|
4221 | if (state.src.charCodeAt(pos++) === 0x3E/* > */) {
|
---|
4222 | // This line is inside the blockquote.
|
---|
4223 |
|
---|
4224 | // skip one optional space after '>'
|
---|
4225 | if (state.src.charCodeAt(pos) === 0x20) { pos++; }
|
---|
4226 |
|
---|
4227 | oldBMarks.push(state.bMarks[nextLine]);
|
---|
4228 | state.bMarks[nextLine] = pos;
|
---|
4229 |
|
---|
4230 | pos = pos < max ? state.skipSpaces(pos) : pos;
|
---|
4231 | lastLineEmpty = pos >= max;
|
---|
4232 |
|
---|
4233 | oldTShift.push(state.tShift[nextLine]);
|
---|
4234 | state.tShift[nextLine] = pos - state.bMarks[nextLine];
|
---|
4235 | continue;
|
---|
4236 | }
|
---|
4237 |
|
---|
4238 | // Case 2: line is not inside the blockquote, and the last line was empty.
|
---|
4239 | if (lastLineEmpty) { break; }
|
---|
4240 |
|
---|
4241 | // Case 3: another tag found.
|
---|
4242 | terminate = false;
|
---|
4243 | for (i = 0, l = terminatorRules.length; i < l; i++) {
|
---|
4244 | if (terminatorRules[i](state, nextLine, endLine, true)) {
|
---|
4245 | terminate = true;
|
---|
4246 | break;
|
---|
4247 | }
|
---|
4248 | }
|
---|
4249 | if (terminate) { break; }
|
---|
4250 |
|
---|
4251 | oldBMarks.push(state.bMarks[nextLine]);
|
---|
4252 | oldTShift.push(state.tShift[nextLine]);
|
---|
4253 |
|
---|
4254 | // A negative number means that this is a paragraph continuation;
|
---|
4255 | //
|
---|
4256 | // Any negative number will do the job here, but it's better for it
|
---|
4257 | // to be large enough to make any bugs obvious.
|
---|
4258 | state.tShift[nextLine] = -1337;
|
---|
4259 | }
|
---|
4260 |
|
---|
4261 | oldParentType = state.parentType;
|
---|
4262 | state.parentType = 'blockquote';
|
---|
4263 | state.tokens.push({
|
---|
4264 | type: 'blockquote_open',
|
---|
4265 | lines: lines = [ startLine, 0 ],
|
---|
4266 | level: state.level++
|
---|
4267 | });
|
---|
4268 | state.parser.tokenize(state, startLine, nextLine);
|
---|
4269 | state.tokens.push({
|
---|
4270 | type: 'blockquote_close',
|
---|
4271 | level: --state.level
|
---|
4272 | });
|
---|
4273 | state.parentType = oldParentType;
|
---|
4274 | lines[1] = state.line;
|
---|
4275 |
|
---|
4276 | // Restore original tShift; this might not be necessary since the parser
|
---|
4277 | // has already been here, but just to make sure we can do that.
|
---|
4278 | for (i = 0; i < oldTShift.length; i++) {
|
---|
4279 | state.bMarks[i + startLine] = oldBMarks[i];
|
---|
4280 | state.tShift[i + startLine] = oldTShift[i];
|
---|
4281 | }
|
---|
4282 | state.blkIndent = oldIndent;
|
---|
4283 |
|
---|
4284 | return true;
|
---|
4285 | }
|
---|
4286 |
|
---|
4287 | // Horizontal rule
|
---|
4288 |
|
---|
4289 | function hr(state, startLine, endLine, silent) {
|
---|
4290 | var marker, cnt, ch,
|
---|
4291 | pos = state.bMarks[startLine],
|
---|
4292 | max = state.eMarks[startLine];
|
---|
4293 |
|
---|
4294 | pos += state.tShift[startLine];
|
---|
4295 |
|
---|
4296 | if (pos > max) { return false; }
|
---|
4297 |
|
---|
4298 | marker = state.src.charCodeAt(pos++);
|
---|
4299 |
|
---|
4300 | // Check hr marker
|
---|
4301 | if (marker !== 0x2A/* * */ &&
|
---|
4302 | marker !== 0x2D/* - */ &&
|
---|
4303 | marker !== 0x5F/* _ */) {
|
---|
4304 | return false;
|
---|
4305 | }
|
---|
4306 |
|
---|
4307 | // markers can be mixed with spaces, but there should be at least 3 one
|
---|
4308 |
|
---|
4309 | cnt = 1;
|
---|
4310 | while (pos < max) {
|
---|
4311 | ch = state.src.charCodeAt(pos++);
|
---|
4312 | if (ch !== marker && ch !== 0x20/* space */) { return false; }
|
---|
4313 | if (ch === marker) { cnt++; }
|
---|
4314 | }
|
---|
4315 |
|
---|
4316 | if (cnt < 3) { return false; }
|
---|
4317 |
|
---|
4318 | if (silent) { return true; }
|
---|
4319 |
|
---|
4320 | state.line = startLine + 1;
|
---|
4321 | state.tokens.push({
|
---|
4322 | type: 'hr',
|
---|
4323 | lines: [ startLine, state.line ],
|
---|
4324 | level: state.level
|
---|
4325 | });
|
---|
4326 |
|
---|
4327 | return true;
|
---|
4328 | }
|
---|
4329 |
|
---|
4330 | // Lists
|
---|
4331 |
|
---|
4332 | // Search `[-+*][\n ]`, returns next pos arter marker on success
|
---|
4333 | // or -1 on fail.
|
---|
4334 | function skipBulletListMarker(state, startLine) {
|
---|
4335 | var marker, pos, max;
|
---|
4336 |
|
---|
4337 | pos = state.bMarks[startLine] + state.tShift[startLine];
|
---|
4338 | max = state.eMarks[startLine];
|
---|
4339 |
|
---|
4340 | if (pos >= max) { return -1; }
|
---|
4341 |
|
---|
4342 | marker = state.src.charCodeAt(pos++);
|
---|
4343 | // Check bullet
|
---|
4344 | if (marker !== 0x2A/* * */ &&
|
---|
4345 | marker !== 0x2D/* - */ &&
|
---|
4346 | marker !== 0x2B/* + */) {
|
---|
4347 | return -1;
|
---|
4348 | }
|
---|
4349 |
|
---|
4350 | if (pos < max && state.src.charCodeAt(pos) !== 0x20) {
|
---|
4351 | // " 1.test " - is not a list item
|
---|
4352 | return -1;
|
---|
4353 | }
|
---|
4354 |
|
---|
4355 | return pos;
|
---|
4356 | }
|
---|
4357 |
|
---|
4358 | // Search `\d+[.)][\n ]`, returns next pos arter marker on success
|
---|
4359 | // or -1 on fail.
|
---|
4360 | function skipOrderedListMarker(state, startLine) {
|
---|
4361 | var ch,
|
---|
4362 | pos = state.bMarks[startLine] + state.tShift[startLine],
|
---|
4363 | max = state.eMarks[startLine];
|
---|
4364 |
|
---|
4365 | if (pos + 1 >= max) { return -1; }
|
---|
4366 |
|
---|
4367 | ch = state.src.charCodeAt(pos++);
|
---|
4368 |
|
---|
4369 | if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
|
---|
4370 |
|
---|
4371 | for (;;) {
|
---|
4372 | // EOL -> fail
|
---|
4373 | if (pos >= max) { return -1; }
|
---|
4374 |
|
---|
4375 | ch = state.src.charCodeAt(pos++);
|
---|
4376 |
|
---|
4377 | if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
|
---|
4378 | continue;
|
---|
4379 | }
|
---|
4380 |
|
---|
4381 | // found valid marker
|
---|
4382 | if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
|
---|
4383 | break;
|
---|
4384 | }
|
---|
4385 |
|
---|
4386 | return -1;
|
---|
4387 | }
|
---|
4388 |
|
---|
4389 |
|
---|
4390 | if (pos < max && state.src.charCodeAt(pos) !== 0x20/* space */) {
|
---|
4391 | // " 1.test " - is not a list item
|
---|
4392 | return -1;
|
---|
4393 | }
|
---|
4394 | return pos;
|
---|
4395 | }
|
---|
4396 |
|
---|
4397 | function markTightParagraphs(state, idx) {
|
---|
4398 | var i, l,
|
---|
4399 | level = state.level + 2;
|
---|
4400 |
|
---|
4401 | for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
|
---|
4402 | if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
|
---|
4403 | state.tokens[i + 2].tight = true;
|
---|
4404 | state.tokens[i].tight = true;
|
---|
4405 | i += 2;
|
---|
4406 | }
|
---|
4407 | }
|
---|
4408 | }
|
---|
4409 |
|
---|
4410 |
|
---|
4411 | function list(state, startLine, endLine, silent) {
|
---|
4412 | var nextLine,
|
---|
4413 | indent,
|
---|
4414 | oldTShift,
|
---|
4415 | oldIndent,
|
---|
4416 | oldTight,
|
---|
4417 | oldParentType,
|
---|
4418 | start,
|
---|
4419 | posAfterMarker,
|
---|
4420 | max,
|
---|
4421 | indentAfterMarker,
|
---|
4422 | markerValue,
|
---|
4423 | markerCharCode,
|
---|
4424 | isOrdered,
|
---|
4425 | contentStart,
|
---|
4426 | listTokIdx,
|
---|
4427 | prevEmptyEnd,
|
---|
4428 | listLines,
|
---|
4429 | itemLines,
|
---|
4430 | tight = true,
|
---|
4431 | terminatorRules,
|
---|
4432 | i, l, terminate;
|
---|
4433 |
|
---|
4434 | // Detect list type and position after marker
|
---|
4435 | if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
|
---|
4436 | isOrdered = true;
|
---|
4437 | } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
|
---|
4438 | isOrdered = false;
|
---|
4439 | } else {
|
---|
4440 | return false;
|
---|
4441 | }
|
---|
4442 |
|
---|
4443 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
4444 |
|
---|
4445 | // We should terminate list on style change. Remember first one to compare.
|
---|
4446 | markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
|
---|
4447 |
|
---|
4448 | // For validation mode we can terminate immediately
|
---|
4449 | if (silent) { return true; }
|
---|
4450 |
|
---|
4451 | // Start list
|
---|
4452 | listTokIdx = state.tokens.length;
|
---|
4453 |
|
---|
4454 | if (isOrdered) {
|
---|
4455 | start = state.bMarks[startLine] + state.tShift[startLine];
|
---|
4456 | markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
|
---|
4457 |
|
---|
4458 | state.tokens.push({
|
---|
4459 | type: 'ordered_list_open',
|
---|
4460 | order: markerValue,
|
---|
4461 | lines: listLines = [ startLine, 0 ],
|
---|
4462 | level: state.level++
|
---|
4463 | });
|
---|
4464 |
|
---|
4465 | } else {
|
---|
4466 | state.tokens.push({
|
---|
4467 | type: 'bullet_list_open',
|
---|
4468 | lines: listLines = [ startLine, 0 ],
|
---|
4469 | level: state.level++
|
---|
4470 | });
|
---|
4471 | }
|
---|
4472 |
|
---|
4473 | //
|
---|
4474 | // Iterate list items
|
---|
4475 | //
|
---|
4476 |
|
---|
4477 | nextLine = startLine;
|
---|
4478 | prevEmptyEnd = false;
|
---|
4479 | terminatorRules = state.parser.ruler.getRules('list');
|
---|
4480 |
|
---|
4481 | while (nextLine < endLine) {
|
---|
4482 | contentStart = state.skipSpaces(posAfterMarker);
|
---|
4483 | max = state.eMarks[nextLine];
|
---|
4484 |
|
---|
4485 | if (contentStart >= max) {
|
---|
4486 | // trimming space in "- \n 3" case, indent is 1 here
|
---|
4487 | indentAfterMarker = 1;
|
---|
4488 | } else {
|
---|
4489 | indentAfterMarker = contentStart - posAfterMarker;
|
---|
4490 | }
|
---|
4491 |
|
---|
4492 | // If we have more than 4 spaces, the indent is 1
|
---|
4493 | // (the rest is just indented code block)
|
---|
4494 | if (indentAfterMarker > 4) { indentAfterMarker = 1; }
|
---|
4495 |
|
---|
4496 | // If indent is less than 1, assume that it's one, example:
|
---|
4497 | // "-\n test"
|
---|
4498 | if (indentAfterMarker < 1) { indentAfterMarker = 1; }
|
---|
4499 |
|
---|
4500 | // " - test"
|
---|
4501 | // ^^^^^ - calculating total length of this thing
|
---|
4502 | indent = (posAfterMarker - state.bMarks[nextLine]) + indentAfterMarker;
|
---|
4503 |
|
---|
4504 | // Run subparser & write tokens
|
---|
4505 | state.tokens.push({
|
---|
4506 | type: 'list_item_open',
|
---|
4507 | lines: itemLines = [ startLine, 0 ],
|
---|
4508 | level: state.level++
|
---|
4509 | });
|
---|
4510 |
|
---|
4511 | oldIndent = state.blkIndent;
|
---|
4512 | oldTight = state.tight;
|
---|
4513 | oldTShift = state.tShift[startLine];
|
---|
4514 | oldParentType = state.parentType;
|
---|
4515 | state.tShift[startLine] = contentStart - state.bMarks[startLine];
|
---|
4516 | state.blkIndent = indent;
|
---|
4517 | state.tight = true;
|
---|
4518 | state.parentType = 'list';
|
---|
4519 |
|
---|
4520 | state.parser.tokenize(state, startLine, endLine, true);
|
---|
4521 |
|
---|
4522 | // If any of list item is tight, mark list as tight
|
---|
4523 | if (!state.tight || prevEmptyEnd) {
|
---|
4524 | tight = false;
|
---|
4525 | }
|
---|
4526 | // Item become loose if finish with empty line,
|
---|
4527 | // but we should filter last element, because it means list finish
|
---|
4528 | prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);
|
---|
4529 |
|
---|
4530 | state.blkIndent = oldIndent;
|
---|
4531 | state.tShift[startLine] = oldTShift;
|
---|
4532 | state.tight = oldTight;
|
---|
4533 | state.parentType = oldParentType;
|
---|
4534 |
|
---|
4535 | state.tokens.push({
|
---|
4536 | type: 'list_item_close',
|
---|
4537 | level: --state.level
|
---|
4538 | });
|
---|
4539 |
|
---|
4540 | nextLine = startLine = state.line;
|
---|
4541 | itemLines[1] = nextLine;
|
---|
4542 | contentStart = state.bMarks[startLine];
|
---|
4543 |
|
---|
4544 | if (nextLine >= endLine) { break; }
|
---|
4545 |
|
---|
4546 | if (state.isEmpty(nextLine)) {
|
---|
4547 | break;
|
---|
4548 | }
|
---|
4549 |
|
---|
4550 | //
|
---|
4551 | // Try to check if list is terminated or continued.
|
---|
4552 | //
|
---|
4553 | if (state.tShift[nextLine] < state.blkIndent) { break; }
|
---|
4554 |
|
---|
4555 | // fail if terminating block found
|
---|
4556 | terminate = false;
|
---|
4557 | for (i = 0, l = terminatorRules.length; i < l; i++) {
|
---|
4558 | if (terminatorRules[i](state, nextLine, endLine, true)) {
|
---|
4559 | terminate = true;
|
---|
4560 | break;
|
---|
4561 | }
|
---|
4562 | }
|
---|
4563 | if (terminate) { break; }
|
---|
4564 |
|
---|
4565 | // fail if list has another type
|
---|
4566 | if (isOrdered) {
|
---|
4567 | posAfterMarker = skipOrderedListMarker(state, nextLine);
|
---|
4568 | if (posAfterMarker < 0) { break; }
|
---|
4569 | } else {
|
---|
4570 | posAfterMarker = skipBulletListMarker(state, nextLine);
|
---|
4571 | if (posAfterMarker < 0) { break; }
|
---|
4572 | }
|
---|
4573 |
|
---|
4574 | if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
|
---|
4575 | }
|
---|
4576 |
|
---|
4577 | // Finilize list
|
---|
4578 | state.tokens.push({
|
---|
4579 | type: isOrdered ? 'ordered_list_close' : 'bullet_list_close',
|
---|
4580 | level: --state.level
|
---|
4581 | });
|
---|
4582 | listLines[1] = nextLine;
|
---|
4583 |
|
---|
4584 | state.line = nextLine;
|
---|
4585 |
|
---|
4586 | // mark paragraphs tight if needed
|
---|
4587 | if (tight) {
|
---|
4588 | markTightParagraphs(state, listTokIdx);
|
---|
4589 | }
|
---|
4590 |
|
---|
4591 | return true;
|
---|
4592 | }
|
---|
4593 |
|
---|
4594 | // Process footnote reference list
|
---|
4595 |
|
---|
4596 | function footnote(state, startLine, endLine, silent) {
|
---|
4597 | var oldBMark, oldTShift, oldParentType, pos, label,
|
---|
4598 | start = state.bMarks[startLine] + state.tShift[startLine],
|
---|
4599 | max = state.eMarks[startLine];
|
---|
4600 |
|
---|
4601 | // line should be at least 5 chars - "[^x]:"
|
---|
4602 | if (start + 4 > max) { return false; }
|
---|
4603 |
|
---|
4604 | if (state.src.charCodeAt(start) !== 0x5B/* [ */) { return false; }
|
---|
4605 | if (state.src.charCodeAt(start + 1) !== 0x5E/* ^ */) { return false; }
|
---|
4606 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
4607 |
|
---|
4608 | for (pos = start + 2; pos < max; pos++) {
|
---|
4609 | if (state.src.charCodeAt(pos) === 0x20) { return false; }
|
---|
4610 | if (state.src.charCodeAt(pos) === 0x5D /* ] */) {
|
---|
4611 | break;
|
---|
4612 | }
|
---|
4613 | }
|
---|
4614 |
|
---|
4615 | if (pos === start + 2) { return false; } // no empty footnote labels
|
---|
4616 | if (pos + 1 >= max || state.src.charCodeAt(++pos) !== 0x3A /* : */) { return false; }
|
---|
4617 | if (silent) { return true; }
|
---|
4618 | pos++;
|
---|
4619 |
|
---|
4620 | if (!state.env.footnotes) { state.env.footnotes = {}; }
|
---|
4621 | if (!state.env.footnotes.refs) { state.env.footnotes.refs = {}; }
|
---|
4622 | label = state.src.slice(start + 2, pos - 2);
|
---|
4623 | state.env.footnotes.refs[':' + label] = -1;
|
---|
4624 |
|
---|
4625 | state.tokens.push({
|
---|
4626 | type: 'footnote_reference_open',
|
---|
4627 | label: label,
|
---|
4628 | level: state.level++
|
---|
4629 | });
|
---|
4630 |
|
---|
4631 | oldBMark = state.bMarks[startLine];
|
---|
4632 | oldTShift = state.tShift[startLine];
|
---|
4633 | oldParentType = state.parentType;
|
---|
4634 | state.tShift[startLine] = state.skipSpaces(pos) - pos;
|
---|
4635 | state.bMarks[startLine] = pos;
|
---|
4636 | state.blkIndent += 4;
|
---|
4637 | state.parentType = 'footnote';
|
---|
4638 |
|
---|
4639 | if (state.tShift[startLine] < state.blkIndent) {
|
---|
4640 | state.tShift[startLine] += state.blkIndent;
|
---|
4641 | state.bMarks[startLine] -= state.blkIndent;
|
---|
4642 | }
|
---|
4643 |
|
---|
4644 | state.parser.tokenize(state, startLine, endLine, true);
|
---|
4645 |
|
---|
4646 | state.parentType = oldParentType;
|
---|
4647 | state.blkIndent -= 4;
|
---|
4648 | state.tShift[startLine] = oldTShift;
|
---|
4649 | state.bMarks[startLine] = oldBMark;
|
---|
4650 |
|
---|
4651 | state.tokens.push({
|
---|
4652 | type: 'footnote_reference_close',
|
---|
4653 | level: --state.level
|
---|
4654 | });
|
---|
4655 |
|
---|
4656 | return true;
|
---|
4657 | }
|
---|
4658 |
|
---|
4659 | // heading (#, ##, ...)
|
---|
4660 |
|
---|
4661 | function heading(state, startLine, endLine, silent) {
|
---|
4662 | var ch, level, tmp,
|
---|
4663 | pos = state.bMarks[startLine] + state.tShift[startLine],
|
---|
4664 | max = state.eMarks[startLine];
|
---|
4665 |
|
---|
4666 | if (pos >= max) { return false; }
|
---|
4667 |
|
---|
4668 | ch = state.src.charCodeAt(pos);
|
---|
4669 |
|
---|
4670 | if (ch !== 0x23/* # */ || pos >= max) { return false; }
|
---|
4671 |
|
---|
4672 | // count heading level
|
---|
4673 | level = 1;
|
---|
4674 | ch = state.src.charCodeAt(++pos);
|
---|
4675 | while (ch === 0x23/* # */ && pos < max && level <= 6) {
|
---|
4676 | level++;
|
---|
4677 | ch = state.src.charCodeAt(++pos);
|
---|
4678 | }
|
---|
4679 |
|
---|
4680 | if (level > 6 || (pos < max && ch !== 0x20/* space */)) { return false; }
|
---|
4681 |
|
---|
4682 | if (silent) { return true; }
|
---|
4683 |
|
---|
4684 | // Let's cut tails like ' ### ' from the end of string
|
---|
4685 |
|
---|
4686 | max = state.skipCharsBack(max, 0x20, pos); // space
|
---|
4687 | tmp = state.skipCharsBack(max, 0x23, pos); // #
|
---|
4688 | if (tmp > pos && state.src.charCodeAt(tmp - 1) === 0x20/* space */) {
|
---|
4689 | max = tmp;
|
---|
4690 | }
|
---|
4691 |
|
---|
4692 | state.line = startLine + 1;
|
---|
4693 |
|
---|
4694 | state.tokens.push({ type: 'heading_open',
|
---|
4695 | hLevel: level,
|
---|
4696 | lines: [ startLine, state.line ],
|
---|
4697 | level: state.level
|
---|
4698 | });
|
---|
4699 |
|
---|
4700 | // only if header is not empty
|
---|
4701 | if (pos < max) {
|
---|
4702 | state.tokens.push({
|
---|
4703 | type: 'inline',
|
---|
4704 | content: state.src.slice(pos, max).trim(),
|
---|
4705 | level: state.level + 1,
|
---|
4706 | lines: [ startLine, state.line ],
|
---|
4707 | children: []
|
---|
4708 | });
|
---|
4709 | }
|
---|
4710 | state.tokens.push({ type: 'heading_close', hLevel: level, level: state.level });
|
---|
4711 |
|
---|
4712 | return true;
|
---|
4713 | }
|
---|
4714 |
|
---|
4715 | // lheading (---, ===)
|
---|
4716 |
|
---|
4717 | function lheading(state, startLine, endLine/*, silent*/) {
|
---|
4718 | var marker, pos, max,
|
---|
4719 | next = startLine + 1;
|
---|
4720 |
|
---|
4721 | if (next >= endLine) { return false; }
|
---|
4722 | if (state.tShift[next] < state.blkIndent) { return false; }
|
---|
4723 |
|
---|
4724 | // Scan next line
|
---|
4725 |
|
---|
4726 | if (state.tShift[next] - state.blkIndent > 3) { return false; }
|
---|
4727 |
|
---|
4728 | pos = state.bMarks[next] + state.tShift[next];
|
---|
4729 | max = state.eMarks[next];
|
---|
4730 |
|
---|
4731 | if (pos >= max) { return false; }
|
---|
4732 |
|
---|
4733 | marker = state.src.charCodeAt(pos);
|
---|
4734 |
|
---|
4735 | if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; }
|
---|
4736 |
|
---|
4737 | pos = state.skipChars(pos, marker);
|
---|
4738 |
|
---|
4739 | pos = state.skipSpaces(pos);
|
---|
4740 |
|
---|
4741 | if (pos < max) { return false; }
|
---|
4742 |
|
---|
4743 | pos = state.bMarks[startLine] + state.tShift[startLine];
|
---|
4744 |
|
---|
4745 | state.line = next + 1;
|
---|
4746 | state.tokens.push({
|
---|
4747 | type: 'heading_open',
|
---|
4748 | hLevel: marker === 0x3D/* = */ ? 1 : 2,
|
---|
4749 | lines: [ startLine, state.line ],
|
---|
4750 | level: state.level
|
---|
4751 | });
|
---|
4752 | state.tokens.push({
|
---|
4753 | type: 'inline',
|
---|
4754 | content: state.src.slice(pos, state.eMarks[startLine]).trim(),
|
---|
4755 | level: state.level + 1,
|
---|
4756 | lines: [ startLine, state.line - 1 ],
|
---|
4757 | children: []
|
---|
4758 | });
|
---|
4759 | state.tokens.push({
|
---|
4760 | type: 'heading_close',
|
---|
4761 | hLevel: marker === 0x3D/* = */ ? 1 : 2,
|
---|
4762 | level: state.level
|
---|
4763 | });
|
---|
4764 |
|
---|
4765 | return true;
|
---|
4766 | }
|
---|
4767 |
|
---|
4768 | // List of valid html blocks names, accorting to commonmark spec
|
---|
4769 | // http://jgm.github.io/CommonMark/spec.html#html-blocks
|
---|
4770 |
|
---|
4771 | var html_blocks = {};
|
---|
4772 |
|
---|
4773 | [
|
---|
4774 | 'article',
|
---|
4775 | 'aside',
|
---|
4776 | 'button',
|
---|
4777 | 'blockquote',
|
---|
4778 | 'body',
|
---|
4779 | 'canvas',
|
---|
4780 | 'caption',
|
---|
4781 | 'col',
|
---|
4782 | 'colgroup',
|
---|
4783 | 'dd',
|
---|
4784 | 'div',
|
---|
4785 | 'dl',
|
---|
4786 | 'dt',
|
---|
4787 | 'embed',
|
---|
4788 | 'fieldset',
|
---|
4789 | 'figcaption',
|
---|
4790 | 'figure',
|
---|
4791 | 'footer',
|
---|
4792 | 'form',
|
---|
4793 | 'h1',
|
---|
4794 | 'h2',
|
---|
4795 | 'h3',
|
---|
4796 | 'h4',
|
---|
4797 | 'h5',
|
---|
4798 | 'h6',
|
---|
4799 | 'header',
|
---|
4800 | 'hgroup',
|
---|
4801 | 'hr',
|
---|
4802 | 'iframe',
|
---|
4803 | 'li',
|
---|
4804 | 'map',
|
---|
4805 | 'object',
|
---|
4806 | 'ol',
|
---|
4807 | 'output',
|
---|
4808 | 'p',
|
---|
4809 | 'pre',
|
---|
4810 | 'progress',
|
---|
4811 | 'script',
|
---|
4812 | 'section',
|
---|
4813 | 'style',
|
---|
4814 | 'table',
|
---|
4815 | 'tbody',
|
---|
4816 | 'td',
|
---|
4817 | 'textarea',
|
---|
4818 | 'tfoot',
|
---|
4819 | 'th',
|
---|
4820 | 'tr',
|
---|
4821 | 'thead',
|
---|
4822 | 'ul',
|
---|
4823 | 'video'
|
---|
4824 | ].forEach(function (name) { html_blocks[name] = true; });
|
---|
4825 |
|
---|
4826 | // HTML block
|
---|
4827 |
|
---|
4828 |
|
---|
4829 | var HTML_TAG_OPEN_RE = /^<([a-zA-Z]{1,15})[\s\/>]/;
|
---|
4830 | var HTML_TAG_CLOSE_RE = /^<\/([a-zA-Z]{1,15})[\s>]/;
|
---|
4831 |
|
---|
4832 | function isLetter$1(ch) {
|
---|
4833 | /*eslint no-bitwise:0*/
|
---|
4834 | var lc = ch | 0x20; // to lower case
|
---|
4835 | return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
|
---|
4836 | }
|
---|
4837 |
|
---|
4838 | function htmlblock(state, startLine, endLine, silent) {
|
---|
4839 | var ch, match, nextLine,
|
---|
4840 | pos = state.bMarks[startLine],
|
---|
4841 | max = state.eMarks[startLine],
|
---|
4842 | shift = state.tShift[startLine];
|
---|
4843 |
|
---|
4844 | pos += shift;
|
---|
4845 |
|
---|
4846 | if (!state.options.html) { return false; }
|
---|
4847 |
|
---|
4848 | if (shift > 3 || pos + 2 >= max) { return false; }
|
---|
4849 |
|
---|
4850 | if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
|
---|
4851 |
|
---|
4852 | ch = state.src.charCodeAt(pos + 1);
|
---|
4853 |
|
---|
4854 | if (ch === 0x21/* ! */ || ch === 0x3F/* ? */) {
|
---|
4855 | // Directive start / comment start / processing instruction start
|
---|
4856 | if (silent) { return true; }
|
---|
4857 |
|
---|
4858 | } else if (ch === 0x2F/* / */ || isLetter$1(ch)) {
|
---|
4859 |
|
---|
4860 | // Probably start or end of tag
|
---|
4861 | if (ch === 0x2F/* \ */) {
|
---|
4862 | // closing tag
|
---|
4863 | match = state.src.slice(pos, max).match(HTML_TAG_CLOSE_RE);
|
---|
4864 | if (!match) { return false; }
|
---|
4865 | } else {
|
---|
4866 | // opening tag
|
---|
4867 | match = state.src.slice(pos, max).match(HTML_TAG_OPEN_RE);
|
---|
4868 | if (!match) { return false; }
|
---|
4869 | }
|
---|
4870 | // Make sure tag name is valid
|
---|
4871 | if (html_blocks[match[1].toLowerCase()] !== true) { return false; }
|
---|
4872 | if (silent) { return true; }
|
---|
4873 |
|
---|
4874 | } else {
|
---|
4875 | return false;
|
---|
4876 | }
|
---|
4877 |
|
---|
4878 | // If we are here - we detected HTML block.
|
---|
4879 | // Let's roll down till empty line (block end).
|
---|
4880 | nextLine = startLine + 1;
|
---|
4881 | while (nextLine < state.lineMax && !state.isEmpty(nextLine)) {
|
---|
4882 | nextLine++;
|
---|
4883 | }
|
---|
4884 |
|
---|
4885 | state.line = nextLine;
|
---|
4886 | state.tokens.push({
|
---|
4887 | type: 'htmlblock',
|
---|
4888 | level: state.level,
|
---|
4889 | lines: [ startLine, state.line ],
|
---|
4890 | content: state.getLines(startLine, nextLine, 0, true)
|
---|
4891 | });
|
---|
4892 |
|
---|
4893 | return true;
|
---|
4894 | }
|
---|
4895 |
|
---|
4896 | // GFM table, non-standard
|
---|
4897 |
|
---|
4898 | function getLine(state, line) {
|
---|
4899 | var pos = state.bMarks[line] + state.blkIndent,
|
---|
4900 | max = state.eMarks[line];
|
---|
4901 |
|
---|
4902 | return state.src.substr(pos, max - pos);
|
---|
4903 | }
|
---|
4904 |
|
---|
4905 | function table(state, startLine, endLine, silent) {
|
---|
4906 | var ch, lineText, pos, i, nextLine, rows, cell,
|
---|
4907 | aligns, t, tableLines, tbodyLines;
|
---|
4908 |
|
---|
4909 | // should have at least three lines
|
---|
4910 | if (startLine + 2 > endLine) { return false; }
|
---|
4911 |
|
---|
4912 | nextLine = startLine + 1;
|
---|
4913 |
|
---|
4914 | if (state.tShift[nextLine] < state.blkIndent) { return false; }
|
---|
4915 |
|
---|
4916 | // first character of the second line should be '|' or '-'
|
---|
4917 |
|
---|
4918 | pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
---|
4919 | if (pos >= state.eMarks[nextLine]) { return false; }
|
---|
4920 |
|
---|
4921 | ch = state.src.charCodeAt(pos);
|
---|
4922 | if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }
|
---|
4923 |
|
---|
4924 | lineText = getLine(state, startLine + 1);
|
---|
4925 | if (!/^[-:| ]+$/.test(lineText)) { return false; }
|
---|
4926 |
|
---|
4927 | rows = lineText.split('|');
|
---|
4928 | if (rows <= 2) { return false; }
|
---|
4929 | aligns = [];
|
---|
4930 | for (i = 0; i < rows.length; i++) {
|
---|
4931 | t = rows[i].trim();
|
---|
4932 | if (!t) {
|
---|
4933 | // allow empty columns before and after table, but not in between columns;
|
---|
4934 | // e.g. allow ` |---| `, disallow ` ---||--- `
|
---|
4935 | if (i === 0 || i === rows.length - 1) {
|
---|
4936 | continue;
|
---|
4937 | } else {
|
---|
4938 | return false;
|
---|
4939 | }
|
---|
4940 | }
|
---|
4941 |
|
---|
4942 | if (!/^:?-+:?$/.test(t)) { return false; }
|
---|
4943 | if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
|
---|
4944 | aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
|
---|
4945 | } else if (t.charCodeAt(0) === 0x3A/* : */) {
|
---|
4946 | aligns.push('left');
|
---|
4947 | } else {
|
---|
4948 | aligns.push('');
|
---|
4949 | }
|
---|
4950 | }
|
---|
4951 |
|
---|
4952 | lineText = getLine(state, startLine).trim();
|
---|
4953 | if (lineText.indexOf('|') === -1) { return false; }
|
---|
4954 | rows = lineText.replace(/^\||\|$/g, '').split('|');
|
---|
4955 | if (aligns.length !== rows.length) { return false; }
|
---|
4956 | if (silent) { return true; }
|
---|
4957 |
|
---|
4958 | state.tokens.push({
|
---|
4959 | type: 'table_open',
|
---|
4960 | lines: tableLines = [ startLine, 0 ],
|
---|
4961 | level: state.level++
|
---|
4962 | });
|
---|
4963 | state.tokens.push({
|
---|
4964 | type: 'thead_open',
|
---|
4965 | lines: [ startLine, startLine + 1 ],
|
---|
4966 | level: state.level++
|
---|
4967 | });
|
---|
4968 |
|
---|
4969 | state.tokens.push({
|
---|
4970 | type: 'tr_open',
|
---|
4971 | lines: [ startLine, startLine + 1 ],
|
---|
4972 | level: state.level++
|
---|
4973 | });
|
---|
4974 | for (i = 0; i < rows.length; i++) {
|
---|
4975 | state.tokens.push({
|
---|
4976 | type: 'th_open',
|
---|
4977 | align: aligns[i],
|
---|
4978 | lines: [ startLine, startLine + 1 ],
|
---|
4979 | level: state.level++
|
---|
4980 | });
|
---|
4981 | state.tokens.push({
|
---|
4982 | type: 'inline',
|
---|
4983 | content: rows[i].trim(),
|
---|
4984 | lines: [ startLine, startLine + 1 ],
|
---|
4985 | level: state.level,
|
---|
4986 | children: []
|
---|
4987 | });
|
---|
4988 | state.tokens.push({ type: 'th_close', level: --state.level });
|
---|
4989 | }
|
---|
4990 | state.tokens.push({ type: 'tr_close', level: --state.level });
|
---|
4991 | state.tokens.push({ type: 'thead_close', level: --state.level });
|
---|
4992 |
|
---|
4993 | state.tokens.push({
|
---|
4994 | type: 'tbody_open',
|
---|
4995 | lines: tbodyLines = [ startLine + 2, 0 ],
|
---|
4996 | level: state.level++
|
---|
4997 | });
|
---|
4998 |
|
---|
4999 | for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
|
---|
5000 | if (state.tShift[nextLine] < state.blkIndent) { break; }
|
---|
5001 |
|
---|
5002 | lineText = getLine(state, nextLine).trim();
|
---|
5003 | if (lineText.indexOf('|') === -1) { break; }
|
---|
5004 | rows = lineText.replace(/^\||\|$/g, '').split('|');
|
---|
5005 |
|
---|
5006 | state.tokens.push({ type: 'tr_open', level: state.level++ });
|
---|
5007 | for (i = 0; i < rows.length; i++) {
|
---|
5008 | state.tokens.push({ type: 'td_open', align: aligns[i], level: state.level++ });
|
---|
5009 | // 0x7c === '|'
|
---|
5010 | cell = rows[i].substring(
|
---|
5011 | rows[i].charCodeAt(0) === 0x7c ? 1 : 0,
|
---|
5012 | rows[i].charCodeAt(rows[i].length - 1) === 0x7c ? rows[i].length - 1 : rows[i].length
|
---|
5013 | ).trim();
|
---|
5014 | state.tokens.push({
|
---|
5015 | type: 'inline',
|
---|
5016 | content: cell,
|
---|
5017 | level: state.level,
|
---|
5018 | children: []
|
---|
5019 | });
|
---|
5020 | state.tokens.push({ type: 'td_close', level: --state.level });
|
---|
5021 | }
|
---|
5022 | state.tokens.push({ type: 'tr_close', level: --state.level });
|
---|
5023 | }
|
---|
5024 | state.tokens.push({ type: 'tbody_close', level: --state.level });
|
---|
5025 | state.tokens.push({ type: 'table_close', level: --state.level });
|
---|
5026 |
|
---|
5027 | tableLines[1] = tbodyLines[1] = nextLine;
|
---|
5028 | state.line = nextLine;
|
---|
5029 | return true;
|
---|
5030 | }
|
---|
5031 |
|
---|
5032 | // Definition lists
|
---|
5033 |
|
---|
5034 | // Search `[:~][\n ]`, returns next pos after marker on success
|
---|
5035 | // or -1 on fail.
|
---|
5036 | function skipMarker(state, line) {
|
---|
5037 | var pos, marker,
|
---|
5038 | start = state.bMarks[line] + state.tShift[line],
|
---|
5039 | max = state.eMarks[line];
|
---|
5040 |
|
---|
5041 | if (start >= max) { return -1; }
|
---|
5042 |
|
---|
5043 | // Check bullet
|
---|
5044 | marker = state.src.charCodeAt(start++);
|
---|
5045 | if (marker !== 0x7E/* ~ */ && marker !== 0x3A/* : */) { return -1; }
|
---|
5046 |
|
---|
5047 | pos = state.skipSpaces(start);
|
---|
5048 |
|
---|
5049 | // require space after ":"
|
---|
5050 | if (start === pos) { return -1; }
|
---|
5051 |
|
---|
5052 | // no empty definitions, e.g. " : "
|
---|
5053 | if (pos >= max) { return -1; }
|
---|
5054 |
|
---|
5055 | return pos;
|
---|
5056 | }
|
---|
5057 |
|
---|
5058 | function markTightParagraphs$1(state, idx) {
|
---|
5059 | var i, l,
|
---|
5060 | level = state.level + 2;
|
---|
5061 |
|
---|
5062 | for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
|
---|
5063 | if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
|
---|
5064 | state.tokens[i + 2].tight = true;
|
---|
5065 | state.tokens[i].tight = true;
|
---|
5066 | i += 2;
|
---|
5067 | }
|
---|
5068 | }
|
---|
5069 | }
|
---|
5070 |
|
---|
5071 | function deflist(state, startLine, endLine, silent) {
|
---|
5072 | var contentStart,
|
---|
5073 | ddLine,
|
---|
5074 | dtLine,
|
---|
5075 | itemLines,
|
---|
5076 | listLines,
|
---|
5077 | listTokIdx,
|
---|
5078 | nextLine,
|
---|
5079 | oldIndent,
|
---|
5080 | oldDDIndent,
|
---|
5081 | oldParentType,
|
---|
5082 | oldTShift,
|
---|
5083 | oldTight,
|
---|
5084 | prevEmptyEnd,
|
---|
5085 | tight;
|
---|
5086 |
|
---|
5087 | if (silent) {
|
---|
5088 | // quirk: validation mode validates a dd block only, not a whole deflist
|
---|
5089 | if (state.ddIndent < 0) { return false; }
|
---|
5090 | return skipMarker(state, startLine) >= 0;
|
---|
5091 | }
|
---|
5092 |
|
---|
5093 | nextLine = startLine + 1;
|
---|
5094 | if (state.isEmpty(nextLine)) {
|
---|
5095 | if (++nextLine > endLine) { return false; }
|
---|
5096 | }
|
---|
5097 |
|
---|
5098 | if (state.tShift[nextLine] < state.blkIndent) { return false; }
|
---|
5099 | contentStart = skipMarker(state, nextLine);
|
---|
5100 | if (contentStart < 0) { return false; }
|
---|
5101 |
|
---|
5102 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
5103 |
|
---|
5104 | // Start list
|
---|
5105 | listTokIdx = state.tokens.length;
|
---|
5106 |
|
---|
5107 | state.tokens.push({
|
---|
5108 | type: 'dl_open',
|
---|
5109 | lines: listLines = [ startLine, 0 ],
|
---|
5110 | level: state.level++
|
---|
5111 | });
|
---|
5112 |
|
---|
5113 | //
|
---|
5114 | // Iterate list items
|
---|
5115 | //
|
---|
5116 |
|
---|
5117 | dtLine = startLine;
|
---|
5118 | ddLine = nextLine;
|
---|
5119 |
|
---|
5120 | // One definition list can contain multiple DTs,
|
---|
5121 | // and one DT can be followed by multiple DDs.
|
---|
5122 | //
|
---|
5123 | // Thus, there is two loops here, and label is
|
---|
5124 | // needed to break out of the second one
|
---|
5125 | //
|
---|
5126 | /*eslint no-labels:0,block-scoped-var:0*/
|
---|
5127 | OUTER:
|
---|
5128 | for (;;) {
|
---|
5129 | tight = true;
|
---|
5130 | prevEmptyEnd = false;
|
---|
5131 |
|
---|
5132 | state.tokens.push({
|
---|
5133 | type: 'dt_open',
|
---|
5134 | lines: [ dtLine, dtLine ],
|
---|
5135 | level: state.level++
|
---|
5136 | });
|
---|
5137 | state.tokens.push({
|
---|
5138 | type: 'inline',
|
---|
5139 | content: state.getLines(dtLine, dtLine + 1, state.blkIndent, false).trim(),
|
---|
5140 | level: state.level + 1,
|
---|
5141 | lines: [ dtLine, dtLine ],
|
---|
5142 | children: []
|
---|
5143 | });
|
---|
5144 | state.tokens.push({
|
---|
5145 | type: 'dt_close',
|
---|
5146 | level: --state.level
|
---|
5147 | });
|
---|
5148 |
|
---|
5149 | for (;;) {
|
---|
5150 | state.tokens.push({
|
---|
5151 | type: 'dd_open',
|
---|
5152 | lines: itemLines = [ nextLine, 0 ],
|
---|
5153 | level: state.level++
|
---|
5154 | });
|
---|
5155 |
|
---|
5156 | oldTight = state.tight;
|
---|
5157 | oldDDIndent = state.ddIndent;
|
---|
5158 | oldIndent = state.blkIndent;
|
---|
5159 | oldTShift = state.tShift[ddLine];
|
---|
5160 | oldParentType = state.parentType;
|
---|
5161 | state.blkIndent = state.ddIndent = state.tShift[ddLine] + 2;
|
---|
5162 | state.tShift[ddLine] = contentStart - state.bMarks[ddLine];
|
---|
5163 | state.tight = true;
|
---|
5164 | state.parentType = 'deflist';
|
---|
5165 |
|
---|
5166 | state.parser.tokenize(state, ddLine, endLine, true);
|
---|
5167 |
|
---|
5168 | // If any of list item is tight, mark list as tight
|
---|
5169 | if (!state.tight || prevEmptyEnd) {
|
---|
5170 | tight = false;
|
---|
5171 | }
|
---|
5172 | // Item become loose if finish with empty line,
|
---|
5173 | // but we should filter last element, because it means list finish
|
---|
5174 | prevEmptyEnd = (state.line - ddLine) > 1 && state.isEmpty(state.line - 1);
|
---|
5175 |
|
---|
5176 | state.tShift[ddLine] = oldTShift;
|
---|
5177 | state.tight = oldTight;
|
---|
5178 | state.parentType = oldParentType;
|
---|
5179 | state.blkIndent = oldIndent;
|
---|
5180 | state.ddIndent = oldDDIndent;
|
---|
5181 |
|
---|
5182 | state.tokens.push({
|
---|
5183 | type: 'dd_close',
|
---|
5184 | level: --state.level
|
---|
5185 | });
|
---|
5186 |
|
---|
5187 | itemLines[1] = nextLine = state.line;
|
---|
5188 |
|
---|
5189 | if (nextLine >= endLine) { break OUTER; }
|
---|
5190 |
|
---|
5191 | if (state.tShift[nextLine] < state.blkIndent) { break OUTER; }
|
---|
5192 | contentStart = skipMarker(state, nextLine);
|
---|
5193 | if (contentStart < 0) { break; }
|
---|
5194 |
|
---|
5195 | ddLine = nextLine;
|
---|
5196 |
|
---|
5197 | // go to the next loop iteration:
|
---|
5198 | // insert DD tag and repeat checking
|
---|
5199 | }
|
---|
5200 |
|
---|
5201 | if (nextLine >= endLine) { break; }
|
---|
5202 | dtLine = nextLine;
|
---|
5203 |
|
---|
5204 | if (state.isEmpty(dtLine)) { break; }
|
---|
5205 | if (state.tShift[dtLine] < state.blkIndent) { break; }
|
---|
5206 |
|
---|
5207 | ddLine = dtLine + 1;
|
---|
5208 | if (ddLine >= endLine) { break; }
|
---|
5209 | if (state.isEmpty(ddLine)) { ddLine++; }
|
---|
5210 | if (ddLine >= endLine) { break; }
|
---|
5211 |
|
---|
5212 | if (state.tShift[ddLine] < state.blkIndent) { break; }
|
---|
5213 | contentStart = skipMarker(state, ddLine);
|
---|
5214 | if (contentStart < 0) { break; }
|
---|
5215 |
|
---|
5216 | // go to the next loop iteration:
|
---|
5217 | // insert DT and DD tags and repeat checking
|
---|
5218 | }
|
---|
5219 |
|
---|
5220 | // Finilize list
|
---|
5221 | state.tokens.push({
|
---|
5222 | type: 'dl_close',
|
---|
5223 | level: --state.level
|
---|
5224 | });
|
---|
5225 | listLines[1] = nextLine;
|
---|
5226 |
|
---|
5227 | state.line = nextLine;
|
---|
5228 |
|
---|
5229 | // mark paragraphs tight if needed
|
---|
5230 | if (tight) {
|
---|
5231 | markTightParagraphs$1(state, listTokIdx);
|
---|
5232 | }
|
---|
5233 |
|
---|
5234 | return true;
|
---|
5235 | }
|
---|
5236 |
|
---|
5237 | // Paragraph
|
---|
5238 |
|
---|
5239 | function paragraph(state, startLine/*, endLine*/) {
|
---|
5240 | var endLine, content, terminate, i, l,
|
---|
5241 | nextLine = startLine + 1,
|
---|
5242 | terminatorRules;
|
---|
5243 |
|
---|
5244 | endLine = state.lineMax;
|
---|
5245 |
|
---|
5246 | // jump line-by-line until empty one or EOF
|
---|
5247 | if (nextLine < endLine && !state.isEmpty(nextLine)) {
|
---|
5248 | terminatorRules = state.parser.ruler.getRules('paragraph');
|
---|
5249 |
|
---|
5250 | for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
|
---|
5251 | // this would be a code block normally, but after paragraph
|
---|
5252 | // it's considered a lazy continuation regardless of what's there
|
---|
5253 | if (state.tShift[nextLine] - state.blkIndent > 3) { continue; }
|
---|
5254 |
|
---|
5255 | // Some tags can terminate paragraph without empty line.
|
---|
5256 | terminate = false;
|
---|
5257 | for (i = 0, l = terminatorRules.length; i < l; i++) {
|
---|
5258 | if (terminatorRules[i](state, nextLine, endLine, true)) {
|
---|
5259 | terminate = true;
|
---|
5260 | break;
|
---|
5261 | }
|
---|
5262 | }
|
---|
5263 | if (terminate) { break; }
|
---|
5264 | }
|
---|
5265 | }
|
---|
5266 |
|
---|
5267 | content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
|
---|
5268 |
|
---|
5269 | state.line = nextLine;
|
---|
5270 | if (content.length) {
|
---|
5271 | state.tokens.push({
|
---|
5272 | type: 'paragraph_open',
|
---|
5273 | tight: false,
|
---|
5274 | lines: [ startLine, state.line ],
|
---|
5275 | level: state.level
|
---|
5276 | });
|
---|
5277 | state.tokens.push({
|
---|
5278 | type: 'inline',
|
---|
5279 | content: content,
|
---|
5280 | level: state.level + 1,
|
---|
5281 | lines: [ startLine, state.line ],
|
---|
5282 | children: []
|
---|
5283 | });
|
---|
5284 | state.tokens.push({
|
---|
5285 | type: 'paragraph_close',
|
---|
5286 | tight: false,
|
---|
5287 | level: state.level
|
---|
5288 | });
|
---|
5289 | }
|
---|
5290 |
|
---|
5291 | return true;
|
---|
5292 | }
|
---|
5293 |
|
---|
5294 | /**
|
---|
5295 | * Parser rules
|
---|
5296 | */
|
---|
5297 |
|
---|
5298 | var _rules$1 = [
|
---|
5299 | [ 'code', code ],
|
---|
5300 | [ 'fences', fences, [ 'paragraph', 'blockquote', 'list' ] ],
|
---|
5301 | [ 'blockquote', blockquote, [ 'paragraph', 'blockquote', 'list' ] ],
|
---|
5302 | [ 'hr', hr, [ 'paragraph', 'blockquote', 'list' ] ],
|
---|
5303 | [ 'list', list, [ 'paragraph', 'blockquote' ] ],
|
---|
5304 | [ 'footnote', footnote, [ 'paragraph' ] ],
|
---|
5305 | [ 'heading', heading, [ 'paragraph', 'blockquote' ] ],
|
---|
5306 | [ 'lheading', lheading ],
|
---|
5307 | [ 'htmlblock', htmlblock, [ 'paragraph', 'blockquote' ] ],
|
---|
5308 | [ 'table', table, [ 'paragraph' ] ],
|
---|
5309 | [ 'deflist', deflist, [ 'paragraph' ] ],
|
---|
5310 | [ 'paragraph', paragraph ]
|
---|
5311 | ];
|
---|
5312 |
|
---|
5313 | /**
|
---|
5314 | * Block Parser class
|
---|
5315 | *
|
---|
5316 | * @api private
|
---|
5317 | */
|
---|
5318 |
|
---|
5319 | function ParserBlock() {
|
---|
5320 | this.ruler = new Ruler();
|
---|
5321 | for (var i = 0; i < _rules$1.length; i++) {
|
---|
5322 | this.ruler.push(_rules$1[i][0], _rules$1[i][1], {
|
---|
5323 | alt: (_rules$1[i][2] || []).slice()
|
---|
5324 | });
|
---|
5325 | }
|
---|
5326 | }
|
---|
5327 |
|
---|
5328 | /**
|
---|
5329 | * Generate tokens for the given input range.
|
---|
5330 | *
|
---|
5331 | * @param {Object} `state` Has properties like `src`, `parser`, `options` etc
|
---|
5332 | * @param {Number} `startLine`
|
---|
5333 | * @param {Number} `endLine`
|
---|
5334 | * @api private
|
---|
5335 | */
|
---|
5336 |
|
---|
5337 | ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
|
---|
5338 | var rules = this.ruler.getRules('');
|
---|
5339 | var len = rules.length;
|
---|
5340 | var line = startLine;
|
---|
5341 | var hasEmptyLines = false;
|
---|
5342 | var ok, i;
|
---|
5343 |
|
---|
5344 | while (line < endLine) {
|
---|
5345 | state.line = line = state.skipEmptyLines(line);
|
---|
5346 | if (line >= endLine) {
|
---|
5347 | break;
|
---|
5348 | }
|
---|
5349 |
|
---|
5350 | // Termination condition for nested calls.
|
---|
5351 | // Nested calls currently used for blockquotes & lists
|
---|
5352 | if (state.tShift[line] < state.blkIndent) {
|
---|
5353 | break;
|
---|
5354 | }
|
---|
5355 |
|
---|
5356 | // Try all possible rules.
|
---|
5357 | // On success, rule should:
|
---|
5358 | //
|
---|
5359 | // - update `state.line`
|
---|
5360 | // - update `state.tokens`
|
---|
5361 | // - return true
|
---|
5362 |
|
---|
5363 | for (i = 0; i < len; i++) {
|
---|
5364 | ok = rules[i](state, line, endLine, false);
|
---|
5365 | if (ok) {
|
---|
5366 | break;
|
---|
5367 | }
|
---|
5368 | }
|
---|
5369 |
|
---|
5370 | // set state.tight iff we had an empty line before current tag
|
---|
5371 | // i.e. latest empty line should not count
|
---|
5372 | state.tight = !hasEmptyLines;
|
---|
5373 |
|
---|
5374 | // paragraph might "eat" one newline after it in nested lists
|
---|
5375 | if (state.isEmpty(state.line - 1)) {
|
---|
5376 | hasEmptyLines = true;
|
---|
5377 | }
|
---|
5378 |
|
---|
5379 | line = state.line;
|
---|
5380 |
|
---|
5381 | if (line < endLine && state.isEmpty(line)) {
|
---|
5382 | hasEmptyLines = true;
|
---|
5383 | line++;
|
---|
5384 |
|
---|
5385 | // two empty lines should stop the parser in list mode
|
---|
5386 | if (line < endLine && state.parentType === 'list' && state.isEmpty(line)) { break; }
|
---|
5387 | state.line = line;
|
---|
5388 | }
|
---|
5389 | }
|
---|
5390 | };
|
---|
5391 |
|
---|
5392 | var TABS_SCAN_RE = /[\n\t]/g;
|
---|
5393 | var NEWLINES_RE = /\r[\n\u0085]|[\u2424\u2028\u0085]/g;
|
---|
5394 | var SPACES_RE = /\u00a0/g;
|
---|
5395 |
|
---|
5396 | /**
|
---|
5397 | * Tokenize the given `str`.
|
---|
5398 | *
|
---|
5399 | * @param {String} `str` Source string
|
---|
5400 | * @param {Object} `options`
|
---|
5401 | * @param {Object} `env`
|
---|
5402 | * @param {Array} `outTokens`
|
---|
5403 | * @api private
|
---|
5404 | */
|
---|
5405 |
|
---|
5406 | ParserBlock.prototype.parse = function (str, options, env, outTokens) {
|
---|
5407 | var state, lineStart = 0, lastTabPos = 0;
|
---|
5408 | if (!str) { return []; }
|
---|
5409 |
|
---|
5410 | // Normalize spaces
|
---|
5411 | str = str.replace(SPACES_RE, ' ');
|
---|
5412 |
|
---|
5413 | // Normalize newlines
|
---|
5414 | str = str.replace(NEWLINES_RE, '\n');
|
---|
5415 |
|
---|
5416 | // Replace tabs with proper number of spaces (1..4)
|
---|
5417 | if (str.indexOf('\t') >= 0) {
|
---|
5418 | str = str.replace(TABS_SCAN_RE, function (match, offset) {
|
---|
5419 | var result;
|
---|
5420 | if (str.charCodeAt(offset) === 0x0A) {
|
---|
5421 | lineStart = offset + 1;
|
---|
5422 | lastTabPos = 0;
|
---|
5423 | return match;
|
---|
5424 | }
|
---|
5425 | result = ' '.slice((offset - lineStart - lastTabPos) % 4);
|
---|
5426 | lastTabPos = offset - lineStart + 1;
|
---|
5427 | return result;
|
---|
5428 | });
|
---|
5429 | }
|
---|
5430 |
|
---|
5431 | state = new StateBlock(str, this, options, env, outTokens);
|
---|
5432 | this.tokenize(state, state.line, state.lineMax);
|
---|
5433 | };
|
---|
5434 |
|
---|
5435 | // Skip text characters for text token, place those to pending buffer
|
---|
5436 | // and increment current pos
|
---|
5437 |
|
---|
5438 | // Rule to skip pure text
|
---|
5439 | // '{}$%@~+=:' reserved for extentions
|
---|
5440 |
|
---|
5441 | function isTerminatorChar(ch) {
|
---|
5442 | switch (ch) {
|
---|
5443 | case 0x0A/* \n */:
|
---|
5444 | case 0x5C/* \ */:
|
---|
5445 | case 0x60/* ` */:
|
---|
5446 | case 0x2A/* * */:
|
---|
5447 | case 0x5F/* _ */:
|
---|
5448 | case 0x5E/* ^ */:
|
---|
5449 | case 0x5B/* [ */:
|
---|
5450 | case 0x5D/* ] */:
|
---|
5451 | case 0x21/* ! */:
|
---|
5452 | case 0x26/* & */:
|
---|
5453 | case 0x3C/* < */:
|
---|
5454 | case 0x3E/* > */:
|
---|
5455 | case 0x7B/* { */:
|
---|
5456 | case 0x7D/* } */:
|
---|
5457 | case 0x24/* $ */:
|
---|
5458 | case 0x25/* % */:
|
---|
5459 | case 0x40/* @ */:
|
---|
5460 | case 0x7E/* ~ */:
|
---|
5461 | case 0x2B/* + */:
|
---|
5462 | case 0x3D/* = */:
|
---|
5463 | case 0x3A/* : */:
|
---|
5464 | return true;
|
---|
5465 | default:
|
---|
5466 | return false;
|
---|
5467 | }
|
---|
5468 | }
|
---|
5469 |
|
---|
5470 | function text(state, silent) {
|
---|
5471 | var pos = state.pos;
|
---|
5472 |
|
---|
5473 | while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
|
---|
5474 | pos++;
|
---|
5475 | }
|
---|
5476 |
|
---|
5477 | if (pos === state.pos) { return false; }
|
---|
5478 |
|
---|
5479 | if (!silent) { state.pending += state.src.slice(state.pos, pos); }
|
---|
5480 |
|
---|
5481 | state.pos = pos;
|
---|
5482 |
|
---|
5483 | return true;
|
---|
5484 | }
|
---|
5485 |
|
---|
5486 | // Proceess '\n'
|
---|
5487 |
|
---|
5488 | function newline(state, silent) {
|
---|
5489 | var pmax, max, pos = state.pos;
|
---|
5490 |
|
---|
5491 | if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
|
---|
5492 |
|
---|
5493 | pmax = state.pending.length - 1;
|
---|
5494 | max = state.posMax;
|
---|
5495 |
|
---|
5496 | // ' \n' -> hardbreak
|
---|
5497 | // Lookup in pending chars is bad practice! Don't copy to other rules!
|
---|
5498 | // Pending string is stored in concat mode, indexed lookups will cause
|
---|
5499 | // convertion to flat mode.
|
---|
5500 | if (!silent) {
|
---|
5501 | if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
|
---|
5502 | if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
|
---|
5503 | // Strip out all trailing spaces on this line.
|
---|
5504 | for (var i = pmax - 2; i >= 0; i--) {
|
---|
5505 | if (state.pending.charCodeAt(i) !== 0x20) {
|
---|
5506 | state.pending = state.pending.substring(0, i + 1);
|
---|
5507 | break;
|
---|
5508 | }
|
---|
5509 | }
|
---|
5510 | state.push({
|
---|
5511 | type: 'hardbreak',
|
---|
5512 | level: state.level
|
---|
5513 | });
|
---|
5514 | } else {
|
---|
5515 | state.pending = state.pending.slice(0, -1);
|
---|
5516 | state.push({
|
---|
5517 | type: 'softbreak',
|
---|
5518 | level: state.level
|
---|
5519 | });
|
---|
5520 | }
|
---|
5521 |
|
---|
5522 | } else {
|
---|
5523 | state.push({
|
---|
5524 | type: 'softbreak',
|
---|
5525 | level: state.level
|
---|
5526 | });
|
---|
5527 | }
|
---|
5528 | }
|
---|
5529 |
|
---|
5530 | pos++;
|
---|
5531 |
|
---|
5532 | // skip heading spaces for next line
|
---|
5533 | while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; }
|
---|
5534 |
|
---|
5535 | state.pos = pos;
|
---|
5536 | return true;
|
---|
5537 | }
|
---|
5538 |
|
---|
5539 | // Proceess escaped chars and hardbreaks
|
---|
5540 |
|
---|
5541 | var ESCAPED = [];
|
---|
5542 |
|
---|
5543 | for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
|
---|
5544 |
|
---|
5545 | '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
|
---|
5546 | .split('').forEach(function(ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
|
---|
5547 |
|
---|
5548 |
|
---|
5549 | function escape(state, silent) {
|
---|
5550 | var ch, pos = state.pos, max = state.posMax;
|
---|
5551 |
|
---|
5552 | if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }
|
---|
5553 |
|
---|
5554 | pos++;
|
---|
5555 |
|
---|
5556 | if (pos < max) {
|
---|
5557 | ch = state.src.charCodeAt(pos);
|
---|
5558 |
|
---|
5559 | if (ch < 256 && ESCAPED[ch] !== 0) {
|
---|
5560 | if (!silent) { state.pending += state.src[pos]; }
|
---|
5561 | state.pos += 2;
|
---|
5562 | return true;
|
---|
5563 | }
|
---|
5564 |
|
---|
5565 | if (ch === 0x0A) {
|
---|
5566 | if (!silent) {
|
---|
5567 | state.push({
|
---|
5568 | type: 'hardbreak',
|
---|
5569 | level: state.level
|
---|
5570 | });
|
---|
5571 | }
|
---|
5572 |
|
---|
5573 | pos++;
|
---|
5574 | // skip leading whitespaces from next line
|
---|
5575 | while (pos < max && state.src.charCodeAt(pos) === 0x20) { pos++; }
|
---|
5576 |
|
---|
5577 | state.pos = pos;
|
---|
5578 | return true;
|
---|
5579 | }
|
---|
5580 | }
|
---|
5581 |
|
---|
5582 | if (!silent) { state.pending += '\\'; }
|
---|
5583 | state.pos++;
|
---|
5584 | return true;
|
---|
5585 | }
|
---|
5586 |
|
---|
5587 | // Parse backticks
|
---|
5588 |
|
---|
5589 | function backticks(state, silent) {
|
---|
5590 | var start, max, marker, matchStart, matchEnd,
|
---|
5591 | pos = state.pos,
|
---|
5592 | ch = state.src.charCodeAt(pos);
|
---|
5593 |
|
---|
5594 | if (ch !== 0x60/* ` */) { return false; }
|
---|
5595 |
|
---|
5596 | start = pos;
|
---|
5597 | pos++;
|
---|
5598 | max = state.posMax;
|
---|
5599 |
|
---|
5600 | while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
|
---|
5601 |
|
---|
5602 | marker = state.src.slice(start, pos);
|
---|
5603 |
|
---|
5604 | matchStart = matchEnd = pos;
|
---|
5605 |
|
---|
5606 | while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
|
---|
5607 | matchEnd = matchStart + 1;
|
---|
5608 |
|
---|
5609 | while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
|
---|
5610 |
|
---|
5611 | if (matchEnd - matchStart === marker.length) {
|
---|
5612 | if (!silent) {
|
---|
5613 | state.push({
|
---|
5614 | type: 'code',
|
---|
5615 | content: state.src.slice(pos, matchStart)
|
---|
5616 | .replace(/[ \n]+/g, ' ')
|
---|
5617 | .trim(),
|
---|
5618 | block: false,
|
---|
5619 | level: state.level
|
---|
5620 | });
|
---|
5621 | }
|
---|
5622 | state.pos = matchEnd;
|
---|
5623 | return true;
|
---|
5624 | }
|
---|
5625 | }
|
---|
5626 |
|
---|
5627 | if (!silent) { state.pending += marker; }
|
---|
5628 | state.pos += marker.length;
|
---|
5629 | return true;
|
---|
5630 | }
|
---|
5631 |
|
---|
5632 | // Process ~~deleted text~~
|
---|
5633 |
|
---|
5634 | function del(state, silent) {
|
---|
5635 | var found,
|
---|
5636 | pos,
|
---|
5637 | stack,
|
---|
5638 | max = state.posMax,
|
---|
5639 | start = state.pos,
|
---|
5640 | lastChar,
|
---|
5641 | nextChar;
|
---|
5642 |
|
---|
5643 | if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
|
---|
5644 | if (silent) { return false; } // don't run any pairs in validation mode
|
---|
5645 | if (start + 4 >= max) { return false; }
|
---|
5646 | if (state.src.charCodeAt(start + 1) !== 0x7E/* ~ */) { return false; }
|
---|
5647 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
5648 |
|
---|
5649 | lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
|
---|
5650 | nextChar = state.src.charCodeAt(start + 2);
|
---|
5651 |
|
---|
5652 | if (lastChar === 0x7E/* ~ */) { return false; }
|
---|
5653 | if (nextChar === 0x7E/* ~ */) { return false; }
|
---|
5654 | if (nextChar === 0x20 || nextChar === 0x0A) { return false; }
|
---|
5655 |
|
---|
5656 | pos = start + 2;
|
---|
5657 | while (pos < max && state.src.charCodeAt(pos) === 0x7E/* ~ */) { pos++; }
|
---|
5658 | if (pos > start + 3) {
|
---|
5659 | // sequence of 4+ markers taking as literal, same as in a emphasis
|
---|
5660 | state.pos += pos - start;
|
---|
5661 | if (!silent) { state.pending += state.src.slice(start, pos); }
|
---|
5662 | return true;
|
---|
5663 | }
|
---|
5664 |
|
---|
5665 | state.pos = start + 2;
|
---|
5666 | stack = 1;
|
---|
5667 |
|
---|
5668 | while (state.pos + 1 < max) {
|
---|
5669 | if (state.src.charCodeAt(state.pos) === 0x7E/* ~ */) {
|
---|
5670 | if (state.src.charCodeAt(state.pos + 1) === 0x7E/* ~ */) {
|
---|
5671 | lastChar = state.src.charCodeAt(state.pos - 1);
|
---|
5672 | nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1;
|
---|
5673 | if (nextChar !== 0x7E/* ~ */ && lastChar !== 0x7E/* ~ */) {
|
---|
5674 | if (lastChar !== 0x20 && lastChar !== 0x0A) {
|
---|
5675 | // closing '~~'
|
---|
5676 | stack--;
|
---|
5677 | } else if (nextChar !== 0x20 && nextChar !== 0x0A) {
|
---|
5678 | // opening '~~'
|
---|
5679 | stack++;
|
---|
5680 | } // else {
|
---|
5681 | // // standalone ' ~~ ' indented with spaces
|
---|
5682 | // }
|
---|
5683 | if (stack <= 0) {
|
---|
5684 | found = true;
|
---|
5685 | break;
|
---|
5686 | }
|
---|
5687 | }
|
---|
5688 | }
|
---|
5689 | }
|
---|
5690 |
|
---|
5691 | state.parser.skipToken(state);
|
---|
5692 | }
|
---|
5693 |
|
---|
5694 | if (!found) {
|
---|
5695 | // parser failed to find ending tag, so it's not valid emphasis
|
---|
5696 | state.pos = start;
|
---|
5697 | return false;
|
---|
5698 | }
|
---|
5699 |
|
---|
5700 | // found!
|
---|
5701 | state.posMax = state.pos;
|
---|
5702 | state.pos = start + 2;
|
---|
5703 |
|
---|
5704 | if (!silent) {
|
---|
5705 | state.push({ type: 'del_open', level: state.level++ });
|
---|
5706 | state.parser.tokenize(state);
|
---|
5707 | state.push({ type: 'del_close', level: --state.level });
|
---|
5708 | }
|
---|
5709 |
|
---|
5710 | state.pos = state.posMax + 2;
|
---|
5711 | state.posMax = max;
|
---|
5712 | return true;
|
---|
5713 | }
|
---|
5714 |
|
---|
5715 | // Process ++inserted text++
|
---|
5716 |
|
---|
5717 | function ins(state, silent) {
|
---|
5718 | var found,
|
---|
5719 | pos,
|
---|
5720 | stack,
|
---|
5721 | max = state.posMax,
|
---|
5722 | start = state.pos,
|
---|
5723 | lastChar,
|
---|
5724 | nextChar;
|
---|
5725 |
|
---|
5726 | if (state.src.charCodeAt(start) !== 0x2B/* + */) { return false; }
|
---|
5727 | if (silent) { return false; } // don't run any pairs in validation mode
|
---|
5728 | if (start + 4 >= max) { return false; }
|
---|
5729 | if (state.src.charCodeAt(start + 1) !== 0x2B/* + */) { return false; }
|
---|
5730 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
5731 |
|
---|
5732 | lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
|
---|
5733 | nextChar = state.src.charCodeAt(start + 2);
|
---|
5734 |
|
---|
5735 | if (lastChar === 0x2B/* + */) { return false; }
|
---|
5736 | if (nextChar === 0x2B/* + */) { return false; }
|
---|
5737 | if (nextChar === 0x20 || nextChar === 0x0A) { return false; }
|
---|
5738 |
|
---|
5739 | pos = start + 2;
|
---|
5740 | while (pos < max && state.src.charCodeAt(pos) === 0x2B/* + */) { pos++; }
|
---|
5741 | if (pos !== start + 2) {
|
---|
5742 | // sequence of 3+ markers taking as literal, same as in a emphasis
|
---|
5743 | state.pos += pos - start;
|
---|
5744 | if (!silent) { state.pending += state.src.slice(start, pos); }
|
---|
5745 | return true;
|
---|
5746 | }
|
---|
5747 |
|
---|
5748 | state.pos = start + 2;
|
---|
5749 | stack = 1;
|
---|
5750 |
|
---|
5751 | while (state.pos + 1 < max) {
|
---|
5752 | if (state.src.charCodeAt(state.pos) === 0x2B/* + */) {
|
---|
5753 | if (state.src.charCodeAt(state.pos + 1) === 0x2B/* + */) {
|
---|
5754 | lastChar = state.src.charCodeAt(state.pos - 1);
|
---|
5755 | nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1;
|
---|
5756 | if (nextChar !== 0x2B/* + */ && lastChar !== 0x2B/* + */) {
|
---|
5757 | if (lastChar !== 0x20 && lastChar !== 0x0A) {
|
---|
5758 | // closing '++'
|
---|
5759 | stack--;
|
---|
5760 | } else if (nextChar !== 0x20 && nextChar !== 0x0A) {
|
---|
5761 | // opening '++'
|
---|
5762 | stack++;
|
---|
5763 | } // else {
|
---|
5764 | // // standalone ' ++ ' indented with spaces
|
---|
5765 | // }
|
---|
5766 | if (stack <= 0) {
|
---|
5767 | found = true;
|
---|
5768 | break;
|
---|
5769 | }
|
---|
5770 | }
|
---|
5771 | }
|
---|
5772 | }
|
---|
5773 |
|
---|
5774 | state.parser.skipToken(state);
|
---|
5775 | }
|
---|
5776 |
|
---|
5777 | if (!found) {
|
---|
5778 | // parser failed to find ending tag, so it's not valid emphasis
|
---|
5779 | state.pos = start;
|
---|
5780 | return false;
|
---|
5781 | }
|
---|
5782 |
|
---|
5783 | // found!
|
---|
5784 | state.posMax = state.pos;
|
---|
5785 | state.pos = start + 2;
|
---|
5786 |
|
---|
5787 | if (!silent) {
|
---|
5788 | state.push({ type: 'ins_open', level: state.level++ });
|
---|
5789 | state.parser.tokenize(state);
|
---|
5790 | state.push({ type: 'ins_close', level: --state.level });
|
---|
5791 | }
|
---|
5792 |
|
---|
5793 | state.pos = state.posMax + 2;
|
---|
5794 | state.posMax = max;
|
---|
5795 | return true;
|
---|
5796 | }
|
---|
5797 |
|
---|
5798 | // Process ==highlighted text==
|
---|
5799 |
|
---|
5800 | function mark(state, silent) {
|
---|
5801 | var found,
|
---|
5802 | pos,
|
---|
5803 | stack,
|
---|
5804 | max = state.posMax,
|
---|
5805 | start = state.pos,
|
---|
5806 | lastChar,
|
---|
5807 | nextChar;
|
---|
5808 |
|
---|
5809 | if (state.src.charCodeAt(start) !== 0x3D/* = */) { return false; }
|
---|
5810 | if (silent) { return false; } // don't run any pairs in validation mode
|
---|
5811 | if (start + 4 >= max) { return false; }
|
---|
5812 | if (state.src.charCodeAt(start + 1) !== 0x3D/* = */) { return false; }
|
---|
5813 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
5814 |
|
---|
5815 | lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
|
---|
5816 | nextChar = state.src.charCodeAt(start + 2);
|
---|
5817 |
|
---|
5818 | if (lastChar === 0x3D/* = */) { return false; }
|
---|
5819 | if (nextChar === 0x3D/* = */) { return false; }
|
---|
5820 | if (nextChar === 0x20 || nextChar === 0x0A) { return false; }
|
---|
5821 |
|
---|
5822 | pos = start + 2;
|
---|
5823 | while (pos < max && state.src.charCodeAt(pos) === 0x3D/* = */) { pos++; }
|
---|
5824 | if (pos !== start + 2) {
|
---|
5825 | // sequence of 3+ markers taking as literal, same as in a emphasis
|
---|
5826 | state.pos += pos - start;
|
---|
5827 | if (!silent) { state.pending += state.src.slice(start, pos); }
|
---|
5828 | return true;
|
---|
5829 | }
|
---|
5830 |
|
---|
5831 | state.pos = start + 2;
|
---|
5832 | stack = 1;
|
---|
5833 |
|
---|
5834 | while (state.pos + 1 < max) {
|
---|
5835 | if (state.src.charCodeAt(state.pos) === 0x3D/* = */) {
|
---|
5836 | if (state.src.charCodeAt(state.pos + 1) === 0x3D/* = */) {
|
---|
5837 | lastChar = state.src.charCodeAt(state.pos - 1);
|
---|
5838 | nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1;
|
---|
5839 | if (nextChar !== 0x3D/* = */ && lastChar !== 0x3D/* = */) {
|
---|
5840 | if (lastChar !== 0x20 && lastChar !== 0x0A) {
|
---|
5841 | // closing '=='
|
---|
5842 | stack--;
|
---|
5843 | } else if (nextChar !== 0x20 && nextChar !== 0x0A) {
|
---|
5844 | // opening '=='
|
---|
5845 | stack++;
|
---|
5846 | } // else {
|
---|
5847 | // // standalone ' == ' indented with spaces
|
---|
5848 | // }
|
---|
5849 | if (stack <= 0) {
|
---|
5850 | found = true;
|
---|
5851 | break;
|
---|
5852 | }
|
---|
5853 | }
|
---|
5854 | }
|
---|
5855 | }
|
---|
5856 |
|
---|
5857 | state.parser.skipToken(state);
|
---|
5858 | }
|
---|
5859 |
|
---|
5860 | if (!found) {
|
---|
5861 | // parser failed to find ending tag, so it's not valid emphasis
|
---|
5862 | state.pos = start;
|
---|
5863 | return false;
|
---|
5864 | }
|
---|
5865 |
|
---|
5866 | // found!
|
---|
5867 | state.posMax = state.pos;
|
---|
5868 | state.pos = start + 2;
|
---|
5869 |
|
---|
5870 | if (!silent) {
|
---|
5871 | state.push({ type: 'mark_open', level: state.level++ });
|
---|
5872 | state.parser.tokenize(state);
|
---|
5873 | state.push({ type: 'mark_close', level: --state.level });
|
---|
5874 | }
|
---|
5875 |
|
---|
5876 | state.pos = state.posMax + 2;
|
---|
5877 | state.posMax = max;
|
---|
5878 | return true;
|
---|
5879 | }
|
---|
5880 |
|
---|
5881 | // Process *this* and _that_
|
---|
5882 |
|
---|
5883 | function isAlphaNum(code) {
|
---|
5884 | return (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */) ||
|
---|
5885 | (code >= 0x41 /* A */ && code <= 0x5A /* Z */) ||
|
---|
5886 | (code >= 0x61 /* a */ && code <= 0x7A /* z */);
|
---|
5887 | }
|
---|
5888 |
|
---|
5889 | // parse sequence of emphasis markers,
|
---|
5890 | // "start" should point at a valid marker
|
---|
5891 | function scanDelims(state, start) {
|
---|
5892 | var pos = start, lastChar, nextChar, count,
|
---|
5893 | can_open = true,
|
---|
5894 | can_close = true,
|
---|
5895 | max = state.posMax,
|
---|
5896 | marker = state.src.charCodeAt(start);
|
---|
5897 |
|
---|
5898 | lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1;
|
---|
5899 |
|
---|
5900 | while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; }
|
---|
5901 | if (pos >= max) { can_open = false; }
|
---|
5902 | count = pos - start;
|
---|
5903 |
|
---|
5904 | if (count >= 4) {
|
---|
5905 | // sequence of four or more unescaped markers can't start/end an emphasis
|
---|
5906 | can_open = can_close = false;
|
---|
5907 | } else {
|
---|
5908 | nextChar = pos < max ? state.src.charCodeAt(pos) : -1;
|
---|
5909 |
|
---|
5910 | // check whitespace conditions
|
---|
5911 | if (nextChar === 0x20 || nextChar === 0x0A) { can_open = false; }
|
---|
5912 | if (lastChar === 0x20 || lastChar === 0x0A) { can_close = false; }
|
---|
5913 |
|
---|
5914 | if (marker === 0x5F /* _ */) {
|
---|
5915 | // check if we aren't inside the word
|
---|
5916 | if (isAlphaNum(lastChar)) { can_open = false; }
|
---|
5917 | if (isAlphaNum(nextChar)) { can_close = false; }
|
---|
5918 | }
|
---|
5919 | }
|
---|
5920 |
|
---|
5921 | return {
|
---|
5922 | can_open: can_open,
|
---|
5923 | can_close: can_close,
|
---|
5924 | delims: count
|
---|
5925 | };
|
---|
5926 | }
|
---|
5927 |
|
---|
5928 | function emphasis(state, silent) {
|
---|
5929 | var startCount,
|
---|
5930 | count,
|
---|
5931 | found,
|
---|
5932 | oldCount,
|
---|
5933 | newCount,
|
---|
5934 | stack,
|
---|
5935 | res,
|
---|
5936 | max = state.posMax,
|
---|
5937 | start = state.pos,
|
---|
5938 | marker = state.src.charCodeAt(start);
|
---|
5939 |
|
---|
5940 | if (marker !== 0x5F/* _ */ && marker !== 0x2A /* * */) { return false; }
|
---|
5941 | if (silent) { return false; } // don't run any pairs in validation mode
|
---|
5942 |
|
---|
5943 | res = scanDelims(state, start);
|
---|
5944 | startCount = res.delims;
|
---|
5945 | if (!res.can_open) {
|
---|
5946 | state.pos += startCount;
|
---|
5947 | if (!silent) { state.pending += state.src.slice(start, state.pos); }
|
---|
5948 | return true;
|
---|
5949 | }
|
---|
5950 |
|
---|
5951 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
5952 |
|
---|
5953 | state.pos = start + startCount;
|
---|
5954 | stack = [ startCount ];
|
---|
5955 |
|
---|
5956 | while (state.pos < max) {
|
---|
5957 | if (state.src.charCodeAt(state.pos) === marker) {
|
---|
5958 | res = scanDelims(state, state.pos);
|
---|
5959 | count = res.delims;
|
---|
5960 | if (res.can_close) {
|
---|
5961 | oldCount = stack.pop();
|
---|
5962 | newCount = count;
|
---|
5963 |
|
---|
5964 | while (oldCount !== newCount) {
|
---|
5965 | if (newCount < oldCount) {
|
---|
5966 | stack.push(oldCount - newCount);
|
---|
5967 | break;
|
---|
5968 | }
|
---|
5969 |
|
---|
5970 | // assert(newCount > oldCount)
|
---|
5971 | newCount -= oldCount;
|
---|
5972 |
|
---|
5973 | if (stack.length === 0) { break; }
|
---|
5974 | state.pos += oldCount;
|
---|
5975 | oldCount = stack.pop();
|
---|
5976 | }
|
---|
5977 |
|
---|
5978 | if (stack.length === 0) {
|
---|
5979 | startCount = oldCount;
|
---|
5980 | found = true;
|
---|
5981 | break;
|
---|
5982 | }
|
---|
5983 | state.pos += count;
|
---|
5984 | continue;
|
---|
5985 | }
|
---|
5986 |
|
---|
5987 | if (res.can_open) { stack.push(count); }
|
---|
5988 | state.pos += count;
|
---|
5989 | continue;
|
---|
5990 | }
|
---|
5991 |
|
---|
5992 | state.parser.skipToken(state);
|
---|
5993 | }
|
---|
5994 |
|
---|
5995 | if (!found) {
|
---|
5996 | // parser failed to find ending tag, so it's not valid emphasis
|
---|
5997 | state.pos = start;
|
---|
5998 | return false;
|
---|
5999 | }
|
---|
6000 |
|
---|
6001 | // found!
|
---|
6002 | state.posMax = state.pos;
|
---|
6003 | state.pos = start + startCount;
|
---|
6004 |
|
---|
6005 | if (!silent) {
|
---|
6006 | if (startCount === 2 || startCount === 3) {
|
---|
6007 | state.push({ type: 'strong_open', level: state.level++ });
|
---|
6008 | }
|
---|
6009 | if (startCount === 1 || startCount === 3) {
|
---|
6010 | state.push({ type: 'em_open', level: state.level++ });
|
---|
6011 | }
|
---|
6012 |
|
---|
6013 | state.parser.tokenize(state);
|
---|
6014 |
|
---|
6015 | if (startCount === 1 || startCount === 3) {
|
---|
6016 | state.push({ type: 'em_close', level: --state.level });
|
---|
6017 | }
|
---|
6018 | if (startCount === 2 || startCount === 3) {
|
---|
6019 | state.push({ type: 'strong_close', level: --state.level });
|
---|
6020 | }
|
---|
6021 | }
|
---|
6022 |
|
---|
6023 | state.pos = state.posMax + startCount;
|
---|
6024 | state.posMax = max;
|
---|
6025 | return true;
|
---|
6026 | }
|
---|
6027 |
|
---|
6028 | // Process ~subscript~
|
---|
6029 |
|
---|
6030 | // same as UNESCAPE_MD_RE plus a space
|
---|
6031 | var UNESCAPE_RE = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
|
---|
6032 |
|
---|
6033 | function sub(state, silent) {
|
---|
6034 | var found,
|
---|
6035 | content,
|
---|
6036 | max = state.posMax,
|
---|
6037 | start = state.pos;
|
---|
6038 |
|
---|
6039 | if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
|
---|
6040 | if (silent) { return false; } // don't run any pairs in validation mode
|
---|
6041 | if (start + 2 >= max) { return false; }
|
---|
6042 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
6043 |
|
---|
6044 | state.pos = start + 1;
|
---|
6045 |
|
---|
6046 | while (state.pos < max) {
|
---|
6047 | if (state.src.charCodeAt(state.pos) === 0x7E/* ~ */) {
|
---|
6048 | found = true;
|
---|
6049 | break;
|
---|
6050 | }
|
---|
6051 |
|
---|
6052 | state.parser.skipToken(state);
|
---|
6053 | }
|
---|
6054 |
|
---|
6055 | if (!found || start + 1 === state.pos) {
|
---|
6056 | state.pos = start;
|
---|
6057 | return false;
|
---|
6058 | }
|
---|
6059 |
|
---|
6060 | content = state.src.slice(start + 1, state.pos);
|
---|
6061 |
|
---|
6062 | // don't allow unescaped spaces/newlines inside
|
---|
6063 | if (content.match(/(^|[^\\])(\\\\)*\s/)) {
|
---|
6064 | state.pos = start;
|
---|
6065 | return false;
|
---|
6066 | }
|
---|
6067 |
|
---|
6068 | // found!
|
---|
6069 | state.posMax = state.pos;
|
---|
6070 | state.pos = start + 1;
|
---|
6071 |
|
---|
6072 | if (!silent) {
|
---|
6073 | state.push({
|
---|
6074 | type: 'sub',
|
---|
6075 | level: state.level,
|
---|
6076 | content: content.replace(UNESCAPE_RE, '$1')
|
---|
6077 | });
|
---|
6078 | }
|
---|
6079 |
|
---|
6080 | state.pos = state.posMax + 1;
|
---|
6081 | state.posMax = max;
|
---|
6082 | return true;
|
---|
6083 | }
|
---|
6084 |
|
---|
6085 | // Process ^superscript^
|
---|
6086 |
|
---|
6087 | // same as UNESCAPE_MD_RE plus a space
|
---|
6088 | var UNESCAPE_RE$1 = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
|
---|
6089 |
|
---|
6090 | function sup(state, silent) {
|
---|
6091 | var found,
|
---|
6092 | content,
|
---|
6093 | max = state.posMax,
|
---|
6094 | start = state.pos;
|
---|
6095 |
|
---|
6096 | if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; }
|
---|
6097 | if (silent) { return false; } // don't run any pairs in validation mode
|
---|
6098 | if (start + 2 >= max) { return false; }
|
---|
6099 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
6100 |
|
---|
6101 | state.pos = start + 1;
|
---|
6102 |
|
---|
6103 | while (state.pos < max) {
|
---|
6104 | if (state.src.charCodeAt(state.pos) === 0x5E/* ^ */) {
|
---|
6105 | found = true;
|
---|
6106 | break;
|
---|
6107 | }
|
---|
6108 |
|
---|
6109 | state.parser.skipToken(state);
|
---|
6110 | }
|
---|
6111 |
|
---|
6112 | if (!found || start + 1 === state.pos) {
|
---|
6113 | state.pos = start;
|
---|
6114 | return false;
|
---|
6115 | }
|
---|
6116 |
|
---|
6117 | content = state.src.slice(start + 1, state.pos);
|
---|
6118 |
|
---|
6119 | // don't allow unescaped spaces/newlines inside
|
---|
6120 | if (content.match(/(^|[^\\])(\\\\)*\s/)) {
|
---|
6121 | state.pos = start;
|
---|
6122 | return false;
|
---|
6123 | }
|
---|
6124 |
|
---|
6125 | // found!
|
---|
6126 | state.posMax = state.pos;
|
---|
6127 | state.pos = start + 1;
|
---|
6128 |
|
---|
6129 | if (!silent) {
|
---|
6130 | state.push({
|
---|
6131 | type: 'sup',
|
---|
6132 | level: state.level,
|
---|
6133 | content: content.replace(UNESCAPE_RE$1, '$1')
|
---|
6134 | });
|
---|
6135 | }
|
---|
6136 |
|
---|
6137 | state.pos = state.posMax + 1;
|
---|
6138 | state.posMax = max;
|
---|
6139 | return true;
|
---|
6140 | }
|
---|
6141 |
|
---|
6142 | // Process [links](<to> "stuff")
|
---|
6143 |
|
---|
6144 |
|
---|
6145 | function links(state, silent) {
|
---|
6146 | var labelStart,
|
---|
6147 | labelEnd,
|
---|
6148 | label,
|
---|
6149 | href,
|
---|
6150 | title,
|
---|
6151 | pos,
|
---|
6152 | ref,
|
---|
6153 | code,
|
---|
6154 | isImage = false,
|
---|
6155 | oldPos = state.pos,
|
---|
6156 | max = state.posMax,
|
---|
6157 | start = state.pos,
|
---|
6158 | marker = state.src.charCodeAt(start);
|
---|
6159 |
|
---|
6160 | if (marker === 0x21/* ! */) {
|
---|
6161 | isImage = true;
|
---|
6162 | marker = state.src.charCodeAt(++start);
|
---|
6163 | }
|
---|
6164 |
|
---|
6165 | if (marker !== 0x5B/* [ */) { return false; }
|
---|
6166 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
6167 |
|
---|
6168 | labelStart = start + 1;
|
---|
6169 | labelEnd = parseLinkLabel(state, start);
|
---|
6170 |
|
---|
6171 | // parser failed to find ']', so it's not a valid link
|
---|
6172 | if (labelEnd < 0) { return false; }
|
---|
6173 |
|
---|
6174 | pos = labelEnd + 1;
|
---|
6175 | if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
|
---|
6176 | //
|
---|
6177 | // Inline link
|
---|
6178 | //
|
---|
6179 |
|
---|
6180 | // [link]( <href> "title" )
|
---|
6181 | // ^^ skipping these spaces
|
---|
6182 | pos++;
|
---|
6183 | for (; pos < max; pos++) {
|
---|
6184 | code = state.src.charCodeAt(pos);
|
---|
6185 | if (code !== 0x20 && code !== 0x0A) { break; }
|
---|
6186 | }
|
---|
6187 | if (pos >= max) { return false; }
|
---|
6188 |
|
---|
6189 | // [link]( <href> "title" )
|
---|
6190 | // ^^^^^^ parsing link destination
|
---|
6191 | start = pos;
|
---|
6192 | if (parseLinkDestination(state, pos)) {
|
---|
6193 | href = state.linkContent;
|
---|
6194 | pos = state.pos;
|
---|
6195 | } else {
|
---|
6196 | href = '';
|
---|
6197 | }
|
---|
6198 |
|
---|
6199 | // [link]( <href> "title" )
|
---|
6200 | // ^^ skipping these spaces
|
---|
6201 | start = pos;
|
---|
6202 | for (; pos < max; pos++) {
|
---|
6203 | code = state.src.charCodeAt(pos);
|
---|
6204 | if (code !== 0x20 && code !== 0x0A) { break; }
|
---|
6205 | }
|
---|
6206 |
|
---|
6207 | // [link]( <href> "title" )
|
---|
6208 | // ^^^^^^^ parsing link title
|
---|
6209 | if (pos < max && start !== pos && parseLinkTitle(state, pos)) {
|
---|
6210 | title = state.linkContent;
|
---|
6211 | pos = state.pos;
|
---|
6212 |
|
---|
6213 | // [link]( <href> "title" )
|
---|
6214 | // ^^ skipping these spaces
|
---|
6215 | for (; pos < max; pos++) {
|
---|
6216 | code = state.src.charCodeAt(pos);
|
---|
6217 | if (code !== 0x20 && code !== 0x0A) { break; }
|
---|
6218 | }
|
---|
6219 | } else {
|
---|
6220 | title = '';
|
---|
6221 | }
|
---|
6222 |
|
---|
6223 | if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
|
---|
6224 | state.pos = oldPos;
|
---|
6225 | return false;
|
---|
6226 | }
|
---|
6227 | pos++;
|
---|
6228 | } else {
|
---|
6229 | //
|
---|
6230 | // Link reference
|
---|
6231 | //
|
---|
6232 |
|
---|
6233 | // do not allow nested reference links
|
---|
6234 | if (state.linkLevel > 0) { return false; }
|
---|
6235 |
|
---|
6236 | // [foo] [bar]
|
---|
6237 | // ^^ optional whitespace (can include newlines)
|
---|
6238 | for (; pos < max; pos++) {
|
---|
6239 | code = state.src.charCodeAt(pos);
|
---|
6240 | if (code !== 0x20 && code !== 0x0A) { break; }
|
---|
6241 | }
|
---|
6242 |
|
---|
6243 | if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
|
---|
6244 | start = pos + 1;
|
---|
6245 | pos = parseLinkLabel(state, pos);
|
---|
6246 | if (pos >= 0) {
|
---|
6247 | label = state.src.slice(start, pos++);
|
---|
6248 | } else {
|
---|
6249 | pos = start - 1;
|
---|
6250 | }
|
---|
6251 | }
|
---|
6252 |
|
---|
6253 | // covers label === '' and label === undefined
|
---|
6254 | // (collapsed reference link and shortcut reference link respectively)
|
---|
6255 | if (!label) {
|
---|
6256 | if (typeof label === 'undefined') {
|
---|
6257 | pos = labelEnd + 1;
|
---|
6258 | }
|
---|
6259 | label = state.src.slice(labelStart, labelEnd);
|
---|
6260 | }
|
---|
6261 |
|
---|
6262 | ref = state.env.references[normalizeReference(label)];
|
---|
6263 | if (!ref) {
|
---|
6264 | state.pos = oldPos;
|
---|
6265 | return false;
|
---|
6266 | }
|
---|
6267 | href = ref.href;
|
---|
6268 | title = ref.title;
|
---|
6269 | }
|
---|
6270 |
|
---|
6271 | //
|
---|
6272 | // We found the end of the link, and know for a fact it's a valid link;
|
---|
6273 | // so all that's left to do is to call tokenizer.
|
---|
6274 | //
|
---|
6275 | if (!silent) {
|
---|
6276 | state.pos = labelStart;
|
---|
6277 | state.posMax = labelEnd;
|
---|
6278 |
|
---|
6279 | if (isImage) {
|
---|
6280 | state.push({
|
---|
6281 | type: 'image',
|
---|
6282 | src: href,
|
---|
6283 | title: title,
|
---|
6284 | alt: state.src.substr(labelStart, labelEnd - labelStart),
|
---|
6285 | level: state.level
|
---|
6286 | });
|
---|
6287 | } else {
|
---|
6288 | state.push({
|
---|
6289 | type: 'link_open',
|
---|
6290 | href: href,
|
---|
6291 | title: title,
|
---|
6292 | level: state.level++
|
---|
6293 | });
|
---|
6294 | state.linkLevel++;
|
---|
6295 | state.parser.tokenize(state);
|
---|
6296 | state.linkLevel--;
|
---|
6297 | state.push({ type: 'link_close', level: --state.level });
|
---|
6298 | }
|
---|
6299 | }
|
---|
6300 |
|
---|
6301 | state.pos = pos;
|
---|
6302 | state.posMax = max;
|
---|
6303 | return true;
|
---|
6304 | }
|
---|
6305 |
|
---|
6306 | // Process inline footnotes (^[...])
|
---|
6307 |
|
---|
6308 |
|
---|
6309 | function footnote_inline(state, silent) {
|
---|
6310 | var labelStart,
|
---|
6311 | labelEnd,
|
---|
6312 | footnoteId,
|
---|
6313 | oldLength,
|
---|
6314 | max = state.posMax,
|
---|
6315 | start = state.pos;
|
---|
6316 |
|
---|
6317 | if (start + 2 >= max) { return false; }
|
---|
6318 | if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; }
|
---|
6319 | if (state.src.charCodeAt(start + 1) !== 0x5B/* [ */) { return false; }
|
---|
6320 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
6321 |
|
---|
6322 | labelStart = start + 2;
|
---|
6323 | labelEnd = parseLinkLabel(state, start + 1);
|
---|
6324 |
|
---|
6325 | // parser failed to find ']', so it's not a valid note
|
---|
6326 | if (labelEnd < 0) { return false; }
|
---|
6327 |
|
---|
6328 | // We found the end of the link, and know for a fact it's a valid link;
|
---|
6329 | // so all that's left to do is to call tokenizer.
|
---|
6330 | //
|
---|
6331 | if (!silent) {
|
---|
6332 | if (!state.env.footnotes) { state.env.footnotes = {}; }
|
---|
6333 | if (!state.env.footnotes.list) { state.env.footnotes.list = []; }
|
---|
6334 | footnoteId = state.env.footnotes.list.length;
|
---|
6335 |
|
---|
6336 | state.pos = labelStart;
|
---|
6337 | state.posMax = labelEnd;
|
---|
6338 |
|
---|
6339 | state.push({
|
---|
6340 | type: 'footnote_ref',
|
---|
6341 | id: footnoteId,
|
---|
6342 | level: state.level
|
---|
6343 | });
|
---|
6344 | state.linkLevel++;
|
---|
6345 | oldLength = state.tokens.length;
|
---|
6346 | state.parser.tokenize(state);
|
---|
6347 | state.env.footnotes.list[footnoteId] = { tokens: state.tokens.splice(oldLength) };
|
---|
6348 | state.linkLevel--;
|
---|
6349 | }
|
---|
6350 |
|
---|
6351 | state.pos = labelEnd + 1;
|
---|
6352 | state.posMax = max;
|
---|
6353 | return true;
|
---|
6354 | }
|
---|
6355 |
|
---|
6356 | // Process footnote references ([^...])
|
---|
6357 |
|
---|
6358 | function footnote_ref(state, silent) {
|
---|
6359 | var label,
|
---|
6360 | pos,
|
---|
6361 | footnoteId,
|
---|
6362 | footnoteSubId,
|
---|
6363 | max = state.posMax,
|
---|
6364 | start = state.pos;
|
---|
6365 |
|
---|
6366 | // should be at least 4 chars - "[^x]"
|
---|
6367 | if (start + 3 > max) { return false; }
|
---|
6368 |
|
---|
6369 | if (!state.env.footnotes || !state.env.footnotes.refs) { return false; }
|
---|
6370 | if (state.src.charCodeAt(start) !== 0x5B/* [ */) { return false; }
|
---|
6371 | if (state.src.charCodeAt(start + 1) !== 0x5E/* ^ */) { return false; }
|
---|
6372 | if (state.level >= state.options.maxNesting) { return false; }
|
---|
6373 |
|
---|
6374 | for (pos = start + 2; pos < max; pos++) {
|
---|
6375 | if (state.src.charCodeAt(pos) === 0x20) { return false; }
|
---|
6376 | if (state.src.charCodeAt(pos) === 0x0A) { return false; }
|
---|
6377 | if (state.src.charCodeAt(pos) === 0x5D /* ] */) {
|
---|
6378 | break;
|
---|
6379 | }
|
---|
6380 | }
|
---|
6381 |
|
---|
6382 | if (pos === start + 2) { return false; } // no empty footnote labels
|
---|
6383 | if (pos >= max) { return false; }
|
---|
6384 | pos++;
|
---|
6385 |
|
---|
6386 | label = state.src.slice(start + 2, pos - 1);
|
---|
6387 | if (typeof state.env.footnotes.refs[':' + label] === 'undefined') { return false; }
|
---|
6388 |
|
---|
6389 | if (!silent) {
|
---|
6390 | if (!state.env.footnotes.list) { state.env.footnotes.list = []; }
|
---|
6391 |
|
---|
6392 | if (state.env.footnotes.refs[':' + label] < 0) {
|
---|
6393 | footnoteId = state.env.footnotes.list.length;
|
---|
6394 | state.env.footnotes.list[footnoteId] = { label: label, count: 0 };
|
---|
6395 | state.env.footnotes.refs[':' + label] = footnoteId;
|
---|
6396 | } else {
|
---|
6397 | footnoteId = state.env.footnotes.refs[':' + label];
|
---|
6398 | }
|
---|
6399 |
|
---|
6400 | footnoteSubId = state.env.footnotes.list[footnoteId].count;
|
---|
6401 | state.env.footnotes.list[footnoteId].count++;
|
---|
6402 |
|
---|
6403 | state.push({
|
---|
6404 | type: 'footnote_ref',
|
---|
6405 | id: footnoteId,
|
---|
6406 | subId: footnoteSubId,
|
---|
6407 | level: state.level
|
---|
6408 | });
|
---|
6409 | }
|
---|
6410 |
|
---|
6411 | state.pos = pos;
|
---|
6412 | state.posMax = max;
|
---|
6413 | return true;
|
---|
6414 | }
|
---|
6415 |
|
---|
6416 | // List of valid url schemas, accorting to commonmark spec
|
---|
6417 | // http://jgm.github.io/CommonMark/spec.html#autolinks
|
---|
6418 |
|
---|
6419 | var url_schemas = [
|
---|
6420 | 'coap',
|
---|
6421 | 'doi',
|
---|
6422 | 'javascript',
|
---|
6423 | 'aaa',
|
---|
6424 | 'aaas',
|
---|
6425 | 'about',
|
---|
6426 | 'acap',
|
---|
6427 | 'cap',
|
---|
6428 | 'cid',
|
---|
6429 | 'crid',
|
---|
6430 | 'data',
|
---|
6431 | 'dav',
|
---|
6432 | 'dict',
|
---|
6433 | 'dns',
|
---|
6434 | 'file',
|
---|
6435 | 'ftp',
|
---|
6436 | 'geo',
|
---|
6437 | 'go',
|
---|
6438 | 'gopher',
|
---|
6439 | 'h323',
|
---|
6440 | 'http',
|
---|
6441 | 'https',
|
---|
6442 | 'iax',
|
---|
6443 | 'icap',
|
---|
6444 | 'im',
|
---|
6445 | 'imap',
|
---|
6446 | 'info',
|
---|
6447 | 'ipp',
|
---|
6448 | 'iris',
|
---|
6449 | 'iris.beep',
|
---|
6450 | 'iris.xpc',
|
---|
6451 | 'iris.xpcs',
|
---|
6452 | 'iris.lwz',
|
---|
6453 | 'ldap',
|
---|
6454 | 'mailto',
|
---|
6455 | 'mid',
|
---|
6456 | 'msrp',
|
---|
6457 | 'msrps',
|
---|
6458 | 'mtqp',
|
---|
6459 | 'mupdate',
|
---|
6460 | 'news',
|
---|
6461 | 'nfs',
|
---|
6462 | 'ni',
|
---|
6463 | 'nih',
|
---|
6464 | 'nntp',
|
---|
6465 | 'opaquelocktoken',
|
---|
6466 | 'pop',
|
---|
6467 | 'pres',
|
---|
6468 | 'rtsp',
|
---|
6469 | 'service',
|
---|
6470 | 'session',
|
---|
6471 | 'shttp',
|
---|
6472 | 'sieve',
|
---|
6473 | 'sip',
|
---|
6474 | 'sips',
|
---|
6475 | 'sms',
|
---|
6476 | 'snmp',
|
---|
6477 | 'soap.beep',
|
---|
6478 | 'soap.beeps',
|
---|
6479 | 'tag',
|
---|
6480 | 'tel',
|
---|
6481 | 'telnet',
|
---|
6482 | 'tftp',
|
---|
6483 | 'thismessage',
|
---|
6484 | 'tn3270',
|
---|
6485 | 'tip',
|
---|
6486 | 'tv',
|
---|
6487 | 'urn',
|
---|
6488 | 'vemmi',
|
---|
6489 | 'ws',
|
---|
6490 | 'wss',
|
---|
6491 | 'xcon',
|
---|
6492 | 'xcon-userid',
|
---|
6493 | 'xmlrpc.beep',
|
---|
6494 | 'xmlrpc.beeps',
|
---|
6495 | 'xmpp',
|
---|
6496 | 'z39.50r',
|
---|
6497 | 'z39.50s',
|
---|
6498 | 'adiumxtra',
|
---|
6499 | 'afp',
|
---|
6500 | 'afs',
|
---|
6501 | 'aim',
|
---|
6502 | 'apt',
|
---|
6503 | 'attachment',
|
---|
6504 | 'aw',
|
---|
6505 | 'beshare',
|
---|
6506 | 'bitcoin',
|
---|
6507 | 'bolo',
|
---|
6508 | 'callto',
|
---|
6509 | 'chrome',
|
---|
6510 | 'chrome-extension',
|
---|
6511 | 'com-eventbrite-attendee',
|
---|
6512 | 'content',
|
---|
6513 | 'cvs',
|
---|
6514 | 'dlna-playsingle',
|
---|
6515 | 'dlna-playcontainer',
|
---|
6516 | 'dtn',
|
---|
6517 | 'dvb',
|
---|
6518 | 'ed2k',
|
---|
6519 | 'facetime',
|
---|
6520 | 'feed',
|
---|
6521 | 'finger',
|
---|
6522 | 'fish',
|
---|
6523 | 'gg',
|
---|
6524 | 'git',
|
---|
6525 | 'gizmoproject',
|
---|
6526 | 'gtalk',
|
---|
6527 | 'hcp',
|
---|
6528 | 'icon',
|
---|
6529 | 'ipn',
|
---|
6530 | 'irc',
|
---|
6531 | 'irc6',
|
---|
6532 | 'ircs',
|
---|
6533 | 'itms',
|
---|
6534 | 'jar',
|
---|
6535 | 'jms',
|
---|
6536 | 'keyparc',
|
---|
6537 | 'lastfm',
|
---|
6538 | 'ldaps',
|
---|
6539 | 'magnet',
|
---|
6540 | 'maps',
|
---|
6541 | 'market',
|
---|
6542 | 'message',
|
---|
6543 | 'mms',
|
---|
6544 | 'ms-help',
|
---|
6545 | 'msnim',
|
---|
6546 | 'mumble',
|
---|
6547 | 'mvn',
|
---|
6548 | 'notes',
|
---|
6549 | 'oid',
|
---|
6550 | 'palm',
|
---|
6551 | 'paparazzi',
|
---|
6552 | 'platform',
|
---|
6553 | 'proxy',
|
---|
6554 | 'psyc',
|
---|
6555 | 'query',
|
---|
6556 | 'res',
|
---|
6557 | 'resource',
|
---|
6558 | 'rmi',
|
---|
6559 | 'rsync',
|
---|
6560 | 'rtmp',
|
---|
6561 | 'secondlife',
|
---|
6562 | 'sftp',
|
---|
6563 | 'sgn',
|
---|
6564 | 'skype',
|
---|
6565 | 'smb',
|
---|
6566 | 'soldat',
|
---|
6567 | 'spotify',
|
---|
6568 | 'ssh',
|
---|
6569 | 'steam',
|
---|
6570 | 'svn',
|
---|
6571 | 'teamspeak',
|
---|
6572 | 'things',
|
---|
6573 | 'udp',
|
---|
6574 | 'unreal',
|
---|
6575 | 'ut2004',
|
---|
6576 | 'ventrilo',
|
---|
6577 | 'view-source',
|
---|
6578 | 'webcal',
|
---|
6579 | 'wtai',
|
---|
6580 | 'wyciwyg',
|
---|
6581 | 'xfire',
|
---|
6582 | 'xri',
|
---|
6583 | 'ymsgr'
|
---|
6584 | ];
|
---|
6585 |
|
---|
6586 | // Process autolinks '<protocol:...>'
|
---|
6587 |
|
---|
6588 |
|
---|
6589 | /*eslint max-len:0*/
|
---|
6590 | var EMAIL_RE = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/;
|
---|
6591 | var AUTOLINK_RE = /^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;
|
---|
6592 |
|
---|
6593 |
|
---|
6594 | function autolink(state, silent) {
|
---|
6595 | var tail, linkMatch, emailMatch, url, fullUrl, pos = state.pos;
|
---|
6596 |
|
---|
6597 | if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
|
---|
6598 |
|
---|
6599 | tail = state.src.slice(pos);
|
---|
6600 |
|
---|
6601 | if (tail.indexOf('>') < 0) { return false; }
|
---|
6602 |
|
---|
6603 | linkMatch = tail.match(AUTOLINK_RE);
|
---|
6604 |
|
---|
6605 | if (linkMatch) {
|
---|
6606 | if (url_schemas.indexOf(linkMatch[1].toLowerCase()) < 0) { return false; }
|
---|
6607 |
|
---|
6608 | url = linkMatch[0].slice(1, -1);
|
---|
6609 | fullUrl = normalizeLink(url);
|
---|
6610 | if (!state.parser.validateLink(url)) { return false; }
|
---|
6611 |
|
---|
6612 | if (!silent) {
|
---|
6613 | state.push({
|
---|
6614 | type: 'link_open',
|
---|
6615 | href: fullUrl,
|
---|
6616 | level: state.level
|
---|
6617 | });
|
---|
6618 | state.push({
|
---|
6619 | type: 'text',
|
---|
6620 | content: url,
|
---|
6621 | level: state.level + 1
|
---|
6622 | });
|
---|
6623 | state.push({ type: 'link_close', level: state.level });
|
---|
6624 | }
|
---|
6625 |
|
---|
6626 | state.pos += linkMatch[0].length;
|
---|
6627 | return true;
|
---|
6628 | }
|
---|
6629 |
|
---|
6630 | emailMatch = tail.match(EMAIL_RE);
|
---|
6631 |
|
---|
6632 | if (emailMatch) {
|
---|
6633 |
|
---|
6634 | url = emailMatch[0].slice(1, -1);
|
---|
6635 |
|
---|
6636 | fullUrl = normalizeLink('mailto:' + url);
|
---|
6637 | if (!state.parser.validateLink(fullUrl)) { return false; }
|
---|
6638 |
|
---|
6639 | if (!silent) {
|
---|
6640 | state.push({
|
---|
6641 | type: 'link_open',
|
---|
6642 | href: fullUrl,
|
---|
6643 | level: state.level
|
---|
6644 | });
|
---|
6645 | state.push({
|
---|
6646 | type: 'text',
|
---|
6647 | content: url,
|
---|
6648 | level: state.level + 1
|
---|
6649 | });
|
---|
6650 | state.push({ type: 'link_close', level: state.level });
|
---|
6651 | }
|
---|
6652 |
|
---|
6653 | state.pos += emailMatch[0].length;
|
---|
6654 | return true;
|
---|
6655 | }
|
---|
6656 |
|
---|
6657 | return false;
|
---|
6658 | }
|
---|
6659 |
|
---|
6660 | // Regexps to match html elements
|
---|
6661 |
|
---|
6662 | function replace$1(regex, options) {
|
---|
6663 | regex = regex.source;
|
---|
6664 | options = options || '';
|
---|
6665 |
|
---|
6666 | return function self(name, val) {
|
---|
6667 | if (!name) {
|
---|
6668 | return new RegExp(regex, options);
|
---|
6669 | }
|
---|
6670 | val = val.source || val;
|
---|
6671 | regex = regex.replace(name, val);
|
---|
6672 | return self;
|
---|
6673 | };
|
---|
6674 | }
|
---|
6675 |
|
---|
6676 |
|
---|
6677 | var attr_name = /[a-zA-Z_:][a-zA-Z0-9:._-]*/;
|
---|
6678 |
|
---|
6679 | var unquoted = /[^"'=<>`\x00-\x20]+/;
|
---|
6680 | var single_quoted = /'[^']*'/;
|
---|
6681 | var double_quoted = /"[^"]*"/;
|
---|
6682 |
|
---|
6683 | /*eslint no-spaced-func:0*/
|
---|
6684 | var attr_value = replace$1(/(?:unquoted|single_quoted|double_quoted)/)
|
---|
6685 | ('unquoted', unquoted)
|
---|
6686 | ('single_quoted', single_quoted)
|
---|
6687 | ('double_quoted', double_quoted)
|
---|
6688 | ();
|
---|
6689 |
|
---|
6690 | var attribute = replace$1(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)
|
---|
6691 | ('attr_name', attr_name)
|
---|
6692 | ('attr_value', attr_value)
|
---|
6693 | ();
|
---|
6694 |
|
---|
6695 | var open_tag = replace$1(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)
|
---|
6696 | ('attribute', attribute)
|
---|
6697 | ();
|
---|
6698 |
|
---|
6699 | var close_tag = /<\/[A-Za-z][A-Za-z0-9]*\s*>/;
|
---|
6700 | var comment = /<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
|
---|
6701 | var processing = /<[?].*?[?]>/;
|
---|
6702 | var declaration = /<![A-Z]+\s+[^>]*>/;
|
---|
6703 | var cdata = /<!\[CDATA\[[\s\S]*?\]\]>/;
|
---|
6704 |
|
---|
6705 | var HTML_TAG_RE = replace$1(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)
|
---|
6706 | ('open_tag', open_tag)
|
---|
6707 | ('close_tag', close_tag)
|
---|
6708 | ('comment', comment)
|
---|
6709 | ('processing', processing)
|
---|
6710 | ('declaration', declaration)
|
---|
6711 | ('cdata', cdata)
|
---|
6712 | ();
|
---|
6713 |
|
---|
6714 | // Process html tags
|
---|
6715 |
|
---|
6716 |
|
---|
6717 | function isLetter$2(ch) {
|
---|
6718 | /*eslint no-bitwise:0*/
|
---|
6719 | var lc = ch | 0x20; // to lower case
|
---|
6720 | return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
|
---|
6721 | }
|
---|
6722 |
|
---|
6723 |
|
---|
6724 | function htmltag(state, silent) {
|
---|
6725 | var ch, match, max, pos = state.pos;
|
---|
6726 |
|
---|
6727 | if (!state.options.html) { return false; }
|
---|
6728 |
|
---|
6729 | // Check start
|
---|
6730 | max = state.posMax;
|
---|
6731 | if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
|
---|
6732 | pos + 2 >= max) {
|
---|
6733 | return false;
|
---|
6734 | }
|
---|
6735 |
|
---|
6736 | // Quick fail on second char
|
---|
6737 | ch = state.src.charCodeAt(pos + 1);
|
---|
6738 | if (ch !== 0x21/* ! */ &&
|
---|
6739 | ch !== 0x3F/* ? */ &&
|
---|
6740 | ch !== 0x2F/* / */ &&
|
---|
6741 | !isLetter$2(ch)) {
|
---|
6742 | return false;
|
---|
6743 | }
|
---|
6744 |
|
---|
6745 | match = state.src.slice(pos).match(HTML_TAG_RE);
|
---|
6746 | if (!match) { return false; }
|
---|
6747 |
|
---|
6748 | if (!silent) {
|
---|
6749 | state.push({
|
---|
6750 | type: 'htmltag',
|
---|
6751 | content: state.src.slice(pos, pos + match[0].length),
|
---|
6752 | level: state.level
|
---|
6753 | });
|
---|
6754 | }
|
---|
6755 | state.pos += match[0].length;
|
---|
6756 | return true;
|
---|
6757 | }
|
---|
6758 |
|
---|
6759 | // Process html entity - {, ¯, ", ...
|
---|
6760 |
|
---|
6761 |
|
---|
6762 | var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i;
|
---|
6763 | var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
|
---|
6764 |
|
---|
6765 |
|
---|
6766 | function entity(state, silent) {
|
---|
6767 | var ch, code, match, pos = state.pos, max = state.posMax;
|
---|
6768 |
|
---|
6769 | if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }
|
---|
6770 |
|
---|
6771 | if (pos + 1 < max) {
|
---|
6772 | ch = state.src.charCodeAt(pos + 1);
|
---|
6773 |
|
---|
6774 | if (ch === 0x23 /* # */) {
|
---|
6775 | match = state.src.slice(pos).match(DIGITAL_RE);
|
---|
6776 | if (match) {
|
---|
6777 | if (!silent) {
|
---|
6778 | code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
|
---|
6779 | state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
|
---|
6780 | }
|
---|
6781 | state.pos += match[0].length;
|
---|
6782 | return true;
|
---|
6783 | }
|
---|
6784 | } else {
|
---|
6785 | match = state.src.slice(pos).match(NAMED_RE);
|
---|
6786 | if (match) {
|
---|
6787 | var decoded = decodeEntity(match[1]);
|
---|
6788 | if (match[1] !== decoded) {
|
---|
6789 | if (!silent) { state.pending += decoded; }
|
---|
6790 | state.pos += match[0].length;
|
---|
6791 | return true;
|
---|
6792 | }
|
---|
6793 | }
|
---|
6794 | }
|
---|
6795 | }
|
---|
6796 |
|
---|
6797 | if (!silent) { state.pending += '&'; }
|
---|
6798 | state.pos++;
|
---|
6799 | return true;
|
---|
6800 | }
|
---|
6801 |
|
---|
6802 | /**
|
---|
6803 | * Inline Parser `rules`
|
---|
6804 | */
|
---|
6805 |
|
---|
6806 | var _rules$2 = [
|
---|
6807 | [ 'text', text ],
|
---|
6808 | [ 'newline', newline ],
|
---|
6809 | [ 'escape', escape ],
|
---|
6810 | [ 'backticks', backticks ],
|
---|
6811 | [ 'del', del ],
|
---|
6812 | [ 'ins', ins ],
|
---|
6813 | [ 'mark', mark ],
|
---|
6814 | [ 'emphasis', emphasis ],
|
---|
6815 | [ 'sub', sub ],
|
---|
6816 | [ 'sup', sup ],
|
---|
6817 | [ 'links', links ],
|
---|
6818 | [ 'footnote_inline', footnote_inline ],
|
---|
6819 | [ 'footnote_ref', footnote_ref ],
|
---|
6820 | [ 'autolink', autolink ],
|
---|
6821 | [ 'htmltag', htmltag ],
|
---|
6822 | [ 'entity', entity ]
|
---|
6823 | ];
|
---|
6824 |
|
---|
6825 | /**
|
---|
6826 | * Inline Parser class. Note that link validation is stricter
|
---|
6827 | * in Remarkable than what is specified by CommonMark. If you
|
---|
6828 | * want to change this you can use a custom validator.
|
---|
6829 | *
|
---|
6830 | * @api private
|
---|
6831 | */
|
---|
6832 |
|
---|
6833 | function ParserInline() {
|
---|
6834 | this.ruler = new Ruler();
|
---|
6835 | for (var i = 0; i < _rules$2.length; i++) {
|
---|
6836 | this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
|
---|
6837 | }
|
---|
6838 |
|
---|
6839 | // Can be overridden with a custom validator
|
---|
6840 | this.validateLink = validateLink;
|
---|
6841 | }
|
---|
6842 |
|
---|
6843 | /**
|
---|
6844 | * Skip a single token by running all rules in validation mode.
|
---|
6845 | * Returns `true` if any rule reports success.
|
---|
6846 | *
|
---|
6847 | * @param {Object} `state`
|
---|
6848 | * @api privage
|
---|
6849 | */
|
---|
6850 |
|
---|
6851 | ParserInline.prototype.skipToken = function (state) {
|
---|
6852 | var rules = this.ruler.getRules('');
|
---|
6853 | var len = rules.length;
|
---|
6854 | var pos = state.pos;
|
---|
6855 | var i, cached_pos;
|
---|
6856 |
|
---|
6857 | if ((cached_pos = state.cacheGet(pos)) > 0) {
|
---|
6858 | state.pos = cached_pos;
|
---|
6859 | return;
|
---|
6860 | }
|
---|
6861 |
|
---|
6862 | for (i = 0; i < len; i++) {
|
---|
6863 | if (rules[i](state, true)) {
|
---|
6864 | state.cacheSet(pos, state.pos);
|
---|
6865 | return;
|
---|
6866 | }
|
---|
6867 | }
|
---|
6868 |
|
---|
6869 | state.pos++;
|
---|
6870 | state.cacheSet(pos, state.pos);
|
---|
6871 | };
|
---|
6872 |
|
---|
6873 | /**
|
---|
6874 | * Generate tokens for the given input range.
|
---|
6875 | *
|
---|
6876 | * @param {Object} `state`
|
---|
6877 | * @api private
|
---|
6878 | */
|
---|
6879 |
|
---|
6880 | ParserInline.prototype.tokenize = function (state) {
|
---|
6881 | var rules = this.ruler.getRules('');
|
---|
6882 | var len = rules.length;
|
---|
6883 | var end = state.posMax;
|
---|
6884 | var ok, i;
|
---|
6885 |
|
---|
6886 | while (state.pos < end) {
|
---|
6887 |
|
---|
6888 | // Try all possible rules.
|
---|
6889 | // On success, the rule should:
|
---|
6890 | //
|
---|
6891 | // - update `state.pos`
|
---|
6892 | // - update `state.tokens`
|
---|
6893 | // - return true
|
---|
6894 | for (i = 0; i < len; i++) {
|
---|
6895 | ok = rules[i](state, false);
|
---|
6896 |
|
---|
6897 | if (ok) {
|
---|
6898 | break;
|
---|
6899 | }
|
---|
6900 | }
|
---|
6901 |
|
---|
6902 | if (ok) {
|
---|
6903 | if (state.pos >= end) { break; }
|
---|
6904 | continue;
|
---|
6905 | }
|
---|
6906 |
|
---|
6907 | state.pending += state.src[state.pos++];
|
---|
6908 | }
|
---|
6909 |
|
---|
6910 | if (state.pending) {
|
---|
6911 | state.pushPending();
|
---|
6912 | }
|
---|
6913 | };
|
---|
6914 |
|
---|
6915 | /**
|
---|
6916 | * Parse the given input string.
|
---|
6917 | *
|
---|
6918 | * @param {String} `str`
|
---|
6919 | * @param {Object} `options`
|
---|
6920 | * @param {Object} `env`
|
---|
6921 | * @param {Array} `outTokens`
|
---|
6922 | * @api private
|
---|
6923 | */
|
---|
6924 |
|
---|
6925 | ParserInline.prototype.parse = function (str, options, env, outTokens) {
|
---|
6926 | var state = new StateInline(str, this, options, env, outTokens);
|
---|
6927 | this.tokenize(state);
|
---|
6928 | };
|
---|
6929 |
|
---|
6930 | /**
|
---|
6931 | * Validate the given `url` by checking for bad protocols.
|
---|
6932 | *
|
---|
6933 | * @param {String} `url`
|
---|
6934 | * @return {Boolean}
|
---|
6935 | */
|
---|
6936 |
|
---|
6937 | function validateLink(url) {
|
---|
6938 | var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file', 'data' ];
|
---|
6939 | var str = url.trim().toLowerCase();
|
---|
6940 | // Care about digital entities "javascript:alert(1)"
|
---|
6941 | str = replaceEntities(str);
|
---|
6942 | if (str.indexOf(':') !== -1 && BAD_PROTOCOLS.indexOf(str.split(':')[0]) !== -1) {
|
---|
6943 | return false;
|
---|
6944 | }
|
---|
6945 | return true;
|
---|
6946 | }
|
---|
6947 |
|
---|
6948 | // Remarkable default options
|
---|
6949 |
|
---|
6950 | var defaultConfig = {
|
---|
6951 | options: {
|
---|
6952 | html: false, // Enable HTML tags in source
|
---|
6953 | xhtmlOut: false, // Use '/' to close single tags (<br />)
|
---|
6954 | breaks: false, // Convert '\n' in paragraphs into <br>
|
---|
6955 | langPrefix: 'language-', // CSS language prefix for fenced blocks
|
---|
6956 | linkTarget: '', // set target to open link in
|
---|
6957 |
|
---|
6958 | // Enable some language-neutral replacements + quotes beautification
|
---|
6959 | typographer: false,
|
---|
6960 |
|
---|
6961 | // Double + single quotes replacement pairs, when typographer enabled,
|
---|
6962 | // and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
|
---|
6963 | quotes: '“”‘’',
|
---|
6964 |
|
---|
6965 | // Highlighter function. Should return escaped HTML,
|
---|
6966 | // or '' if input not changed
|
---|
6967 | //
|
---|
6968 | // function (/*str, lang*/) { return ''; }
|
---|
6969 | //
|
---|
6970 | highlight: null,
|
---|
6971 |
|
---|
6972 | maxNesting: 20 // Internal protection, recursion limit
|
---|
6973 | },
|
---|
6974 |
|
---|
6975 | components: {
|
---|
6976 |
|
---|
6977 | core: {
|
---|
6978 | rules: [
|
---|
6979 | 'block',
|
---|
6980 | 'inline',
|
---|
6981 | 'references',
|
---|
6982 | 'replacements',
|
---|
6983 | 'smartquotes',
|
---|
6984 | 'references',
|
---|
6985 | 'abbr2',
|
---|
6986 | 'footnote_tail'
|
---|
6987 | ]
|
---|
6988 | },
|
---|
6989 |
|
---|
6990 | block: {
|
---|
6991 | rules: [
|
---|
6992 | 'blockquote',
|
---|
6993 | 'code',
|
---|
6994 | 'fences',
|
---|
6995 | 'footnote',
|
---|
6996 | 'heading',
|
---|
6997 | 'hr',
|
---|
6998 | 'htmlblock',
|
---|
6999 | 'lheading',
|
---|
7000 | 'list',
|
---|
7001 | 'paragraph',
|
---|
7002 | 'table'
|
---|
7003 | ]
|
---|
7004 | },
|
---|
7005 |
|
---|
7006 | inline: {
|
---|
7007 | rules: [
|
---|
7008 | 'autolink',
|
---|
7009 | 'backticks',
|
---|
7010 | 'del',
|
---|
7011 | 'emphasis',
|
---|
7012 | 'entity',
|
---|
7013 | 'escape',
|
---|
7014 | 'footnote_ref',
|
---|
7015 | 'htmltag',
|
---|
7016 | 'links',
|
---|
7017 | 'newline',
|
---|
7018 | 'text'
|
---|
7019 | ]
|
---|
7020 | }
|
---|
7021 | }
|
---|
7022 | };
|
---|
7023 |
|
---|
7024 | // Remarkable default options
|
---|
7025 |
|
---|
7026 | var fullConfig = {
|
---|
7027 | options: {
|
---|
7028 | html: false, // Enable HTML tags in source
|
---|
7029 | xhtmlOut: false, // Use '/' to close single tags (<br />)
|
---|
7030 | breaks: false, // Convert '\n' in paragraphs into <br>
|
---|
7031 | langPrefix: 'language-', // CSS language prefix for fenced blocks
|
---|
7032 | linkTarget: '', // set target to open link in
|
---|
7033 |
|
---|
7034 | // Enable some language-neutral replacements + quotes beautification
|
---|
7035 | typographer: false,
|
---|
7036 |
|
---|
7037 | // Double + single quotes replacement pairs, when typographer enabled,
|
---|
7038 | // and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
|
---|
7039 | quotes: '“”‘’',
|
---|
7040 |
|
---|
7041 | // Highlighter function. Should return escaped HTML,
|
---|
7042 | // or '' if input not changed
|
---|
7043 | //
|
---|
7044 | // function (/*str, lang*/) { return ''; }
|
---|
7045 | //
|
---|
7046 | highlight: null,
|
---|
7047 |
|
---|
7048 | maxNesting: 20 // Internal protection, recursion limit
|
---|
7049 | },
|
---|
7050 |
|
---|
7051 | components: {
|
---|
7052 | // Don't restrict core/block/inline rules
|
---|
7053 | core: {},
|
---|
7054 | block: {},
|
---|
7055 | inline: {}
|
---|
7056 | }
|
---|
7057 | };
|
---|
7058 |
|
---|
7059 | // Commonmark default options
|
---|
7060 |
|
---|
7061 | var commonmarkConfig = {
|
---|
7062 | options: {
|
---|
7063 | html: true, // Enable HTML tags in source
|
---|
7064 | xhtmlOut: true, // Use '/' to close single tags (<br />)
|
---|
7065 | breaks: false, // Convert '\n' in paragraphs into <br>
|
---|
7066 | langPrefix: 'language-', // CSS language prefix for fenced blocks
|
---|
7067 | linkTarget: '', // set target to open link in
|
---|
7068 |
|
---|
7069 | // Enable some language-neutral replacements + quotes beautification
|
---|
7070 | typographer: false,
|
---|
7071 |
|
---|
7072 | // Double + single quotes replacement pairs, when typographer enabled,
|
---|
7073 | // and smartquotes on. Set doubles to '«»' for Russian, '„“' for German.
|
---|
7074 | quotes: '“”‘’',
|
---|
7075 |
|
---|
7076 | // Highlighter function. Should return escaped HTML,
|
---|
7077 | // or '' if input not changed
|
---|
7078 | //
|
---|
7079 | // function (/*str, lang*/) { return ''; }
|
---|
7080 | //
|
---|
7081 | highlight: null,
|
---|
7082 |
|
---|
7083 | maxNesting: 20 // Internal protection, recursion limit
|
---|
7084 | },
|
---|
7085 |
|
---|
7086 | components: {
|
---|
7087 |
|
---|
7088 | core: {
|
---|
7089 | rules: [
|
---|
7090 | 'block',
|
---|
7091 | 'inline',
|
---|
7092 | 'references',
|
---|
7093 | 'abbr2'
|
---|
7094 | ]
|
---|
7095 | },
|
---|
7096 |
|
---|
7097 | block: {
|
---|
7098 | rules: [
|
---|
7099 | 'blockquote',
|
---|
7100 | 'code',
|
---|
7101 | 'fences',
|
---|
7102 | 'heading',
|
---|
7103 | 'hr',
|
---|
7104 | 'htmlblock',
|
---|
7105 | 'lheading',
|
---|
7106 | 'list',
|
---|
7107 | 'paragraph'
|
---|
7108 | ]
|
---|
7109 | },
|
---|
7110 |
|
---|
7111 | inline: {
|
---|
7112 | rules: [
|
---|
7113 | 'autolink',
|
---|
7114 | 'backticks',
|
---|
7115 | 'emphasis',
|
---|
7116 | 'entity',
|
---|
7117 | 'escape',
|
---|
7118 | 'htmltag',
|
---|
7119 | 'links',
|
---|
7120 | 'newline',
|
---|
7121 | 'text'
|
---|
7122 | ]
|
---|
7123 | }
|
---|
7124 | }
|
---|
7125 | };
|
---|
7126 |
|
---|
7127 | /**
|
---|
7128 | * Preset configs
|
---|
7129 | */
|
---|
7130 |
|
---|
7131 | var config = {
|
---|
7132 | 'default': defaultConfig,
|
---|
7133 | 'full': fullConfig,
|
---|
7134 | 'commonmark': commonmarkConfig
|
---|
7135 | };
|
---|
7136 |
|
---|
7137 | /**
|
---|
7138 | * The `StateCore` class manages state.
|
---|
7139 | *
|
---|
7140 | * @param {Object} `instance` Remarkable instance
|
---|
7141 | * @param {String} `str` Markdown string
|
---|
7142 | * @param {Object} `env`
|
---|
7143 | */
|
---|
7144 |
|
---|
7145 | function StateCore(instance, str, env) {
|
---|
7146 | this.src = str;
|
---|
7147 | this.env = env;
|
---|
7148 | this.options = instance.options;
|
---|
7149 | this.tokens = [];
|
---|
7150 | this.inlineMode = false;
|
---|
7151 |
|
---|
7152 | this.inline = instance.inline;
|
---|
7153 | this.block = instance.block;
|
---|
7154 | this.renderer = instance.renderer;
|
---|
7155 | this.typographer = instance.typographer;
|
---|
7156 | }
|
---|
7157 |
|
---|
7158 | /**
|
---|
7159 | * The main `Remarkable` class. Create an instance of
|
---|
7160 | * `Remarkable` with a `preset` and/or `options`.
|
---|
7161 | *
|
---|
7162 | * @param {String} `preset` If no preset is given, `default` is used.
|
---|
7163 | * @param {Object} `options`
|
---|
7164 | */
|
---|
7165 |
|
---|
7166 | function Remarkable(preset, options) {
|
---|
7167 | if (typeof preset !== 'string') {
|
---|
7168 | options = preset;
|
---|
7169 | preset = 'default';
|
---|
7170 | }
|
---|
7171 |
|
---|
7172 | if (options && options.linkify != null) {
|
---|
7173 | console.warn(
|
---|
7174 | 'linkify option is removed. Use linkify plugin instead:\n\n' +
|
---|
7175 | 'import Remarkable from \'remarkable\';\n' +
|
---|
7176 | 'import linkify from \'remarkable/linkify\';\n' +
|
---|
7177 | 'new Remarkable().use(linkify)\n'
|
---|
7178 | );
|
---|
7179 | }
|
---|
7180 |
|
---|
7181 | this.inline = new ParserInline();
|
---|
7182 | this.block = new ParserBlock();
|
---|
7183 | this.core = new Core();
|
---|
7184 | this.renderer = new Renderer();
|
---|
7185 | this.ruler = new Ruler();
|
---|
7186 |
|
---|
7187 | this.options = {};
|
---|
7188 | this.configure(config[preset]);
|
---|
7189 | this.set(options || {});
|
---|
7190 | }
|
---|
7191 |
|
---|
7192 | /**
|
---|
7193 | * Set options as an alternative to passing them
|
---|
7194 | * to the constructor.
|
---|
7195 | *
|
---|
7196 | * ```js
|
---|
7197 | * md.set({typographer: true});
|
---|
7198 | * ```
|
---|
7199 | * @param {Object} `options`
|
---|
7200 | * @api public
|
---|
7201 | */
|
---|
7202 |
|
---|
7203 | Remarkable.prototype.set = function (options) {
|
---|
7204 | assign(this.options, options);
|
---|
7205 | };
|
---|
7206 |
|
---|
7207 | /**
|
---|
7208 | * Batch loader for components rules states, and options
|
---|
7209 | *
|
---|
7210 | * @param {Object} `presets`
|
---|
7211 | */
|
---|
7212 |
|
---|
7213 | Remarkable.prototype.configure = function (presets) {
|
---|
7214 | var self = this;
|
---|
7215 |
|
---|
7216 | if (!presets) { throw new Error('Wrong `remarkable` preset, check name/content'); }
|
---|
7217 | if (presets.options) { self.set(presets.options); }
|
---|
7218 | if (presets.components) {
|
---|
7219 | Object.keys(presets.components).forEach(function (name) {
|
---|
7220 | if (presets.components[name].rules) {
|
---|
7221 | self[name].ruler.enable(presets.components[name].rules, true);
|
---|
7222 | }
|
---|
7223 | });
|
---|
7224 | }
|
---|
7225 | };
|
---|
7226 |
|
---|
7227 | /**
|
---|
7228 | * Use a plugin.
|
---|
7229 | *
|
---|
7230 | * ```js
|
---|
7231 | * var md = new Remarkable();
|
---|
7232 | *
|
---|
7233 | * md.use(plugin1)
|
---|
7234 | * .use(plugin2, opts)
|
---|
7235 | * .use(plugin3);
|
---|
7236 | * ```
|
---|
7237 | *
|
---|
7238 | * @param {Function} `plugin`
|
---|
7239 | * @param {Object} `options`
|
---|
7240 | * @return {Object} `Remarkable` for chaining
|
---|
7241 | */
|
---|
7242 |
|
---|
7243 | Remarkable.prototype.use = function (plugin, options) {
|
---|
7244 | plugin(this, options);
|
---|
7245 | return this;
|
---|
7246 | };
|
---|
7247 |
|
---|
7248 |
|
---|
7249 | /**
|
---|
7250 | * Parse the input `string` and return a tokens array.
|
---|
7251 | * Modifies `env` with definitions data.
|
---|
7252 | *
|
---|
7253 | * @param {String} `string`
|
---|
7254 | * @param {Object} `env`
|
---|
7255 | * @return {Array} Array of tokens
|
---|
7256 | */
|
---|
7257 |
|
---|
7258 | Remarkable.prototype.parse = function (str, env) {
|
---|
7259 | var state = new StateCore(this, str, env);
|
---|
7260 | this.core.process(state);
|
---|
7261 | return state.tokens;
|
---|
7262 | };
|
---|
7263 |
|
---|
7264 | /**
|
---|
7265 | * The main `.render()` method that does all the magic :)
|
---|
7266 | *
|
---|
7267 | * @param {String} `string`
|
---|
7268 | * @param {Object} `env`
|
---|
7269 | * @return {String} Rendered HTML.
|
---|
7270 | */
|
---|
7271 |
|
---|
7272 | Remarkable.prototype.render = function (str, env) {
|
---|
7273 | env = env || {};
|
---|
7274 | return this.renderer.render(this.parse(str, env), this.options, env);
|
---|
7275 | };
|
---|
7276 |
|
---|
7277 | /**
|
---|
7278 | * Parse the given content `string` as a single string.
|
---|
7279 | *
|
---|
7280 | * @param {String} `string`
|
---|
7281 | * @param {Object} `env`
|
---|
7282 | * @return {Array} Array of tokens
|
---|
7283 | */
|
---|
7284 |
|
---|
7285 | Remarkable.prototype.parseInline = function (str, env) {
|
---|
7286 | var state = new StateCore(this, str, env);
|
---|
7287 | state.inlineMode = true;
|
---|
7288 | this.core.process(state);
|
---|
7289 | return state.tokens;
|
---|
7290 | };
|
---|
7291 |
|
---|
7292 | /**
|
---|
7293 | * Render a single content `string`, without wrapping it
|
---|
7294 | * to paragraphs
|
---|
7295 | *
|
---|
7296 | * @param {String} `str`
|
---|
7297 | * @param {Object} `env`
|
---|
7298 | * @return {String}
|
---|
7299 | */
|
---|
7300 |
|
---|
7301 | Remarkable.prototype.renderInline = function (str, env) {
|
---|
7302 | env = env || {};
|
---|
7303 | return this.renderer.render(this.parseInline(str, env), this.options, env);
|
---|
7304 | };
|
---|
7305 |
|
---|
7306 | export { Remarkable, utils };
|
---|