marked 4.0.12 → 4.0.13
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/marked.js +3 -0
- package/lib/marked.cjs +135 -37
- package/lib/marked.esm.js +109 -36
- package/lib/marked.umd.js +135 -37
- package/marked.min.js +1 -1
- package/package.json +12 -12
- package/src/Lexer.js +2 -0
- package/src/Renderer.js +63 -26
- package/src/Slugger.js +8 -2
- package/src/helpers.js +32 -5
- package/src/marked.js +1 -0
- package/src/rules.js +3 -3
package/bin/marked.js
CHANGED
package/lib/marked.cjs
CHANGED
|
@@ -131,6 +131,10 @@ function escape(html, encode) {
|
|
|
131
131
|
return html;
|
|
132
132
|
}
|
|
133
133
|
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
134
|
+
/**
|
|
135
|
+
* @param {string} html
|
|
136
|
+
*/
|
|
137
|
+
|
|
134
138
|
function unescape(html) {
|
|
135
139
|
// explicitly match decimal, hex, and named HTML entities
|
|
136
140
|
return html.replace(unescapeTest, function (_, n) {
|
|
@@ -145,8 +149,13 @@ function unescape(html) {
|
|
|
145
149
|
});
|
|
146
150
|
}
|
|
147
151
|
var caret = /(^|[^\[])\^/g;
|
|
152
|
+
/**
|
|
153
|
+
* @param {string | RegExp} regex
|
|
154
|
+
* @param {string} opt
|
|
155
|
+
*/
|
|
156
|
+
|
|
148
157
|
function edit(regex, opt) {
|
|
149
|
-
regex = regex
|
|
158
|
+
regex = typeof regex === 'string' ? regex : regex.source;
|
|
150
159
|
opt = opt || '';
|
|
151
160
|
var obj = {
|
|
152
161
|
replace: function replace(name, val) {
|
|
@@ -163,6 +172,12 @@ function edit(regex, opt) {
|
|
|
163
172
|
}
|
|
164
173
|
var nonWordAndColonTest = /[^\w:]/g;
|
|
165
174
|
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
175
|
+
/**
|
|
176
|
+
* @param {boolean} sanitize
|
|
177
|
+
* @param {string} base
|
|
178
|
+
* @param {string} href
|
|
179
|
+
*/
|
|
180
|
+
|
|
166
181
|
function cleanUrl(sanitize, base, href) {
|
|
167
182
|
if (sanitize) {
|
|
168
183
|
var prot;
|
|
@@ -194,6 +209,11 @@ var baseUrls = {};
|
|
|
194
209
|
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
195
210
|
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
196
211
|
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
212
|
+
/**
|
|
213
|
+
* @param {string} base
|
|
214
|
+
* @param {string} href
|
|
215
|
+
*/
|
|
216
|
+
|
|
197
217
|
function resolveUrl(base, href) {
|
|
198
218
|
if (!baseUrls[' ' + base]) {
|
|
199
219
|
// we can ignore everything in base after the last slash of its path component,
|
|
@@ -290,9 +310,15 @@ function splitCells(tableRow, count) {
|
|
|
290
310
|
}
|
|
291
311
|
|
|
292
312
|
return cells;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
316
|
+
* /c*$/ is vulnerable to REDOS.
|
|
317
|
+
*
|
|
318
|
+
* @param {string} str
|
|
319
|
+
* @param {string} c
|
|
320
|
+
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
321
|
+
*/
|
|
296
322
|
|
|
297
323
|
function rtrim(str, c, invert) {
|
|
298
324
|
var l = str.length;
|
|
@@ -316,7 +342,7 @@ function rtrim(str, c, invert) {
|
|
|
316
342
|
}
|
|
317
343
|
}
|
|
318
344
|
|
|
319
|
-
return str.
|
|
345
|
+
return str.slice(0, l - suffLen);
|
|
320
346
|
}
|
|
321
347
|
function findClosingBracket(str, b) {
|
|
322
348
|
if (str.indexOf(b[1]) === -1) {
|
|
@@ -349,6 +375,11 @@ function checkSanitizeDeprecation(opt) {
|
|
|
349
375
|
}
|
|
350
376
|
} // copied from https://stackoverflow.com/a/5450113/806777
|
|
351
377
|
|
|
378
|
+
/**
|
|
379
|
+
* @param {string} pattern
|
|
380
|
+
* @param {number} count
|
|
381
|
+
*/
|
|
382
|
+
|
|
352
383
|
function repeatString(pattern, count) {
|
|
353
384
|
if (count < 1) {
|
|
354
385
|
return '';
|
|
@@ -1278,9 +1309,9 @@ var inline = {
|
|
|
1278
1309
|
emStrong: {
|
|
1279
1310
|
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
1280
1311
|
// (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
|
|
1281
|
-
//
|
|
1282
|
-
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1283
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1312
|
+
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
1313
|
+
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1314
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1284
1315
|
|
|
1285
1316
|
},
|
|
1286
1317
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
@@ -1362,6 +1393,7 @@ inline.breaks = merge({}, inline.gfm, {
|
|
|
1362
1393
|
|
|
1363
1394
|
/**
|
|
1364
1395
|
* smartypants text replacement
|
|
1396
|
+
* @param {string} text
|
|
1365
1397
|
*/
|
|
1366
1398
|
|
|
1367
1399
|
function smartypants(text) {
|
|
@@ -1376,6 +1408,7 @@ function smartypants(text) {
|
|
|
1376
1408
|
}
|
|
1377
1409
|
/**
|
|
1378
1410
|
* mangle email addresses
|
|
1411
|
+
* @param {string} text
|
|
1379
1412
|
*/
|
|
1380
1413
|
|
|
1381
1414
|
|
|
@@ -1949,23 +1982,35 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
1949
1982
|
}
|
|
1950
1983
|
|
|
1951
1984
|
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
|
|
1952
|
-
}
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* @param {string} quote
|
|
1988
|
+
*/
|
|
1989
|
+
;
|
|
1953
1990
|
|
|
1954
1991
|
_proto.blockquote = function blockquote(quote) {
|
|
1955
|
-
return
|
|
1992
|
+
return "<blockquote>\n" + quote + "</blockquote>\n";
|
|
1956
1993
|
};
|
|
1957
1994
|
|
|
1958
1995
|
_proto.html = function html(_html) {
|
|
1959
1996
|
return _html;
|
|
1960
|
-
}
|
|
1997
|
+
}
|
|
1998
|
+
/**
|
|
1999
|
+
* @param {string} text
|
|
2000
|
+
* @param {string} level
|
|
2001
|
+
* @param {string} raw
|
|
2002
|
+
* @param {any} slugger
|
|
2003
|
+
*/
|
|
2004
|
+
;
|
|
1961
2005
|
|
|
1962
2006
|
_proto.heading = function heading(text, level, raw, slugger) {
|
|
1963
2007
|
if (this.options.headerIds) {
|
|
1964
|
-
|
|
2008
|
+
var id = this.options.headerPrefix + slugger.slug(raw);
|
|
2009
|
+
return "<h" + level + " id=\"" + id + "\">" + text + "</h" + level + ">\n";
|
|
1965
2010
|
} // ignore IDs
|
|
1966
2011
|
|
|
1967
2012
|
|
|
1968
|
-
return
|
|
2013
|
+
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
|
1969
2014
|
};
|
|
1970
2015
|
|
|
1971
2016
|
_proto.hr = function hr() {
|
|
@@ -1976,55 +2021,94 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
1976
2021
|
var type = ordered ? 'ol' : 'ul',
|
|
1977
2022
|
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
1978
2023
|
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1979
|
-
}
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* @param {string} text
|
|
2027
|
+
*/
|
|
2028
|
+
;
|
|
1980
2029
|
|
|
1981
2030
|
_proto.listitem = function listitem(text) {
|
|
1982
|
-
return
|
|
2031
|
+
return "<li>" + text + "</li>\n";
|
|
1983
2032
|
};
|
|
1984
2033
|
|
|
1985
2034
|
_proto.checkbox = function checkbox(checked) {
|
|
1986
2035
|
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
|
1987
|
-
}
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* @param {string} text
|
|
2039
|
+
*/
|
|
2040
|
+
;
|
|
1988
2041
|
|
|
1989
2042
|
_proto.paragraph = function paragraph(text) {
|
|
1990
|
-
return
|
|
1991
|
-
}
|
|
2043
|
+
return "<p>" + text + "</p>\n";
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* @param {string} header
|
|
2047
|
+
* @param {string} body
|
|
2048
|
+
*/
|
|
2049
|
+
;
|
|
1992
2050
|
|
|
1993
2051
|
_proto.table = function table(header, body) {
|
|
1994
|
-
if (body) body =
|
|
2052
|
+
if (body) body = "<tbody>" + body + "</tbody>";
|
|
1995
2053
|
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
1996
|
-
}
|
|
2054
|
+
}
|
|
2055
|
+
/**
|
|
2056
|
+
* @param {string} content
|
|
2057
|
+
*/
|
|
2058
|
+
;
|
|
1997
2059
|
|
|
1998
2060
|
_proto.tablerow = function tablerow(content) {
|
|
1999
|
-
return
|
|
2061
|
+
return "<tr>\n" + content + "</tr>\n";
|
|
2000
2062
|
};
|
|
2001
2063
|
|
|
2002
2064
|
_proto.tablecell = function tablecell(content, flags) {
|
|
2003
2065
|
var type = flags.header ? 'th' : 'td';
|
|
2004
|
-
var tag = flags.align ?
|
|
2005
|
-
return tag + content +
|
|
2006
|
-
}
|
|
2066
|
+
var tag = flags.align ? "<" + type + " align=\"" + flags.align + "\">" : "<" + type + ">";
|
|
2067
|
+
return tag + content + ("</" + type + ">\n");
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* span level renderer
|
|
2071
|
+
* @param {string} text
|
|
2072
|
+
*/
|
|
2007
2073
|
;
|
|
2008
2074
|
|
|
2009
2075
|
_proto.strong = function strong(text) {
|
|
2010
|
-
return
|
|
2011
|
-
}
|
|
2076
|
+
return "<strong>" + text + "</strong>";
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* @param {string} text
|
|
2080
|
+
*/
|
|
2081
|
+
;
|
|
2012
2082
|
|
|
2013
2083
|
_proto.em = function em(text) {
|
|
2014
|
-
return
|
|
2015
|
-
}
|
|
2084
|
+
return "<em>" + text + "</em>";
|
|
2085
|
+
}
|
|
2086
|
+
/**
|
|
2087
|
+
* @param {string} text
|
|
2088
|
+
*/
|
|
2089
|
+
;
|
|
2016
2090
|
|
|
2017
2091
|
_proto.codespan = function codespan(text) {
|
|
2018
|
-
return
|
|
2092
|
+
return "<code>" + text + "</code>";
|
|
2019
2093
|
};
|
|
2020
2094
|
|
|
2021
2095
|
_proto.br = function br() {
|
|
2022
2096
|
return this.options.xhtml ? '<br/>' : '<br>';
|
|
2023
|
-
}
|
|
2097
|
+
}
|
|
2098
|
+
/**
|
|
2099
|
+
* @param {string} text
|
|
2100
|
+
*/
|
|
2101
|
+
;
|
|
2024
2102
|
|
|
2025
2103
|
_proto.del = function del(text) {
|
|
2026
|
-
return
|
|
2027
|
-
}
|
|
2104
|
+
return "<del>" + text + "</del>";
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* @param {string} href
|
|
2108
|
+
* @param {string} title
|
|
2109
|
+
* @param {string} text
|
|
2110
|
+
*/
|
|
2111
|
+
;
|
|
2028
2112
|
|
|
2029
2113
|
_proto.link = function link(href, title, text) {
|
|
2030
2114
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
@@ -2041,7 +2125,13 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
2041
2125
|
|
|
2042
2126
|
out += '>' + text + '</a>';
|
|
2043
2127
|
return out;
|
|
2044
|
-
}
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* @param {string} href
|
|
2131
|
+
* @param {string} title
|
|
2132
|
+
* @param {string} text
|
|
2133
|
+
*/
|
|
2134
|
+
;
|
|
2045
2135
|
|
|
2046
2136
|
_proto.image = function image(href, title, text) {
|
|
2047
2137
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
@@ -2050,10 +2140,10 @@ var Renderer = /*#__PURE__*/function () {
|
|
|
2050
2140
|
return text;
|
|
2051
2141
|
}
|
|
2052
2142
|
|
|
2053
|
-
var out =
|
|
2143
|
+
var out = "<img src=\"" + href + "\" alt=\"" + text + "\"";
|
|
2054
2144
|
|
|
2055
2145
|
if (title) {
|
|
2056
|
-
out +=
|
|
2146
|
+
out += " title=\"" + title + "\"";
|
|
2057
2147
|
}
|
|
2058
2148
|
|
|
2059
2149
|
out += this.options.xhtml ? '/>' : '>';
|
|
@@ -2123,6 +2213,10 @@ var Slugger = /*#__PURE__*/function () {
|
|
|
2123
2213
|
function Slugger() {
|
|
2124
2214
|
this.seen = {};
|
|
2125
2215
|
}
|
|
2216
|
+
/**
|
|
2217
|
+
* @param {string} value
|
|
2218
|
+
*/
|
|
2219
|
+
|
|
2126
2220
|
|
|
2127
2221
|
var _proto = Slugger.prototype;
|
|
2128
2222
|
|
|
@@ -2133,6 +2227,8 @@ var Slugger = /*#__PURE__*/function () {
|
|
|
2133
2227
|
}
|
|
2134
2228
|
/**
|
|
2135
2229
|
* Finds the next safe (unique) slug to use
|
|
2230
|
+
* @param {string} originalSlug
|
|
2231
|
+
* @param {boolean} isDryRun
|
|
2136
2232
|
*/
|
|
2137
2233
|
;
|
|
2138
2234
|
|
|
@@ -2158,8 +2254,9 @@ var Slugger = /*#__PURE__*/function () {
|
|
|
2158
2254
|
}
|
|
2159
2255
|
/**
|
|
2160
2256
|
* Convert string to unique id
|
|
2161
|
-
* @param {object} options
|
|
2162
|
-
* @param {boolean} options.dryrun Generates the next unique slug without
|
|
2257
|
+
* @param {object} [options]
|
|
2258
|
+
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
|
2259
|
+
* updating the internal accumulator.
|
|
2163
2260
|
*/
|
|
2164
2261
|
;
|
|
2165
2262
|
|
|
@@ -2856,6 +2953,7 @@ marked.walkTokens = function (tokens, callback) {
|
|
|
2856
2953
|
};
|
|
2857
2954
|
/**
|
|
2858
2955
|
* Parse Inline
|
|
2956
|
+
* @param {string} src
|
|
2859
2957
|
*/
|
|
2860
2958
|
|
|
2861
2959
|
|
package/lib/marked.esm.js
CHANGED
|
@@ -70,6 +70,9 @@ function escape(html, encode) {
|
|
|
70
70
|
|
|
71
71
|
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} html
|
|
75
|
+
*/
|
|
73
76
|
function unescape(html) {
|
|
74
77
|
// explicitly match decimal, hex, and named HTML entities
|
|
75
78
|
return html.replace(unescapeTest, (_, n) => {
|
|
@@ -85,8 +88,13 @@ function unescape(html) {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
const caret = /(^|[^\[])\^/g;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {string | RegExp} regex
|
|
94
|
+
* @param {string} opt
|
|
95
|
+
*/
|
|
88
96
|
function edit(regex, opt) {
|
|
89
|
-
regex = regex
|
|
97
|
+
regex = typeof regex === 'string' ? regex : regex.source;
|
|
90
98
|
opt = opt || '';
|
|
91
99
|
const obj = {
|
|
92
100
|
replace: (name, val) => {
|
|
@@ -104,6 +112,12 @@ function edit(regex, opt) {
|
|
|
104
112
|
|
|
105
113
|
const nonWordAndColonTest = /[^\w:]/g;
|
|
106
114
|
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @param {boolean} sanitize
|
|
118
|
+
* @param {string} base
|
|
119
|
+
* @param {string} href
|
|
120
|
+
*/
|
|
107
121
|
function cleanUrl(sanitize, base, href) {
|
|
108
122
|
if (sanitize) {
|
|
109
123
|
let prot;
|
|
@@ -134,6 +148,10 @@ const justDomain = /^[^:]+:\/*[^/]*$/;
|
|
|
134
148
|
const protocol = /^([^:]+:)[\s\S]*$/;
|
|
135
149
|
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
136
150
|
|
|
151
|
+
/**
|
|
152
|
+
* @param {string} base
|
|
153
|
+
* @param {string} href
|
|
154
|
+
*/
|
|
137
155
|
function resolveUrl(base, href) {
|
|
138
156
|
if (!baseUrls[' ' + base]) {
|
|
139
157
|
// we can ignore everything in base after the last slash of its path component,
|
|
@@ -218,9 +236,14 @@ function splitCells(tableRow, count) {
|
|
|
218
236
|
return cells;
|
|
219
237
|
}
|
|
220
238
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
241
|
+
* /c*$/ is vulnerable to REDOS.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} str
|
|
244
|
+
* @param {string} c
|
|
245
|
+
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
246
|
+
*/
|
|
224
247
|
function rtrim(str, c, invert) {
|
|
225
248
|
const l = str.length;
|
|
226
249
|
if (l === 0) {
|
|
@@ -242,7 +265,7 @@ function rtrim(str, c, invert) {
|
|
|
242
265
|
}
|
|
243
266
|
}
|
|
244
267
|
|
|
245
|
-
return str.
|
|
268
|
+
return str.slice(0, l - suffLen);
|
|
246
269
|
}
|
|
247
270
|
|
|
248
271
|
function findClosingBracket(str, b) {
|
|
@@ -274,6 +297,10 @@ function checkSanitizeDeprecation(opt) {
|
|
|
274
297
|
}
|
|
275
298
|
|
|
276
299
|
// copied from https://stackoverflow.com/a/5450113/806777
|
|
300
|
+
/**
|
|
301
|
+
* @param {string} pattern
|
|
302
|
+
* @param {number} count
|
|
303
|
+
*/
|
|
277
304
|
function repeatString(pattern, count) {
|
|
278
305
|
if (count < 1) {
|
|
279
306
|
return '';
|
|
@@ -1214,9 +1241,9 @@ const inline = {
|
|
|
1214
1241
|
emStrong: {
|
|
1215
1242
|
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
1216
1243
|
// (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
|
|
1217
|
-
//
|
|
1218
|
-
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1219
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1244
|
+
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
1245
|
+
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1246
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1220
1247
|
},
|
|
1221
1248
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1222
1249
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
@@ -1349,6 +1376,7 @@ inline.breaks = merge({}, inline.gfm, {
|
|
|
1349
1376
|
|
|
1350
1377
|
/**
|
|
1351
1378
|
* smartypants text replacement
|
|
1379
|
+
* @param {string} text
|
|
1352
1380
|
*/
|
|
1353
1381
|
function smartypants(text) {
|
|
1354
1382
|
return text
|
|
@@ -1370,6 +1398,7 @@ function smartypants(text) {
|
|
|
1370
1398
|
|
|
1371
1399
|
/**
|
|
1372
1400
|
* mangle email addresses
|
|
1401
|
+
* @param {string} text
|
|
1373
1402
|
*/
|
|
1374
1403
|
function mangle(text) {
|
|
1375
1404
|
let out = '',
|
|
@@ -1872,29 +1901,31 @@ class Renderer {
|
|
|
1872
1901
|
+ '</code></pre>\n';
|
|
1873
1902
|
}
|
|
1874
1903
|
|
|
1904
|
+
/**
|
|
1905
|
+
* @param {string} quote
|
|
1906
|
+
*/
|
|
1875
1907
|
blockquote(quote) {
|
|
1876
|
-
return
|
|
1908
|
+
return `<blockquote>\n${quote}</blockquote>\n`;
|
|
1877
1909
|
}
|
|
1878
1910
|
|
|
1879
1911
|
html(html) {
|
|
1880
1912
|
return html;
|
|
1881
1913
|
}
|
|
1882
1914
|
|
|
1915
|
+
/**
|
|
1916
|
+
* @param {string} text
|
|
1917
|
+
* @param {string} level
|
|
1918
|
+
* @param {string} raw
|
|
1919
|
+
* @param {any} slugger
|
|
1920
|
+
*/
|
|
1883
1921
|
heading(text, level, raw, slugger) {
|
|
1884
1922
|
if (this.options.headerIds) {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
+ ' id="'
|
|
1888
|
-
+ this.options.headerPrefix
|
|
1889
|
-
+ slugger.slug(raw)
|
|
1890
|
-
+ '">'
|
|
1891
|
-
+ text
|
|
1892
|
-
+ '</h'
|
|
1893
|
-
+ level
|
|
1894
|
-
+ '>\n';
|
|
1923
|
+
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
1924
|
+
return `<h${level} id="${id}">${text}</h${level}>\n`;
|
|
1895
1925
|
}
|
|
1926
|
+
|
|
1896
1927
|
// ignore IDs
|
|
1897
|
-
return
|
|
1928
|
+
return `<h${level}>${text}</h${level}>\n`;
|
|
1898
1929
|
}
|
|
1899
1930
|
|
|
1900
1931
|
hr() {
|
|
@@ -1907,8 +1938,11 @@ class Renderer {
|
|
|
1907
1938
|
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1908
1939
|
}
|
|
1909
1940
|
|
|
1941
|
+
/**
|
|
1942
|
+
* @param {string} text
|
|
1943
|
+
*/
|
|
1910
1944
|
listitem(text) {
|
|
1911
|
-
return
|
|
1945
|
+
return `<li>${text}</li>\n`;
|
|
1912
1946
|
}
|
|
1913
1947
|
|
|
1914
1948
|
checkbox(checked) {
|
|
@@ -1919,12 +1953,19 @@ class Renderer {
|
|
|
1919
1953
|
+ '> ';
|
|
1920
1954
|
}
|
|
1921
1955
|
|
|
1956
|
+
/**
|
|
1957
|
+
* @param {string} text
|
|
1958
|
+
*/
|
|
1922
1959
|
paragraph(text) {
|
|
1923
|
-
return
|
|
1960
|
+
return `<p>${text}</p>\n`;
|
|
1924
1961
|
}
|
|
1925
1962
|
|
|
1963
|
+
/**
|
|
1964
|
+
* @param {string} header
|
|
1965
|
+
* @param {string} body
|
|
1966
|
+
*/
|
|
1926
1967
|
table(header, body) {
|
|
1927
|
-
if (body) body =
|
|
1968
|
+
if (body) body = `<tbody>${body}</tbody>`;
|
|
1928
1969
|
|
|
1929
1970
|
return '<table>\n'
|
|
1930
1971
|
+ '<thead>\n'
|
|
@@ -1934,39 +1975,59 @@ class Renderer {
|
|
|
1934
1975
|
+ '</table>\n';
|
|
1935
1976
|
}
|
|
1936
1977
|
|
|
1978
|
+
/**
|
|
1979
|
+
* @param {string} content
|
|
1980
|
+
*/
|
|
1937
1981
|
tablerow(content) {
|
|
1938
|
-
return
|
|
1982
|
+
return `<tr>\n${content}</tr>\n`;
|
|
1939
1983
|
}
|
|
1940
1984
|
|
|
1941
1985
|
tablecell(content, flags) {
|
|
1942
1986
|
const type = flags.header ? 'th' : 'td';
|
|
1943
1987
|
const tag = flags.align
|
|
1944
|
-
?
|
|
1945
|
-
:
|
|
1946
|
-
return tag + content +
|
|
1988
|
+
? `<${type} align="${flags.align}">`
|
|
1989
|
+
: `<${type}>`;
|
|
1990
|
+
return tag + content + `</${type}>\n`;
|
|
1947
1991
|
}
|
|
1948
1992
|
|
|
1949
|
-
|
|
1993
|
+
/**
|
|
1994
|
+
* span level renderer
|
|
1995
|
+
* @param {string} text
|
|
1996
|
+
*/
|
|
1950
1997
|
strong(text) {
|
|
1951
|
-
return
|
|
1998
|
+
return `<strong>${text}</strong>`;
|
|
1952
1999
|
}
|
|
1953
2000
|
|
|
2001
|
+
/**
|
|
2002
|
+
* @param {string} text
|
|
2003
|
+
*/
|
|
1954
2004
|
em(text) {
|
|
1955
|
-
return
|
|
2005
|
+
return `<em>${text}</em>`;
|
|
1956
2006
|
}
|
|
1957
2007
|
|
|
2008
|
+
/**
|
|
2009
|
+
* @param {string} text
|
|
2010
|
+
*/
|
|
1958
2011
|
codespan(text) {
|
|
1959
|
-
return
|
|
2012
|
+
return `<code>${text}</code>`;
|
|
1960
2013
|
}
|
|
1961
2014
|
|
|
1962
2015
|
br() {
|
|
1963
2016
|
return this.options.xhtml ? '<br/>' : '<br>';
|
|
1964
2017
|
}
|
|
1965
2018
|
|
|
2019
|
+
/**
|
|
2020
|
+
* @param {string} text
|
|
2021
|
+
*/
|
|
1966
2022
|
del(text) {
|
|
1967
|
-
return
|
|
2023
|
+
return `<del>${text}</del>`;
|
|
1968
2024
|
}
|
|
1969
2025
|
|
|
2026
|
+
/**
|
|
2027
|
+
* @param {string} href
|
|
2028
|
+
* @param {string} title
|
|
2029
|
+
* @param {string} text
|
|
2030
|
+
*/
|
|
1970
2031
|
link(href, title, text) {
|
|
1971
2032
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1972
2033
|
if (href === null) {
|
|
@@ -1980,15 +2041,20 @@ class Renderer {
|
|
|
1980
2041
|
return out;
|
|
1981
2042
|
}
|
|
1982
2043
|
|
|
2044
|
+
/**
|
|
2045
|
+
* @param {string} href
|
|
2046
|
+
* @param {string} title
|
|
2047
|
+
* @param {string} text
|
|
2048
|
+
*/
|
|
1983
2049
|
image(href, title, text) {
|
|
1984
2050
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
1985
2051
|
if (href === null) {
|
|
1986
2052
|
return text;
|
|
1987
2053
|
}
|
|
1988
2054
|
|
|
1989
|
-
let out =
|
|
2055
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
1990
2056
|
if (title) {
|
|
1991
|
-
out +=
|
|
2057
|
+
out += ` title="${title}"`;
|
|
1992
2058
|
}
|
|
1993
2059
|
out += this.options.xhtml ? '/>' : '>';
|
|
1994
2060
|
return out;
|
|
@@ -2050,6 +2116,9 @@ class Slugger {
|
|
|
2050
2116
|
this.seen = {};
|
|
2051
2117
|
}
|
|
2052
2118
|
|
|
2119
|
+
/**
|
|
2120
|
+
* @param {string} value
|
|
2121
|
+
*/
|
|
2053
2122
|
serialize(value) {
|
|
2054
2123
|
return value
|
|
2055
2124
|
.toLowerCase()
|
|
@@ -2063,6 +2132,8 @@ class Slugger {
|
|
|
2063
2132
|
|
|
2064
2133
|
/**
|
|
2065
2134
|
* Finds the next safe (unique) slug to use
|
|
2135
|
+
* @param {string} originalSlug
|
|
2136
|
+
* @param {boolean} isDryRun
|
|
2066
2137
|
*/
|
|
2067
2138
|
getNextSafeSlug(originalSlug, isDryRun) {
|
|
2068
2139
|
let slug = originalSlug;
|
|
@@ -2083,8 +2154,9 @@ class Slugger {
|
|
|
2083
2154
|
|
|
2084
2155
|
/**
|
|
2085
2156
|
* Convert string to unique id
|
|
2086
|
-
* @param {object} options
|
|
2087
|
-
* @param {boolean} options.dryrun Generates the next unique slug without
|
|
2157
|
+
* @param {object} [options]
|
|
2158
|
+
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
|
2159
|
+
* updating the internal accumulator.
|
|
2088
2160
|
*/
|
|
2089
2161
|
slug(value, options = {}) {
|
|
2090
2162
|
const slug = this.serialize(value);
|
|
@@ -2645,6 +2717,7 @@ marked.walkTokens = function(tokens, callback) {
|
|
|
2645
2717
|
|
|
2646
2718
|
/**
|
|
2647
2719
|
* Parse Inline
|
|
2720
|
+
* @param {string} src
|
|
2648
2721
|
*/
|
|
2649
2722
|
marked.parseInline = function(src, opt) {
|
|
2650
2723
|
// throw error in case of non string input
|