marked 7.0.5 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/main.js +270 -0
- package/bin/marked.js +2 -204
- package/lib/marked.cjs +37 -320
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.ts +142 -252
- package/lib/marked.esm.js +38 -320
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +37 -320
- package/lib/marked.umd.js.map +1 -1
- package/man/marked.1 +5 -18
- package/man/marked.1.txt +2 -15
- package/marked.min.js +6 -7
- package/package.json +11 -11
package/lib/marked.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked
|
|
2
|
+
* marked v8.0.1 - a markdown parser
|
|
3
3
|
* Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
@@ -15,25 +15,15 @@
|
|
|
15
15
|
function _getDefaults() {
|
|
16
16
|
return {
|
|
17
17
|
async: false,
|
|
18
|
-
baseUrl: null,
|
|
19
18
|
breaks: false,
|
|
20
19
|
extensions: null,
|
|
21
20
|
gfm: true,
|
|
22
|
-
headerIds: false,
|
|
23
|
-
headerPrefix: '',
|
|
24
|
-
highlight: null,
|
|
25
21
|
hooks: null,
|
|
26
|
-
langPrefix: 'language-',
|
|
27
|
-
mangle: false,
|
|
28
22
|
pedantic: false,
|
|
29
23
|
renderer: null,
|
|
30
|
-
sanitize: false,
|
|
31
|
-
sanitizer: null,
|
|
32
24
|
silent: false,
|
|
33
|
-
smartypants: false,
|
|
34
25
|
tokenizer: null,
|
|
35
|
-
walkTokens: null
|
|
36
|
-
xhtml: false
|
|
26
|
+
walkTokens: null
|
|
37
27
|
};
|
|
38
28
|
}
|
|
39
29
|
let _defaults = _getDefaults();
|
|
@@ -101,26 +91,7 @@ function edit(regex, opt) {
|
|
|
101
91
|
};
|
|
102
92
|
return obj;
|
|
103
93
|
}
|
|
104
|
-
|
|
105
|
-
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
106
|
-
function cleanUrl(sanitize, base, href) {
|
|
107
|
-
if (sanitize) {
|
|
108
|
-
let prot;
|
|
109
|
-
try {
|
|
110
|
-
prot = decodeURIComponent(unescape(href))
|
|
111
|
-
.replace(nonWordAndColonTest, '')
|
|
112
|
-
.toLowerCase();
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (base && !originIndependentUrl.test(href)) {
|
|
122
|
-
href = resolveUrl(base, href);
|
|
123
|
-
}
|
|
94
|
+
function cleanUrl(href) {
|
|
124
95
|
try {
|
|
125
96
|
href = encodeURI(href).replace(/%25/g, '%');
|
|
126
97
|
}
|
|
@@ -129,40 +100,6 @@ function cleanUrl(sanitize, base, href) {
|
|
|
129
100
|
}
|
|
130
101
|
return href;
|
|
131
102
|
}
|
|
132
|
-
const baseUrls = {};
|
|
133
|
-
const justDomain = /^[^:]+:\/*[^/]*$/;
|
|
134
|
-
const protocol = /^([^:]+:)[\s\S]*$/;
|
|
135
|
-
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
136
|
-
function resolveUrl(base, href) {
|
|
137
|
-
if (!baseUrls[' ' + base]) {
|
|
138
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
139
|
-
// but we might need to add _that_
|
|
140
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
141
|
-
if (justDomain.test(base)) {
|
|
142
|
-
baseUrls[' ' + base] = base + '/';
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
base = baseUrls[' ' + base];
|
|
149
|
-
const relativeBase = base.indexOf(':') === -1;
|
|
150
|
-
if (href.substring(0, 2) === '//') {
|
|
151
|
-
if (relativeBase) {
|
|
152
|
-
return href;
|
|
153
|
-
}
|
|
154
|
-
return base.replace(protocol, '$1') + href;
|
|
155
|
-
}
|
|
156
|
-
else if (href.charAt(0) === '/') {
|
|
157
|
-
if (relativeBase) {
|
|
158
|
-
return href;
|
|
159
|
-
}
|
|
160
|
-
return base.replace(domain, '$1') + href;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return base + href;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
103
|
const noopTest = { exec: () => null };
|
|
167
104
|
function splitCells(tableRow, count) {
|
|
168
105
|
// ensure that every cell-delimiting pipe has a space
|
|
@@ -256,35 +193,6 @@ function findClosingBracket(str, b) {
|
|
|
256
193
|
}
|
|
257
194
|
return -1;
|
|
258
195
|
}
|
|
259
|
-
function checkDeprecations(opt, callback) {
|
|
260
|
-
if (!opt || opt.silent) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
if (callback) {
|
|
264
|
-
console.warn('marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async');
|
|
265
|
-
}
|
|
266
|
-
if (opt.sanitize || opt.sanitizer) {
|
|
267
|
-
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
|
|
268
|
-
}
|
|
269
|
-
if (opt.highlight || opt.langPrefix !== 'language-') {
|
|
270
|
-
console.warn('marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight.');
|
|
271
|
-
}
|
|
272
|
-
if (opt.mangle) {
|
|
273
|
-
console.warn('marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`.');
|
|
274
|
-
}
|
|
275
|
-
if (opt.baseUrl) {
|
|
276
|
-
console.warn('marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url.');
|
|
277
|
-
}
|
|
278
|
-
if (opt.smartypants) {
|
|
279
|
-
console.warn('marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants.');
|
|
280
|
-
}
|
|
281
|
-
if (opt.xhtml) {
|
|
282
|
-
console.warn('marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml.');
|
|
283
|
-
}
|
|
284
|
-
if (opt.headerIds || opt.headerPrefix) {
|
|
285
|
-
console.warn('marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`.');
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
196
|
|
|
289
197
|
function outputLink(cap, link, raw, lexer) {
|
|
290
198
|
const href = link.href;
|
|
@@ -466,7 +374,7 @@ class _Tokenizer {
|
|
|
466
374
|
let indent = 0;
|
|
467
375
|
if (this.options.pedantic) {
|
|
468
376
|
indent = 2;
|
|
469
|
-
itemContents = line.
|
|
377
|
+
itemContents = line.trimStart();
|
|
470
378
|
}
|
|
471
379
|
else {
|
|
472
380
|
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
@@ -571,9 +479,9 @@ class _Tokenizer {
|
|
|
571
479
|
list.raw += raw;
|
|
572
480
|
}
|
|
573
481
|
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
574
|
-
list.items[list.items.length - 1].raw = raw.
|
|
575
|
-
list.items[list.items.length - 1].text = itemContents.
|
|
576
|
-
list.raw = list.raw.
|
|
482
|
+
list.items[list.items.length - 1].raw = raw.trimEnd();
|
|
483
|
+
list.items[list.items.length - 1].text = itemContents.trimEnd();
|
|
484
|
+
list.raw = list.raw.trimEnd();
|
|
577
485
|
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
578
486
|
for (let i = 0; i < list.items.length; i++) {
|
|
579
487
|
this.lexer.state.top = false;
|
|
@@ -601,17 +509,9 @@ class _Tokenizer {
|
|
|
601
509
|
type: 'html',
|
|
602
510
|
block: true,
|
|
603
511
|
raw: cap[0],
|
|
604
|
-
pre:
|
|
605
|
-
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
512
|
+
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
|
|
606
513
|
text: cap[0]
|
|
607
514
|
};
|
|
608
|
-
if (this.options.sanitize) {
|
|
609
|
-
const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
|
|
610
|
-
const paragraph = token;
|
|
611
|
-
paragraph.type = 'paragraph';
|
|
612
|
-
paragraph.text = text;
|
|
613
|
-
paragraph.tokens = this.lexer.inline(text);
|
|
614
|
-
}
|
|
615
515
|
return token;
|
|
616
516
|
}
|
|
617
517
|
}
|
|
@@ -749,18 +649,12 @@ class _Tokenizer {
|
|
|
749
649
|
this.lexer.state.inRawBlock = false;
|
|
750
650
|
}
|
|
751
651
|
return {
|
|
752
|
-
type:
|
|
753
|
-
? 'text'
|
|
754
|
-
: 'html',
|
|
652
|
+
type: 'html',
|
|
755
653
|
raw: cap[0],
|
|
756
654
|
inLink: this.lexer.state.inLink,
|
|
757
655
|
inRawBlock: this.lexer.state.inRawBlock,
|
|
758
656
|
block: false,
|
|
759
|
-
text:
|
|
760
|
-
? (this.options.sanitizer
|
|
761
|
-
? this.options.sanitizer(cap[0])
|
|
762
|
-
: escape(cap[0]))
|
|
763
|
-
: cap[0]
|
|
657
|
+
text: cap[0]
|
|
764
658
|
};
|
|
765
659
|
}
|
|
766
660
|
}
|
|
@@ -931,12 +825,12 @@ class _Tokenizer {
|
|
|
931
825
|
};
|
|
932
826
|
}
|
|
933
827
|
}
|
|
934
|
-
autolink(src
|
|
828
|
+
autolink(src) {
|
|
935
829
|
const cap = this.rules.inline.autolink.exec(src);
|
|
936
830
|
if (cap) {
|
|
937
831
|
let text, href;
|
|
938
832
|
if (cap[2] === '@') {
|
|
939
|
-
text = escape(
|
|
833
|
+
text = escape(cap[1]);
|
|
940
834
|
href = 'mailto:' + text;
|
|
941
835
|
}
|
|
942
836
|
else {
|
|
@@ -958,12 +852,12 @@ class _Tokenizer {
|
|
|
958
852
|
};
|
|
959
853
|
}
|
|
960
854
|
}
|
|
961
|
-
url(src
|
|
855
|
+
url(src) {
|
|
962
856
|
let cap;
|
|
963
857
|
if (cap = this.rules.inline.url.exec(src)) {
|
|
964
858
|
let text, href;
|
|
965
859
|
if (cap[2] === '@') {
|
|
966
|
-
text = escape(
|
|
860
|
+
text = escape(cap[0]);
|
|
967
861
|
href = 'mailto:' + text;
|
|
968
862
|
}
|
|
969
863
|
else {
|
|
@@ -996,15 +890,15 @@ class _Tokenizer {
|
|
|
996
890
|
};
|
|
997
891
|
}
|
|
998
892
|
}
|
|
999
|
-
inlineText(src
|
|
893
|
+
inlineText(src) {
|
|
1000
894
|
const cap = this.rules.inline.text.exec(src);
|
|
1001
895
|
if (cap) {
|
|
1002
896
|
let text;
|
|
1003
897
|
if (this.lexer.state.inRawBlock) {
|
|
1004
|
-
text =
|
|
898
|
+
text = cap[0];
|
|
1005
899
|
}
|
|
1006
900
|
else {
|
|
1007
|
-
text = escape(
|
|
901
|
+
text = escape(cap[0]);
|
|
1008
902
|
}
|
|
1009
903
|
return {
|
|
1010
904
|
type: 'text',
|
|
@@ -1292,39 +1186,6 @@ inline.breaks = {
|
|
|
1292
1186
|
.getRegex()
|
|
1293
1187
|
};
|
|
1294
1188
|
|
|
1295
|
-
/**
|
|
1296
|
-
* smartypants text replacement
|
|
1297
|
-
*/
|
|
1298
|
-
function smartypants(text) {
|
|
1299
|
-
return text
|
|
1300
|
-
// em-dashes
|
|
1301
|
-
.replace(/---/g, '\u2014')
|
|
1302
|
-
// en-dashes
|
|
1303
|
-
.replace(/--/g, '\u2013')
|
|
1304
|
-
// opening singles
|
|
1305
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
|
1306
|
-
// closing singles & apostrophes
|
|
1307
|
-
.replace(/'/g, '\u2019')
|
|
1308
|
-
// opening doubles
|
|
1309
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
|
1310
|
-
// closing doubles
|
|
1311
|
-
.replace(/"/g, '\u201d')
|
|
1312
|
-
// ellipses
|
|
1313
|
-
.replace(/\.{3}/g, '\u2026');
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
* mangle email addresses
|
|
1317
|
-
*/
|
|
1318
|
-
function mangle(text) {
|
|
1319
|
-
let out = '';
|
|
1320
|
-
for (let i = 0; i < text.length; i++) {
|
|
1321
|
-
const ch = Math.random() > 0.5
|
|
1322
|
-
? 'x' + text.charCodeAt(i).toString(16)
|
|
1323
|
-
: text.charCodeAt(i).toString();
|
|
1324
|
-
out += '&#' + ch + ';';
|
|
1325
|
-
}
|
|
1326
|
-
return out;
|
|
1327
|
-
}
|
|
1328
1189
|
/**
|
|
1329
1190
|
* Block Lexer
|
|
1330
1191
|
*/
|
|
@@ -1698,13 +1559,13 @@ class _Lexer {
|
|
|
1698
1559
|
continue;
|
|
1699
1560
|
}
|
|
1700
1561
|
// autolink
|
|
1701
|
-
if (token = this.tokenizer.autolink(src
|
|
1562
|
+
if (token = this.tokenizer.autolink(src)) {
|
|
1702
1563
|
src = src.substring(token.raw.length);
|
|
1703
1564
|
tokens.push(token);
|
|
1704
1565
|
continue;
|
|
1705
1566
|
}
|
|
1706
1567
|
// url (gfm)
|
|
1707
|
-
if (!this.state.inLink && (token = this.tokenizer.url(src
|
|
1568
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src))) {
|
|
1708
1569
|
src = src.substring(token.raw.length);
|
|
1709
1570
|
tokens.push(token);
|
|
1710
1571
|
continue;
|
|
@@ -1726,7 +1587,7 @@ class _Lexer {
|
|
|
1726
1587
|
cutSrc = src.substring(0, startIndex + 1);
|
|
1727
1588
|
}
|
|
1728
1589
|
}
|
|
1729
|
-
if (token = this.tokenizer.inlineText(cutSrc
|
|
1590
|
+
if (token = this.tokenizer.inlineText(cutSrc)) {
|
|
1730
1591
|
src = src.substring(token.raw.length);
|
|
1731
1592
|
if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
|
|
1732
1593
|
prevChar = token.raw.slice(-1);
|
|
@@ -1767,21 +1628,13 @@ class _Renderer {
|
|
|
1767
1628
|
}
|
|
1768
1629
|
code(code, infostring, escaped) {
|
|
1769
1630
|
const lang = (infostring || '').match(/^\S*/)?.[0];
|
|
1770
|
-
if (this.options.highlight) {
|
|
1771
|
-
const out = this.options.highlight(code, lang);
|
|
1772
|
-
if (out != null && out !== code) {
|
|
1773
|
-
escaped = true;
|
|
1774
|
-
code = out;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
1631
|
code = code.replace(/\n$/, '') + '\n';
|
|
1778
1632
|
if (!lang) {
|
|
1779
1633
|
return '<pre><code>'
|
|
1780
1634
|
+ (escaped ? code : escape(code, true))
|
|
1781
1635
|
+ '</code></pre>\n';
|
|
1782
1636
|
}
|
|
1783
|
-
return '<pre><code class="'
|
|
1784
|
-
+ this.options.langPrefix
|
|
1637
|
+
return '<pre><code class="language-'
|
|
1785
1638
|
+ escape(lang)
|
|
1786
1639
|
+ '">'
|
|
1787
1640
|
+ (escaped ? code : escape(code, true))
|
|
@@ -1793,16 +1646,12 @@ class _Renderer {
|
|
|
1793
1646
|
html(html, block) {
|
|
1794
1647
|
return html;
|
|
1795
1648
|
}
|
|
1796
|
-
heading(text, level, raw
|
|
1797
|
-
if (this.options.headerIds) {
|
|
1798
|
-
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
1799
|
-
return `<h${level} id="${id}">${text}</h${level}>\n`;
|
|
1800
|
-
}
|
|
1649
|
+
heading(text, level, raw) {
|
|
1801
1650
|
// ignore IDs
|
|
1802
1651
|
return `<h${level}>${text}</h${level}>\n`;
|
|
1803
1652
|
}
|
|
1804
1653
|
hr() {
|
|
1805
|
-
return
|
|
1654
|
+
return '<hr>\n';
|
|
1806
1655
|
}
|
|
1807
1656
|
list(body, ordered, start) {
|
|
1808
1657
|
const type = ordered ? 'ol' : 'ul';
|
|
@@ -1815,9 +1664,7 @@ class _Renderer {
|
|
|
1815
1664
|
checkbox(checked) {
|
|
1816
1665
|
return '<input '
|
|
1817
1666
|
+ (checked ? 'checked="" ' : '')
|
|
1818
|
-
+ 'disabled="" type="checkbox"'
|
|
1819
|
-
+ (this.options.xhtml ? ' /' : '')
|
|
1820
|
-
+ '> ';
|
|
1667
|
+
+ 'disabled="" type="checkbox">';
|
|
1821
1668
|
}
|
|
1822
1669
|
paragraph(text) {
|
|
1823
1670
|
return `<p>${text}</p>\n`;
|
|
@@ -1855,13 +1702,13 @@ class _Renderer {
|
|
|
1855
1702
|
return `<code>${text}</code>`;
|
|
1856
1703
|
}
|
|
1857
1704
|
br() {
|
|
1858
|
-
return
|
|
1705
|
+
return '<br>';
|
|
1859
1706
|
}
|
|
1860
1707
|
del(text) {
|
|
1861
1708
|
return `<del>${text}</del>`;
|
|
1862
1709
|
}
|
|
1863
1710
|
link(href, title, text) {
|
|
1864
|
-
const cleanHref = cleanUrl(
|
|
1711
|
+
const cleanHref = cleanUrl(href);
|
|
1865
1712
|
if (cleanHref === null) {
|
|
1866
1713
|
return text;
|
|
1867
1714
|
}
|
|
@@ -1874,7 +1721,7 @@ class _Renderer {
|
|
|
1874
1721
|
return out;
|
|
1875
1722
|
}
|
|
1876
1723
|
image(href, title, text) {
|
|
1877
|
-
const cleanHref = cleanUrl(
|
|
1724
|
+
const cleanHref = cleanUrl(href);
|
|
1878
1725
|
if (cleanHref === null) {
|
|
1879
1726
|
return text;
|
|
1880
1727
|
}
|
|
@@ -1883,7 +1730,7 @@ class _Renderer {
|
|
|
1883
1730
|
if (title) {
|
|
1884
1731
|
out += ` title="${title}"`;
|
|
1885
1732
|
}
|
|
1886
|
-
out +=
|
|
1733
|
+
out += '>';
|
|
1887
1734
|
return out;
|
|
1888
1735
|
}
|
|
1889
1736
|
text(text) {
|
|
@@ -1926,52 +1773,6 @@ class _TextRenderer {
|
|
|
1926
1773
|
}
|
|
1927
1774
|
}
|
|
1928
1775
|
|
|
1929
|
-
/**
|
|
1930
|
-
* Slugger generates header id
|
|
1931
|
-
*/
|
|
1932
|
-
class _Slugger {
|
|
1933
|
-
seen;
|
|
1934
|
-
constructor() {
|
|
1935
|
-
this.seen = {};
|
|
1936
|
-
}
|
|
1937
|
-
serialize(value) {
|
|
1938
|
-
return value
|
|
1939
|
-
.toLowerCase()
|
|
1940
|
-
.trim()
|
|
1941
|
-
// remove html tags
|
|
1942
|
-
.replace(/<[!\/a-z].*?>/ig, '')
|
|
1943
|
-
// remove unwanted chars
|
|
1944
|
-
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
|
|
1945
|
-
.replace(/\s/g, '-');
|
|
1946
|
-
}
|
|
1947
|
-
/**
|
|
1948
|
-
* Finds the next safe (unique) slug to use
|
|
1949
|
-
*/
|
|
1950
|
-
getNextSafeSlug(originalSlug, isDryRun) {
|
|
1951
|
-
let slug = originalSlug;
|
|
1952
|
-
let occurenceAccumulator = 0;
|
|
1953
|
-
if (this.seen.hasOwnProperty(slug)) {
|
|
1954
|
-
occurenceAccumulator = this.seen[originalSlug];
|
|
1955
|
-
do {
|
|
1956
|
-
occurenceAccumulator++;
|
|
1957
|
-
slug = originalSlug + '-' + occurenceAccumulator;
|
|
1958
|
-
} while (this.seen.hasOwnProperty(slug));
|
|
1959
|
-
}
|
|
1960
|
-
if (!isDryRun) {
|
|
1961
|
-
this.seen[originalSlug] = occurenceAccumulator;
|
|
1962
|
-
this.seen[slug] = 0;
|
|
1963
|
-
}
|
|
1964
|
-
return slug;
|
|
1965
|
-
}
|
|
1966
|
-
/**
|
|
1967
|
-
* Convert string to unique id
|
|
1968
|
-
*/
|
|
1969
|
-
slug(value, options = {}) {
|
|
1970
|
-
const slug = this.serialize(value);
|
|
1971
|
-
return this.getNextSafeSlug(slug, options.dryrun);
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
1776
|
/**
|
|
1976
1777
|
* Parsing & Compiling
|
|
1977
1778
|
*/
|
|
@@ -1979,14 +1780,12 @@ class _Parser {
|
|
|
1979
1780
|
options;
|
|
1980
1781
|
renderer;
|
|
1981
1782
|
textRenderer;
|
|
1982
|
-
slugger;
|
|
1983
1783
|
constructor(options) {
|
|
1984
1784
|
this.options = options || _defaults;
|
|
1985
1785
|
this.options.renderer = this.options.renderer || new _Renderer();
|
|
1986
1786
|
this.renderer = this.options.renderer;
|
|
1987
1787
|
this.renderer.options = this.options;
|
|
1988
1788
|
this.textRenderer = new _TextRenderer();
|
|
1989
|
-
this.slugger = new _Slugger();
|
|
1990
1789
|
}
|
|
1991
1790
|
/**
|
|
1992
1791
|
* Static Parse Method
|
|
@@ -2028,7 +1827,7 @@ class _Parser {
|
|
|
2028
1827
|
}
|
|
2029
1828
|
case 'heading': {
|
|
2030
1829
|
const headingToken = token;
|
|
2031
|
-
out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer))
|
|
1830
|
+
out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)));
|
|
2032
1831
|
continue;
|
|
2033
1832
|
}
|
|
2034
1833
|
case 'code': {
|
|
@@ -2086,12 +1885,12 @@ class _Parser {
|
|
|
2086
1885
|
else {
|
|
2087
1886
|
item.tokens.unshift({
|
|
2088
1887
|
type: 'text',
|
|
2089
|
-
text: checkbox
|
|
1888
|
+
text: checkbox + ' '
|
|
2090
1889
|
});
|
|
2091
1890
|
}
|
|
2092
1891
|
}
|
|
2093
1892
|
else {
|
|
2094
|
-
itemBody += checkbox;
|
|
1893
|
+
itemBody += checkbox + ' ';
|
|
2095
1894
|
}
|
|
2096
1895
|
}
|
|
2097
1896
|
itemBody += this.parse(item.tokens, loose);
|
|
@@ -2251,7 +2050,6 @@ class Marked {
|
|
|
2251
2050
|
Lexer = _Lexer;
|
|
2252
2051
|
lexer = _Lexer.lex;
|
|
2253
2052
|
Tokenizer = _Tokenizer;
|
|
2254
|
-
Slugger = _Slugger;
|
|
2255
2053
|
Hooks = _Hooks;
|
|
2256
2054
|
constructor(...args) {
|
|
2257
2055
|
this.use(...args);
|
|
@@ -2448,12 +2246,8 @@ class Marked {
|
|
|
2448
2246
|
return this;
|
|
2449
2247
|
}
|
|
2450
2248
|
#parseMarkdown(lexer, parser) {
|
|
2451
|
-
return (src,
|
|
2452
|
-
|
|
2453
|
-
callback = optOrCallback;
|
|
2454
|
-
optOrCallback = null;
|
|
2455
|
-
}
|
|
2456
|
-
const origOpt = { ...optOrCallback };
|
|
2249
|
+
return (src, options) => {
|
|
2250
|
+
const origOpt = { ...options };
|
|
2457
2251
|
const opt = { ...this.defaults, ...origOpt };
|
|
2458
2252
|
// Show warning if an extension set async to true but the parse was called with async: false
|
|
2459
2253
|
if (this.defaults.async === true && origOpt.async === false) {
|
|
@@ -2462,7 +2256,7 @@ class Marked {
|
|
|
2462
2256
|
}
|
|
2463
2257
|
opt.async = true;
|
|
2464
2258
|
}
|
|
2465
|
-
const throwError = this.#onError(!!opt.silent, !!opt.async
|
|
2259
|
+
const throwError = this.#onError(!!opt.silent, !!opt.async);
|
|
2466
2260
|
// throw error in case of non string input
|
|
2467
2261
|
if (typeof src === 'undefined' || src === null) {
|
|
2468
2262
|
return throwError(new Error('marked(): input parameter is undefined or null'));
|
|
@@ -2471,76 +2265,9 @@ class Marked {
|
|
|
2471
2265
|
return throwError(new Error('marked(): input parameter is of type '
|
|
2472
2266
|
+ Object.prototype.toString.call(src) + ', string expected'));
|
|
2473
2267
|
}
|
|
2474
|
-
checkDeprecations(opt, callback);
|
|
2475
2268
|
if (opt.hooks) {
|
|
2476
2269
|
opt.hooks.options = opt;
|
|
2477
2270
|
}
|
|
2478
|
-
if (callback) {
|
|
2479
|
-
const resultCallback = callback;
|
|
2480
|
-
const highlight = opt.highlight;
|
|
2481
|
-
let tokens;
|
|
2482
|
-
try {
|
|
2483
|
-
if (opt.hooks) {
|
|
2484
|
-
src = opt.hooks.preprocess(src);
|
|
2485
|
-
}
|
|
2486
|
-
tokens = lexer(src, opt);
|
|
2487
|
-
}
|
|
2488
|
-
catch (e) {
|
|
2489
|
-
return throwError(e);
|
|
2490
|
-
}
|
|
2491
|
-
const done = (err) => {
|
|
2492
|
-
let out;
|
|
2493
|
-
if (!err) {
|
|
2494
|
-
try {
|
|
2495
|
-
if (opt.walkTokens) {
|
|
2496
|
-
this.walkTokens(tokens, opt.walkTokens);
|
|
2497
|
-
}
|
|
2498
|
-
out = parser(tokens, opt);
|
|
2499
|
-
if (opt.hooks) {
|
|
2500
|
-
out = opt.hooks.postprocess(out);
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
catch (e) {
|
|
2504
|
-
err = e;
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
opt.highlight = highlight;
|
|
2508
|
-
return err
|
|
2509
|
-
? throwError(err)
|
|
2510
|
-
: resultCallback(null, out);
|
|
2511
|
-
};
|
|
2512
|
-
if (!highlight || highlight.length < 3) {
|
|
2513
|
-
return done();
|
|
2514
|
-
}
|
|
2515
|
-
delete opt.highlight;
|
|
2516
|
-
if (!tokens.length)
|
|
2517
|
-
return done();
|
|
2518
|
-
let pending = 0;
|
|
2519
|
-
this.walkTokens(tokens, (token) => {
|
|
2520
|
-
if (token.type === 'code') {
|
|
2521
|
-
pending++;
|
|
2522
|
-
setTimeout(() => {
|
|
2523
|
-
highlight(token.text, token.lang, (err, code) => {
|
|
2524
|
-
if (err) {
|
|
2525
|
-
return done(err);
|
|
2526
|
-
}
|
|
2527
|
-
if (code != null && code !== token.text) {
|
|
2528
|
-
token.text = code;
|
|
2529
|
-
token.escaped = true;
|
|
2530
|
-
}
|
|
2531
|
-
pending--;
|
|
2532
|
-
if (pending === 0) {
|
|
2533
|
-
done();
|
|
2534
|
-
}
|
|
2535
|
-
});
|
|
2536
|
-
}, 0);
|
|
2537
|
-
}
|
|
2538
|
-
});
|
|
2539
|
-
if (pending === 0) {
|
|
2540
|
-
done();
|
|
2541
|
-
}
|
|
2542
|
-
return;
|
|
2543
|
-
}
|
|
2544
2271
|
if (opt.async) {
|
|
2545
2272
|
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
|
|
2546
2273
|
.then(src => lexer(src, opt))
|
|
@@ -2568,7 +2295,7 @@ class Marked {
|
|
|
2568
2295
|
}
|
|
2569
2296
|
};
|
|
2570
2297
|
}
|
|
2571
|
-
#onError(silent, async
|
|
2298
|
+
#onError(silent, async) {
|
|
2572
2299
|
return (e) => {
|
|
2573
2300
|
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
2574
2301
|
if (silent) {
|
|
@@ -2578,27 +2305,19 @@ class Marked {
|
|
|
2578
2305
|
if (async) {
|
|
2579
2306
|
return Promise.resolve(msg);
|
|
2580
2307
|
}
|
|
2581
|
-
if (callback) {
|
|
2582
|
-
callback(null, msg);
|
|
2583
|
-
return;
|
|
2584
|
-
}
|
|
2585
2308
|
return msg;
|
|
2586
2309
|
}
|
|
2587
2310
|
if (async) {
|
|
2588
2311
|
return Promise.reject(e);
|
|
2589
2312
|
}
|
|
2590
|
-
if (callback) {
|
|
2591
|
-
callback(e);
|
|
2592
|
-
return;
|
|
2593
|
-
}
|
|
2594
2313
|
throw e;
|
|
2595
2314
|
};
|
|
2596
2315
|
}
|
|
2597
2316
|
}
|
|
2598
2317
|
|
|
2599
2318
|
const markedInstance = new Marked();
|
|
2600
|
-
function marked(src, opt
|
|
2601
|
-
return markedInstance.parse(src, opt
|
|
2319
|
+
function marked(src, opt) {
|
|
2320
|
+
return markedInstance.parse(src, opt);
|
|
2602
2321
|
}
|
|
2603
2322
|
/**
|
|
2604
2323
|
* Sets the default options.
|
|
@@ -2650,7 +2369,6 @@ marked.TextRenderer = _TextRenderer;
|
|
|
2650
2369
|
marked.Lexer = _Lexer;
|
|
2651
2370
|
marked.lexer = _Lexer.lex;
|
|
2652
2371
|
marked.Tokenizer = _Tokenizer;
|
|
2653
|
-
marked.Slugger = _Slugger;
|
|
2654
2372
|
marked.Hooks = _Hooks;
|
|
2655
2373
|
marked.parse = marked;
|
|
2656
2374
|
const options = marked.options;
|
|
@@ -2662,5 +2380,5 @@ const parse = marked;
|
|
|
2662
2380
|
const parser = _Parser.parse;
|
|
2663
2381
|
const lexer = _Lexer.lex;
|
|
2664
2382
|
|
|
2665
|
-
export { _Hooks as Hooks, _Lexer as Lexer, Marked, _Parser as Parser, _Renderer as Renderer,
|
|
2383
|
+
export { _Hooks as Hooks, _Lexer as Lexer, Marked, _Parser as Parser, _Renderer as Renderer, _TextRenderer as TextRenderer, _Tokenizer as Tokenizer, _defaults as defaults, _getDefaults as getDefaults, lexer, marked, options, parse, parseInline, parser, setOptions, use, walkTokens };
|
|
2666
2384
|
//# sourceMappingURL=marked.esm.js.map
|