Skip to content

Commit

Permalink
🗜️ build [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkedJS bot committed Apr 8, 2022
1 parent 35583c3 commit d62ccbb
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 111 deletions.
172 changes: 135 additions & 37 deletions lib/marked.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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 '';
Expand Down Expand Up @@ -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(?!`)/,
Expand Down Expand Up @@ -1362,6 +1393,7 @@ inline.breaks = merge({}, inline.gfm, {

/**
* smartypants text replacement
* @param {string} text
*/

function smartypants(text) {
Expand All @@ -1376,6 +1408,7 @@ function smartypants(text) {
}
/**
* mangle email addresses
* @param {string} text
*/


Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 ? '/>' : '>';
Expand Down Expand Up @@ -2123,6 +2213,10 @@ var Slugger = /*#__PURE__*/function () {
function Slugger() {
this.seen = {};
}
/**
* @param {string} value
*/


var _proto = Slugger.prototype;

Expand All @@ -2133,6 +2227,8 @@ var Slugger = /*#__PURE__*/function () {
}
/**
* Finds the next safe (unique) slug to use
* @param {string} originalSlug
* @param {boolean} isDryRun
*/
;

Expand All @@ -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.
*/
;

Expand Down Expand Up @@ -2856,6 +2953,7 @@ marked.walkTokens = function (tokens, callback) {
};
/**
* Parse Inline
* @param {string} src
*/


Expand Down
Loading

0 comments on commit d62ccbb

Please sign in to comment.