@lvce-editor/markdown-worker 1.7.0 → 1.9.0
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/dist/markdownWorkerMain.js +560 -541
- package/package.json +1 -1
|
@@ -620,7 +620,8 @@ const splitLines = lines => {
|
|
|
620
620
|
return lines.split(NewLine);
|
|
621
621
|
};
|
|
622
622
|
const getCurrentStack = () => {
|
|
623
|
-
const
|
|
623
|
+
const stackLinesToSkip = 3;
|
|
624
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
624
625
|
return currentStack;
|
|
625
626
|
};
|
|
626
627
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
@@ -891,6 +892,12 @@ const invokeAndTransfer = (ipc, method, ...params) => {
|
|
|
891
892
|
return invokeHelper(ipc, method, params, true);
|
|
892
893
|
};
|
|
893
894
|
|
|
895
|
+
class CommandNotFoundError extends Error {
|
|
896
|
+
constructor(command) {
|
|
897
|
+
super(`Command not found ${command}`);
|
|
898
|
+
this.name = 'CommandNotFoundError';
|
|
899
|
+
}
|
|
900
|
+
}
|
|
894
901
|
const commands = Object.create(null);
|
|
895
902
|
const register = commandMap => {
|
|
896
903
|
Object.assign(commands, commandMap);
|
|
@@ -901,7 +908,7 @@ const getCommand = key => {
|
|
|
901
908
|
const execute = (command, ...args) => {
|
|
902
909
|
const fn = getCommand(command);
|
|
903
910
|
if (!fn) {
|
|
904
|
-
throw new
|
|
911
|
+
throw new CommandNotFoundError(command);
|
|
905
912
|
}
|
|
906
913
|
return fn(...args);
|
|
907
914
|
};
|
|
@@ -1022,7 +1029,7 @@ const Li$1 = 48;
|
|
|
1022
1029
|
const Ol$1 = 49;
|
|
1023
1030
|
const P$2 = 50;
|
|
1024
1031
|
const Pre$1 = 51;
|
|
1025
|
-
const A$
|
|
1032
|
+
const A$1 = 53;
|
|
1026
1033
|
const Abbr$1 = 54;
|
|
1027
1034
|
const Br$1 = 55;
|
|
1028
1035
|
const Cite$1 = 56;
|
|
@@ -1031,7 +1038,7 @@ const Time$1 = 58;
|
|
|
1031
1038
|
const Tfoot$1 = 59;
|
|
1032
1039
|
const VirtualDomElements = {
|
|
1033
1040
|
__proto__: null,
|
|
1034
|
-
A: A$
|
|
1041
|
+
A: A$1,
|
|
1035
1042
|
Abbr: Abbr$1,
|
|
1036
1043
|
Article: Article$1,
|
|
1037
1044
|
Aside: Aside$1,
|
|
@@ -1115,7 +1122,7 @@ const Li = 'li';
|
|
|
1115
1122
|
const Ol = 'ol';
|
|
1116
1123
|
const P$1 = 'p';
|
|
1117
1124
|
const Pre = 'pre';
|
|
1118
|
-
const A
|
|
1125
|
+
const A = 'a';
|
|
1119
1126
|
const Abbr = 'abbr';
|
|
1120
1127
|
const Br = 'br';
|
|
1121
1128
|
const Cite = 'cite';
|
|
@@ -1169,7 +1176,7 @@ const getVirtualDomTag = text => {
|
|
|
1169
1176
|
return VirtualDomElements.P;
|
|
1170
1177
|
case Pre:
|
|
1171
1178
|
return VirtualDomElements.Pre;
|
|
1172
|
-
case A
|
|
1179
|
+
case A:
|
|
1173
1180
|
return VirtualDomElements.A;
|
|
1174
1181
|
case Abbr:
|
|
1175
1182
|
return VirtualDomElements.Abbr;
|
|
@@ -1553,7 +1560,7 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
1553
1560
|
};
|
|
1554
1561
|
|
|
1555
1562
|
/**
|
|
1556
|
-
* marked v16.
|
|
1563
|
+
* marked v16.2.0 - a markdown parser
|
|
1557
1564
|
* Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
|
|
1558
1565
|
* https://github.com/markedjs/marked
|
|
1559
1566
|
*/
|
|
@@ -1563,7 +1570,7 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
1563
1570
|
* The code in this file is generated from files in ./src/
|
|
1564
1571
|
*/
|
|
1565
1572
|
|
|
1566
|
-
function
|
|
1573
|
+
function L() {
|
|
1567
1574
|
return {
|
|
1568
1575
|
async: false,
|
|
1569
1576
|
breaks: false,
|
|
@@ -1577,19 +1584,19 @@ function M() {
|
|
|
1577
1584
|
walkTokens: null
|
|
1578
1585
|
};
|
|
1579
1586
|
}
|
|
1580
|
-
var
|
|
1581
|
-
function H(
|
|
1582
|
-
|
|
1587
|
+
var O = L();
|
|
1588
|
+
function H(l) {
|
|
1589
|
+
O = l;
|
|
1583
1590
|
}
|
|
1584
|
-
var
|
|
1591
|
+
var E = {
|
|
1585
1592
|
exec: () => null
|
|
1586
1593
|
};
|
|
1587
|
-
function h(
|
|
1588
|
-
let t = typeof
|
|
1594
|
+
function h(l, e = "") {
|
|
1595
|
+
let t = typeof l == "string" ? l : l.source,
|
|
1589
1596
|
n = {
|
|
1590
|
-
replace: (
|
|
1591
|
-
let
|
|
1592
|
-
return
|
|
1597
|
+
replace: (r, i) => {
|
|
1598
|
+
let s = typeof i == "string" ? i : i.source;
|
|
1599
|
+
return s = s.replace(m.caret, "$1"), t = t.replace(r, s), n;
|
|
1593
1600
|
},
|
|
1594
1601
|
getRegex: () => new RegExp(t, e)
|
|
1595
1602
|
};
|
|
@@ -1646,83 +1653,83 @@ var m = {
|
|
|
1646
1653
|
spaceLine: /^ +$/gm,
|
|
1647
1654
|
notSpaceStart: /^\S*/,
|
|
1648
1655
|
endingNewline: /\n$/,
|
|
1649
|
-
listItemRegex:
|
|
1650
|
-
nextBulletRegex:
|
|
1651
|
-
hrRegex:
|
|
1652
|
-
fencesBeginRegex:
|
|
1653
|
-
headingBeginRegex:
|
|
1654
|
-
htmlBeginRegex:
|
|
1656
|
+
listItemRegex: l => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1657
|
+
nextBulletRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1658
|
+
hrRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
1659
|
+
fencesBeginRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`),
|
|
1660
|
+
headingBeginRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}#`),
|
|
1661
|
+
htmlBeginRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
1655
1662
|
},
|
|
1656
1663
|
xe = /^(?:[ \t]*(?:\n|$))+/,
|
|
1657
1664
|
be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1665
|
+
Re = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1666
|
+
C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
1667
|
+
Oe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1661
1668
|
j = /(?:[*+-]|\d{1,9}[.)])/,
|
|
1662
|
-
|
|
1663
|
-
ie = h(
|
|
1664
|
-
|
|
1669
|
+
se = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1670
|
+
ie = h(se).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(),
|
|
1671
|
+
Te = h(se).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),
|
|
1665
1672
|
F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
1666
|
-
|
|
1673
|
+
we = /^[^\n]+/,
|
|
1667
1674
|
Q = /(?!\s*\])(?:\\.|[^\[\]\\])+/,
|
|
1668
|
-
|
|
1669
|
-
|
|
1675
|
+
ye = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Q).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),
|
|
1676
|
+
Pe = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex(),
|
|
1670
1677
|
v = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",
|
|
1671
1678
|
U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/,
|
|
1672
|
-
|
|
1673
|
-
oe = h(F).replace("hr",
|
|
1674
|
-
|
|
1679
|
+
Se = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),
|
|
1680
|
+
oe = h(F).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(),
|
|
1681
|
+
$e = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(),
|
|
1675
1682
|
K = {
|
|
1676
|
-
blockquote:
|
|
1683
|
+
blockquote: $e,
|
|
1677
1684
|
code: be,
|
|
1678
|
-
def:
|
|
1679
|
-
fences:
|
|
1680
|
-
heading:
|
|
1681
|
-
hr:
|
|
1682
|
-
html:
|
|
1685
|
+
def: ye,
|
|
1686
|
+
fences: Re,
|
|
1687
|
+
heading: Oe,
|
|
1688
|
+
hr: C,
|
|
1689
|
+
html: Se,
|
|
1683
1690
|
lheading: ie,
|
|
1684
|
-
list:
|
|
1691
|
+
list: Pe,
|
|
1685
1692
|
newline: xe,
|
|
1686
1693
|
paragraph: oe,
|
|
1687
|
-
table:
|
|
1688
|
-
text:
|
|
1694
|
+
table: E,
|
|
1695
|
+
text: we
|
|
1689
1696
|
},
|
|
1690
|
-
|
|
1691
|
-
|
|
1697
|
+
re = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex(),
|
|
1698
|
+
_e = {
|
|
1692
1699
|
...K,
|
|
1693
|
-
lheading:
|
|
1694
|
-
table:
|
|
1695
|
-
paragraph: h(F).replace("hr",
|
|
1700
|
+
lheading: Te,
|
|
1701
|
+
table: re,
|
|
1702
|
+
paragraph: h(F).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex()
|
|
1696
1703
|
},
|
|
1697
|
-
|
|
1704
|
+
Le = {
|
|
1698
1705
|
...K,
|
|
1699
1706
|
html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
1700
1707
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1701
1708
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1702
|
-
fences:
|
|
1709
|
+
fences: E,
|
|
1703
1710
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1704
|
-
paragraph: h(F).replace("hr",
|
|
1711
|
+
paragraph: h(F).replace("hr", C).replace("heading", ` *#{1,6} *[^
|
|
1705
1712
|
]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
1706
1713
|
},
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1714
|
+
Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1715
|
+
ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1716
|
+
ae = /^( {2,}|\\)\n(?!\s*$)/,
|
|
1717
|
+
Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1711
1718
|
D = /[\p{P}\p{S}]/u,
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
Be = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,
|
|
1719
|
+
W = /[\s\p{P}\p{S}]/u,
|
|
1720
|
+
le = /[^\s\p{P}\p{S}]/u,
|
|
1721
|
+
Ee = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex(),
|
|
1722
|
+
ue = /(?!~)[\p{P}\p{S}]/u,
|
|
1723
|
+
Ce = /(?!~)[\s\p{P}\p{S}]/u,
|
|
1724
|
+
Ie = /(?:[^\s\p{P}\p{S}]|~)/u,
|
|
1725
|
+
Be = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,
|
|
1719
1726
|
pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,
|
|
1720
1727
|
qe = h(pe, "u").replace(/punct/g, D).getRegex(),
|
|
1721
|
-
ve = h(pe, "u").replace(/punct/g,
|
|
1722
|
-
|
|
1723
|
-
De = h(
|
|
1724
|
-
Ze = h(
|
|
1725
|
-
Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g,
|
|
1728
|
+
ve = h(pe, "u").replace(/punct/g, ue).getRegex(),
|
|
1729
|
+
ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",
|
|
1730
|
+
De = h(ce, "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(),
|
|
1731
|
+
Ze = h(ce, "gu").replace(/notPunctSpace/g, Ie).replace(/punctSpace/g, Ce).replace(/punct/g, ue).getRegex(),
|
|
1732
|
+
Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(),
|
|
1726
1733
|
He = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(),
|
|
1727
1734
|
Ne = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),
|
|
1728
1735
|
je = h(U).replace("(?:-->|$)", "-->").getRegex(),
|
|
@@ -1730,36 +1737,36 @@ var m = {
|
|
|
1730
1737
|
q = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,
|
|
1731
1738
|
Qe = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),
|
|
1732
1739
|
he = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex(),
|
|
1733
|
-
|
|
1734
|
-
Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink",
|
|
1735
|
-
|
|
1736
|
-
_backpedal:
|
|
1740
|
+
de = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex(),
|
|
1741
|
+
Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", de).getRegex(),
|
|
1742
|
+
X = {
|
|
1743
|
+
_backpedal: E,
|
|
1737
1744
|
anyPunctuation: He,
|
|
1738
1745
|
autolink: Ne,
|
|
1739
1746
|
blockSkip: Be,
|
|
1740
|
-
br:
|
|
1741
|
-
code:
|
|
1742
|
-
del:
|
|
1747
|
+
br: ae,
|
|
1748
|
+
code: ze,
|
|
1749
|
+
del: E,
|
|
1743
1750
|
emStrongLDelim: qe,
|
|
1744
1751
|
emStrongRDelimAst: De,
|
|
1745
1752
|
emStrongRDelimUnd: Ge,
|
|
1746
|
-
escape:
|
|
1753
|
+
escape: Me,
|
|
1747
1754
|
link: Qe,
|
|
1748
|
-
nolink:
|
|
1749
|
-
punctuation:
|
|
1755
|
+
nolink: de,
|
|
1756
|
+
punctuation: Ee,
|
|
1750
1757
|
reflink: he,
|
|
1751
1758
|
reflinkSearch: Ue,
|
|
1752
1759
|
tag: Fe,
|
|
1753
|
-
text:
|
|
1754
|
-
url:
|
|
1760
|
+
text: Ae,
|
|
1761
|
+
url: E
|
|
1755
1762
|
},
|
|
1756
1763
|
Ke = {
|
|
1757
|
-
...
|
|
1764
|
+
...X,
|
|
1758
1765
|
link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(),
|
|
1759
1766
|
reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex()
|
|
1760
1767
|
},
|
|
1761
1768
|
N = {
|
|
1762
|
-
...
|
|
1769
|
+
...X,
|
|
1763
1770
|
emStrongRDelimAst: Ze,
|
|
1764
1771
|
emStrongLDelim: ve,
|
|
1765
1772
|
url: h(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
@@ -1767,107 +1774,107 @@ var m = {
|
|
|
1767
1774
|
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
1768
1775
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1769
1776
|
},
|
|
1770
|
-
|
|
1777
|
+
We = {
|
|
1771
1778
|
...N,
|
|
1772
|
-
br: h(
|
|
1779
|
+
br: h(ae).replace("{2,}", "*").getRegex(),
|
|
1773
1780
|
text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1774
1781
|
},
|
|
1775
|
-
|
|
1782
|
+
I = {
|
|
1776
1783
|
normal: K,
|
|
1777
|
-
gfm:
|
|
1778
|
-
pedantic:
|
|
1784
|
+
gfm: _e,
|
|
1785
|
+
pedantic: Le
|
|
1779
1786
|
},
|
|
1780
|
-
|
|
1781
|
-
normal:
|
|
1787
|
+
M = {
|
|
1788
|
+
normal: X,
|
|
1782
1789
|
gfm: N,
|
|
1783
|
-
breaks:
|
|
1790
|
+
breaks: We,
|
|
1784
1791
|
pedantic: Ke
|
|
1785
1792
|
};
|
|
1786
|
-
var
|
|
1793
|
+
var Xe = {
|
|
1787
1794
|
"&": "&",
|
|
1788
1795
|
"<": "<",
|
|
1789
1796
|
">": ">",
|
|
1790
1797
|
'"': """,
|
|
1791
1798
|
"'": "'"
|
|
1792
1799
|
},
|
|
1793
|
-
|
|
1794
|
-
function
|
|
1800
|
+
ke = l => Xe[l];
|
|
1801
|
+
function w(l, e) {
|
|
1795
1802
|
if (e) {
|
|
1796
|
-
if (m.escapeTest.test(
|
|
1797
|
-
} else if (m.escapeTestNoEncode.test(
|
|
1798
|
-
return
|
|
1803
|
+
if (m.escapeTest.test(l)) return l.replace(m.escapeReplace, ke);
|
|
1804
|
+
} else if (m.escapeTestNoEncode.test(l)) return l.replace(m.escapeReplaceNoEncode, ke);
|
|
1805
|
+
return l;
|
|
1799
1806
|
}
|
|
1800
|
-
function J(
|
|
1807
|
+
function J(l) {
|
|
1801
1808
|
try {
|
|
1802
|
-
|
|
1809
|
+
l = encodeURI(l).replace(m.percentDecode, "%");
|
|
1803
1810
|
} catch {
|
|
1804
1811
|
return null;
|
|
1805
1812
|
}
|
|
1806
|
-
return
|
|
1813
|
+
return l;
|
|
1807
1814
|
}
|
|
1808
|
-
function V(
|
|
1809
|
-
let t =
|
|
1810
|
-
let
|
|
1811
|
-
|
|
1812
|
-
for (; --
|
|
1813
|
-
return
|
|
1815
|
+
function V(l, e) {
|
|
1816
|
+
let t = l.replace(m.findPipe, (i, s, o) => {
|
|
1817
|
+
let a = false,
|
|
1818
|
+
u = s;
|
|
1819
|
+
for (; --u >= 0 && o[u] === "\\";) a = !a;
|
|
1820
|
+
return a ? "|" : " |";
|
|
1814
1821
|
}),
|
|
1815
1822
|
n = t.split(m.splitPipe),
|
|
1816
|
-
|
|
1823
|
+
r = 0;
|
|
1817
1824
|
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);else for (; n.length < e;) n.push("");
|
|
1818
|
-
for (;
|
|
1825
|
+
for (; r < n.length; r++) n[r] = n[r].trim().replace(m.slashPipe, "|");
|
|
1819
1826
|
return n;
|
|
1820
1827
|
}
|
|
1821
|
-
function
|
|
1822
|
-
let n =
|
|
1828
|
+
function z(l, e, t) {
|
|
1829
|
+
let n = l.length;
|
|
1823
1830
|
if (n === 0) return "";
|
|
1824
|
-
let
|
|
1825
|
-
for (;
|
|
1826
|
-
let i =
|
|
1827
|
-
if (i === e && true)
|
|
1831
|
+
let r = 0;
|
|
1832
|
+
for (; r < n;) {
|
|
1833
|
+
let i = l.charAt(n - r - 1);
|
|
1834
|
+
if (i === e && true) r++;else break;
|
|
1828
1835
|
}
|
|
1829
|
-
return
|
|
1836
|
+
return l.slice(0, n - r);
|
|
1830
1837
|
}
|
|
1831
|
-
function
|
|
1832
|
-
if (
|
|
1838
|
+
function ge(l, e) {
|
|
1839
|
+
if (l.indexOf(e[1]) === -1) return -1;
|
|
1833
1840
|
let t = 0;
|
|
1834
|
-
for (let n = 0; n <
|
|
1841
|
+
for (let n = 0; n < l.length; n++) if (l[n] === "\\") n++;else if (l[n] === e[0]) t++;else if (l[n] === e[1] && (t--, t < 0)) return n;
|
|
1835
1842
|
return t > 0 ? -2 : -1;
|
|
1836
1843
|
}
|
|
1837
|
-
function
|
|
1844
|
+
function fe(l, e, t, n, r) {
|
|
1838
1845
|
let i = e.href,
|
|
1839
|
-
|
|
1840
|
-
o =
|
|
1846
|
+
s = e.title || null,
|
|
1847
|
+
o = l[1].replace(r.other.outputLinkReplace, "$1");
|
|
1841
1848
|
n.state.inLink = true;
|
|
1842
|
-
let
|
|
1843
|
-
type:
|
|
1849
|
+
let a = {
|
|
1850
|
+
type: l[0].charAt(0) === "!" ? "image" : "link",
|
|
1844
1851
|
raw: t,
|
|
1845
1852
|
href: i,
|
|
1846
|
-
title:
|
|
1853
|
+
title: s,
|
|
1847
1854
|
text: o,
|
|
1848
1855
|
tokens: n.inlineTokens(o)
|
|
1849
1856
|
};
|
|
1850
|
-
return n.state.inLink = false,
|
|
1857
|
+
return n.state.inLink = false, a;
|
|
1851
1858
|
}
|
|
1852
|
-
function Je(
|
|
1853
|
-
let n =
|
|
1859
|
+
function Je(l, e, t) {
|
|
1860
|
+
let n = l.match(t.other.indentCodeCompensation);
|
|
1854
1861
|
if (n === null) return e;
|
|
1855
|
-
let
|
|
1862
|
+
let r = n[1];
|
|
1856
1863
|
return e.split(`
|
|
1857
1864
|
`).map(i => {
|
|
1858
|
-
let
|
|
1859
|
-
if (
|
|
1860
|
-
let [o] =
|
|
1861
|
-
return o.length >=
|
|
1865
|
+
let s = i.match(t.other.beginningSpace);
|
|
1866
|
+
if (s === null) return i;
|
|
1867
|
+
let [o] = s;
|
|
1868
|
+
return o.length >= r.length ? i.slice(r.length) : i;
|
|
1862
1869
|
}).join(`
|
|
1863
1870
|
`);
|
|
1864
1871
|
}
|
|
1865
|
-
var
|
|
1872
|
+
var y = class {
|
|
1866
1873
|
options;
|
|
1867
1874
|
rules;
|
|
1868
1875
|
lexer;
|
|
1869
1876
|
constructor(e) {
|
|
1870
|
-
this.options = e ||
|
|
1877
|
+
this.options = e || O;
|
|
1871
1878
|
}
|
|
1872
1879
|
space(e) {
|
|
1873
1880
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -1884,7 +1891,7 @@ var S = class {
|
|
|
1884
1891
|
type: "code",
|
|
1885
1892
|
raw: t[0],
|
|
1886
1893
|
codeBlockStyle: "indented",
|
|
1887
|
-
text: this.options.pedantic ? n :
|
|
1894
|
+
text: this.options.pedantic ? n : z(n, `
|
|
1888
1895
|
`)
|
|
1889
1896
|
};
|
|
1890
1897
|
}
|
|
@@ -1893,12 +1900,12 @@ var S = class {
|
|
|
1893
1900
|
let t = this.rules.block.fences.exec(e);
|
|
1894
1901
|
if (t) {
|
|
1895
1902
|
let n = t[0],
|
|
1896
|
-
|
|
1903
|
+
r = Je(n, t[3] || "", this.rules);
|
|
1897
1904
|
return {
|
|
1898
1905
|
type: "code",
|
|
1899
1906
|
raw: n,
|
|
1900
1907
|
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
1901
|
-
text:
|
|
1908
|
+
text: r
|
|
1902
1909
|
};
|
|
1903
1910
|
}
|
|
1904
1911
|
}
|
|
@@ -1907,8 +1914,8 @@ var S = class {
|
|
|
1907
1914
|
if (t) {
|
|
1908
1915
|
let n = t[2].trim();
|
|
1909
1916
|
if (this.rules.other.endingHash.test(n)) {
|
|
1910
|
-
let
|
|
1911
|
-
(this.options.pedantic || !
|
|
1917
|
+
let r = z(n, "#");
|
|
1918
|
+
(this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
|
|
1912
1919
|
}
|
|
1913
1920
|
return {
|
|
1914
1921
|
type: "heading",
|
|
@@ -1923,59 +1930,59 @@ var S = class {
|
|
|
1923
1930
|
let t = this.rules.block.hr.exec(e);
|
|
1924
1931
|
if (t) return {
|
|
1925
1932
|
type: "hr",
|
|
1926
|
-
raw:
|
|
1933
|
+
raw: z(t[0], `
|
|
1927
1934
|
`)
|
|
1928
1935
|
};
|
|
1929
1936
|
}
|
|
1930
1937
|
blockquote(e) {
|
|
1931
1938
|
let t = this.rules.block.blockquote.exec(e);
|
|
1932
1939
|
if (t) {
|
|
1933
|
-
let n =
|
|
1940
|
+
let n = z(t[0], `
|
|
1934
1941
|
`).split(`
|
|
1935
1942
|
`),
|
|
1936
|
-
|
|
1943
|
+
r = "",
|
|
1937
1944
|
i = "",
|
|
1938
|
-
|
|
1945
|
+
s = [];
|
|
1939
1946
|
for (; n.length > 0;) {
|
|
1940
1947
|
let o = false,
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
for (
|
|
1944
|
-
n = n.slice(
|
|
1945
|
-
let p =
|
|
1948
|
+
a = [],
|
|
1949
|
+
u;
|
|
1950
|
+
for (u = 0; u < n.length; u++) if (this.rules.other.blockquoteStart.test(n[u])) a.push(n[u]), o = true;else if (!o) a.push(n[u]);else break;
|
|
1951
|
+
n = n.slice(u);
|
|
1952
|
+
let p = a.join(`
|
|
1946
1953
|
`),
|
|
1947
|
-
|
|
1954
|
+
c = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1948
1955
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1949
|
-
|
|
1956
|
+
r = r ? `${r}
|
|
1950
1957
|
${p}` : p, i = i ? `${i}
|
|
1951
|
-
${
|
|
1952
|
-
let
|
|
1953
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(
|
|
1954
|
-
let
|
|
1955
|
-
if (
|
|
1956
|
-
if (
|
|
1957
|
-
let x =
|
|
1958
|
-
|
|
1958
|
+
${c}` : c;
|
|
1959
|
+
let f = this.lexer.state.top;
|
|
1960
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = f, n.length === 0) break;
|
|
1961
|
+
let k = s.at(-1);
|
|
1962
|
+
if (k?.type === "code") break;
|
|
1963
|
+
if (k?.type === "blockquote") {
|
|
1964
|
+
let x = k,
|
|
1965
|
+
g = x.raw + `
|
|
1959
1966
|
` + n.join(`
|
|
1960
1967
|
`),
|
|
1961
|
-
|
|
1962
|
-
|
|
1968
|
+
T = this.blockquote(g);
|
|
1969
|
+
s[s.length - 1] = T, r = r.substring(0, r.length - x.raw.length) + T.raw, i = i.substring(0, i.length - x.text.length) + T.text;
|
|
1963
1970
|
break;
|
|
1964
|
-
} else if (
|
|
1965
|
-
let x =
|
|
1966
|
-
|
|
1971
|
+
} else if (k?.type === "list") {
|
|
1972
|
+
let x = k,
|
|
1973
|
+
g = x.raw + `
|
|
1967
1974
|
` + n.join(`
|
|
1968
1975
|
`),
|
|
1969
|
-
|
|
1970
|
-
|
|
1976
|
+
T = this.list(g);
|
|
1977
|
+
s[s.length - 1] = T, r = r.substring(0, r.length - k.raw.length) + T.raw, i = i.substring(0, i.length - x.raw.length) + T.raw, n = g.substring(s.at(-1).raw.length).split(`
|
|
1971
1978
|
`);
|
|
1972
1979
|
continue;
|
|
1973
1980
|
}
|
|
1974
1981
|
}
|
|
1975
1982
|
return {
|
|
1976
1983
|
type: "blockquote",
|
|
1977
|
-
raw:
|
|
1978
|
-
tokens:
|
|
1984
|
+
raw: r,
|
|
1985
|
+
tokens: s,
|
|
1979
1986
|
text: i
|
|
1980
1987
|
};
|
|
1981
1988
|
}
|
|
@@ -1984,74 +1991,74 @@ ${u}` : u;
|
|
|
1984
1991
|
let t = this.rules.block.list.exec(e);
|
|
1985
1992
|
if (t) {
|
|
1986
1993
|
let n = t[1].trim(),
|
|
1987
|
-
|
|
1994
|
+
r = n.length > 1,
|
|
1988
1995
|
i = {
|
|
1989
1996
|
type: "list",
|
|
1990
1997
|
raw: "",
|
|
1991
|
-
ordered:
|
|
1992
|
-
start:
|
|
1998
|
+
ordered: r,
|
|
1999
|
+
start: r ? +n.slice(0, -1) : "",
|
|
1993
2000
|
loose: false,
|
|
1994
2001
|
items: []
|
|
1995
2002
|
};
|
|
1996
|
-
n =
|
|
1997
|
-
let
|
|
2003
|
+
n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
|
|
2004
|
+
let s = this.rules.other.listItemRegex(n),
|
|
1998
2005
|
o = false;
|
|
1999
2006
|
for (; e;) {
|
|
2000
|
-
let
|
|
2007
|
+
let u = false,
|
|
2001
2008
|
p = "",
|
|
2002
|
-
|
|
2003
|
-
if (!(t =
|
|
2009
|
+
c = "";
|
|
2010
|
+
if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
2004
2011
|
p = t[0], e = e.substring(p.length);
|
|
2005
|
-
let
|
|
2012
|
+
let f = t[2].split(`
|
|
2006
2013
|
`, 1)[0].replace(this.rules.other.listReplaceTabs, Z => " ".repeat(3 * Z.length)),
|
|
2007
|
-
|
|
2014
|
+
k = e.split(`
|
|
2008
2015
|
`, 1)[0],
|
|
2009
|
-
x = !
|
|
2010
|
-
|
|
2011
|
-
if (this.options.pedantic ? (
|
|
2012
|
-
`, e = e.substring(
|
|
2013
|
-
let Z = this.rules.other.nextBulletRegex(
|
|
2014
|
-
ee = this.rules.other.hrRegex(
|
|
2015
|
-
te = this.rules.other.fencesBeginRegex(
|
|
2016
|
-
ne = this.rules.other.headingBeginRegex(
|
|
2017
|
-
me = this.rules.other.htmlBeginRegex(
|
|
2016
|
+
x = !f.trim(),
|
|
2017
|
+
g = 0;
|
|
2018
|
+
if (this.options.pedantic ? (g = 2, c = f.trimStart()) : x ? g = t[1].length + 1 : (g = t[2].search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = f.slice(g), g += t[1].length), x && this.rules.other.blankLine.test(k) && (p += k + `
|
|
2019
|
+
`, e = e.substring(k.length + 1), u = true), !u) {
|
|
2020
|
+
let Z = this.rules.other.nextBulletRegex(g),
|
|
2021
|
+
ee = this.rules.other.hrRegex(g),
|
|
2022
|
+
te = this.rules.other.fencesBeginRegex(g),
|
|
2023
|
+
ne = this.rules.other.headingBeginRegex(g),
|
|
2024
|
+
me = this.rules.other.htmlBeginRegex(g);
|
|
2018
2025
|
for (; e;) {
|
|
2019
2026
|
let G = e.split(`
|
|
2020
2027
|
`, 1)[0],
|
|
2021
|
-
|
|
2022
|
-
if (
|
|
2023
|
-
if (
|
|
2024
|
-
` +
|
|
2025
|
-
if (x ||
|
|
2026
|
-
|
|
2027
|
-
` +
|
|
2028
|
+
A;
|
|
2029
|
+
if (k = G, this.options.pedantic ? (k = k.replace(this.rules.other.listReplaceNesting, " "), A = k) : A = k.replace(this.rules.other.tabCharGlobal, " "), te.test(k) || ne.test(k) || me.test(k) || Z.test(k) || ee.test(k)) break;
|
|
2030
|
+
if (A.search(this.rules.other.nonSpaceChar) >= g || !k.trim()) c += `
|
|
2031
|
+
` + A.slice(g);else {
|
|
2032
|
+
if (x || f.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(f) || ne.test(f) || ee.test(f)) break;
|
|
2033
|
+
c += `
|
|
2034
|
+
` + k;
|
|
2028
2035
|
}
|
|
2029
|
-
!x && !
|
|
2030
|
-
`, e = e.substring(G.length + 1),
|
|
2036
|
+
!x && !k.trim() && (x = true), p += G + `
|
|
2037
|
+
`, e = e.substring(G.length + 1), f = A.slice(g);
|
|
2031
2038
|
}
|
|
2032
2039
|
}
|
|
2033
2040
|
i.loose || (o ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true));
|
|
2034
|
-
let
|
|
2041
|
+
let T = null,
|
|
2035
2042
|
Y;
|
|
2036
|
-
this.options.gfm && (
|
|
2043
|
+
this.options.gfm && (T = this.rules.other.listIsTask.exec(c), T && (Y = T[0] !== "[ ] ", c = c.replace(this.rules.other.listReplaceTask, ""))), i.items.push({
|
|
2037
2044
|
type: "list_item",
|
|
2038
2045
|
raw: p,
|
|
2039
|
-
task: !!
|
|
2046
|
+
task: !!T,
|
|
2040
2047
|
checked: Y,
|
|
2041
2048
|
loose: false,
|
|
2042
|
-
text:
|
|
2049
|
+
text: c,
|
|
2043
2050
|
tokens: []
|
|
2044
2051
|
}), i.raw += p;
|
|
2045
2052
|
}
|
|
2046
|
-
let
|
|
2047
|
-
if (
|
|
2053
|
+
let a = i.items.at(-1);
|
|
2054
|
+
if (a) a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();else return;
|
|
2048
2055
|
i.raw = i.raw.trimEnd();
|
|
2049
|
-
for (let
|
|
2050
|
-
let p = i.items[
|
|
2051
|
-
|
|
2052
|
-
i.loose =
|
|
2056
|
+
for (let u = 0; u < i.items.length; u++) if (this.lexer.state.top = false, i.items[u].tokens = this.lexer.blockTokens(i.items[u].text, []), !i.loose) {
|
|
2057
|
+
let p = i.items[u].tokens.filter(f => f.type === "space"),
|
|
2058
|
+
c = p.length > 0 && p.some(f => this.rules.other.anyLine.test(f.raw));
|
|
2059
|
+
i.loose = c;
|
|
2053
2060
|
}
|
|
2054
|
-
if (i.loose) for (let
|
|
2061
|
+
if (i.loose) for (let u = 0; u < i.items.length; u++) i.items[u].loose = true;
|
|
2055
2062
|
return i;
|
|
2056
2063
|
}
|
|
2057
2064
|
}
|
|
@@ -2069,13 +2076,13 @@ ${u}` : u;
|
|
|
2069
2076
|
let t = this.rules.block.def.exec(e);
|
|
2070
2077
|
if (t) {
|
|
2071
2078
|
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
2072
|
-
|
|
2079
|
+
r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "",
|
|
2073
2080
|
i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
2074
2081
|
return {
|
|
2075
2082
|
type: "def",
|
|
2076
2083
|
tag: n,
|
|
2077
2084
|
raw: t[0],
|
|
2078
|
-
href:
|
|
2085
|
+
href: r,
|
|
2079
2086
|
title: i
|
|
2080
2087
|
};
|
|
2081
2088
|
}
|
|
@@ -2084,31 +2091,31 @@ ${u}` : u;
|
|
|
2084
2091
|
let t = this.rules.block.table.exec(e);
|
|
2085
2092
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
2086
2093
|
let n = V(t[1]),
|
|
2087
|
-
|
|
2094
|
+
r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"),
|
|
2088
2095
|
i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
2089
2096
|
`) : [],
|
|
2090
|
-
|
|
2097
|
+
s = {
|
|
2091
2098
|
type: "table",
|
|
2092
2099
|
raw: t[0],
|
|
2093
2100
|
header: [],
|
|
2094
2101
|
align: [],
|
|
2095
2102
|
rows: []
|
|
2096
2103
|
};
|
|
2097
|
-
if (n.length ===
|
|
2098
|
-
for (let o of
|
|
2099
|
-
for (let o = 0; o < n.length; o++)
|
|
2104
|
+
if (n.length === r.length) {
|
|
2105
|
+
for (let o of r) this.rules.other.tableAlignRight.test(o) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? s.align.push("left") : s.align.push(null);
|
|
2106
|
+
for (let o = 0; o < n.length; o++) s.header.push({
|
|
2100
2107
|
text: n[o],
|
|
2101
2108
|
tokens: this.lexer.inline(n[o]),
|
|
2102
2109
|
header: true,
|
|
2103
|
-
align:
|
|
2110
|
+
align: s.align[o]
|
|
2104
2111
|
});
|
|
2105
|
-
for (let o of i)
|
|
2106
|
-
text:
|
|
2107
|
-
tokens: this.lexer.inline(
|
|
2112
|
+
for (let o of i) s.rows.push(V(o, s.header.length).map((a, u) => ({
|
|
2113
|
+
text: a,
|
|
2114
|
+
tokens: this.lexer.inline(a),
|
|
2108
2115
|
header: false,
|
|
2109
|
-
align:
|
|
2116
|
+
align: s.align[u]
|
|
2110
2117
|
})));
|
|
2111
|
-
return
|
|
2118
|
+
return s;
|
|
2112
2119
|
}
|
|
2113
2120
|
}
|
|
2114
2121
|
lheading(e) {
|
|
@@ -2168,24 +2175,24 @@ ${u}` : u;
|
|
|
2168
2175
|
let n = t[2].trim();
|
|
2169
2176
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
2170
2177
|
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
2171
|
-
let
|
|
2172
|
-
if ((n.length -
|
|
2178
|
+
let s = z(n.slice(0, -1), "\\");
|
|
2179
|
+
if ((n.length - s.length) % 2 === 0) return;
|
|
2173
2180
|
} else {
|
|
2174
|
-
let
|
|
2175
|
-
if (
|
|
2176
|
-
if (
|
|
2177
|
-
let
|
|
2178
|
-
t[2] = t[2].substring(0,
|
|
2181
|
+
let s = ge(t[2], "()");
|
|
2182
|
+
if (s === -2) return;
|
|
2183
|
+
if (s > -1) {
|
|
2184
|
+
let a = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
|
|
2185
|
+
t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, a).trim(), t[3] = "";
|
|
2179
2186
|
}
|
|
2180
2187
|
}
|
|
2181
|
-
let
|
|
2188
|
+
let r = t[2],
|
|
2182
2189
|
i = "";
|
|
2183
2190
|
if (this.options.pedantic) {
|
|
2184
|
-
let
|
|
2185
|
-
|
|
2191
|
+
let s = this.rules.other.pedanticHrefTitle.exec(r);
|
|
2192
|
+
s && (r = s[1], i = s[3]);
|
|
2186
2193
|
} else i = t[3] ? t[3].slice(1, -1) : "";
|
|
2187
|
-
return
|
|
2188
|
-
href:
|
|
2194
|
+
return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), fe(t, {
|
|
2195
|
+
href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
2189
2196
|
title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
|
|
2190
2197
|
}, t[0], this.lexer, this.rules);
|
|
2191
2198
|
}
|
|
@@ -2193,55 +2200,55 @@ ${u}` : u;
|
|
|
2193
2200
|
reflink(e, t) {
|
|
2194
2201
|
let n;
|
|
2195
2202
|
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
2196
|
-
let
|
|
2197
|
-
i = t[
|
|
2203
|
+
let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
2204
|
+
i = t[r.toLowerCase()];
|
|
2198
2205
|
if (!i) {
|
|
2199
|
-
let
|
|
2206
|
+
let s = n[0].charAt(0);
|
|
2200
2207
|
return {
|
|
2201
2208
|
type: "text",
|
|
2202
|
-
raw:
|
|
2203
|
-
text:
|
|
2209
|
+
raw: s,
|
|
2210
|
+
text: s
|
|
2204
2211
|
};
|
|
2205
2212
|
}
|
|
2206
|
-
return
|
|
2213
|
+
return fe(n, i, n[0], this.lexer, this.rules);
|
|
2207
2214
|
}
|
|
2208
2215
|
}
|
|
2209
2216
|
emStrong(e, t, n = "") {
|
|
2210
|
-
let
|
|
2211
|
-
if (!
|
|
2212
|
-
if (!(
|
|
2213
|
-
let
|
|
2217
|
+
let r = this.rules.inline.emStrongLDelim.exec(e);
|
|
2218
|
+
if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
2219
|
+
if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2220
|
+
let s = [...r[0]].length - 1,
|
|
2214
2221
|
o,
|
|
2215
|
-
|
|
2216
|
-
|
|
2222
|
+
a,
|
|
2223
|
+
u = s,
|
|
2217
2224
|
p = 0,
|
|
2218
|
-
|
|
2219
|
-
for (
|
|
2220
|
-
if (o =
|
|
2221
|
-
if (
|
|
2222
|
-
|
|
2225
|
+
c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
2226
|
+
for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) != null;) {
|
|
2227
|
+
if (o = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !o) continue;
|
|
2228
|
+
if (a = [...o].length, r[3] || r[4]) {
|
|
2229
|
+
u += a;
|
|
2223
2230
|
continue;
|
|
2224
|
-
} else if ((
|
|
2225
|
-
p +=
|
|
2231
|
+
} else if ((r[5] || r[6]) && s % 3 && !((s + a) % 3)) {
|
|
2232
|
+
p += a;
|
|
2226
2233
|
continue;
|
|
2227
2234
|
}
|
|
2228
|
-
if (
|
|
2229
|
-
|
|
2230
|
-
let
|
|
2231
|
-
|
|
2232
|
-
if (Math.min(
|
|
2233
|
-
let
|
|
2235
|
+
if (u -= a, u > 0) continue;
|
|
2236
|
+
a = Math.min(a, a + u + p);
|
|
2237
|
+
let f = [...r[0]][0].length,
|
|
2238
|
+
k = e.slice(0, s + r.index + f + a);
|
|
2239
|
+
if (Math.min(s, a) % 2) {
|
|
2240
|
+
let g = k.slice(1, -1);
|
|
2234
2241
|
return {
|
|
2235
2242
|
type: "em",
|
|
2236
|
-
raw:
|
|
2237
|
-
text:
|
|
2238
|
-
tokens: this.lexer.inlineTokens(
|
|
2243
|
+
raw: k,
|
|
2244
|
+
text: g,
|
|
2245
|
+
tokens: this.lexer.inlineTokens(g)
|
|
2239
2246
|
};
|
|
2240
2247
|
}
|
|
2241
|
-
let x =
|
|
2248
|
+
let x = k.slice(2, -2);
|
|
2242
2249
|
return {
|
|
2243
2250
|
type: "strong",
|
|
2244
|
-
raw:
|
|
2251
|
+
raw: k,
|
|
2245
2252
|
text: x,
|
|
2246
2253
|
tokens: this.lexer.inlineTokens(x)
|
|
2247
2254
|
};
|
|
@@ -2252,9 +2259,9 @@ ${u}` : u;
|
|
|
2252
2259
|
let t = this.rules.inline.code.exec(e);
|
|
2253
2260
|
if (t) {
|
|
2254
2261
|
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "),
|
|
2255
|
-
|
|
2262
|
+
r = this.rules.other.nonSpaceChar.test(n),
|
|
2256
2263
|
i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
2257
|
-
return
|
|
2264
|
+
return r && i && (n = n.substring(1, n.length - 1)), {
|
|
2258
2265
|
type: "codespan",
|
|
2259
2266
|
raw: t[0],
|
|
2260
2267
|
text: n
|
|
@@ -2280,12 +2287,12 @@ ${u}` : u;
|
|
|
2280
2287
|
autolink(e) {
|
|
2281
2288
|
let t = this.rules.inline.autolink.exec(e);
|
|
2282
2289
|
if (t) {
|
|
2283
|
-
let n,
|
|
2284
|
-
return t[2] === "@" ? (n = t[1],
|
|
2290
|
+
let n, r;
|
|
2291
|
+
return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), {
|
|
2285
2292
|
type: "link",
|
|
2286
2293
|
raw: t[0],
|
|
2287
2294
|
text: n,
|
|
2288
|
-
href:
|
|
2295
|
+
href: r,
|
|
2289
2296
|
tokens: [{
|
|
2290
2297
|
type: "text",
|
|
2291
2298
|
raw: n,
|
|
@@ -2297,17 +2304,17 @@ ${u}` : u;
|
|
|
2297
2304
|
url(e) {
|
|
2298
2305
|
let t;
|
|
2299
2306
|
if (t = this.rules.inline.url.exec(e)) {
|
|
2300
|
-
let n,
|
|
2301
|
-
if (t[2] === "@") n = t[0],
|
|
2307
|
+
let n, r;
|
|
2308
|
+
if (t[2] === "@") n = t[0], r = "mailto:" + n;else {
|
|
2302
2309
|
let i;
|
|
2303
2310
|
do i = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? ""; while (i !== t[0]);
|
|
2304
|
-
n = t[0], t[1] === "www." ?
|
|
2311
|
+
n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
2305
2312
|
}
|
|
2306
2313
|
return {
|
|
2307
2314
|
type: "link",
|
|
2308
2315
|
raw: t[0],
|
|
2309
2316
|
text: n,
|
|
2310
|
-
href:
|
|
2317
|
+
href: r,
|
|
2311
2318
|
tokens: [{
|
|
2312
2319
|
type: "text",
|
|
2313
2320
|
raw: n,
|
|
@@ -2329,36 +2336,36 @@ ${u}` : u;
|
|
|
2329
2336
|
}
|
|
2330
2337
|
}
|
|
2331
2338
|
};
|
|
2332
|
-
var b = class
|
|
2339
|
+
var b = class l {
|
|
2333
2340
|
tokens;
|
|
2334
2341
|
options;
|
|
2335
2342
|
state;
|
|
2336
2343
|
tokenizer;
|
|
2337
2344
|
inlineQueue;
|
|
2338
2345
|
constructor(e) {
|
|
2339
|
-
this.tokens = [], this.tokens.links = Object.create(null), this.options = e ||
|
|
2346
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || O, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
2340
2347
|
inLink: false,
|
|
2341
2348
|
inRawBlock: false,
|
|
2342
2349
|
top: true
|
|
2343
2350
|
};
|
|
2344
2351
|
let t = {
|
|
2345
2352
|
other: m,
|
|
2346
|
-
block:
|
|
2347
|
-
inline:
|
|
2353
|
+
block: I.normal,
|
|
2354
|
+
inline: M.normal
|
|
2348
2355
|
};
|
|
2349
|
-
this.options.pedantic ? (t.block =
|
|
2356
|
+
this.options.pedantic ? (t.block = I.pedantic, t.inline = M.pedantic) : this.options.gfm && (t.block = I.gfm, this.options.breaks ? t.inline = M.breaks : t.inline = M.gfm), this.tokenizer.rules = t;
|
|
2350
2357
|
}
|
|
2351
2358
|
static get rules() {
|
|
2352
2359
|
return {
|
|
2353
|
-
block:
|
|
2354
|
-
inline:
|
|
2360
|
+
block: I,
|
|
2361
|
+
inline: M
|
|
2355
2362
|
};
|
|
2356
2363
|
}
|
|
2357
2364
|
static lex(e, t) {
|
|
2358
|
-
return new
|
|
2365
|
+
return new l(t).lex(e);
|
|
2359
2366
|
}
|
|
2360
2367
|
static lexInline(e, t) {
|
|
2361
|
-
return new
|
|
2368
|
+
return new l(t).inlineTokens(e);
|
|
2362
2369
|
}
|
|
2363
2370
|
lex(e) {
|
|
2364
2371
|
e = e.replace(m.carriageReturn, `
|
|
@@ -2371,100 +2378,104 @@ var b = class a {
|
|
|
2371
2378
|
}
|
|
2372
2379
|
blockTokens(e, t = [], n = false) {
|
|
2373
2380
|
for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e;) {
|
|
2374
|
-
let
|
|
2375
|
-
if (this.options.extensions?.block?.some(
|
|
2381
|
+
let r;
|
|
2382
|
+
if (this.options.extensions?.block?.some(s => (r = s.call({
|
|
2376
2383
|
lexer: this
|
|
2377
|
-
}, e, t)) ? (e = e.substring(
|
|
2378
|
-
if (
|
|
2379
|
-
e = e.substring(
|
|
2380
|
-
let
|
|
2381
|
-
|
|
2382
|
-
` : t.push(
|
|
2384
|
+
}, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
2385
|
+
if (r = this.tokenizer.space(e)) {
|
|
2386
|
+
e = e.substring(r.raw.length);
|
|
2387
|
+
let s = t.at(-1);
|
|
2388
|
+
r.raw.length === 1 && s !== void 0 ? s.raw += `
|
|
2389
|
+
` : t.push(r);
|
|
2383
2390
|
continue;
|
|
2384
2391
|
}
|
|
2385
|
-
if (
|
|
2386
|
-
e = e.substring(
|
|
2387
|
-
let
|
|
2388
|
-
|
|
2389
|
-
`
|
|
2390
|
-
` +
|
|
2392
|
+
if (r = this.tokenizer.code(e)) {
|
|
2393
|
+
e = e.substring(r.raw.length);
|
|
2394
|
+
let s = t.at(-1);
|
|
2395
|
+
s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
|
|
2396
|
+
`) ? "" : `
|
|
2397
|
+
`) + r.raw, s.text += `
|
|
2398
|
+
` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
|
|
2391
2399
|
continue;
|
|
2392
2400
|
}
|
|
2393
|
-
if (
|
|
2394
|
-
e = e.substring(
|
|
2401
|
+
if (r = this.tokenizer.fences(e)) {
|
|
2402
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2395
2403
|
continue;
|
|
2396
2404
|
}
|
|
2397
|
-
if (
|
|
2398
|
-
e = e.substring(
|
|
2405
|
+
if (r = this.tokenizer.heading(e)) {
|
|
2406
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2399
2407
|
continue;
|
|
2400
2408
|
}
|
|
2401
|
-
if (
|
|
2402
|
-
e = e.substring(
|
|
2409
|
+
if (r = this.tokenizer.hr(e)) {
|
|
2410
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2403
2411
|
continue;
|
|
2404
2412
|
}
|
|
2405
|
-
if (
|
|
2406
|
-
e = e.substring(
|
|
2413
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
2414
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2407
2415
|
continue;
|
|
2408
2416
|
}
|
|
2409
|
-
if (
|
|
2410
|
-
e = e.substring(
|
|
2417
|
+
if (r = this.tokenizer.list(e)) {
|
|
2418
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2411
2419
|
continue;
|
|
2412
2420
|
}
|
|
2413
|
-
if (
|
|
2414
|
-
e = e.substring(
|
|
2421
|
+
if (r = this.tokenizer.html(e)) {
|
|
2422
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2415
2423
|
continue;
|
|
2416
2424
|
}
|
|
2417
|
-
if (
|
|
2418
|
-
e = e.substring(
|
|
2419
|
-
let
|
|
2420
|
-
|
|
2421
|
-
`
|
|
2422
|
-
` +
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2425
|
+
if (r = this.tokenizer.def(e)) {
|
|
2426
|
+
e = e.substring(r.raw.length);
|
|
2427
|
+
let s = t.at(-1);
|
|
2428
|
+
s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
|
|
2429
|
+
`) ? "" : `
|
|
2430
|
+
`) + r.raw, s.text += `
|
|
2431
|
+
` + r.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
|
|
2432
|
+
href: r.href,
|
|
2433
|
+
title: r.title
|
|
2434
|
+
}, t.push(r));
|
|
2426
2435
|
continue;
|
|
2427
2436
|
}
|
|
2428
|
-
if (
|
|
2429
|
-
e = e.substring(
|
|
2437
|
+
if (r = this.tokenizer.table(e)) {
|
|
2438
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2430
2439
|
continue;
|
|
2431
2440
|
}
|
|
2432
|
-
if (
|
|
2433
|
-
e = e.substring(
|
|
2441
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
2442
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2434
2443
|
continue;
|
|
2435
2444
|
}
|
|
2436
2445
|
let i = e;
|
|
2437
2446
|
if (this.options.extensions?.startBlock) {
|
|
2438
|
-
let
|
|
2447
|
+
let s = 1 / 0,
|
|
2439
2448
|
o = e.slice(1),
|
|
2440
|
-
|
|
2441
|
-
this.options.extensions.startBlock.forEach(
|
|
2442
|
-
|
|
2449
|
+
a;
|
|
2450
|
+
this.options.extensions.startBlock.forEach(u => {
|
|
2451
|
+
a = u.call({
|
|
2443
2452
|
lexer: this
|
|
2444
|
-
}, o), typeof
|
|
2445
|
-
}),
|
|
2453
|
+
}, o), typeof a == "number" && a >= 0 && (s = Math.min(s, a));
|
|
2454
|
+
}), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
|
|
2446
2455
|
}
|
|
2447
|
-
if (this.state.top && (
|
|
2448
|
-
let
|
|
2449
|
-
n &&
|
|
2450
|
-
`
|
|
2451
|
-
` +
|
|
2456
|
+
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
2457
|
+
let s = t.at(-1);
|
|
2458
|
+
n && s?.type === "paragraph" ? (s.raw += (s.raw.endsWith(`
|
|
2459
|
+
`) ? "" : `
|
|
2460
|
+
`) + r.raw, s.text += `
|
|
2461
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
|
|
2452
2462
|
continue;
|
|
2453
2463
|
}
|
|
2454
|
-
if (
|
|
2455
|
-
e = e.substring(
|
|
2456
|
-
let
|
|
2457
|
-
|
|
2458
|
-
`
|
|
2459
|
-
` +
|
|
2464
|
+
if (r = this.tokenizer.text(e)) {
|
|
2465
|
+
e = e.substring(r.raw.length);
|
|
2466
|
+
let s = t.at(-1);
|
|
2467
|
+
s?.type === "text" ? (s.raw += (s.raw.endsWith(`
|
|
2468
|
+
`) ? "" : `
|
|
2469
|
+
`) + r.raw, s.text += `
|
|
2470
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
|
|
2460
2471
|
continue;
|
|
2461
2472
|
}
|
|
2462
2473
|
if (e) {
|
|
2463
|
-
let
|
|
2474
|
+
let s = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2464
2475
|
if (this.options.silent) {
|
|
2465
|
-
console.error(
|
|
2476
|
+
console.error(s);
|
|
2466
2477
|
break;
|
|
2467
|
-
} else throw new Error(
|
|
2478
|
+
} else throw new Error(s);
|
|
2468
2479
|
}
|
|
2469
2480
|
}
|
|
2470
2481
|
return this.state.top = true, t;
|
|
@@ -2477,19 +2488,19 @@ var b = class a {
|
|
|
2477
2488
|
}
|
|
2478
2489
|
inlineTokens(e, t = []) {
|
|
2479
2490
|
let n = e,
|
|
2480
|
-
|
|
2491
|
+
r = null;
|
|
2481
2492
|
if (this.tokens.links) {
|
|
2482
2493
|
let o = Object.keys(this.tokens.links);
|
|
2483
|
-
if (o.length > 0) for (; (
|
|
2494
|
+
if (o.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null;) o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
2484
2495
|
}
|
|
2485
|
-
for (; (
|
|
2486
|
-
for (; (
|
|
2496
|
+
for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null;) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
2497
|
+
for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null;) n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
2487
2498
|
let i = false,
|
|
2488
|
-
|
|
2499
|
+
s = "";
|
|
2489
2500
|
for (; e;) {
|
|
2490
|
-
i || (
|
|
2501
|
+
i || (s = ""), i = false;
|
|
2491
2502
|
let o;
|
|
2492
|
-
if (this.options.extensions?.inline?.some(
|
|
2503
|
+
if (this.options.extensions?.inline?.some(u => (o = u.call({
|
|
2493
2504
|
lexer: this
|
|
2494
2505
|
}, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
2495
2506
|
if (o = this.tokenizer.escape(e)) {
|
|
@@ -2506,11 +2517,11 @@ var b = class a {
|
|
|
2506
2517
|
}
|
|
2507
2518
|
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
2508
2519
|
e = e.substring(o.raw.length);
|
|
2509
|
-
let
|
|
2510
|
-
o.type === "text" &&
|
|
2520
|
+
let u = t.at(-1);
|
|
2521
|
+
o.type === "text" && u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : t.push(o);
|
|
2511
2522
|
continue;
|
|
2512
2523
|
}
|
|
2513
|
-
if (o = this.tokenizer.emStrong(e, n,
|
|
2524
|
+
if (o = this.tokenizer.emStrong(e, n, s)) {
|
|
2514
2525
|
e = e.substring(o.raw.length), t.push(o);
|
|
2515
2526
|
continue;
|
|
2516
2527
|
}
|
|
@@ -2534,39 +2545,39 @@ var b = class a {
|
|
|
2534
2545
|
e = e.substring(o.raw.length), t.push(o);
|
|
2535
2546
|
continue;
|
|
2536
2547
|
}
|
|
2537
|
-
let
|
|
2548
|
+
let a = e;
|
|
2538
2549
|
if (this.options.extensions?.startInline) {
|
|
2539
|
-
let
|
|
2550
|
+
let u = 1 / 0,
|
|
2540
2551
|
p = e.slice(1),
|
|
2541
|
-
|
|
2542
|
-
this.options.extensions.startInline.forEach(
|
|
2543
|
-
|
|
2552
|
+
c;
|
|
2553
|
+
this.options.extensions.startInline.forEach(f => {
|
|
2554
|
+
c = f.call({
|
|
2544
2555
|
lexer: this
|
|
2545
|
-
}, p), typeof
|
|
2546
|
-
}),
|
|
2556
|
+
}, p), typeof c == "number" && c >= 0 && (u = Math.min(u, c));
|
|
2557
|
+
}), u < 1 / 0 && u >= 0 && (a = e.substring(0, u + 1));
|
|
2547
2558
|
}
|
|
2548
|
-
if (o = this.tokenizer.inlineText(
|
|
2549
|
-
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (
|
|
2550
|
-
let
|
|
2551
|
-
|
|
2559
|
+
if (o = this.tokenizer.inlineText(a)) {
|
|
2560
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (s = o.raw.slice(-1)), i = true;
|
|
2561
|
+
let u = t.at(-1);
|
|
2562
|
+
u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : t.push(o);
|
|
2552
2563
|
continue;
|
|
2553
2564
|
}
|
|
2554
2565
|
if (e) {
|
|
2555
|
-
let
|
|
2566
|
+
let u = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2556
2567
|
if (this.options.silent) {
|
|
2557
|
-
console.error(
|
|
2568
|
+
console.error(u);
|
|
2558
2569
|
break;
|
|
2559
|
-
} else throw new Error(
|
|
2570
|
+
} else throw new Error(u);
|
|
2560
2571
|
}
|
|
2561
2572
|
}
|
|
2562
2573
|
return t;
|
|
2563
2574
|
}
|
|
2564
2575
|
};
|
|
2565
|
-
var
|
|
2576
|
+
var P = class {
|
|
2566
2577
|
options;
|
|
2567
2578
|
parser;
|
|
2568
2579
|
constructor(e) {
|
|
2569
|
-
this.options = e ||
|
|
2580
|
+
this.options = e || O;
|
|
2570
2581
|
}
|
|
2571
2582
|
space(e) {
|
|
2572
2583
|
return "";
|
|
@@ -2576,11 +2587,11 @@ var $ = class {
|
|
|
2576
2587
|
lang: t,
|
|
2577
2588
|
escaped: n
|
|
2578
2589
|
}) {
|
|
2579
|
-
let
|
|
2590
|
+
let r = (t || "").match(m.notSpaceStart)?.[0],
|
|
2580
2591
|
i = e.replace(m.endingNewline, "") + `
|
|
2581
2592
|
`;
|
|
2582
|
-
return
|
|
2583
|
-
` : "<pre><code>" + (n ? i :
|
|
2593
|
+
return r ? '<pre><code class="language-' + w(r) + '">' + (n ? i : w(i, true)) + `</code></pre>
|
|
2594
|
+
` : "<pre><code>" + (n ? i : w(i, true)) + `</code></pre>
|
|
2584
2595
|
`;
|
|
2585
2596
|
}
|
|
2586
2597
|
blockquote({
|
|
@@ -2595,6 +2606,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2595
2606
|
}) {
|
|
2596
2607
|
return e;
|
|
2597
2608
|
}
|
|
2609
|
+
def(e) {
|
|
2610
|
+
return "";
|
|
2611
|
+
}
|
|
2598
2612
|
heading({
|
|
2599
2613
|
tokens: e,
|
|
2600
2614
|
depth: t
|
|
@@ -2609,15 +2623,15 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2609
2623
|
list(e) {
|
|
2610
2624
|
let t = e.ordered,
|
|
2611
2625
|
n = e.start,
|
|
2612
|
-
|
|
2626
|
+
r = "";
|
|
2613
2627
|
for (let o = 0; o < e.items.length; o++) {
|
|
2614
|
-
let
|
|
2615
|
-
|
|
2628
|
+
let a = e.items[o];
|
|
2629
|
+
r += this.listitem(a);
|
|
2616
2630
|
}
|
|
2617
2631
|
let i = t ? "ol" : "ul",
|
|
2618
|
-
|
|
2619
|
-
return "<" + i +
|
|
2620
|
-
` +
|
|
2632
|
+
s = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
2633
|
+
return "<" + i + s + `>
|
|
2634
|
+
` + r + "</" + i + `>
|
|
2621
2635
|
`;
|
|
2622
2636
|
}
|
|
2623
2637
|
listitem(e) {
|
|
@@ -2626,7 +2640,7 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2626
2640
|
let n = this.checkbox({
|
|
2627
2641
|
checked: !!e.checked
|
|
2628
2642
|
});
|
|
2629
|
-
e.loose ? e.tokens[0]?.type === "paragraph" ? (e.tokens[0].text = n + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = n + " " +
|
|
2643
|
+
e.loose ? e.tokens[0]?.type === "paragraph" ? (e.tokens[0].text = n + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = n + " " + w(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = true)) : e.tokens.unshift({
|
|
2630
2644
|
type: "text",
|
|
2631
2645
|
raw: n + " ",
|
|
2632
2646
|
text: n + " ",
|
|
@@ -2654,19 +2668,19 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2654
2668
|
t += this.tablerow({
|
|
2655
2669
|
text: n
|
|
2656
2670
|
});
|
|
2657
|
-
let
|
|
2671
|
+
let r = "";
|
|
2658
2672
|
for (let i = 0; i < e.rows.length; i++) {
|
|
2659
|
-
let
|
|
2673
|
+
let s = e.rows[i];
|
|
2660
2674
|
n = "";
|
|
2661
|
-
for (let o = 0; o <
|
|
2662
|
-
|
|
2675
|
+
for (let o = 0; o < s.length; o++) n += this.tablecell(s[o]);
|
|
2676
|
+
r += this.tablerow({
|
|
2663
2677
|
text: n
|
|
2664
2678
|
});
|
|
2665
2679
|
}
|
|
2666
|
-
return
|
|
2680
|
+
return r && (r = `<tbody>${r}</tbody>`), `<table>
|
|
2667
2681
|
<thead>
|
|
2668
2682
|
` + t + `</thead>
|
|
2669
|
-
` +
|
|
2683
|
+
` + r + `</table>
|
|
2670
2684
|
`;
|
|
2671
2685
|
}
|
|
2672
2686
|
tablerow({
|
|
@@ -2695,7 +2709,7 @@ ${e}</tr>
|
|
|
2695
2709
|
codespan({
|
|
2696
2710
|
text: e
|
|
2697
2711
|
}) {
|
|
2698
|
-
return `<code>${
|
|
2712
|
+
return `<code>${w(e, true)}</code>`;
|
|
2699
2713
|
}
|
|
2700
2714
|
br(e) {
|
|
2701
2715
|
return "<br>";
|
|
@@ -2710,31 +2724,31 @@ ${e}</tr>
|
|
|
2710
2724
|
title: t,
|
|
2711
2725
|
tokens: n
|
|
2712
2726
|
}) {
|
|
2713
|
-
let
|
|
2727
|
+
let r = this.parser.parseInline(n),
|
|
2714
2728
|
i = J(e);
|
|
2715
|
-
if (i === null) return
|
|
2729
|
+
if (i === null) return r;
|
|
2716
2730
|
e = i;
|
|
2717
|
-
let
|
|
2718
|
-
return t && (
|
|
2731
|
+
let s = '<a href="' + e + '"';
|
|
2732
|
+
return t && (s += ' title="' + w(t) + '"'), s += ">" + r + "</a>", s;
|
|
2719
2733
|
}
|
|
2720
2734
|
image({
|
|
2721
2735
|
href: e,
|
|
2722
2736
|
title: t,
|
|
2723
2737
|
text: n,
|
|
2724
|
-
tokens:
|
|
2738
|
+
tokens: r
|
|
2725
2739
|
}) {
|
|
2726
|
-
|
|
2740
|
+
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
2727
2741
|
let i = J(e);
|
|
2728
|
-
if (i === null) return
|
|
2742
|
+
if (i === null) return w(n);
|
|
2729
2743
|
e = i;
|
|
2730
|
-
let
|
|
2731
|
-
return t && (
|
|
2744
|
+
let s = `<img src="${e}" alt="${n}"`;
|
|
2745
|
+
return t && (s += ` title="${w(t)}"`), s += ">", s;
|
|
2732
2746
|
}
|
|
2733
2747
|
text(e) {
|
|
2734
|
-
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text :
|
|
2748
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : w(e.text);
|
|
2735
2749
|
}
|
|
2736
2750
|
};
|
|
2737
|
-
var
|
|
2751
|
+
var S = class {
|
|
2738
2752
|
strong({
|
|
2739
2753
|
text: e
|
|
2740
2754
|
}) {
|
|
@@ -2779,102 +2793,107 @@ var _ = class {
|
|
|
2779
2793
|
return "";
|
|
2780
2794
|
}
|
|
2781
2795
|
};
|
|
2782
|
-
var
|
|
2796
|
+
var R = class l {
|
|
2783
2797
|
options;
|
|
2784
2798
|
renderer;
|
|
2785
2799
|
textRenderer;
|
|
2786
2800
|
constructor(e) {
|
|
2787
|
-
this.options = e ||
|
|
2801
|
+
this.options = e || O, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new S();
|
|
2788
2802
|
}
|
|
2789
2803
|
static parse(e, t) {
|
|
2790
|
-
return new
|
|
2804
|
+
return new l(t).parse(e);
|
|
2791
2805
|
}
|
|
2792
2806
|
static parseInline(e, t) {
|
|
2793
|
-
return new
|
|
2807
|
+
return new l(t).parseInline(e);
|
|
2794
2808
|
}
|
|
2795
2809
|
parse(e, t = true) {
|
|
2796
2810
|
let n = "";
|
|
2797
|
-
for (let
|
|
2798
|
-
let i = e[
|
|
2811
|
+
for (let r = 0; r < e.length; r++) {
|
|
2812
|
+
let i = e[r];
|
|
2799
2813
|
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2800
2814
|
let o = i,
|
|
2801
|
-
|
|
2815
|
+
a = this.options.extensions.renderers[o.type].call({
|
|
2802
2816
|
parser: this
|
|
2803
2817
|
}, o);
|
|
2804
|
-
if (
|
|
2805
|
-
n +=
|
|
2818
|
+
if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(o.type)) {
|
|
2819
|
+
n += a || "";
|
|
2806
2820
|
continue;
|
|
2807
2821
|
}
|
|
2808
2822
|
}
|
|
2809
|
-
let
|
|
2810
|
-
switch (
|
|
2823
|
+
let s = i;
|
|
2824
|
+
switch (s.type) {
|
|
2811
2825
|
case "space":
|
|
2812
2826
|
{
|
|
2813
|
-
n += this.renderer.space(
|
|
2827
|
+
n += this.renderer.space(s);
|
|
2814
2828
|
continue;
|
|
2815
2829
|
}
|
|
2816
2830
|
case "hr":
|
|
2817
2831
|
{
|
|
2818
|
-
n += this.renderer.hr(
|
|
2832
|
+
n += this.renderer.hr(s);
|
|
2819
2833
|
continue;
|
|
2820
2834
|
}
|
|
2821
2835
|
case "heading":
|
|
2822
2836
|
{
|
|
2823
|
-
n += this.renderer.heading(
|
|
2837
|
+
n += this.renderer.heading(s);
|
|
2824
2838
|
continue;
|
|
2825
2839
|
}
|
|
2826
2840
|
case "code":
|
|
2827
2841
|
{
|
|
2828
|
-
n += this.renderer.code(
|
|
2842
|
+
n += this.renderer.code(s);
|
|
2829
2843
|
continue;
|
|
2830
2844
|
}
|
|
2831
2845
|
case "table":
|
|
2832
2846
|
{
|
|
2833
|
-
n += this.renderer.table(
|
|
2847
|
+
n += this.renderer.table(s);
|
|
2834
2848
|
continue;
|
|
2835
2849
|
}
|
|
2836
2850
|
case "blockquote":
|
|
2837
2851
|
{
|
|
2838
|
-
n += this.renderer.blockquote(
|
|
2852
|
+
n += this.renderer.blockquote(s);
|
|
2839
2853
|
continue;
|
|
2840
2854
|
}
|
|
2841
2855
|
case "list":
|
|
2842
2856
|
{
|
|
2843
|
-
n += this.renderer.list(
|
|
2857
|
+
n += this.renderer.list(s);
|
|
2844
2858
|
continue;
|
|
2845
2859
|
}
|
|
2846
2860
|
case "html":
|
|
2847
2861
|
{
|
|
2848
|
-
n += this.renderer.html(
|
|
2862
|
+
n += this.renderer.html(s);
|
|
2863
|
+
continue;
|
|
2864
|
+
}
|
|
2865
|
+
case "def":
|
|
2866
|
+
{
|
|
2867
|
+
n += this.renderer.def(s);
|
|
2849
2868
|
continue;
|
|
2850
2869
|
}
|
|
2851
2870
|
case "paragraph":
|
|
2852
2871
|
{
|
|
2853
|
-
n += this.renderer.paragraph(
|
|
2872
|
+
n += this.renderer.paragraph(s);
|
|
2854
2873
|
continue;
|
|
2855
2874
|
}
|
|
2856
2875
|
case "text":
|
|
2857
2876
|
{
|
|
2858
|
-
let o =
|
|
2859
|
-
|
|
2860
|
-
for (;
|
|
2877
|
+
let o = s,
|
|
2878
|
+
a = this.renderer.text(o);
|
|
2879
|
+
for (; r + 1 < e.length && e[r + 1].type === "text";) o = e[++r], a += `
|
|
2861
2880
|
` + this.renderer.text(o);
|
|
2862
2881
|
t ? n += this.renderer.paragraph({
|
|
2863
2882
|
type: "paragraph",
|
|
2864
|
-
raw:
|
|
2865
|
-
text:
|
|
2883
|
+
raw: a,
|
|
2884
|
+
text: a,
|
|
2866
2885
|
tokens: [{
|
|
2867
2886
|
type: "text",
|
|
2868
|
-
raw:
|
|
2869
|
-
text:
|
|
2887
|
+
raw: a,
|
|
2888
|
+
text: a,
|
|
2870
2889
|
escaped: true
|
|
2871
2890
|
}]
|
|
2872
|
-
}) : n +=
|
|
2891
|
+
}) : n += a;
|
|
2873
2892
|
continue;
|
|
2874
2893
|
}
|
|
2875
2894
|
default:
|
|
2876
2895
|
{
|
|
2877
|
-
let o = 'Token with "' +
|
|
2896
|
+
let o = 'Token with "' + s.type + '" type was not found.';
|
|
2878
2897
|
if (this.options.silent) return console.error(o), "";
|
|
2879
2898
|
throw new Error(o);
|
|
2880
2899
|
}
|
|
@@ -2884,8 +2903,8 @@ var T = class a {
|
|
|
2884
2903
|
}
|
|
2885
2904
|
parseInline(e, t = this.renderer) {
|
|
2886
2905
|
let n = "";
|
|
2887
|
-
for (let
|
|
2888
|
-
let i = e[
|
|
2906
|
+
for (let r = 0; r < e.length; r++) {
|
|
2907
|
+
let i = e[r];
|
|
2889
2908
|
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2890
2909
|
let o = this.options.extensions.renderers[i.type].call({
|
|
2891
2910
|
parser: this
|
|
@@ -2895,61 +2914,61 @@ var T = class a {
|
|
|
2895
2914
|
continue;
|
|
2896
2915
|
}
|
|
2897
2916
|
}
|
|
2898
|
-
let
|
|
2899
|
-
switch (
|
|
2917
|
+
let s = i;
|
|
2918
|
+
switch (s.type) {
|
|
2900
2919
|
case "escape":
|
|
2901
2920
|
{
|
|
2902
|
-
n += t.text(
|
|
2921
|
+
n += t.text(s);
|
|
2903
2922
|
break;
|
|
2904
2923
|
}
|
|
2905
2924
|
case "html":
|
|
2906
2925
|
{
|
|
2907
|
-
n += t.html(
|
|
2926
|
+
n += t.html(s);
|
|
2908
2927
|
break;
|
|
2909
2928
|
}
|
|
2910
2929
|
case "link":
|
|
2911
2930
|
{
|
|
2912
|
-
n += t.link(
|
|
2931
|
+
n += t.link(s);
|
|
2913
2932
|
break;
|
|
2914
2933
|
}
|
|
2915
2934
|
case "image":
|
|
2916
2935
|
{
|
|
2917
|
-
n += t.image(
|
|
2936
|
+
n += t.image(s);
|
|
2918
2937
|
break;
|
|
2919
2938
|
}
|
|
2920
2939
|
case "strong":
|
|
2921
2940
|
{
|
|
2922
|
-
n += t.strong(
|
|
2941
|
+
n += t.strong(s);
|
|
2923
2942
|
break;
|
|
2924
2943
|
}
|
|
2925
2944
|
case "em":
|
|
2926
2945
|
{
|
|
2927
|
-
n += t.em(
|
|
2946
|
+
n += t.em(s);
|
|
2928
2947
|
break;
|
|
2929
2948
|
}
|
|
2930
2949
|
case "codespan":
|
|
2931
2950
|
{
|
|
2932
|
-
n += t.codespan(
|
|
2951
|
+
n += t.codespan(s);
|
|
2933
2952
|
break;
|
|
2934
2953
|
}
|
|
2935
2954
|
case "br":
|
|
2936
2955
|
{
|
|
2937
|
-
n += t.br(
|
|
2956
|
+
n += t.br(s);
|
|
2938
2957
|
break;
|
|
2939
2958
|
}
|
|
2940
2959
|
case "del":
|
|
2941
2960
|
{
|
|
2942
|
-
n += t.del(
|
|
2961
|
+
n += t.del(s);
|
|
2943
2962
|
break;
|
|
2944
2963
|
}
|
|
2945
2964
|
case "text":
|
|
2946
2965
|
{
|
|
2947
|
-
n += t.text(
|
|
2966
|
+
n += t.text(s);
|
|
2948
2967
|
break;
|
|
2949
2968
|
}
|
|
2950
2969
|
default:
|
|
2951
2970
|
{
|
|
2952
|
-
let o = 'Token with "' +
|
|
2971
|
+
let o = 'Token with "' + s.type + '" type was not found.';
|
|
2953
2972
|
if (this.options.silent) return console.error(o), "";
|
|
2954
2973
|
throw new Error(o);
|
|
2955
2974
|
}
|
|
@@ -2958,11 +2977,11 @@ var T = class a {
|
|
|
2958
2977
|
return n;
|
|
2959
2978
|
}
|
|
2960
2979
|
};
|
|
2961
|
-
var
|
|
2980
|
+
var $ = class {
|
|
2962
2981
|
options;
|
|
2963
2982
|
block;
|
|
2964
2983
|
constructor(e) {
|
|
2965
|
-
this.options = e ||
|
|
2984
|
+
this.options = e || O;
|
|
2966
2985
|
}
|
|
2967
2986
|
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2968
2987
|
preprocess(e) {
|
|
@@ -2978,44 +2997,44 @@ var L = class {
|
|
|
2978
2997
|
return this.block ? b.lex : b.lexInline;
|
|
2979
2998
|
}
|
|
2980
2999
|
provideParser() {
|
|
2981
|
-
return this.block ?
|
|
3000
|
+
return this.block ? R.parse : R.parseInline;
|
|
2982
3001
|
}
|
|
2983
3002
|
};
|
|
2984
3003
|
var B = class {
|
|
2985
|
-
defaults =
|
|
3004
|
+
defaults = L();
|
|
2986
3005
|
options = this.setOptions;
|
|
2987
3006
|
parse = this.parseMarkdown(true);
|
|
2988
3007
|
parseInline = this.parseMarkdown(false);
|
|
2989
|
-
Parser =
|
|
2990
|
-
Renderer =
|
|
2991
|
-
TextRenderer =
|
|
3008
|
+
Parser = R;
|
|
3009
|
+
Renderer = P;
|
|
3010
|
+
TextRenderer = S;
|
|
2992
3011
|
Lexer = b;
|
|
2993
|
-
Tokenizer =
|
|
2994
|
-
Hooks =
|
|
3012
|
+
Tokenizer = y;
|
|
3013
|
+
Hooks = $;
|
|
2995
3014
|
constructor(...e) {
|
|
2996
3015
|
this.use(...e);
|
|
2997
3016
|
}
|
|
2998
3017
|
walkTokens(e, t) {
|
|
2999
3018
|
let n = [];
|
|
3000
|
-
for (let
|
|
3019
|
+
for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
|
|
3001
3020
|
case "table":
|
|
3002
3021
|
{
|
|
3003
|
-
let i =
|
|
3004
|
-
for (let
|
|
3005
|
-
for (let
|
|
3022
|
+
let i = r;
|
|
3023
|
+
for (let s of i.header) n = n.concat(this.walkTokens(s.tokens, t));
|
|
3024
|
+
for (let s of i.rows) for (let o of s) n = n.concat(this.walkTokens(o.tokens, t));
|
|
3006
3025
|
break;
|
|
3007
3026
|
}
|
|
3008
3027
|
case "list":
|
|
3009
3028
|
{
|
|
3010
|
-
let i =
|
|
3029
|
+
let i = r;
|
|
3011
3030
|
n = n.concat(this.walkTokens(i.items, t));
|
|
3012
3031
|
break;
|
|
3013
3032
|
}
|
|
3014
3033
|
default:
|
|
3015
3034
|
{
|
|
3016
|
-
let i =
|
|
3017
|
-
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach(
|
|
3018
|
-
let o = i[
|
|
3035
|
+
let i = r;
|
|
3036
|
+
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach(s => {
|
|
3037
|
+
let o = i[s].flat(1 / 0);
|
|
3019
3038
|
n = n.concat(this.walkTokens(o, t));
|
|
3020
3039
|
}) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
|
|
3021
3040
|
}
|
|
@@ -3028,84 +3047,84 @@ var B = class {
|
|
|
3028
3047
|
childTokens: {}
|
|
3029
3048
|
};
|
|
3030
3049
|
return e.forEach(n => {
|
|
3031
|
-
let
|
|
3050
|
+
let r = {
|
|
3032
3051
|
...n
|
|
3033
3052
|
};
|
|
3034
|
-
if (
|
|
3053
|
+
if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach(i => {
|
|
3035
3054
|
if (!i.name) throw new Error("extension name required");
|
|
3036
3055
|
if ("renderer" in i) {
|
|
3037
|
-
let
|
|
3038
|
-
|
|
3039
|
-
let
|
|
3040
|
-
return
|
|
3056
|
+
let s = t.renderers[i.name];
|
|
3057
|
+
s ? t.renderers[i.name] = function (...o) {
|
|
3058
|
+
let a = i.renderer.apply(this, o);
|
|
3059
|
+
return a === false && (a = s.apply(this, o)), a;
|
|
3041
3060
|
} : t.renderers[i.name] = i.renderer;
|
|
3042
3061
|
}
|
|
3043
3062
|
if ("tokenizer" in i) {
|
|
3044
3063
|
if (!i.level || i.level !== "block" && i.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
3045
|
-
let
|
|
3046
|
-
|
|
3064
|
+
let s = t[i.level];
|
|
3065
|
+
s ? s.unshift(i.tokenizer) : t[i.level] = [i.tokenizer], i.start && (i.level === "block" ? t.startBlock ? t.startBlock.push(i.start) : t.startBlock = [i.start] : i.level === "inline" && (t.startInline ? t.startInline.push(i.start) : t.startInline = [i.start]));
|
|
3047
3066
|
}
|
|
3048
3067
|
"childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
|
|
3049
|
-
}),
|
|
3050
|
-
let i = this.defaults.renderer || new
|
|
3051
|
-
for (let
|
|
3052
|
-
if (!(
|
|
3053
|
-
if (["options", "parser"].includes(
|
|
3054
|
-
let o =
|
|
3055
|
-
|
|
3056
|
-
|
|
3068
|
+
}), r.extensions = t), n.renderer) {
|
|
3069
|
+
let i = this.defaults.renderer || new P(this.defaults);
|
|
3070
|
+
for (let s in n.renderer) {
|
|
3071
|
+
if (!(s in i)) throw new Error(`renderer '${s}' does not exist`);
|
|
3072
|
+
if (["options", "parser"].includes(s)) continue;
|
|
3073
|
+
let o = s,
|
|
3074
|
+
a = n.renderer[o],
|
|
3075
|
+
u = i[o];
|
|
3057
3076
|
i[o] = (...p) => {
|
|
3058
|
-
let
|
|
3059
|
-
return
|
|
3077
|
+
let c = a.apply(i, p);
|
|
3078
|
+
return c === false && (c = u.apply(i, p)), c || "";
|
|
3060
3079
|
};
|
|
3061
3080
|
}
|
|
3062
|
-
|
|
3081
|
+
r.renderer = i;
|
|
3063
3082
|
}
|
|
3064
3083
|
if (n.tokenizer) {
|
|
3065
|
-
let i = this.defaults.tokenizer || new
|
|
3066
|
-
for (let
|
|
3067
|
-
if (!(
|
|
3068
|
-
if (["options", "rules", "lexer"].includes(
|
|
3069
|
-
let o =
|
|
3070
|
-
|
|
3071
|
-
|
|
3084
|
+
let i = this.defaults.tokenizer || new y(this.defaults);
|
|
3085
|
+
for (let s in n.tokenizer) {
|
|
3086
|
+
if (!(s in i)) throw new Error(`tokenizer '${s}' does not exist`);
|
|
3087
|
+
if (["options", "rules", "lexer"].includes(s)) continue;
|
|
3088
|
+
let o = s,
|
|
3089
|
+
a = n.tokenizer[o],
|
|
3090
|
+
u = i[o];
|
|
3072
3091
|
i[o] = (...p) => {
|
|
3073
|
-
let
|
|
3074
|
-
return
|
|
3092
|
+
let c = a.apply(i, p);
|
|
3093
|
+
return c === false && (c = u.apply(i, p)), c;
|
|
3075
3094
|
};
|
|
3076
3095
|
}
|
|
3077
|
-
|
|
3096
|
+
r.tokenizer = i;
|
|
3078
3097
|
}
|
|
3079
3098
|
if (n.hooks) {
|
|
3080
|
-
let i = this.defaults.hooks || new
|
|
3081
|
-
for (let
|
|
3082
|
-
if (!(
|
|
3083
|
-
if (["options", "block"].includes(
|
|
3084
|
-
let o =
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
if (this.defaults.async) return Promise.resolve(
|
|
3089
|
-
let
|
|
3090
|
-
return
|
|
3099
|
+
let i = this.defaults.hooks || new $();
|
|
3100
|
+
for (let s in n.hooks) {
|
|
3101
|
+
if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
|
|
3102
|
+
if (["options", "block"].includes(s)) continue;
|
|
3103
|
+
let o = s,
|
|
3104
|
+
a = n.hooks[o],
|
|
3105
|
+
u = i[o];
|
|
3106
|
+
$.passThroughHooks.has(s) ? i[o] = p => {
|
|
3107
|
+
if (this.defaults.async) return Promise.resolve(a.call(i, p)).then(f => u.call(i, f));
|
|
3108
|
+
let c = a.call(i, p);
|
|
3109
|
+
return u.call(i, c);
|
|
3091
3110
|
} : i[o] = (...p) => {
|
|
3092
|
-
let
|
|
3093
|
-
return
|
|
3111
|
+
let c = a.apply(i, p);
|
|
3112
|
+
return c === false && (c = u.apply(i, p)), c;
|
|
3094
3113
|
};
|
|
3095
3114
|
}
|
|
3096
|
-
|
|
3115
|
+
r.hooks = i;
|
|
3097
3116
|
}
|
|
3098
3117
|
if (n.walkTokens) {
|
|
3099
3118
|
let i = this.defaults.walkTokens,
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
let
|
|
3103
|
-
return
|
|
3119
|
+
s = n.walkTokens;
|
|
3120
|
+
r.walkTokens = function (o) {
|
|
3121
|
+
let a = [];
|
|
3122
|
+
return a.push(s.call(this, o)), i && (a = a.concat(i.call(this, o))), a;
|
|
3104
3123
|
};
|
|
3105
3124
|
}
|
|
3106
3125
|
this.defaults = {
|
|
3107
3126
|
...this.defaults,
|
|
3108
|
-
...
|
|
3127
|
+
...r
|
|
3109
3128
|
};
|
|
3110
3129
|
}), this;
|
|
3111
3130
|
}
|
|
@@ -3119,31 +3138,31 @@ var B = class {
|
|
|
3119
3138
|
return b.lex(e, t ?? this.defaults);
|
|
3120
3139
|
}
|
|
3121
3140
|
parser(e, t) {
|
|
3122
|
-
return
|
|
3141
|
+
return R.parse(e, t ?? this.defaults);
|
|
3123
3142
|
}
|
|
3124
3143
|
parseMarkdown(e) {
|
|
3125
|
-
return (n,
|
|
3144
|
+
return (n, r) => {
|
|
3126
3145
|
let i = {
|
|
3127
|
-
...
|
|
3146
|
+
...r
|
|
3128
3147
|
},
|
|
3129
|
-
|
|
3148
|
+
s = {
|
|
3130
3149
|
...this.defaults,
|
|
3131
3150
|
...i
|
|
3132
3151
|
},
|
|
3133
|
-
o = this.onError(!!
|
|
3152
|
+
o = this.onError(!!s.silent, !!s.async);
|
|
3134
3153
|
if (this.defaults.async === true && i.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
3135
3154
|
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
3136
3155
|
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
3137
|
-
|
|
3138
|
-
let
|
|
3139
|
-
|
|
3140
|
-
if (
|
|
3156
|
+
s.hooks && (s.hooks.options = s, s.hooks.block = e);
|
|
3157
|
+
let a = s.hooks ? s.hooks.provideLexer() : e ? b.lex : b.lexInline,
|
|
3158
|
+
u = s.hooks ? s.hooks.provideParser() : e ? R.parse : R.parseInline;
|
|
3159
|
+
if (s.async) return Promise.resolve(s.hooks ? s.hooks.preprocess(n) : n).then(p => a(p, s)).then(p => s.hooks ? s.hooks.processAllTokens(p) : p).then(p => s.walkTokens ? Promise.all(this.walkTokens(p, s.walkTokens)).then(() => p) : p).then(p => u(p, s)).then(p => s.hooks ? s.hooks.postprocess(p) : p).catch(o);
|
|
3141
3160
|
try {
|
|
3142
|
-
|
|
3143
|
-
let p =
|
|
3144
|
-
|
|
3145
|
-
let
|
|
3146
|
-
return
|
|
3161
|
+
s.hooks && (n = s.hooks.preprocess(n));
|
|
3162
|
+
let p = a(n, s);
|
|
3163
|
+
s.hooks && (p = s.hooks.processAllTokens(p)), s.walkTokens && this.walkTokens(p, s.walkTokens);
|
|
3164
|
+
let c = u(p, s);
|
|
3165
|
+
return s.hooks && (c = s.hooks.postprocess(c)), c;
|
|
3147
3166
|
} catch (p) {
|
|
3148
3167
|
return o(p);
|
|
3149
3168
|
}
|
|
@@ -3153,42 +3172,42 @@ var B = class {
|
|
|
3153
3172
|
return n => {
|
|
3154
3173
|
if (n.message += `
|
|
3155
3174
|
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
3156
|
-
let
|
|
3157
|
-
return t ? Promise.resolve(
|
|
3175
|
+
let r = "<p>An error occurred:</p><pre>" + w(n.message + "", true) + "</pre>";
|
|
3176
|
+
return t ? Promise.resolve(r) : r;
|
|
3158
3177
|
}
|
|
3159
3178
|
if (t) return Promise.reject(n);
|
|
3160
3179
|
throw n;
|
|
3161
3180
|
};
|
|
3162
3181
|
}
|
|
3163
3182
|
};
|
|
3164
|
-
var
|
|
3165
|
-
function
|
|
3166
|
-
return
|
|
3183
|
+
var _ = new B();
|
|
3184
|
+
function d(l, e) {
|
|
3185
|
+
return _.parse(l, e);
|
|
3167
3186
|
}
|
|
3168
|
-
|
|
3169
|
-
return
|
|
3170
|
-
};
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
return
|
|
3175
|
-
};
|
|
3176
|
-
|
|
3177
|
-
return
|
|
3178
|
-
};
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3187
|
+
d.options = d.setOptions = function (l) {
|
|
3188
|
+
return _.setOptions(l), d.defaults = _.defaults, H(d.defaults), d;
|
|
3189
|
+
};
|
|
3190
|
+
d.getDefaults = L;
|
|
3191
|
+
d.defaults = O;
|
|
3192
|
+
d.use = function (...l) {
|
|
3193
|
+
return _.use(...l), d.defaults = _.defaults, H(d.defaults), d;
|
|
3194
|
+
};
|
|
3195
|
+
d.walkTokens = function (l, e) {
|
|
3196
|
+
return _.walkTokens(l, e);
|
|
3197
|
+
};
|
|
3198
|
+
d.parseInline = _.parseInline;
|
|
3199
|
+
d.Parser = R;
|
|
3200
|
+
d.parser = R.parse;
|
|
3201
|
+
d.Renderer = P;
|
|
3202
|
+
d.TextRenderer = S;
|
|
3203
|
+
d.Lexer = b;
|
|
3204
|
+
d.lexer = b.lex;
|
|
3205
|
+
d.Tokenizer = y;
|
|
3206
|
+
d.Hooks = $;
|
|
3207
|
+
d.parse = d;
|
|
3189
3208
|
|
|
3190
3209
|
const renderMarkdown = async (markdown, options = {}) => {
|
|
3191
|
-
const html = await
|
|
3210
|
+
const html = await d(markdown, {});
|
|
3192
3211
|
return html;
|
|
3193
3212
|
};
|
|
3194
3213
|
|