🗜️ build [skip ci]
This commit is contained in:
parent
35583c3dec
commit
d62ccbbd67
172
lib/marked.cjs
172
lib/marked.cjs
@ -131,6 +131,10 @@ function escape(html, encode) {
|
||||
return html;
|
||||
}
|
||||
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
||||
/**
|
||||
* @param {string} html
|
||||
*/
|
||||
|
||||
function unescape(html) {
|
||||
// explicitly match decimal, hex, and named HTML entities
|
||||
return html.replace(unescapeTest, function (_, n) {
|
||||
@ -145,8 +149,13 @@ function unescape(html) {
|
||||
});
|
||||
}
|
||||
var caret = /(^|[^\[])\^/g;
|
||||
/**
|
||||
* @param {string | RegExp} regex
|
||||
* @param {string} opt
|
||||
*/
|
||||
|
||||
function edit(regex, opt) {
|
||||
regex = regex.source || regex;
|
||||
regex = typeof regex === 'string' ? regex : regex.source;
|
||||
opt = opt || '';
|
||||
var obj = {
|
||||
replace: function replace(name, val) {
|
||||
@ -163,6 +172,12 @@ function edit(regex, opt) {
|
||||
}
|
||||
var nonWordAndColonTest = /[^\w:]/g;
|
||||
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
||||
/**
|
||||
* @param {boolean} sanitize
|
||||
* @param {string} base
|
||||
* @param {string} href
|
||||
*/
|
||||
|
||||
function cleanUrl(sanitize, base, href) {
|
||||
if (sanitize) {
|
||||
var prot;
|
||||
@ -194,6 +209,11 @@ var baseUrls = {};
|
||||
var justDomain = /^[^:]+:\/*[^/]*$/;
|
||||
var protocol = /^([^:]+:)[\s\S]*$/;
|
||||
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
||||
/**
|
||||
* @param {string} base
|
||||
* @param {string} href
|
||||
*/
|
||||
|
||||
function resolveUrl(base, href) {
|
||||
if (!baseUrls[' ' + base]) {
|
||||
// we can ignore everything in base after the last slash of its path component,
|
||||
@ -290,9 +310,15 @@ function splitCells(tableRow, count) {
|
||||
}
|
||||
|
||||
return cells;
|
||||
} // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
// /c*$/ is vulnerable to REDOS.
|
||||
// invert: Remove suffix of non-c chars instead. Default falsey.
|
||||
}
|
||||
/**
|
||||
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
* /c*$/ is vulnerable to REDOS.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} c
|
||||
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
||||
*/
|
||||
|
||||
function rtrim(str, c, invert) {
|
||||
var l = str.length;
|
||||
@ -316,7 +342,7 @@ function rtrim(str, c, invert) {
|
||||
}
|
||||
}
|
||||
|
||||
return str.substr(0, l - suffLen);
|
||||
return str.slice(0, l - suffLen);
|
||||
}
|
||||
function findClosingBracket(str, b) {
|
||||
if (str.indexOf(b[1]) === -1) {
|
||||
@ -349,6 +375,11 @@ function checkSanitizeDeprecation(opt) {
|
||||
}
|
||||
} // copied from https://stackoverflow.com/a/5450113/806777
|
||||
|
||||
/**
|
||||
* @param {string} pattern
|
||||
* @param {number} count
|
||||
*/
|
||||
|
||||
function repeatString(pattern, count) {
|
||||
if (count < 1) {
|
||||
return '';
|
||||
@ -1278,9 +1309,9 @@ var inline = {
|
||||
emStrong: {
|
||||
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
||||
// (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.
|
||||
// () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
||||
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
||||
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
||||
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
||||
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
||||
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
||||
|
||||
},
|
||||
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
||||
@ -1362,6 +1393,7 @@ inline.breaks = merge({}, inline.gfm, {
|
||||
|
||||
/**
|
||||
* smartypants text replacement
|
||||
* @param {string} text
|
||||
*/
|
||||
|
||||
function smartypants(text) {
|
||||
@ -1376,6 +1408,7 @@ function smartypants(text) {
|
||||
}
|
||||
/**
|
||||
* mangle email addresses
|
||||
* @param {string} text
|
||||
*/
|
||||
|
||||
|
||||
@ -1949,23 +1982,35 @@ var Renderer = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} quote
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.blockquote = function blockquote(quote) {
|
||||
return '<blockquote>\n' + quote + '</blockquote>\n';
|
||||
return "<blockquote>\n" + quote + "</blockquote>\n";
|
||||
};
|
||||
|
||||
_proto.html = function html(_html) {
|
||||
return _html;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
* @param {string} level
|
||||
* @param {string} raw
|
||||
* @param {any} slugger
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.heading = function heading(text, level, raw, slugger) {
|
||||
if (this.options.headerIds) {
|
||||
return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
|
||||
var id = this.options.headerPrefix + slugger.slug(raw);
|
||||
return "<h" + level + " id=\"" + id + "\">" + text + "</h" + level + ">\n";
|
||||
} // ignore IDs
|
||||
|
||||
|
||||
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
||||
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
||||
};
|
||||
|
||||
_proto.hr = function hr() {
|
||||
@ -1976,55 +2021,94 @@ var Renderer = /*#__PURE__*/function () {
|
||||
var type = ordered ? 'ol' : 'ul',
|
||||
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
||||
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.listitem = function listitem(text) {
|
||||
return '<li>' + text + '</li>\n';
|
||||
return "<li>" + text + "</li>\n";
|
||||
};
|
||||
|
||||
_proto.checkbox = function checkbox(checked) {
|
||||
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.paragraph = function paragraph(text) {
|
||||
return '<p>' + text + '</p>\n';
|
||||
};
|
||||
return "<p>" + text + "</p>\n";
|
||||
}
|
||||
/**
|
||||
* @param {string} header
|
||||
* @param {string} body
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.table = function table(header, body) {
|
||||
if (body) body = '<tbody>' + body + '</tbody>';
|
||||
if (body) body = "<tbody>" + body + "</tbody>";
|
||||
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} content
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.tablerow = function tablerow(content) {
|
||||
return '<tr>\n' + content + '</tr>\n';
|
||||
return "<tr>\n" + content + "</tr>\n";
|
||||
};
|
||||
|
||||
_proto.tablecell = function tablecell(content, flags) {
|
||||
var type = flags.header ? 'th' : 'td';
|
||||
var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
|
||||
return tag + content + '</' + type + '>\n';
|
||||
} // span level renderer
|
||||
var tag = flags.align ? "<" + type + " align=\"" + flags.align + "\">" : "<" + type + ">";
|
||||
return tag + content + ("</" + type + ">\n");
|
||||
}
|
||||
/**
|
||||
* span level renderer
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.strong = function strong(text) {
|
||||
return '<strong>' + text + '</strong>';
|
||||
};
|
||||
return "<strong>" + text + "</strong>";
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.em = function em(text) {
|
||||
return '<em>' + text + '</em>';
|
||||
};
|
||||
return "<em>" + text + "</em>";
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.codespan = function codespan(text) {
|
||||
return '<code>' + text + '</code>';
|
||||
return "<code>" + text + "</code>";
|
||||
};
|
||||
|
||||
_proto.br = function br() {
|
||||
return this.options.xhtml ? '<br/>' : '<br>';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.del = function del(text) {
|
||||
return '<del>' + text + '</del>';
|
||||
};
|
||||
return "<del>" + text + "</del>";
|
||||
}
|
||||
/**
|
||||
* @param {string} href
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.link = function link(href, title, text) {
|
||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||
@ -2041,7 +2125,13 @@ var Renderer = /*#__PURE__*/function () {
|
||||
|
||||
out += '>' + text + '</a>';
|
||||
return out;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} href
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.image = function image(href, title, text) {
|
||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||
@ -2050,10 +2140,10 @@ var Renderer = /*#__PURE__*/function () {
|
||||
return text;
|
||||
}
|
||||
|
||||
var out = '<img src="' + href + '" alt="' + text + '"';
|
||||
var out = "<img src=\"" + href + "\" alt=\"" + text + "\"";
|
||||
|
||||
if (title) {
|
||||
out += ' title="' + title + '"';
|
||||
out += " title=\"" + title + "\"";
|
||||
}
|
||||
|
||||
out += this.options.xhtml ? '/>' : '>';
|
||||
@ -2123,6 +2213,10 @@ var Slugger = /*#__PURE__*/function () {
|
||||
function Slugger() {
|
||||
this.seen = {};
|
||||
}
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
|
||||
|
||||
var _proto = Slugger.prototype;
|
||||
|
||||
@ -2133,6 +2227,8 @@ var Slugger = /*#__PURE__*/function () {
|
||||
}
|
||||
/**
|
||||
* Finds the next safe (unique) slug to use
|
||||
* @param {string} originalSlug
|
||||
* @param {boolean} isDryRun
|
||||
*/
|
||||
;
|
||||
|
||||
@ -2158,8 +2254,9 @@ var Slugger = /*#__PURE__*/function () {
|
||||
}
|
||||
/**
|
||||
* Convert string to unique id
|
||||
* @param {object} options
|
||||
* @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
||||
* updating the internal accumulator.
|
||||
*/
|
||||
;
|
||||
|
||||
@ -2856,6 +2953,7 @@ marked.walkTokens = function (tokens, callback) {
|
||||
};
|
||||
/**
|
||||
* Parse Inline
|
||||
* @param {string} src
|
||||
*/
|
||||
|
||||
|
||||
|
@ -70,6 +70,9 @@ function escape(html, encode) {
|
||||
|
||||
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
||||
|
||||
/**
|
||||
* @param {string} html
|
||||
*/
|
||||
function unescape(html) {
|
||||
// explicitly match decimal, hex, and named HTML entities
|
||||
return html.replace(unescapeTest, (_, n) => {
|
||||
@ -85,8 +88,13 @@ function unescape(html) {
|
||||
}
|
||||
|
||||
const caret = /(^|[^\[])\^/g;
|
||||
|
||||
/**
|
||||
* @param {string | RegExp} regex
|
||||
* @param {string} opt
|
||||
*/
|
||||
function edit(regex, opt) {
|
||||
regex = regex.source || regex;
|
||||
regex = typeof regex === 'string' ? regex : regex.source;
|
||||
opt = opt || '';
|
||||
const obj = {
|
||||
replace: (name, val) => {
|
||||
@ -104,6 +112,12 @@ function edit(regex, opt) {
|
||||
|
||||
const nonWordAndColonTest = /[^\w:]/g;
|
||||
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
||||
|
||||
/**
|
||||
* @param {boolean} sanitize
|
||||
* @param {string} base
|
||||
* @param {string} href
|
||||
*/
|
||||
function cleanUrl(sanitize, base, href) {
|
||||
if (sanitize) {
|
||||
let prot;
|
||||
@ -134,6 +148,10 @@ const justDomain = /^[^:]+:\/*[^/]*$/;
|
||||
const protocol = /^([^:]+:)[\s\S]*$/;
|
||||
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
||||
|
||||
/**
|
||||
* @param {string} base
|
||||
* @param {string} href
|
||||
*/
|
||||
function resolveUrl(base, href) {
|
||||
if (!baseUrls[' ' + base]) {
|
||||
// we can ignore everything in base after the last slash of its path component,
|
||||
@ -218,9 +236,14 @@ function splitCells(tableRow, count) {
|
||||
return cells;
|
||||
}
|
||||
|
||||
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
// /c*$/ is vulnerable to REDOS.
|
||||
// invert: Remove suffix of non-c chars instead. Default falsey.
|
||||
/**
|
||||
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
* /c*$/ is vulnerable to REDOS.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} c
|
||||
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
||||
*/
|
||||
function rtrim(str, c, invert) {
|
||||
const l = str.length;
|
||||
if (l === 0) {
|
||||
@ -242,7 +265,7 @@ function rtrim(str, c, invert) {
|
||||
}
|
||||
}
|
||||
|
||||
return str.substr(0, l - suffLen);
|
||||
return str.slice(0, l - suffLen);
|
||||
}
|
||||
|
||||
function findClosingBracket(str, b) {
|
||||
@ -274,6 +297,10 @@ function checkSanitizeDeprecation(opt) {
|
||||
}
|
||||
|
||||
// copied from https://stackoverflow.com/a/5450113/806777
|
||||
/**
|
||||
* @param {string} pattern
|
||||
* @param {number} count
|
||||
*/
|
||||
function repeatString(pattern, count) {
|
||||
if (count < 1) {
|
||||
return '';
|
||||
@ -1214,9 +1241,9 @@ const inline = {
|
||||
emStrong: {
|
||||
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
||||
// (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.
|
||||
// () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
||||
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
||||
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
||||
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
||||
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
||||
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
||||
},
|
||||
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
||||
br: /^( {2,}|\\)\n(?!\s*$)/,
|
||||
@ -1349,6 +1376,7 @@ inline.breaks = merge({}, inline.gfm, {
|
||||
|
||||
/**
|
||||
* smartypants text replacement
|
||||
* @param {string} text
|
||||
*/
|
||||
function smartypants(text) {
|
||||
return text
|
||||
@ -1370,6 +1398,7 @@ function smartypants(text) {
|
||||
|
||||
/**
|
||||
* mangle email addresses
|
||||
* @param {string} text
|
||||
*/
|
||||
function mangle(text) {
|
||||
let out = '',
|
||||
@ -1872,29 +1901,31 @@ class Renderer {
|
||||
+ '</code></pre>\n';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} quote
|
||||
*/
|
||||
blockquote(quote) {
|
||||
return '<blockquote>\n' + quote + '</blockquote>\n';
|
||||
return `<blockquote>\n${quote}</blockquote>\n`;
|
||||
}
|
||||
|
||||
html(html) {
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
* @param {string} level
|
||||
* @param {string} raw
|
||||
* @param {any} slugger
|
||||
*/
|
||||
heading(text, level, raw, slugger) {
|
||||
if (this.options.headerIds) {
|
||||
return '<h'
|
||||
+ level
|
||||
+ ' id="'
|
||||
+ this.options.headerPrefix
|
||||
+ slugger.slug(raw)
|
||||
+ '">'
|
||||
+ text
|
||||
+ '</h'
|
||||
+ level
|
||||
+ '>\n';
|
||||
const id = this.options.headerPrefix + slugger.slug(raw);
|
||||
return `<h${level} id="${id}">${text}</h${level}>\n`;
|
||||
}
|
||||
|
||||
// ignore IDs
|
||||
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
||||
return `<h${level}>${text}</h${level}>\n`;
|
||||
}
|
||||
|
||||
hr() {
|
||||
@ -1907,8 +1938,11 @@ class Renderer {
|
||||
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
listitem(text) {
|
||||
return '<li>' + text + '</li>\n';
|
||||
return `<li>${text}</li>\n`;
|
||||
}
|
||||
|
||||
checkbox(checked) {
|
||||
@ -1919,12 +1953,19 @@ class Renderer {
|
||||
+ '> ';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
paragraph(text) {
|
||||
return '<p>' + text + '</p>\n';
|
||||
return `<p>${text}</p>\n`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} header
|
||||
* @param {string} body
|
||||
*/
|
||||
table(header, body) {
|
||||
if (body) body = '<tbody>' + body + '</tbody>';
|
||||
if (body) body = `<tbody>${body}</tbody>`;
|
||||
|
||||
return '<table>\n'
|
||||
+ '<thead>\n'
|
||||
@ -1934,39 +1975,59 @@ class Renderer {
|
||||
+ '</table>\n';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} content
|
||||
*/
|
||||
tablerow(content) {
|
||||
return '<tr>\n' + content + '</tr>\n';
|
||||
return `<tr>\n${content}</tr>\n`;
|
||||
}
|
||||
|
||||
tablecell(content, flags) {
|
||||
const type = flags.header ? 'th' : 'td';
|
||||
const tag = flags.align
|
||||
? '<' + type + ' align="' + flags.align + '">'
|
||||
: '<' + type + '>';
|
||||
return tag + content + '</' + type + '>\n';
|
||||
? `<${type} align="${flags.align}">`
|
||||
: `<${type}>`;
|
||||
return tag + content + `</${type}>\n`;
|
||||
}
|
||||
|
||||
// span level renderer
|
||||
/**
|
||||
* span level renderer
|
||||
* @param {string} text
|
||||
*/
|
||||
strong(text) {
|
||||
return '<strong>' + text + '</strong>';
|
||||
return `<strong>${text}</strong>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
em(text) {
|
||||
return '<em>' + text + '</em>';
|
||||
return `<em>${text}</em>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
codespan(text) {
|
||||
return '<code>' + text + '</code>';
|
||||
return `<code>${text}</code>`;
|
||||
}
|
||||
|
||||
br() {
|
||||
return this.options.xhtml ? '<br/>' : '<br>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
del(text) {
|
||||
return '<del>' + text + '</del>';
|
||||
return `<del>${text}</del>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} href
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
link(href, title, text) {
|
||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||
if (href === null) {
|
||||
@ -1980,15 +2041,20 @@ class Renderer {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} href
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
image(href, title, text) {
|
||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||
if (href === null) {
|
||||
return text;
|
||||
}
|
||||
|
||||
let out = '<img src="' + href + '" alt="' + text + '"';
|
||||
let out = `<img src="${href}" alt="${text}"`;
|
||||
if (title) {
|
||||
out += ' title="' + title + '"';
|
||||
out += ` title="${title}"`;
|
||||
}
|
||||
out += this.options.xhtml ? '/>' : '>';
|
||||
return out;
|
||||
@ -2050,6 +2116,9 @@ class Slugger {
|
||||
this.seen = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
serialize(value) {
|
||||
return value
|
||||
.toLowerCase()
|
||||
@ -2063,6 +2132,8 @@ class Slugger {
|
||||
|
||||
/**
|
||||
* Finds the next safe (unique) slug to use
|
||||
* @param {string} originalSlug
|
||||
* @param {boolean} isDryRun
|
||||
*/
|
||||
getNextSafeSlug(originalSlug, isDryRun) {
|
||||
let slug = originalSlug;
|
||||
@ -2083,8 +2154,9 @@ class Slugger {
|
||||
|
||||
/**
|
||||
* Convert string to unique id
|
||||
* @param {object} options
|
||||
* @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
||||
* updating the internal accumulator.
|
||||
*/
|
||||
slug(value, options = {}) {
|
||||
const slug = this.serialize(value);
|
||||
@ -2645,6 +2717,7 @@ marked.walkTokens = function(tokens, callback) {
|
||||
|
||||
/**
|
||||
* Parse Inline
|
||||
* @param {string} src
|
||||
*/
|
||||
marked.parseInline = function(src, opt) {
|
||||
// throw error in case of non string input
|
||||
|
@ -133,6 +133,10 @@
|
||||
return html;
|
||||
}
|
||||
var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
||||
/**
|
||||
* @param {string} html
|
||||
*/
|
||||
|
||||
function unescape(html) {
|
||||
// explicitly match decimal, hex, and named HTML entities
|
||||
return html.replace(unescapeTest, function (_, n) {
|
||||
@ -147,8 +151,13 @@
|
||||
});
|
||||
}
|
||||
var caret = /(^|[^\[])\^/g;
|
||||
/**
|
||||
* @param {string | RegExp} regex
|
||||
* @param {string} opt
|
||||
*/
|
||||
|
||||
function edit(regex, opt) {
|
||||
regex = regex.source || regex;
|
||||
regex = typeof regex === 'string' ? regex : regex.source;
|
||||
opt = opt || '';
|
||||
var obj = {
|
||||
replace: function replace(name, val) {
|
||||
@ -165,6 +174,12 @@
|
||||
}
|
||||
var nonWordAndColonTest = /[^\w:]/g;
|
||||
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
||||
/**
|
||||
* @param {boolean} sanitize
|
||||
* @param {string} base
|
||||
* @param {string} href
|
||||
*/
|
||||
|
||||
function cleanUrl(sanitize, base, href) {
|
||||
if (sanitize) {
|
||||
var prot;
|
||||
@ -196,6 +211,11 @@
|
||||
var justDomain = /^[^:]+:\/*[^/]*$/;
|
||||
var protocol = /^([^:]+:)[\s\S]*$/;
|
||||
var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
||||
/**
|
||||
* @param {string} base
|
||||
* @param {string} href
|
||||
*/
|
||||
|
||||
function resolveUrl(base, href) {
|
||||
if (!baseUrls[' ' + base]) {
|
||||
// we can ignore everything in base after the last slash of its path component,
|
||||
@ -292,9 +312,15 @@
|
||||
}
|
||||
|
||||
return cells;
|
||||
} // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
// /c*$/ is vulnerable to REDOS.
|
||||
// invert: Remove suffix of non-c chars instead. Default falsey.
|
||||
}
|
||||
/**
|
||||
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
* /c*$/ is vulnerable to REDOS.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} c
|
||||
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
||||
*/
|
||||
|
||||
function rtrim(str, c, invert) {
|
||||
var l = str.length;
|
||||
@ -318,7 +344,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
return str.substr(0, l - suffLen);
|
||||
return str.slice(0, l - suffLen);
|
||||
}
|
||||
function findClosingBracket(str, b) {
|
||||
if (str.indexOf(b[1]) === -1) {
|
||||
@ -351,6 +377,11 @@
|
||||
}
|
||||
} // copied from https://stackoverflow.com/a/5450113/806777
|
||||
|
||||
/**
|
||||
* @param {string} pattern
|
||||
* @param {number} count
|
||||
*/
|
||||
|
||||
function repeatString(pattern, count) {
|
||||
if (count < 1) {
|
||||
return '';
|
||||
@ -1280,9 +1311,9 @@
|
||||
emStrong: {
|
||||
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
||||
// (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.
|
||||
// () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
||||
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
||||
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
||||
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
||||
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
||||
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
||||
|
||||
},
|
||||
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
||||
@ -1364,6 +1395,7 @@
|
||||
|
||||
/**
|
||||
* smartypants text replacement
|
||||
* @param {string} text
|
||||
*/
|
||||
|
||||
function smartypants(text) {
|
||||
@ -1378,6 +1410,7 @@
|
||||
}
|
||||
/**
|
||||
* mangle email addresses
|
||||
* @param {string} text
|
||||
*/
|
||||
|
||||
|
||||
@ -1951,23 +1984,35 @@
|
||||
}
|
||||
|
||||
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} quote
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.blockquote = function blockquote(quote) {
|
||||
return '<blockquote>\n' + quote + '</blockquote>\n';
|
||||
return "<blockquote>\n" + quote + "</blockquote>\n";
|
||||
};
|
||||
|
||||
_proto.html = function html(_html) {
|
||||
return _html;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
* @param {string} level
|
||||
* @param {string} raw
|
||||
* @param {any} slugger
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.heading = function heading(text, level, raw, slugger) {
|
||||
if (this.options.headerIds) {
|
||||
return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
|
||||
var id = this.options.headerPrefix + slugger.slug(raw);
|
||||
return "<h" + level + " id=\"" + id + "\">" + text + "</h" + level + ">\n";
|
||||
} // ignore IDs
|
||||
|
||||
|
||||
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
||||
return "<h" + level + ">" + text + "</h" + level + ">\n";
|
||||
};
|
||||
|
||||
_proto.hr = function hr() {
|
||||
@ -1978,55 +2023,94 @@
|
||||
var type = ordered ? 'ol' : 'ul',
|
||||
startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
||||
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.listitem = function listitem(text) {
|
||||
return '<li>' + text + '</li>\n';
|
||||
return "<li>" + text + "</li>\n";
|
||||
};
|
||||
|
||||
_proto.checkbox = function checkbox(checked) {
|
||||
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.paragraph = function paragraph(text) {
|
||||
return '<p>' + text + '</p>\n';
|
||||
};
|
||||
return "<p>" + text + "</p>\n";
|
||||
}
|
||||
/**
|
||||
* @param {string} header
|
||||
* @param {string} body
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.table = function table(header, body) {
|
||||
if (body) body = '<tbody>' + body + '</tbody>';
|
||||
if (body) body = "<tbody>" + body + "</tbody>";
|
||||
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} content
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.tablerow = function tablerow(content) {
|
||||
return '<tr>\n' + content + '</tr>\n';
|
||||
return "<tr>\n" + content + "</tr>\n";
|
||||
};
|
||||
|
||||
_proto.tablecell = function tablecell(content, flags) {
|
||||
var type = flags.header ? 'th' : 'td';
|
||||
var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
|
||||
return tag + content + '</' + type + '>\n';
|
||||
} // span level renderer
|
||||
var tag = flags.align ? "<" + type + " align=\"" + flags.align + "\">" : "<" + type + ">";
|
||||
return tag + content + ("</" + type + ">\n");
|
||||
}
|
||||
/**
|
||||
* span level renderer
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.strong = function strong(text) {
|
||||
return '<strong>' + text + '</strong>';
|
||||
};
|
||||
return "<strong>" + text + "</strong>";
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.em = function em(text) {
|
||||
return '<em>' + text + '</em>';
|
||||
};
|
||||
return "<em>" + text + "</em>";
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.codespan = function codespan(text) {
|
||||
return '<code>' + text + '</code>';
|
||||
return "<code>" + text + "</code>";
|
||||
};
|
||||
|
||||
_proto.br = function br() {
|
||||
return this.options.xhtml ? '<br/>' : '<br>';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.del = function del(text) {
|
||||
return '<del>' + text + '</del>';
|
||||
};
|
||||
return "<del>" + text + "</del>";
|
||||
}
|
||||
/**
|
||||
* @param {string} href
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.link = function link(href, title, text) {
|
||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||
@ -2043,7 +2127,13 @@
|
||||
|
||||
out += '>' + text + '</a>';
|
||||
return out;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @param {string} href
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.image = function image(href, title, text) {
|
||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||
@ -2052,10 +2142,10 @@
|
||||
return text;
|
||||
}
|
||||
|
||||
var out = '<img src="' + href + '" alt="' + text + '"';
|
||||
var out = "<img src=\"" + href + "\" alt=\"" + text + "\"";
|
||||
|
||||
if (title) {
|
||||
out += ' title="' + title + '"';
|
||||
out += " title=\"" + title + "\"";
|
||||
}
|
||||
|
||||
out += this.options.xhtml ? '/>' : '>';
|
||||
@ -2125,6 +2215,10 @@
|
||||
function Slugger() {
|
||||
this.seen = {};
|
||||
}
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
|
||||
|
||||
var _proto = Slugger.prototype;
|
||||
|
||||
@ -2135,6 +2229,8 @@
|
||||
}
|
||||
/**
|
||||
* Finds the next safe (unique) slug to use
|
||||
* @param {string} originalSlug
|
||||
* @param {boolean} isDryRun
|
||||
*/
|
||||
;
|
||||
|
||||
@ -2160,8 +2256,9 @@
|
||||
}
|
||||
/**
|
||||
* Convert string to unique id
|
||||
* @param {object} options
|
||||
* @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
||||
* updating the internal accumulator.
|
||||
*/
|
||||
;
|
||||
|
||||
@ -2858,6 +2955,7 @@
|
||||
};
|
||||
/**
|
||||
* Parse Inline
|
||||
* @param {string} src
|
||||
*/
|
||||
|
||||
|
||||
|
2
marked.min.js
vendored
2
marked.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user