@@ -131,6 +131,10 @@ function escape(html, encode) {
131
131
return html ;
132
132
}
133
133
var unescapeTest = / & ( # (?: \d + ) | (?: # x [ 0 - 9 A - F a - 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 . source || 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 - z 0 - 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
- } // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
294
- // /c*$/ is vulnerable to REDOS.
295
- // invert: Remove suffix of non-c chars instead. Default falsey.
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 . substr ( 0 , l - suffLen ) ;
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 : / ^ (?: \* + (?: ( [ p u n c t _ ] ) | [ ^ \s * ] ) ) | ^ _ + (?: ( [ p u n c t * ] ) | ( [ ^ \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
- // () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1282
- rDelimAst : / ^ [ ^ _ * ] * ?\_ \_ [ ^ _ * ] * ?\* [ ^ _ * ] * ?(? = \_ \_ ) | [ p u n c t _ ] ( \* + ) (? = [ \s ] | $ ) | [ ^ p u n c t * _ \s ] ( \* + ) (? = [ p u n c t _ \s ] | $ ) | [ p u n c t _ \s ] ( \* + ) (? = [ ^ p u n c t * _ \s ] ) | [ \s ] ( \* + ) (? = [ p u n c t _ ] ) | [ p u n c t _ ] ( \* + ) (? = [ p u n c t _ ] ) | [ ^ p u n c t * _ \s ] ( \* + ) (? = [ ^ p u n c t * _ \s ] ) / ,
1283
- rDelimUnd : / ^ [ ^ _ * ] * ?\* \* [ ^ _ * ] * ?\_ [ ^ _ * ] * ?(? = \* \* ) | [ p u n c t * ] ( \_ + ) (? = [ \s ] | $ ) | [ ^ p u n c t * _ \s ] ( \_ + ) (? = [ p u n c t * \s ] | $ ) | [ p u n c t * \s ] ( \_ + ) (? = [ ^ p u n c t * _ \s ] ) | [ \s ] ( \_ + ) (? = [ p u n c t * ] ) | [ p u n c t * ] ( \_ + ) (? = [ p u n c t * ] ) / // ^- 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 : / ^ [ ^ _ * ] * ?\_ \_ [ ^ _ * ] * ?\* [ ^ _ * ] * ?(? = \_ \_ ) | [ ^ * ] + (? = [ ^ * ] ) | [ p u n c t _ ] ( \* + ) (? = [ \s ] | $ ) | [ ^ p u n c t * _ \s ] ( \* + ) (? = [ p u n c t _ \s ] | $ ) | [ p u n c t _ \s ] ( \* + ) (? = [ ^ p u n c t * _ \s ] ) | [ \s ] ( \* + ) (? = [ p u n c t _ ] ) | [ p u n c t _ ] ( \* + ) (? = [ p u n c t _ ] ) | [ ^ p u n c t * _ \s ] ( \* + ) (? = [ ^ p u n c t * _ \s ] ) / ,
1314
+ rDelimUnd : / ^ [ ^ _ * ] * ?\* \* [ ^ _ * ] * ?\_ [ ^ _ * ] * ?(? = \* \* ) | [ ^ _ ] + (? = [ ^ _ ] ) | [ p u n c t * ] ( \_ + ) (? = [ \s ] | $ ) | [ ^ p u n c t * _ \s ] ( \_ + ) (? = [ p u n c t * \s ] | $ ) | [ p u n c t * \s ] ( \_ + ) (? = [ ^ p u n c t * _ \s ] ) | [ \s ] ( \_ + ) (? = [ p u n c t * ] ) | [ p u n c t * ] ( \_ + ) (? = [ p u n c t * ] ) / // ^- 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 ' <blockquote>\n' + quote + ' </blockquote>\n' ;
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
- return '<h' + level + ' id="' + this . options . headerPrefix + slugger . slug ( raw ) + '">' + text + '</h' + level + '>\n' ;
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 '<h' + level + '>' + text + ' </h' + level + ' >\n' ;
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 ' <li>' + text + ' </li>\n' ;
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 '<p>' + text + '</p>\n' ;
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 = ' <tbody>' + body + ' </tbody>' ;
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 ' <tr>\n' + content + ' </tr>\n' ;
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 ? '<' + type + ' align="' + flags . align + '">' : '<' + type + '>' ;
2005
- return tag + content + '</' + type + '>\n' ;
2006
- } // span level renderer
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 '<strong>' + text + '</strong>' ;
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 '<em>' + text + '</em>' ;
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 ' <code>' + text + ' </code>' ;
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 '<del>' + text + '</del>' ;
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 = ' <img src="' + href + '" alt="' + text + '"' ;
2143
+ var out = " <img src=\"" + href + "\" alt=\"" + text + "\"" ;
2054
2144
2055
2145
if ( title ) {
2056
- out += ' title="' + title + '"' ;
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 updating the internal accumulator.
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
0 commit comments