marked 4.0.10 → 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/README.md +1 -1
- package/bin/marked.js +3 -0
- package/lib/marked.cjs +137 -39
- package/lib/marked.esm.js +111 -38
- package/lib/marked.umd.js +137 -39
- package/marked.min.js +1 -1
- package/package.json +15 -15
- package/src/Lexer.js +2 -0
- package/src/Renderer.js +63 -26
- package/src/Slugger.js +8 -2
- package/src/Tokenizer.js +1 -1
- package/src/helpers.js +33 -6
- package/src/marked.js +1 -0
- package/src/rules.js +3 -3
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,
|
|
@@ -203,7 +221,7 @@ function splitCells(tableRow, count) {
|
|
|
203
221
|
|
|
204
222
|
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
205
223
|
if (!cells[0].trim()) { cells.shift(); }
|
|
206
|
-
if (!cells[cells.length - 1].trim()) { cells.pop(); }
|
|
224
|
+
if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
|
|
207
225
|
|
|
208
226
|
if (cells.length > count) {
|
|
209
227
|
cells.splice(count);
|
|
@@ -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 '';
|
|
@@ -652,7 +679,7 @@ class Tokenizer {
|
|
|
652
679
|
type: 'table',
|
|
653
680
|
header: splitCells(cap[1]).map(c => { return { text: c }; }),
|
|
654
681
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
655
|
-
rows: cap[3] ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
|
|
682
|
+
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
|
|
656
683
|
};
|
|
657
684
|
|
|
658
685
|
if (item.header.length === item.align.length) {
|
|
@@ -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
|
package/lib/marked.umd.js
CHANGED
|
@@ -133,6 +133,10 @@
|
|
|
133
133
|
return html;
|
|
134
134
|
}
|
|
135
135
|
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
136
|
+
/**
|
|
137
|
+
* @param {string} html
|
|
138
|
+
*/
|
|
139
|
+
|
|
136
140
|
function unescape(html) {
|
|
137
141
|
// explicitly match decimal, hex, and named HTML entities
|
|
138
142
|
return html.replace(unescapeTest, function (_, n) {
|
|
@@ -147,8 +151,13 @@
|
|
|
147
151
|
});
|
|
148
152
|
}
|
|
149
153
|
var caret = /(^|[^\[])\^/g;
|
|
154
|
+
/**
|
|
155
|
+
* @param {string | RegExp} regex
|
|
156
|
+
* @param {string} opt
|
|
157
|
+
*/
|
|
158
|
+
|
|
150
159
|
function edit(regex, opt) {
|
|
151
|
-
regex = regex
|
|
160
|
+
regex = typeof regex === 'string' ? regex : regex.source;
|
|
152
161
|
opt = opt || '';
|
|
153
162
|
var obj = {
|
|
154
163
|
replace: function replace(name, val) {
|
|
@@ -165,6 +174,12 @@
|
|
|
165
174
|
}
|
|
166
175
|
var nonWordAndColonTest = /[^\w:]/g;
|
|
167
176
|
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
177
|
+
/**
|
|
178
|
+
* @param {boolean} sanitize
|
|
179
|
+
* @param {string} base
|
|
180
|
+
* @param {string} href
|
|
181
|
+
*/
|
|
182
|
+
|
|
168
183
|
function cleanUrl(sanitize, base, href) {
|
|
169
184
|
if (sanitize) {
|
|
170
185
|
var prot;
|
|
@@ -196,6 +211,11 @@
|
|
|
196
211
|
var justDomain = /^[^:]+:\/*[^/]*$/;
|
|
197
212
|
var protocol = /^([^:]+:)[\s\S]*$/;
|
|
198
213
|
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
214
|
+
/**
|
|
215
|
+
* @param {string} base
|
|
216
|
+
* @param {string} href
|
|
217
|
+
*/
|
|
218
|
+
|
|
199
219
|
function resolveUrl(base, href) {
|
|
200
220
|
if (!baseUrls[' ' + base]) {
|
|
201
221
|
// we can ignore everything in base after the last slash of its path component,
|
|
@@ -274,7 +294,7 @@
|
|
|
274
294
|
cells.shift();
|
|
275
295
|
}
|
|
276
296
|
|
|
277
|
-
if (!cells[cells.length - 1].trim()) {
|
|
297
|
+
if (cells.length > 0 && !cells[cells.length - 1].trim()) {
|
|
278
298
|
cells.pop();
|
|
279
299
|
}
|
|
280
300
|
|
|
@@ -292,9 +312,15 @@
|
|
|
292
312
|
}
|
|
293
313
|
|
|
294
314
|
return cells;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
318
|
+
* /c*$/ is vulnerable to REDOS.
|
|
319
|
+
*
|
|
320
|
+
* @param {string} str
|
|
321
|
+
* @param {string} c
|
|
322
|
+
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
323
|
+
*/
|
|
298
324
|
|
|
299
325
|
function rtrim(str, c, invert) {
|
|
300
326
|
var l = str.length;
|
|
@@ -318,7 +344,7 @@
|
|
|
318
344
|
}
|
|
319
345
|
}
|
|
320
346
|
|
|
321
|
-
return str.
|
|
347
|
+
return str.slice(0, l - suffLen);
|
|
322
348
|
}
|
|
323
349
|
function findClosingBracket(str, b) {
|
|
324
350
|
if (str.indexOf(b[1]) === -1) {
|
|
@@ -351,6 +377,11 @@
|
|
|
351
377
|
}
|
|
352
378
|
} // copied from https://stackoverflow.com/a/5450113/806777
|
|
353
379
|
|
|
380
|
+
/**
|
|
381
|
+
* @param {string} pattern
|
|
382
|
+
* @param {number} count
|
|
383
|
+
*/
|
|
384
|
+
|
|
354
385
|
function repeatString(pattern, count) {
|
|
355
386
|
if (count < 1) {
|
|
356
387
|
return '';
|
|
@@ -749,7 +780,7 @@
|
|
|
749
780
|
};
|
|
750
781
|
}),
|
|
751
782
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
752
|
-
rows: cap[3] ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
|
|
783
|
+
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
|
|
753
784
|
};
|
|
754
785
|
|
|
755
786
|
if (item.header.length === item.align.length) {
|
|
@@ -1280,9 +1311,9 @@
|
|
|
1280
1311
|
emStrong: {
|
|
1281
1312
|
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
1282
1313
|
// (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.
|
|
1283
|
-
//
|
|
1284
|
-
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1285
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1314
|
+
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
1315
|
+
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
1316
|
+
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
1286
1317
|
|
|
1287
1318
|
},
|
|
1288
1319
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
@@ -1364,6 +1395,7 @@
|
|
|
1364
1395
|
|
|
1365
1396
|
/**
|
|
1366
1397
|
* smartypants text replacement
|
|
1398
|
+
* @param {string} text
|
|
1367
1399
|
*/
|
|
1368
1400
|
|
|
1369
1401
|
function smartypants(text) {
|
|
@@ -1378,6 +1410,7 @@
|
|
|
1378
1410
|
}
|
|
1379
1411
|
/**
|
|
1380
1412
|
* mangle email addresses
|
|
1413
|
+
* @param {string} text
|
|
1381
1414
|
*/
|
|
1382
1415
|
|
|
1383
1416
|
|
|
@@ -1951,23 +1984,35 @@
|
|
|
1951
1984
|
}
|
|
1952
1985
|
|
|
1953
1986
|
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
|
|
1954
|
-
}
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* @param {string} quote
|
|
1990
|
+
*/
|
|
1991
|
+
;
|
|
1955
1992
|
|
|
1956
1993
|
_proto.blockquote = function blockquote(quote) {
|
|
1957
|
-
return
|
|
1994
|
+
return "<blockquote>\n" + quote + "</blockquote>\n";
|
|
1958
1995
|
};
|
|
1959
1996
|
|
|
1960
1997
|
_proto.html = function html(_html) {
|
|
1961
1998
|
return _html;
|
|
1962
|
-
}
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* @param {string} text
|
|
2002
|
+
* @param {string} level
|
|
2003
|
+
* @param {string} raw
|
|
2004
|
+
* @param {any} slugger
|
|
2005
|
+
*/
|
|
2006
|
+
;
|
|
1963
2007
|
|
|
1964
2008
|
_proto.heading = function heading(text, level, raw, slugger) {
|
|
1965
2009
|
if (this.options.headerIds) {
|
|
1966
|
-
|
|
2010
|
+
var id = this.options.headerPrefix + slugger.slug(raw);
|
|
2011
|
+
return "<h" + level + " id=\"" + id + "\">" + text + "</h" + level + ">\n";
|
|
1967
2012
|
} // ignore IDs
|
|
1968
2013
|
|
|
1969
2014
|
|
|
1970
|
-
return
|
|
2015
|
+
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
|
1971
2016
|
};
|
|
1972
2017
|
|
|
1973
2018
|
_proto.hr = function hr() {
|
|
@@ -1978,55 +2023,94 @@
|
|
|
1978
2023
|
var type = ordered ? 'ol' : 'ul',
|
|
1979
2024
|
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
1980
2025
|
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
1981
|
-
}
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* @param {string} text
|
|
2029
|
+
*/
|
|
2030
|
+
;
|
|
1982
2031
|
|
|
1983
2032
|
_proto.listitem = function listitem(text) {
|
|
1984
|
-
return
|
|
2033
|
+
return "<li>" + text + "</li>\n";
|
|
1985
2034
|
};
|
|
1986
2035
|
|
|
1987
2036
|
_proto.checkbox = function checkbox(checked) {
|
|
1988
2037
|
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
|
1989
|
-
}
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* @param {string} text
|
|
2041
|
+
*/
|
|
2042
|
+
;
|
|
1990
2043
|
|
|
1991
2044
|
_proto.paragraph = function paragraph(text) {
|
|
1992
|
-
return
|
|
1993
|
-
}
|
|
2045
|
+
return "<p>" + text + "</p>\n";
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* @param {string} header
|
|
2049
|
+
* @param {string} body
|
|
2050
|
+
*/
|
|
2051
|
+
;
|
|
1994
2052
|
|
|
1995
2053
|
_proto.table = function table(header, body) {
|
|
1996
|
-
if (body) body =
|
|
2054
|
+
if (body) body = "<tbody>" + body + "</tbody>";
|
|
1997
2055
|
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
1998
|
-
}
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* @param {string} content
|
|
2059
|
+
*/
|
|
2060
|
+
;
|
|
1999
2061
|
|
|
2000
2062
|
_proto.tablerow = function tablerow(content) {
|
|
2001
|
-
return
|
|
2063
|
+
return "<tr>\n" + content + "</tr>\n";
|
|
2002
2064
|
};
|
|
2003
2065
|
|
|
2004
2066
|
_proto.tablecell = function tablecell(content, flags) {
|
|
2005
2067
|
var type = flags.header ? 'th' : 'td';
|
|
2006
|
-
var tag = flags.align ?
|
|
2007
|
-
return tag + content +
|
|
2008
|
-
}
|
|
2068
|
+
var tag = flags.align ? "<" + type + " align=\"" + flags.align + "\">" : "<" + type + ">";
|
|
2069
|
+
return tag + content + ("</" + type + ">\n");
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* span level renderer
|
|
2073
|
+
* @param {string} text
|
|
2074
|
+
*/
|
|
2009
2075
|
;
|
|
2010
2076
|
|
|
2011
2077
|
_proto.strong = function strong(text) {
|
|
2012
|
-
return
|
|
2013
|
-
}
|
|
2078
|
+
return "<strong>" + text + "</strong>";
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* @param {string} text
|
|
2082
|
+
*/
|
|
2083
|
+
;
|
|
2014
2084
|
|
|
2015
2085
|
_proto.em = function em(text) {
|
|
2016
|
-
return
|
|
2017
|
-
}
|
|
2086
|
+
return "<em>" + text + "</em>";
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* @param {string} text
|
|
2090
|
+
*/
|
|
2091
|
+
;
|
|
2018
2092
|
|
|
2019
2093
|
_proto.codespan = function codespan(text) {
|
|
2020
|
-
return
|
|
2094
|
+
return "<code>" + text + "</code>";
|
|
2021
2095
|
};
|
|
2022
2096
|
|
|
2023
2097
|
_proto.br = function br() {
|
|
2024
2098
|
return this.options.xhtml ? '<br/>' : '<br>';
|
|
2025
|
-
}
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* @param {string} text
|
|
2102
|
+
*/
|
|
2103
|
+
;
|
|
2026
2104
|
|
|
2027
2105
|
_proto.del = function del(text) {
|
|
2028
|
-
return
|
|
2029
|
-
}
|
|
2106
|
+
return "<del>" + text + "</del>";
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* @param {string} href
|
|
2110
|
+
* @param {string} title
|
|
2111
|
+
* @param {string} text
|
|
2112
|
+
*/
|
|
2113
|
+
;
|
|
2030
2114
|
|
|
2031
2115
|
_proto.link = function link(href, title, text) {
|
|
2032
2116
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
@@ -2043,7 +2127,13 @@
|
|
|
2043
2127
|
|
|
2044
2128
|
out += '>' + text + '</a>';
|
|
2045
2129
|
return out;
|
|
2046
|
-
}
|
|
2130
|
+
}
|
|
2131
|
+
/**
|
|
2132
|
+
* @param {string} href
|
|
2133
|
+
* @param {string} title
|
|
2134
|
+
* @param {string} text
|
|
2135
|
+
*/
|
|
2136
|
+
;
|
|
2047
2137
|
|
|
2048
2138
|
_proto.image = function image(href, title, text) {
|
|
2049
2139
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
@@ -2052,10 +2142,10 @@
|
|
|
2052
2142
|
return text;
|
|
2053
2143
|
}
|
|
2054
2144
|
|
|
2055
|
-
var out =
|
|
2145
|
+
var out = "<img src=\"" + href + "\" alt=\"" + text + "\"";
|
|
2056
2146
|
|
|
2057
2147
|
if (title) {
|
|
2058
|
-
out +=
|
|
2148
|
+
out += " title=\"" + title + "\"";
|
|
2059
2149
|
}
|
|
2060
2150
|
|
|
2061
2151
|
out += this.options.xhtml ? '/>' : '>';
|
|
@@ -2125,6 +2215,10 @@
|
|
|
2125
2215
|
function Slugger() {
|
|
2126
2216
|
this.seen = {};
|
|
2127
2217
|
}
|
|
2218
|
+
/**
|
|
2219
|
+
* @param {string} value
|
|
2220
|
+
*/
|
|
2221
|
+
|
|
2128
2222
|
|
|
2129
2223
|
var _proto = Slugger.prototype;
|
|
2130
2224
|
|
|
@@ -2135,6 +2229,8 @@
|
|
|
2135
2229
|
}
|
|
2136
2230
|
/**
|
|
2137
2231
|
* Finds the next safe (unique) slug to use
|
|
2232
|
+
* @param {string} originalSlug
|
|
2233
|
+
* @param {boolean} isDryRun
|
|
2138
2234
|
*/
|
|
2139
2235
|
;
|
|
2140
2236
|
|
|
@@ -2160,8 +2256,9 @@
|
|
|
2160
2256
|
}
|
|
2161
2257
|
/**
|
|
2162
2258
|
* Convert string to unique id
|
|
2163
|
-
* @param {object} options
|
|
2164
|
-
* @param {boolean} options.dryrun Generates the next unique slug without
|
|
2259
|
+
* @param {object} [options]
|
|
2260
|
+
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
|
2261
|
+
* updating the internal accumulator.
|
|
2165
2262
|
*/
|
|
2166
2263
|
;
|
|
2167
2264
|
|
|
@@ -2858,6 +2955,7 @@
|
|
|
2858
2955
|
};
|
|
2859
2956
|
/**
|
|
2860
2957
|
* Parse Inline
|
|
2958
|
+
* @param {string} src
|
|
2861
2959
|
*/
|
|
2862
2960
|
|
|
2863
2961
|
|