modrinth-code/patches/markdown-it@13.0.1.patch

1020 lines
237 KiB
Diff
Raw Permalink Normal View History

2023-07-04 12:15:14 -07:00
diff --git a/dist/markdown-it.js b/dist/markdown-it.js
index 938677aea68c9eafd4d1992f019bfd6f25e9e588..92d268152c6980e03b79b202b0f7dd4c5ad72dc9 100644
--- a/dist/markdown-it.js
+++ b/dist/markdown-it.js
@@ -13,22 +13,6 @@
}
}, fn(module, module.exports), module.exports;
}
- function getAugmentedNamespace(n) {
- if (n.__esModule) return n;
- var a = Object.defineProperty({}, "__esModule", {
- value: true
- });
- Object.keys(n).forEach((function(k) {
- var d = Object.getOwnPropertyDescriptor(n, k);
- Object.defineProperty(a, k, d.get ? d : {
- enumerable: true,
- get: function() {
- return n[k];
- }
- });
- }));
- return a;
- }
function commonjsRequire() {
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
}
@@ -2192,12 +2176,12 @@
// - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
// - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
- function encode$2(string, exclude, keepEscaped) {
+ function encode$1(string, exclude, keepEscaped) {
var i, l, code, nextCode, cache, result = "";
if (typeof exclude !== "string") {
// encode(string, keepEscaped)
keepEscaped = exclude;
- exclude = encode$2.defaultChars;
+ exclude = encode$1.defaultChars;
}
if (typeof keepEscaped === "undefined") {
keepEscaped = true;
@@ -2232,9 +2216,9 @@
}
return result;
}
- encode$2.defaultChars = ";/?:@&=+$,-_.!~*'()#";
- encode$2.componentChars = "-_.!~*'()";
- var encode_1 = encode$2;
+ encode$1.defaultChars = ";/?:@&=+$,-_.!~*'()#";
+ encode$1.componentChars = "-_.!~*'()";
+ var encode_1 = encode$1;
/* eslint-disable no-bitwise */ var decodeCache = {};
function getDecodeCache(exclude) {
var i, ch, cache = decodeCache[exclude];
@@ -2254,10 +2238,10 @@
}
// Decode percent-encoded string.
- function decode$2(string, exclude) {
+ function decode$1(string, exclude) {
var cache;
if (typeof exclude !== "string") {
- exclude = decode$2.defaultChars;
+ exclude = decode$1.defaultChars;
}
cache = getDecodeCache(exclude);
return string.replace(/(%[a-f0-9]{2})+/gi, (function(seq) {
@@ -2319,9 +2303,9 @@
return result;
}));
}
- decode$2.defaultChars = ";/?:@&=+$,#";
- decode$2.componentChars = "";
- var decode_1 = decode$2;
+ decode$1.defaultChars = ";/?:@&=+$,#";
+ decode$1.componentChars = "";
+ var decode_1 = decode$1;
var format$1 = function format(url) {
var result = "";
result += url.protocol || "";
@@ -2594,13 +2578,13 @@
}
};
var parse$1 = urlParse;
- var encode$1 = encode_1;
- var decode$1 = decode_1;
+ var encode = encode_1;
+ var decode = decode_1;
var format = format$1;
var parse = parse$1;
var mdurl = {
- encode: encode$1,
- decode: decode$1,
+ encode: encode,
+ decode: decode,
format: format,
parse: parse
};
@@ -2698,9 +2682,9 @@
var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + "|" + ENTITY_RE.source, "gi");
- var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
+ var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;
function replaceEntityPattern(match, name) {
- var code = 0;
+ var code;
if (has(entities, name)) {
return entities[name];
}
2023-07-04 12:15:14 -07:00
@@ -2951,8 +2935,8 @@
return labelEnd;
};
var unescapeAll$2 = utils.unescapeAll;
- var parse_link_destination = function parseLinkDestination(str, pos, max) {
- var code, level, lines = 0, start = pos, result = {
+ var parse_link_destination = function parseLinkDestination(str, start, max) {
+ var code, level, pos = start, result = {
ok: false,
pos: 0,
lines: 0,
2023-07-04 12:15:14 -07:00
@@ -3022,14 +3006,13 @@
return result;
}
result.str = unescapeAll$2(str.slice(start, pos));
- result.lines = lines;
result.pos = pos;
result.ok = true;
return result;
};
var unescapeAll$1 = utils.unescapeAll;
- var parse_link_title = function parseLinkTitle(str, pos, max) {
- var code, marker, lines = 0, start = pos, result = {
+ var parse_link_title = function parseLinkTitle(str, start, max) {
+ var code, marker, lines = 0, pos = start, result = {
ok: false,
pos: 0,
lines: 0,
2023-07-04 12:15:14 -07:00
@@ -3084,7 +3067,7 @@
var default_rules = {};
default_rules.code_inline = function(tokens, idx, options, env, slf) {
var token = tokens[idx];
- return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(tokens[idx].content) + "</code>";
+ return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
};
default_rules.code_block = function(tokens, idx, options, env, slf) {
var token = tokens[idx];
2023-07-04 12:15:14 -07:00
@@ -3306,7 +3289,7 @@
if (type === "inline") {
result += this.renderInline(tokens[i].children, options, env);
} else if (typeof rules[type] !== "undefined") {
- result += rules[tokens[i].type](tokens, i, options, env, this);
+ result += rules[type](tokens, i, options, env, this);
} else {
result += this.renderToken(tokens, i, options, env);
}
2023-07-04 12:15:14 -07:00
@@ -4527,7 +4510,7 @@
return false;
}
// check the block quote marker
- if (state.src.charCodeAt(pos++) !== 62 /* > */) {
+ if (state.src.charCodeAt(pos) !== 62 /* > */) {
return false;
}
// we know that it's going to be a valid blockquote,
2023-07-04 12:15:14 -07:00
@@ -4535,57 +4518,10 @@
if (silent) {
return true;
}
- // set offset past spaces and ">"
- initial = offset = state.sCount[startLine] + 1;
- // skip one optional space after '>'
- if (state.src.charCodeAt(pos) === 32 /* space */) {
- // ' > test '
- // ^ -- position start of line here:
- pos++;
- initial++;
- offset++;
- adjustTab = false;
- spaceAfterMarker = true;
- } else if (state.src.charCodeAt(pos) === 9 /* tab */) {
- spaceAfterMarker = true;
- if ((state.bsCount[startLine] + offset) % 4 === 3) {
- // ' >\t test '
- // ^ -- position start of line here (tab has width===1)
- pos++;
- initial++;
- offset++;
- adjustTab = false;
- } else {
- // ' >\t test '
- // ^ -- position start of line here + shift bsCount slightly
- // to make extra space appear
- adjustTab = true;
- }
- } else {
- spaceAfterMarker = false;
- }
- oldBMarks = [ state.bMarks[startLine] ];
- state.bMarks[startLine] = pos;
- while (pos < max) {
- ch = state.src.charCodeAt(pos);
- if (isSpace$9(ch)) {
- if (ch === 9) {
- offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
- } else {
- offset++;
- }
- } else {
- break;
- }
- pos++;
- }
- oldBSCount = [ state.bsCount[startLine] ];
- state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
- lastLineEmpty = pos >= max;
- oldSCount = [ state.sCount[startLine] ];
- state.sCount[startLine] = offset - initial;
- oldTShift = [ state.tShift[startLine] ];
- state.tShift[startLine] = pos - state.bMarks[startLine];
+ oldBMarks = [];
+ oldBSCount = [];
+ oldSCount = [];
+ oldTShift = [];
terminatorRules = state.md.block.ruler.getRules("blockquote");
oldParentType = state.parentType;
state.parentType = "blockquote";
2023-07-04 12:15:14 -07:00
@@ -4607,7 +4543,7 @@
// > test
// - - -
// ```
- for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
+ for (nextLine = startLine; nextLine < endLine; nextLine++) {
// check if it's outdented, i.e. it's inside list item and indented
// less than said list item:
// ```
2023-07-04 12:15:14 -07:00
@@ -4625,24 +4561,22 @@
if (state.src.charCodeAt(pos++) === 62 /* > */ && !isOutdented) {
// This line is inside the blockquote.
// set offset past spaces and ">"
- initial = offset = state.sCount[nextLine] + 1;
+ initial = state.sCount[nextLine] + 1;
// skip one optional space after '>'
if (state.src.charCodeAt(pos) === 32 /* space */) {
// ' > test '
// ^ -- position start of line here:
pos++;
initial++;
- offset++;
adjustTab = false;
spaceAfterMarker = true;
} else if (state.src.charCodeAt(pos) === 9 /* tab */) {
spaceAfterMarker = true;
- if ((state.bsCount[nextLine] + offset) % 4 === 3) {
+ if ((state.bsCount[nextLine] + initial) % 4 === 3) {
// ' >\t test '
// ^ -- position start of line here (tab has width===1)
pos++;
initial++;
- offset++;
adjustTab = false;
} else {
// ' >\t test '
2023-07-04 12:15:14 -07:00
@@ -4653,6 +4587,7 @@
} else {
spaceAfterMarker = false;
}
+ offset = initial;
oldBMarks.push(state.bMarks[nextLine]);
state.bMarks[nextLine] = pos;
while (pos < max) {
2023-07-04 12:15:14 -07:00
@@ -4845,9 +4780,9 @@
}
}
var list = function list(state, startLine, endLine, silent) {
- var ch, contentStart, i, indent, indentAfterMarker, initial, isOrdered, itemLines, l, listLines, listTokIdx, markerCharCode, markerValue, max, nextLine, offset, oldListIndent, oldParentType, oldSCount, oldTShift, oldTight, pos, posAfterMarker, prevEmptyEnd, start, terminate, terminatorRules, token, isTerminatingParagraph = false, tight = true;
+ var ch, contentStart, i, indent, indentAfterMarker, initial, isOrdered, itemLines, l, listLines, listTokIdx, markerCharCode, markerValue, max, offset, oldListIndent, oldParentType, oldSCount, oldTShift, oldTight, pos, posAfterMarker, prevEmptyEnd, start, terminate, terminatorRules, token, nextLine = startLine, isTerminatingParagraph = false, tight = true;
// if it's indented more than 3 spaces, it should be a code block
- if (state.sCount[startLine] - state.blkIndent >= 4) {
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
return false;
}
// Special case:
2023-07-04 12:15:14 -07:00
@@ -4856,7 +4791,7 @@
// - item 3
// - item 4
// - this one is a paragraph continuation
- if (state.listIndent >= 0 && state.sCount[startLine] - state.listIndent >= 4 && state.sCount[startLine] < state.blkIndent) {
+ if (state.listIndent >= 0 && state.sCount[nextLine] - state.listIndent >= 4 && state.sCount[nextLine] < state.blkIndent) {
return false;
}
// limit conditions when list can interrupt
2023-07-04 12:15:14 -07:00
@@ -4865,19 +4800,19 @@
// Next list item should still terminate previous list item;
// This code can fail if plugins use blkIndent as well as lists,
// but I hope the spec gets fixed long before that happens.
- if (state.sCount[startLine] >= state.blkIndent) {
+ if (state.sCount[nextLine] >= state.blkIndent) {
isTerminatingParagraph = true;
}
}
// Detect list type and position after marker
- if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
+ if ((posAfterMarker = skipOrderedListMarker(state, nextLine)) >= 0) {
isOrdered = true;
- start = state.bMarks[startLine] + state.tShift[startLine];
+ start = state.bMarks[nextLine] + state.tShift[nextLine];
markerValue = Number(state.src.slice(start, posAfterMarker - 1));
// If we're starting a new ordered list right after
// a paragraph, it should start with 1.
if (isTerminatingParagraph && markerValue !== 1) return false;
- } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
+ } else if ((posAfterMarker = skipBulletListMarker(state, nextLine)) >= 0) {
isOrdered = false;
} else {
return false;
2023-07-04 12:15:14 -07:00
@@ -4885,14 +4820,14 @@
// If we're starting a new unordered list right after
// a paragraph, first line should not be empty.
if (isTerminatingParagraph) {
- if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
+ if (state.skipSpaces(posAfterMarker) >= state.eMarks[nextLine]) return false;
}
- // We should terminate list on style change. Remember first one to compare.
- markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
// For validation mode we can terminate immediately
if (silent) {
return true;
}
+ // We should terminate list on style change. Remember first one to compare.
+ markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
// Start list
listTokIdx = state.tokens.length;
if (isOrdered) {
2023-07-04 12:15:14 -07:00
@@ -4903,20 +4838,19 @@
} else {
token = state.push("bullet_list_open", "ul", 1);
}
- token.map = listLines = [ startLine, 0 ];
+ token.map = listLines = [ nextLine, 0 ];
token.markup = String.fromCharCode(markerCharCode);
2023-07-04 12:15:14 -07:00
// Iterate list items
2023-07-04 12:15:14 -07:00
- nextLine = startLine;
- prevEmptyEnd = false;
+ prevEmptyEnd = false;
terminatorRules = state.md.block.ruler.getRules("list");
oldParentType = state.parentType;
state.parentType = "list";
while (nextLine < endLine) {
pos = posAfterMarker;
max = state.eMarks[nextLine];
- initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
+ initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[nextLine] + state.tShift[nextLine]);
while (pos < max) {
ch = state.src.charCodeAt(pos);
if (ch === 9) {
2023-07-04 12:15:14 -07:00
@@ -4946,14 +4880,14 @@
// Run subparser & write tokens
token = state.push("list_item_open", "li", 1);
token.markup = String.fromCharCode(markerCharCode);
- token.map = itemLines = [ startLine, 0 ];
+ token.map = itemLines = [ nextLine, 0 ];
if (isOrdered) {
token.info = state.src.slice(start, posAfterMarker - 1);
}
// change current state, then restore it after parser subcall
oldTight = state.tight;
- oldTShift = state.tShift[startLine];
- oldSCount = state.sCount[startLine];
+ oldTShift = state.tShift[nextLine];
+ oldSCount = state.sCount[nextLine];
// - example list
// ^ listIndent position will be here
// ^ blkIndent position will be here
2023-07-04 12:15:14 -07:00
@@ -4962,9 +4896,9 @@
state.listIndent = state.blkIndent;
state.blkIndent = indent;
state.tight = true;
- state.tShift[startLine] = contentStart - state.bMarks[startLine];
- state.sCount[startLine] = offset;
- if (contentStart >= max && state.isEmpty(startLine + 1)) {
+ state.tShift[nextLine] = contentStart - state.bMarks[nextLine];
+ state.sCount[nextLine] = offset;
+ if (contentStart >= max && state.isEmpty(nextLine + 1)) {
// workaround for this case
// (list item is empty, list terminates before "foo"):
// ~~~~~~~~
2023-07-04 12:15:14 -07:00
@@ -4973,7 +4907,7 @@
// ~~~~~~~~
state.line = Math.min(state.line + 2, endLine);
} else {
- state.md.block.tokenize(state, startLine, endLine, true);
+ state.md.block.tokenize(state, nextLine, endLine, true);
}
// If any of list item is tight, mark list as tight
if (!state.tight || prevEmptyEnd) {
2023-07-04 12:15:14 -07:00
@@ -4981,17 +4915,16 @@
}
// Item become loose if finish with empty line,
// but we should filter last element, because it means list finish
- prevEmptyEnd = state.line - startLine > 1 && state.isEmpty(state.line - 1);
+ prevEmptyEnd = state.line - nextLine > 1 && state.isEmpty(state.line - 1);
state.blkIndent = state.listIndent;
state.listIndent = oldListIndent;
- state.tShift[startLine] = oldTShift;
- state.sCount[startLine] = oldSCount;
+ state.tShift[nextLine] = oldTShift;
+ state.sCount[nextLine] = oldSCount;
state.tight = oldTight;
token = state.push("list_item_close", "li", -1);
token.markup = String.fromCharCode(markerCharCode);
- nextLine = startLine = state.line;
+ nextLine = state.line;
itemLines[1] = nextLine;
- contentStart = state.bMarks[startLine];
if (nextLine >= endLine) {
break;
}
2023-07-04 12:15:14 -07:00
@@ -5002,7 +4935,7 @@
break;
}
// if it's indented more than 3 spaces, it should be a code block
- if (state.sCount[startLine] - state.blkIndent >= 4) {
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
break;
}
// fail if terminating block found
2023-07-04 12:15:14 -07:00
@@ -5410,8 +5343,8 @@
return true;
};
// Paragraph
- var paragraph = function paragraph(state, startLine /*, endLine*/) {
- var content, terminate, i, l, token, oldParentType, nextLine = startLine + 1, terminatorRules = state.md.block.ruler.getRules("paragraph"), endLine = state.lineMax;
+ var paragraph = function paragraph(state, startLine, endLine) {
+ var content, terminate, i, l, token, oldParentType, nextLine = startLine + 1, terminatorRules = state.md.block.ruler.getRules("paragraph");
oldParentType = state.parentType;
state.parentType = "paragraph";
// jump line-by-line until empty one or EOF
2023-07-04 12:15:14 -07:00
@@ -5677,7 +5610,7 @@
// Generate tokens for input range
2023-07-04 12:15:14 -07:00
ParserBlock.prototype.tokenize = function(state, startLine, endLine) {
- var ok, i, rules = this.ruler.getRules(""), len = rules.length, line = startLine, hasEmptyLines = false, maxNesting = state.md.options.maxNesting;
+ var ok, i, prevLine, rules = this.ruler.getRules(""), len = rules.length, line = startLine, hasEmptyLines = false, maxNesting = state.md.options.maxNesting;
while (line < endLine) {
state.line = line = state.skipEmptyLines(line);
if (line >= endLine) {
2023-07-04 12:15:14 -07:00
@@ -5700,12 +5633,18 @@
// - update `state.line`
// - update `state.tokens`
// - return true
- for (i = 0; i < len; i++) {
+ prevLine = state.line;
+ for (i = 0; i < len; i++) {
ok = rules[i](state, line, endLine, false);
if (ok) {
+ if (prevLine >= state.line) {
+ throw new Error("block rule didn't increment state.line");
+ }
break;
}
}
+ // this can only happen if user disables paragraph rule
+ if (!ok) throw new Error("none of the block rules matched");
// set state.tight if we had an empty line before current tag
// i.e. latest empty line should not count
state.tight = !hasEmptyLines;
2023-07-04 12:15:14 -07:00
@@ -5931,7 +5870,7 @@
state.pos += openerLength;
return true;
}
- matchStart = matchEnd = pos;
+ matchEnd = pos;
// Nothing found in the cache, scan until the end of the line (or until marker is found)
while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1) {
matchEnd = matchStart + 1;
2023-07-04 12:15:14 -07:00
@@ -6485,7 +6424,7 @@
}
if (!silent) {
token = state.push("html_inline", "", 0);
- token.content = state.src.slice(pos, pos + match[0].length);
+ token.content = match[0];
if (isLinkOpen(token.content)) state.linkLevel++;
if (isLinkClose(token.content)) state.linkLevel--;
}
2023-07-04 12:15:14 -07:00
@@ -6533,7 +6472,7 @@
return false;
};
// For each opening emphasis-like marker find a matching closing one
- function processDelimiters(state, delimiters) {
+ function processDelimiters(delimiters) {
var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx, isOddMatch, lastJump, openersBottom = {}, max = delimiters.length;
if (!max) return;
// headerIdx is the first delimiter of the current (where closer is) delimiter run
2023-07-04 12:15:14 -07:00
@@ -6617,10 +6556,10 @@
}
var balance_pairs = function link_pairs(state) {
var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
- processDelimiters(state, state.delimiters);
+ processDelimiters(state.delimiters);
for (curr = 0; curr < max; curr++) {
if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
- processDelimiters(state, tokens_meta[curr].delimiters);
+ processDelimiters(tokens_meta[curr].delimiters);
}
}
};
2023-07-04 12:15:14 -07:00
@@ -6818,6 +6757,9 @@
ok = rules[i](state, true);
state.level--;
if (ok) {
+ if (pos >= state.pos) {
+ throw new Error("inline rule didn't increment state.pos");
+ }
break;
}
}
2023-07-04 12:15:14 -07:00
@@ -6839,17 +6781,21 @@
// Generate tokens for input range
2023-07-04 12:15:14 -07:00
ParserInline.prototype.tokenize = function(state) {
- var ok, i, rules = this.ruler.getRules(""), len = rules.length, end = state.posMax, maxNesting = state.md.options.maxNesting;
+ var ok, i, prevPos, rules = this.ruler.getRules(""), len = rules.length, end = state.posMax, maxNesting = state.md.options.maxNesting;
while (state.pos < end) {
// Try all possible rules.
// On success, rule should:
// - update `state.pos`
// - update `state.tokens`
// - return true
+ prevPos = state.pos;
if (state.level < maxNesting) {
for (i = 0; i < len; i++) {
ok = rules[i](state, false);
if (ok) {
+ if (prevPos >= state.pos) {
+ throw new Error("inline rule didn't increment state.pos");
+ }
break;
}
}
2023-07-04 12:15:14 -07:00
@@ -7490,386 +7436,6 @@
* Override to modify basic RegExp-s.
**/ LinkifyIt.prototype.onCompile = function onCompile() {};
var linkifyIt = LinkifyIt;
- /*! https://mths.be/punycode v1.4.1 by @mathias */
- /** Highest positive signed 32-bit float value */ var maxInt = 2147483647;
- // aka. 0x7FFFFFFF or 2^31-1
- /** Bootstring parameters */ var base = 36;
- var tMin = 1;
- var tMax = 26;
- var skew = 38;
- var damp = 700;
- var initialBias = 72;
- var initialN = 128;
- // 0x80
- var delimiter = "-";
- // '\x2D'
- /** Regular expressions */ var regexPunycode = /^xn--/;
- var regexNonASCII = /[^\x20-\x7E]/;
- // unprintable ASCII chars + non-ASCII chars
- var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
- // RFC 3490 separators
- /** Error messages */ var errors = {
- overflow: "Overflow: input needs wider integers to process",
- "not-basic": "Illegal input >= 0x80 (not a basic code point)",
- "invalid-input": "Invalid input"
- };
- /** Convenience shortcuts */ var baseMinusTMin = base - tMin;
- var floor = Math.floor;
- var stringFromCharCode = String.fromCharCode;
- /*--------------------------------------------------------------------------*/
- /**
- * A generic error utility function.
- * @private
- * @param {String} type The error type.
- * @returns {Error} Throws a `RangeError` with the applicable error message.
- */ function error(type) {
- throw new RangeError(errors[type]);
- }
- /**
- * A generic `Array#map` utility function.
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} callback The function that gets called for every array
- * item.
- * @returns {Array} A new array of values returned by the callback function.
- */ function map(array, fn) {
- var length = array.length;
- var result = [];
- while (length--) {
- result[length] = fn(array[length]);
- }
- return result;
- }
- /**
- * A simple `Array#map`-like wrapper to work with domain name strings or email
- * addresses.
- * @private
- * @param {String} domain The domain name or email address.
- * @param {Function} callback The function that gets called for every
- * character.
- * @returns {Array} A new string of characters returned by the callback
- * function.
- */ function mapDomain(string, fn) {
- var parts = string.split("@");
- var result = "";
- if (parts.length > 1) {
- // In email addresses, only the domain name should be punycoded. Leave
- // the local part (i.e. everything up to `@`) intact.
- result = parts[0] + "@";
- string = parts[1];
- }
- // Avoid `split(regex)` for IE8 compatibility. See #17.
- string = string.replace(regexSeparators, ".");
- var labels = string.split(".");
- var encoded = map(labels, fn).join(".");
- return result + encoded;
- }
- /**
- * Creates an array containing the numeric code points of each Unicode
- * character in the string. While JavaScript uses UCS-2 internally,
- * this function will convert a pair of surrogate halves (each of which
- * UCS-2 exposes as separate characters) into a single code point,
- * matching UTF-16.
- * @see `punycode.ucs2.encode`
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
- * @memberOf punycode.ucs2
- * @name decode
- * @param {String} string The Unicode input string (UCS-2).
- * @returns {Array} The new array of code points.
- */ function ucs2decode(string) {
- var output = [], counter = 0, length = string.length, value, extra;
- while (counter < length) {
- value = string.charCodeAt(counter++);
- if (value >= 55296 && value <= 56319 && counter < length) {
- // high surrogate, and there is a next character
- extra = string.charCodeAt(counter++);
- if ((extra & 64512) == 56320) {
- // low surrogate
- output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
- } else {
- // unmatched surrogate; only append this code unit, in case the next
- // code unit is the high surrogate of a surrogate pair
- output.push(value);
- counter--;
- }
- } else {
- output.push(value);
- }
- }
- return output;
- }
- /**
- * Creates a string based on an array of numeric code points.
- * @see `punycode.ucs2.decode`
- * @memberOf punycode.ucs2
- * @name encode
- * @param {Array} codePoints The array of numeric code points.
- * @returns {String} The new Unicode string (UCS-2).
- */ function ucs2encode(array) {
- return map(array, (function(value) {
- var output = "";
- if (value > 65535) {
- value -= 65536;
- output += stringFromCharCode(value >>> 10 & 1023 | 55296);
- value = 56320 | value & 1023;
- }
- output += stringFromCharCode(value);
- return output;
- })).join("");
- }
- /**
- * Converts a basic code point into a digit/integer.
- * @see `digitToBasic()`
- * @private
- * @param {Number} codePoint The basic numeric code point value.
- * @returns {Number} The numeric value of a basic code point (for use in
- * representing integers) in the range `0` to `base - 1`, or `base` if
- * the code point does not represent a value.
- */ function basicToDigit(codePoint) {
- if (codePoint - 48 < 10) {
- return codePoint - 22;
- }
- if (codePoint - 65 < 26) {
- return codePoint - 65;
- }
- if (codePoint - 97 < 26) {
- return codePoint - 97;
- }
- return base;
- }
- /**
- * Converts a digit/integer into a basic code point.
- * @see `basicToDigit()`
- * @private
- * @param {Number} digit The numeric value of a basic code point.
- * @returns {Number} The basic code point whose value (when used for
- * representing integers) is `digit`, which needs to be in the range
- * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
- * used; else, the lowercase form is used. The behavior is undefined
- * if `flag` is non-zero and `digit` has no uppercase form.
- */ function digitToBasic(digit, flag) {
- // 0..25 map to ASCII a..z or A..Z
- // 26..35 map to ASCII 0..9
- return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
- }
- /**
- * Bias adaptation function as per section 3.4 of RFC 3492.
- * https://tools.ietf.org/html/rfc3492#section-3.4
- * @private
- */ function adapt(delta, numPoints, firstTime) {
- var k = 0;
- delta = firstTime ? floor(delta / damp) : delta >> 1;
- delta += floor(delta / numPoints);
- for (;delta > baseMinusTMin * tMax >> 1; k += base) {
- delta = floor(delta / baseMinusTMin);
- }
- return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
- }
- /**
- * Converts a Punycode string of ASCII-only symbols to a string of Unicode
- * symbols.
- * @memberOf punycode
- * @param {String} input The Punycode string of ASCII-only symbols.
- * @returns {String} The resulting string of Unicode symbols.
- */ function decode(input) {
- // Don't use UCS-2
- var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t,
- /** Cached calculation results */
- baseMinusT;
- // Handle the basic code points: let `basic` be the number of input code
- // points before the last delimiter, or `0` if there is none, then copy
- // the first basic code points to the output.
- basic = input.lastIndexOf(delimiter);
- if (basic < 0) {
- basic = 0;
- }
- for (j = 0; j < basic; ++j) {
- // if it's not a basic code point
- if (input.charCodeAt(j) >= 128) {
- error("not-basic");
- }
- output.push(input.charCodeAt(j));
- }
- // Main decoding loop: start just after the last delimiter if any basic code
- // points were copied; start at the beginning otherwise.
- for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
- // `index` is the index of the next character to be consumed.
- // Decode a generalized variable-length integer into `delta`,
- // which gets added to `i`. The overflow checking is easier
- // if we increase `i` as we go, then subtract off its starting
- // value at the end to obtain `delta`.
- for (oldi = i, w = 1, k = base; ;k += base) {
- if (index >= inputLength) {
- error("invalid-input");
- }
- digit = basicToDigit(input.charCodeAt(index++));
- if (digit >= base || digit > floor((maxInt - i) / w)) {
- error("overflow");
- }
- i += digit * w;
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
- if (digit < t) {
- break;
- }
- baseMinusT = base - t;
- if (w > floor(maxInt / baseMinusT)) {
- error("overflow");
- }
- w *= baseMinusT;
- }
- out = output.length + 1;
- bias = adapt(i - oldi, out, oldi == 0);
- // `i` was supposed to wrap around from `out` to `0`,
- // incrementing `n` each time, so we'll fix that now:
- if (floor(i / out) > maxInt - n) {
- error("overflow");
- }
- n += floor(i / out);
- i %= out;
- // Insert `n` at position `i` of the output
- output.splice(i++, 0, n);
- }
- return ucs2encode(output);
- }
- /**
- * Converts a string of Unicode symbols (e.g. a domain name label) to a
- * Punycode string of ASCII-only symbols.
- * @memberOf punycode
- * @param {String} input The string of Unicode symbols.
- * @returns {String} The resulting Punycode string of ASCII-only symbols.
- */ function encode(input) {
- var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [],
- /** `inputLength` will hold the number of code points in `input`. */
- inputLength,
- /** Cached calculation results */
- handledCPCountPlusOne, baseMinusT, qMinusT;
- // Convert the input in UCS-2 to Unicode
- input = ucs2decode(input);
- // Cache the length
- inputLength = input.length;
- // Initialize the state
- n = initialN;
- delta = 0;
- bias = initialBias;
- // Handle the basic code points
- for (j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue < 128) {
- output.push(stringFromCharCode(currentValue));
- }
- }
- handledCPCount = basicLength = output.length;
- // `handledCPCount` is the number of code points that have been handled;
- // `basicLength` is the number of basic code points.
- // Finish the basic string - if it is not empty - with a delimiter
- if (basicLength) {
- output.push(delimiter);
- }
- // Main encoding loop:
- while (handledCPCount < inputLength) {
- // All non-basic code points < n have been handled already. Find the next
- // larger one:
- for (m = maxInt, j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue >= n && currentValue < m) {
- m = currentValue;
- }
- }
- // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
- // but guard against overflow
- handledCPCountPlusOne = handledCPCount + 1;
- if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
- error("overflow");
- }
- delta += (m - n) * handledCPCountPlusOne;
- n = m;
- for (j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue < n && ++delta > maxInt) {
- error("overflow");
- }
- if (currentValue == n) {
- // Represent delta as a generalized variable-length integer
- for (q = delta, k = base; ;k += base) {
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
- if (q < t) {
- break;
- }
- qMinusT = q - t;
- baseMinusT = base - t;
- output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
- q = floor(qMinusT / baseMinusT);
- }
- output.push(stringFromCharCode(digitToBasic(q, 0)));
- bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
- delta = 0;
- ++handledCPCount;
- }
- }
- ++delta;
- ++n;
- }
- return output.join("");
- }
- /**
- * Converts a Punycode string representing a domain name or an email address
- * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
- * it doesn't matter if you call it on a string that has already been
- * converted to Unicode.
- * @memberOf punycode
- * @param {String} input The Punycoded domain name or email address to
- * convert to Unicode.
- * @returns {String} The Unicode representation of the given Punycode
- * string.
- */ function toUnicode(input) {
- return mapDomain(input, (function(string) {
- return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
- }));
- }
- /**
- * Converts a Unicode string representing a domain name or an email address to
- * Punycode. Only the non-ASCII parts of the domain name will be converted,
- * i.e. it doesn't matter if you call it with a domain that's already in
- * ASCII.
- * @memberOf punycode
- * @param {String} input The domain name or email address to convert, as a
- * Unicode string.
- * @returns {String} The Punycode representation of the given domain name or
- * email address.
- */ function toASCII(input) {
- return mapDomain(input, (function(string) {
- return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
- }));
- }
- var version = "1.4.1";
- /**
- * An object of methods to convert from JavaScript's internal character
- * representation (UCS-2) to Unicode code points, and back.
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
- * @memberOf punycode
- * @type Object
- */ var ucs2 = {
- decode: ucs2decode,
- encode: ucs2encode
- };
- var punycode$1 = {
- version: version,
- ucs2: ucs2,
- toASCII: toASCII,
- toUnicode: toUnicode,
- encode: encode,
- decode: decode
- };
- var punycode$2 = Object.freeze({
- __proto__: null,
- decode: decode,
- encode: encode,
- toUnicode: toUnicode,
- toASCII: toASCII,
- version: version,
- ucs2: ucs2,
- default: punycode$1
- });
// markdown-it default options
var _default = {
options: {
@@ -7986,7 +7552,6 @@
}
}
};
- var punycode = getAugmentedNamespace(punycode$2);
var config = {
default: _default,
zero: zero,
@@ -8018,7 +7583,8 @@
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
- parsed.hostname = punycode.toASCII(parsed.hostname);
+ var parsedUrl = new URL(parsed.href);
+ parsed.hostname = parsedUrl.hostname;
} catch (er) {}
}
}
2023-07-04 12:15:14 -07:00
@@ -8026,17 +7592,6 @@
}
function normalizeLinkText(url) {
var parsed = mdurl.parse(url, true);
- if (parsed.hostname) {
- // Encode hostnames in urls like:
- // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
- // We don't encode unknown schemas, because it's likely that we encode
- // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
- if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
- try {
- parsed.hostname = punycode.toUnicode(parsed.hostname);
- } catch (er) {}
- }
- }
// add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720
return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + "%");
}
diff --git a/dist/markdown-it.min.js b/dist/markdown-it.min.js
index 34201f495ddcbec648502eb353df580513861c22..74502dbb304d5a070e8696dd56e36cc9e905ab6f 100644
--- a/dist/markdown-it.min.js
+++ b/dist/markdown-it.min.js
@@ -1,3 +1,2 @@
/*! markdown-it 13.0.1 https://github.com/markdown-it/markdown-it @license MIT */
-!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).markdownit=r()}(this,(function(){"use strict";function e(e){if(e.__esModule)return e;var r=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r={Aacute:"\xc1",aacute:"\xe1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223e",acd:"\u223f",acE:"\u223e\u0333",Acirc:"\xc2",acirc:"\xe2",acute:"\xb4",Acy:"\u0410",acy:"\u0430",AElig:"\xc6",aelig:"\xe6",af:"\u2061",Afr:"\ud835\udd04",afr:"\ud835\udd1e",Agrave:"\xc0",agrave:"\xe0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03b1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2a3f",amp:"&",AMP:"&",andand:"\u2a55",And:"\u2a53",and:"\u2227",andd:"\u2a5c",andslope:"\u2a58",andv:"\u2a5a",ang:"\u2220",ange:"\u29a4",angle:"\u2220",angmsdaa:"\u29a8",angmsdab:"\u29a9",angmsdac:"\u29aa",angmsdad:"\u29ab",angmsdae:"\u29ac",angmsdaf:"\u29ad",angmsdag:"\u29ae",angmsdah:"\u29af",angmsd:"\u2221",angrt:"\u221f",angrtvb:"\u22be",angrtvbd:"\u299d",angsph:"\u2222",angst:"\xc5",angzarr:"\u237c",Aogon:"\u0104",aogon:"\u0105",Aopf:"\ud835\udd38",aopf:"\ud835\udd52",apacir:"\u2a6f",ap:"\u2248",apE:"\u2a70",ape:"\u224a",apid:"\u224b",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224a",Aring:"\xc5",aring:"\xe5",Ascr:"\ud835\udc9c",ascr:"\ud835\udcb6",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224d",Atilde:"\xc3",atilde:"\xe3",Auml:"\xc4",auml:"\xe4",awconint:"\u2233",awint:"\u2a11",backcong:"\u224c",backepsilon:"\u03f6",backprime:"\u2035",backsim:"\u223d",backsimeq:"\u22cd",Backslash:"\u2216",Barv:"\u2ae7",barvee:"\u22bd",barwed:"\u2305",Barwed:"\u2306",barwedge:"\u2305",bbrk:"\u23b5",bbrktbrk:"\u23b6",bcong:"\u224c",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201e",becaus:"\u2235",because:"\u2235",Because:"\u2235",bemptyv:"\u29b0",bepsi:"\u03f6",bernou:"\u212c",Bernoullis:"\u212c",Beta:"\u0392",beta:"\u03b2",beth:"\u2136",between:"\u226c",Bfr:"\ud835\udd05",bfr:"\ud835\udd1f",bigcap:"\u22c2",bigcirc:"\u25ef",bigcup:"\u22c3",bigodot:"\u2a00",bigoplus:"\u2a01",bigotimes:"\u2a02",bigsqcup:"\u2a06",bigstar:"\u2605",bigtriangledown:"\u25bd",bigtriangleup:"\u25b3",biguplus:"\u2a04",bigvee:"\u22c1",bigwedge:"\u22c0",bkarow:"\u290d",blacklozenge:"\u29eb",blacksquare:"\u25aa",blacktriangle:"\u25b4",blacktriangledown:"\u25be",blacktriangleleft:"\u25c2",blacktriangleright:"\u25b8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20e5",bnequiv:"\u2261\u20e5",bNot:"\u2aed",bnot:"\u2310",Bopf:"\ud835\udd39",bopf:"\ud835\udd53",bot:"\u22a5",bottom:"\u22a5",bowtie:"\u22c8",boxbox:"\u29c9",boxdl:"\u2510",boxdL:"\u2555",boxDl:"\u2556",boxDL:"\u2557",boxdr:"\u250c",boxdR:"\u2552",boxDr:"\u2553",boxDR:"\u2554",boxh:"\u2500",boxH:"\u2550",boxhd:"\u252c",boxHd:"\u2564",boxhD:"\u2565",boxHD:"\u2566",boxhu:"\u2534",boxHu:"\u2567",boxhU:"\u2568",boxHU:"\u2569",boxminus:"\u229f",boxplus:"\u229e",boxtimes:"\u22a0",boxul:"\u2518",boxuL:"\u255b",boxUl:"\u255c",boxUL:"\u255d",boxur:"\u2514",boxuR:"\u2558",boxUr:"\u2559",boxUR:"\u255a",boxv:"\u2502",boxV:"\u2551",boxvh:"\u253c",boxvH:"\u256a",boxVh:"\u256b",boxVH:"\u256c",boxvl:"\u2524",boxvL:"\u2561",boxVl:"\u2562",boxVL:"\u2563",boxvr:"\u251c",boxvR:"\u255e",boxVr:"\u255f",boxVR:"\u2560",bprime:"\u2035",breve:"\u02d8",Breve:"\u02d8",brvbar:"\xa6",bscr:"\ud835\udcb7",Bscr:"\u212c",bsemi:"\u204f",bsim:"\u223d",bsime:"\u22cd",bsolb:"\u29c5",bsol:"\\",bsolhsub:"\u27c8",bull:"\u2022",bullet:"\u2022",bump:"\u224e",bumpE:"\u2aae",bumpe:"\u224f",Bumpeq:"\u224e",bumpeq:"\u224f",Cacute:"\u0106",cacute:"\u0107",capand:"\u2a44",capbrcup:"\u2a49",capcap:"\u2a4b",cap:"\u2229",Cap:"\u22d2",capcup:"\u2a47",capdot:"\u2a40",CapitalDifferentialD:"\u2145",caps:"\u2229\ufe00",caret:"\u2041",caron:"\u02c7",Cayleys:"\u212d",ccaps:"\u2a4d",Ccaron:"\u010c",ccaron:"\u010d",Ccedil:"\xc7",ccedil:"\xe7",Ccirc:"
-/*! https://mths.be/punycode v1.4.1 by @mathias */function Lr(e){throw new RangeError(qr[e])}function zr(e,r){for(var t=e.length,n=[];t--;)n[t]=r(e[t]);return n}function Tr(e,r){var t=e.split("@"),n="";return t.length>1&&(n=t[0]+"@",e=t[1]),n+zr((e=e.replace(Er,".")).split("."),r).join(".")}function Ir(e){for(var r,t,n=[],s=0,o=e.length;s<o;)(r=e.charCodeAt(s++))>=55296&&r<=56319&&s<o?56320==(64512&(t=e.charCodeAt(s++)))?n.push(((1023&r)<<10)+(1023&t)+65536):(n.push(r),s--):n.push(r);return n}function Mr(e){return zr(e,(function(e){var r="";return e>65535&&(r+=Fr((e-=65536)>>>10&1023|55296),e=56320|1023&e),r+=Fr(e)})).join("")}function Rr(e,r){return e+22+75*(e<26)-((0!=r)<<5)}function Br(e,r,t){var n=0;for(e=t?Sr(e/700):e>>1,e+=Sr(e/r);e>455;n+=xr)e=Sr(e/35);return Sr(n+36*e/(e+38))}function Nr(e){var r,t,n,s,o,i,a,c,l,u,p,h=[],f=e.length,d=0,m=128,g=72;for((t=e.lastIndexOf("-"))<0&&(t=0),n=0;n<t;++n)e.charCodeAt(n)>=128&&Lr("not-basic"),h.push(e.charCodeAt(n));for(s=t>0?t+1:0;s<f;){for(o=d,i=1,a=xr;s>=f&&Lr("invalid-input"),((c=(p=e.charCodeAt(s++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:xr)>=xr||c>Sr((Ar-d)/i))&&Lr("overflow"),d+=c*i,!(c<(l=a<=g?1:a>=g+26?26:a-g));a+=xr)i>Sr(Ar/(u=xr-l))&&Lr("overflow"),i*=u;g=Br(d-o,r=h.length+1,0==o),Sr(d/r)>Ar-m&&Lr("overflow"),m+=Sr(d/r),d%=r,h.splice(d++,0,m)}return Mr(h)}function Or(e){var r,t,n,s,o,i,a,c,l,u,p,h,f,d,m,g=[];for(h=(e=Ir(e)).length,r=128,t=0,o=72,i=0;i<h;++i)(p=e[i])<128&&g.push(Fr(p));for(n=s=g.length,s&&g.push("-");n<h;){for(a=Ar,i=0;i<h;++i)(p=e[i])>=r&&p<a&&(a=p);for(a-r>Sr((Ar-t)/(f=n+1))&&Lr("overflow"),t+=(a-r)*f,r=a,i=0;i<h;++i)if((p=e[i])<r&&++t>Ar&&Lr("overflow"),p==r){for(c=t,l=xr;!(c<(u=l<=o?1:l>=o+26?26:l-o));l+=xr)m=c-u,d=xr-u,g.push(Fr(Rr(u+m%d,0))),c=Sr(m/d);g.push(Fr(Rr(c,0))),o=Br(t,f,n==s),t=0,++n}++t,++r}return g.join("")}function Pr(e){return Tr(e,(function(e){return Dr.test(e)?Nr(e.slice(4).toLowerCase()):e}))}function jr(e){return Tr(e,(function(e){return wr.test(e)?"xn--"+Or(e):e}))}var Ur="1.4.1",Vr={decode:Ir,encode:Mr},Zr={version:Ur,ucs2:Vr,toASCII:jr,toUnicode:Pr,encode:Or,decode:Nr},$r=e(Object.freeze({__proto__:null,decode:Nr,encode:Or,toUnicode:Pr,toASCII:jr,version:Ur,ucs2:Vr,default:Zr})),Gr={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201c\u201d\u2018\u2019",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201c\u201d\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201c\u201d\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}},Hr=/^(vbscript|javascript|file|data):/,Jr=/^data:image\/(gif|png|jpeg|webp);/;function Wr(e){var r=e.trim().toLowerCase();return!Hr.test(r)||!!Jr.test(r)}var Yr=["http:","https:","mailto:"];function Kr(e){var r=C.parse(e,!0);if(r.hostname&&(!r.protocol||Yr.indexOf(r.protocol)>=0))try{r.hostname=$r.toASCII(r.hostname)}catch(e){}return C.encode(C.format(r))}function Qr(e){var r=C.parse(e,!0);if(r.hostname&&(!r.protocol||Yr.indexOf(r.protocol)>=0))try{r.hostname=$r.toUnicode(r.hostname)}catch(e){}return C.decode(C.format(r),C.decode.defaultChars+"%")}function Xr(e,r){if(!(this instanceof Xr))return new Xr(e,r);r||w.isString(e)||(r=e||{},e="default"),this.inline=new ur,this.block=new ze,this.core=new ue,this.renderer=new B,this.linkify=new yr,this.validateLink=Wr,this.normalizeLink=Kr,this.normalizeLinkText=Qr,this.utils=w,t
2023-07-04 12:15:14 -07:00
+!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).markdownit=r()}(this,(function(){"use strict";var e={Aacute:"\xc1",aacute:"\xe1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223e",acd:"\u223f",acE:"\u223e\u0333",Acirc:"\xc2",acirc:"\xe2",acute:"\xb4",Acy:"\u0410",acy:"\u0430",AElig:"\xc6",aelig:"\xe6",af:"\u2061",Afr:"\ud835\udd04",afr:"\ud835\udd1e",Agrave:"\xc0",agrave:"\xe0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03b1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2a3f",amp:"&",AMP:"&",andand:"\u2a55",And:"\u2a53",and:"\u2227",andd:"\u2a5c",andslope:"\u2a58",andv:"\u2a5a",ang:"\u2220",ange:"\u29a4",angle:"\u2220",angmsdaa:"\u29a8",angmsdab:"\u29a9",angmsdac:"\u29aa",angmsdad:"\u29ab",angmsdae:"\u29ac",angmsdaf:"\u29ad",angmsdag:"\u29ae",angmsdah:"\u29af",angmsd:"\u2221",angrt:"\u221f",angrtvb:"\u22be",angrtvbd:"\u299d",angsph:"\u2222",angst:"\xc5",angzarr:"\u237c",Aogon:"\u0104",aogon:"\u0105",Aopf:"\ud835\udd38",aopf:"\ud835\udd52",apacir:"\u2a6f",ap:"\u2248",apE:"\u2a70",ape:"\u224a",apid:"\u224b",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224a",Aring:"\xc5",aring:"\xe5",Ascr:"\ud835\udc9c",ascr:"\ud835\udcb6",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224d",Atilde:"\xc3",atilde:"\xe3",Auml:"\xc4",auml:"\xe4",awconint:"\u2233",awint:"\u2a11",backcong:"\u224c",backepsilon:"\u03f6",backprime:"\u2035",backsim:"\u223d",backsimeq:"\u22cd",Backslash:"\u2216",Barv:"\u2ae7",barvee:"\u22bd",barwed:"\u2305",Barwed:"\u2306",barwedge:"\u2305",bbrk:"\u23b5",bbrktbrk:"\u23b6",bcong:"\u224c",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201e",becaus:"\u2235",because:"\u2235",Because:"\u2235",bemptyv:"\u29b0",bepsi:"\u03f6",bernou:"\u212c",Bernoullis:"\u212c",Beta:"\u0392",beta:"\u03b2",beth:"\u2136",between:"\u226c",Bfr:"\ud835\udd05",bfr:"\ud835\udd1f",bigcap:"\u22c2",bigcirc:"\u25ef",bigcup:"\u22c3",bigodot:"\u2a00",bigoplus:"\u2a01",bigotimes:"\u2a02",bigsqcup:"\u2a06",bigstar:"\u2605",bigtriangledown:"\u25bd",bigtriangleup:"\u25b3",biguplus:"\u2a04",bigvee:"\u22c1",bigwedge:"\u22c0",bkarow:"\u290d",blacklozenge:"\u29eb",blacksquare:"\u25aa",blacktriangle:"\u25b4",blacktriangledown:"\u25be",blacktriangleleft:"\u25c2",blacktriangleright:"\u25b8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20e5",bnequiv:"\u2261\u20e5",bNot:"\u2aed",bnot:"\u2310",Bopf:"\ud835\udd39",bopf:"\ud835\udd53",bot:"\u22a5",bottom:"\u22a5",bowtie:"\u22c8",boxbox:"\u29c9",boxdl:"\u2510",boxdL:"\u2555",boxDl:"\u2556",boxDL:"\u2557",boxdr:"\u250c",boxdR:"\u2552",boxDr:"\u2553",boxDR:"\u2554",boxh:"\u2500",boxH:"\u2550",boxhd:"\u252c",boxHd:"\u2564",boxhD:"\u2565",boxHD:"\u2566",boxhu:"\u2534",boxHu:"\u2567",boxhU:"\u2568",boxHU:"\u2569",boxminus:"\u229f",boxplus:"\u229e",boxtimes:"\u22a0",boxul:"\u2518",boxuL:"\u255b",boxUl:"\u255c",boxUL:"\u255d",boxur:"\u2514",boxuR:"\u2558",boxUr:"\u2559",boxUR:"\u255a",boxv:"\u2502",boxV:"\u2551",boxvh:"\u253c",boxvH:"\u256a",boxVh:"\u256b",boxVH:"\u256c",boxvl:"\u2524",boxvL:"\u2561",boxVl:"\u2562",boxVL:"\u2563",boxvr:"\u251c",boxvR:"\u255e",boxVr:"\u255f",boxVR:"\u2560",bprime:"\u2035",breve:"\u02d8",Breve:"\u02d8",brvbar:"\xa6",bscr:"\ud835\udcb7",Bscr:"\u212c",bsemi:"\u204f",bsim:"\u223d",bsime:"\u22cd",bsolb:"\u29c5",bsol:"\\",bsolhsub:"\u27c8",bull:"\u2022",bullet:"\u2022",bump:"\u224e",bumpE:"\u2aae",bumpe:"\u224f",Bumpeq:"\u224e",bumpeq:"\u224f",Cacute:"\u0106",cacute:"\u0107",capand:"\u2a44",capbrcup:"\u2a49",capcap:"\u2a4b",cap:"\u2229",Cap:"\u22d2",capcup:"\u2a47",capdot:"\u2a40",CapitalDifferentialD:"\u2145",caps:"\u2229\ufe00",caret:"\u2041",caron:"\u02c7",Cayleys:"\u212d",ccaps:"\u2a4d",Ccaron:"\u010c",ccaron:"\u010d",Ccedil:"\xc7",ccedil:"\xe7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2a4c",ccupssm:"\u2a50",Cdot:"\u010a",cdot:"\u010b",cedil:"\xb8",Cedilla:"\xb8",cemptyv:"\u29b2",cent:"\xa2",centerdot:"\xb7",CenterDot:"\xb7",cfr:"\ud835\udd20",Cfr:"\u212d",CHcy:"\u0427",chcy:"\u0447",check:"\u2713"
diff --git a/lib/index.js b/lib/index.js
index afec8d8defc975811eaed0b5af0a8d571771c6b1..f76110596f892a12910904bcad8b6c7ddd94543c 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -11,7 +11,6 @@ var ParserBlock = require('./parser_block');
var ParserInline = require('./parser_inline');
var LinkifyIt = require('linkify-it');
var mdurl = require('mdurl');
-var punycode = require('punycode');
var config = {
@@ -56,7 +55,8 @@ function normalizeLink(url) {
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
- parsed.hostname = punycode.toASCII(parsed.hostname);
+ var parsedUrl = new URL(parsed.href);
+ parsed.hostname = parsedUrl.hostname;
} catch (er) { /**/ }
}
}
2023-07-04 12:15:14 -07:00
@@ -66,21 +66,7 @@ function normalizeLink(url) {
function normalizeLinkText(url) {
var parsed = mdurl.parse(url, true);
-
- if (parsed.hostname) {
- // Encode hostnames in urls like:
- // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
- //
- // We don't encode unknown schemas, because it's likely that we encode
- // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
- //
- if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
- try {
- parsed.hostname = punycode.toUnicode(parsed.hostname);
- } catch (er) { /**/ }
- }
- }
-
+
// add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720
return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + '%');
}