@lvce-editor/markdown-worker 1.6.0 → 1.8.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 +677 -548
- package/package.json +1 -1
|
@@ -60,37 +60,45 @@ class AssertionError extends Error {
|
|
|
60
60
|
this.name = 'AssertionError';
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
const Object$1 = 1;
|
|
64
|
+
const Number = 2;
|
|
65
|
+
const Array$1 = 3;
|
|
66
|
+
const String = 4;
|
|
67
|
+
const Boolean = 5;
|
|
68
|
+
const Function = 6;
|
|
69
|
+
const Null = 7;
|
|
70
|
+
const Unknown = 8;
|
|
63
71
|
const getType = value => {
|
|
64
72
|
switch (typeof value) {
|
|
65
73
|
case 'number':
|
|
66
|
-
return
|
|
74
|
+
return Number;
|
|
67
75
|
case 'function':
|
|
68
|
-
return
|
|
76
|
+
return Function;
|
|
69
77
|
case 'string':
|
|
70
|
-
return
|
|
78
|
+
return String;
|
|
71
79
|
case 'object':
|
|
72
80
|
if (value === null) {
|
|
73
|
-
return
|
|
81
|
+
return Null;
|
|
74
82
|
}
|
|
75
83
|
if (Array.isArray(value)) {
|
|
76
|
-
return
|
|
84
|
+
return Array$1;
|
|
77
85
|
}
|
|
78
|
-
return
|
|
86
|
+
return Object$1;
|
|
79
87
|
case 'boolean':
|
|
80
|
-
return
|
|
88
|
+
return Boolean;
|
|
81
89
|
default:
|
|
82
|
-
return
|
|
90
|
+
return Unknown;
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
const array = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
95
|
+
if (type !== Array$1) {
|
|
88
96
|
throw new AssertionError('expected value to be of type array');
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
const string = value => {
|
|
92
100
|
const type = getType(value);
|
|
93
|
-
if (type !==
|
|
101
|
+
if (type !== String) {
|
|
94
102
|
throw new AssertionError('expected value to be of type string');
|
|
95
103
|
}
|
|
96
104
|
};
|
|
@@ -409,6 +417,100 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
409
417
|
listen: listen$6,
|
|
410
418
|
wrap: wrap$e
|
|
411
419
|
};
|
|
420
|
+
const addListener = (emitter, type, callback) => {
|
|
421
|
+
if ('addEventListener' in emitter) {
|
|
422
|
+
emitter.addEventListener(type, callback);
|
|
423
|
+
} else {
|
|
424
|
+
emitter.on(type, callback);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const removeListener = (emitter, type, callback) => {
|
|
428
|
+
if ('removeEventListener' in emitter) {
|
|
429
|
+
emitter.removeEventListener(type, callback);
|
|
430
|
+
} else {
|
|
431
|
+
emitter.off(type, callback);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
435
|
+
const {
|
|
436
|
+
resolve,
|
|
437
|
+
promise
|
|
438
|
+
} = Promise.withResolvers();
|
|
439
|
+
const listenerMap = Object.create(null);
|
|
440
|
+
const cleanup = value => {
|
|
441
|
+
for (const event of Object.keys(eventMap)) {
|
|
442
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
443
|
+
}
|
|
444
|
+
resolve(value);
|
|
445
|
+
};
|
|
446
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
447
|
+
const listener = event => {
|
|
448
|
+
cleanup({
|
|
449
|
+
type,
|
|
450
|
+
event
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
addListener(eventEmitter, event, listener);
|
|
454
|
+
listenerMap[event] = listener;
|
|
455
|
+
}
|
|
456
|
+
return promise;
|
|
457
|
+
};
|
|
458
|
+
const Message$1 = 3;
|
|
459
|
+
const create$5$1 = async ({
|
|
460
|
+
messagePort,
|
|
461
|
+
isMessagePortOpen
|
|
462
|
+
}) => {
|
|
463
|
+
if (!isMessagePort(messagePort)) {
|
|
464
|
+
throw new IpcError('port must be of type MessagePort');
|
|
465
|
+
}
|
|
466
|
+
if (isMessagePortOpen) {
|
|
467
|
+
return messagePort;
|
|
468
|
+
}
|
|
469
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
470
|
+
message: Message$1
|
|
471
|
+
});
|
|
472
|
+
messagePort.start();
|
|
473
|
+
const {
|
|
474
|
+
type,
|
|
475
|
+
event
|
|
476
|
+
} = await eventPromise;
|
|
477
|
+
if (type !== Message$1) {
|
|
478
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
479
|
+
}
|
|
480
|
+
if (event.data !== readyMessage) {
|
|
481
|
+
throw new IpcError('unexpected first message');
|
|
482
|
+
}
|
|
483
|
+
return messagePort;
|
|
484
|
+
};
|
|
485
|
+
const signal$1 = messagePort => {
|
|
486
|
+
messagePort.start();
|
|
487
|
+
};
|
|
488
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
489
|
+
getData = getData$2;
|
|
490
|
+
send(message) {
|
|
491
|
+
this._rawIpc.postMessage(message);
|
|
492
|
+
}
|
|
493
|
+
sendAndTransfer(message) {
|
|
494
|
+
const transfer = getTransferrables(message);
|
|
495
|
+
this._rawIpc.postMessage(message, transfer);
|
|
496
|
+
}
|
|
497
|
+
dispose() {
|
|
498
|
+
this._rawIpc.close();
|
|
499
|
+
}
|
|
500
|
+
onMessage(callback) {
|
|
501
|
+
this._rawIpc.addEventListener('message', callback);
|
|
502
|
+
}
|
|
503
|
+
onClose(callback) {}
|
|
504
|
+
}
|
|
505
|
+
const wrap$5 = messagePort => {
|
|
506
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
507
|
+
};
|
|
508
|
+
const IpcParentWithMessagePort$1 = {
|
|
509
|
+
__proto__: null,
|
|
510
|
+
create: create$5$1,
|
|
511
|
+
signal: signal$1,
|
|
512
|
+
wrap: wrap$5
|
|
513
|
+
};
|
|
412
514
|
|
|
413
515
|
const Two = '2.0';
|
|
414
516
|
const create$4 = (method, params) => {
|
|
@@ -665,7 +767,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
665
767
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
666
768
|
return create$1$1(id, errorProperty);
|
|
667
769
|
};
|
|
668
|
-
const create$
|
|
770
|
+
const create$6 = (message, result) => {
|
|
669
771
|
return {
|
|
670
772
|
jsonrpc: Two,
|
|
671
773
|
id: message.id,
|
|
@@ -674,7 +776,7 @@ const create$5 = (message, result) => {
|
|
|
674
776
|
};
|
|
675
777
|
const getSuccessResponse = (message, result) => {
|
|
676
778
|
const resultProperty = result ?? null;
|
|
677
|
-
return create$
|
|
779
|
+
return create$6(message, resultProperty);
|
|
678
780
|
};
|
|
679
781
|
const getErrorResponseSimple = (id, error) => {
|
|
680
782
|
return {
|
|
@@ -856,6 +958,26 @@ const listen$1 = async (module, options) => {
|
|
|
856
958
|
const ipc = module.wrap(rawIpc);
|
|
857
959
|
return ipc;
|
|
858
960
|
};
|
|
961
|
+
const create$5 = async ({
|
|
962
|
+
commandMap,
|
|
963
|
+
messagePort
|
|
964
|
+
}) => {
|
|
965
|
+
// TODO create a commandMap per rpc instance
|
|
966
|
+
register(commandMap);
|
|
967
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
968
|
+
messagePort,
|
|
969
|
+
isMessagePortOpen: true
|
|
970
|
+
});
|
|
971
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
972
|
+
handleIpc(ipc);
|
|
973
|
+
const rpc = createRpc(ipc);
|
|
974
|
+
messagePort.start();
|
|
975
|
+
return rpc;
|
|
976
|
+
};
|
|
977
|
+
const PlainMessagePortRpc = {
|
|
978
|
+
__proto__: null,
|
|
979
|
+
create: create$5
|
|
980
|
+
};
|
|
859
981
|
const create$1 = async ({
|
|
860
982
|
commandMap
|
|
861
983
|
}) => {
|
|
@@ -871,6 +993,10 @@ const WebWorkerRpcClient = {
|
|
|
871
993
|
create: create$1
|
|
872
994
|
};
|
|
873
995
|
|
|
996
|
+
const terminate = () => {
|
|
997
|
+
globalThis.close();
|
|
998
|
+
};
|
|
999
|
+
|
|
874
1000
|
const Div$1 = 4;
|
|
875
1001
|
const H1$1 = 5;
|
|
876
1002
|
const Span$1 = 8;
|
|
@@ -896,7 +1022,7 @@ const Li$1 = 48;
|
|
|
896
1022
|
const Ol$1 = 49;
|
|
897
1023
|
const P$2 = 50;
|
|
898
1024
|
const Pre$1 = 51;
|
|
899
|
-
const A$
|
|
1025
|
+
const A$1 = 53;
|
|
900
1026
|
const Abbr$1 = 54;
|
|
901
1027
|
const Br$1 = 55;
|
|
902
1028
|
const Cite$1 = 56;
|
|
@@ -905,7 +1031,7 @@ const Time$1 = 58;
|
|
|
905
1031
|
const Tfoot$1 = 59;
|
|
906
1032
|
const VirtualDomElements = {
|
|
907
1033
|
__proto__: null,
|
|
908
|
-
A: A$
|
|
1034
|
+
A: A$1,
|
|
909
1035
|
Abbr: Abbr$1,
|
|
910
1036
|
Article: Article$1,
|
|
911
1037
|
Aside: Aside$1,
|
|
@@ -989,7 +1115,7 @@ const Li = 'li';
|
|
|
989
1115
|
const Ol = 'ol';
|
|
990
1116
|
const P$1 = 'p';
|
|
991
1117
|
const Pre = 'pre';
|
|
992
|
-
const A
|
|
1118
|
+
const A = 'a';
|
|
993
1119
|
const Abbr = 'abbr';
|
|
994
1120
|
const Br = 'br';
|
|
995
1121
|
const Cite = 'cite';
|
|
@@ -1043,7 +1169,7 @@ const getVirtualDomTag = text => {
|
|
|
1043
1169
|
return VirtualDomElements.P;
|
|
1044
1170
|
case Pre:
|
|
1045
1171
|
return VirtualDomElements.Pre;
|
|
1046
|
-
case A
|
|
1172
|
+
case A:
|
|
1047
1173
|
return VirtualDomElements.A;
|
|
1048
1174
|
case Abbr:
|
|
1049
1175
|
return VirtualDomElements.Abbr;
|
|
@@ -1419,8 +1545,15 @@ const getMarkdownVirtualDom = html => {
|
|
|
1419
1545
|
}, ...childDom];
|
|
1420
1546
|
};
|
|
1421
1547
|
|
|
1548
|
+
const handleMessagePort = async (port, rpcId) => {
|
|
1549
|
+
await PlainMessagePortRpc.create({
|
|
1550
|
+
commandMap: {},
|
|
1551
|
+
messagePort: port
|
|
1552
|
+
});
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1422
1555
|
/**
|
|
1423
|
-
* marked v16.
|
|
1556
|
+
* marked v16.1.1 - a markdown parser
|
|
1424
1557
|
* Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
|
|
1425
1558
|
* https://github.com/markedjs/marked
|
|
1426
1559
|
*/
|
|
@@ -1430,7 +1563,7 @@ const getMarkdownVirtualDom = html => {
|
|
|
1430
1563
|
* The code in this file is generated from files in ./src/
|
|
1431
1564
|
*/
|
|
1432
1565
|
|
|
1433
|
-
function
|
|
1566
|
+
function L() {
|
|
1434
1567
|
return {
|
|
1435
1568
|
async: false,
|
|
1436
1569
|
breaks: false,
|
|
@@ -1444,19 +1577,19 @@ function M() {
|
|
|
1444
1577
|
walkTokens: null
|
|
1445
1578
|
};
|
|
1446
1579
|
}
|
|
1447
|
-
var
|
|
1448
|
-
function H(
|
|
1449
|
-
|
|
1580
|
+
var O = L();
|
|
1581
|
+
function H(l) {
|
|
1582
|
+
O = l;
|
|
1450
1583
|
}
|
|
1451
|
-
var
|
|
1584
|
+
var E = {
|
|
1452
1585
|
exec: () => null
|
|
1453
1586
|
};
|
|
1454
|
-
function h(
|
|
1455
|
-
let t = typeof
|
|
1587
|
+
function h(l, e = "") {
|
|
1588
|
+
let t = typeof l == "string" ? l : l.source,
|
|
1456
1589
|
n = {
|
|
1457
|
-
replace: (
|
|
1458
|
-
let
|
|
1459
|
-
return
|
|
1590
|
+
replace: (r, i) => {
|
|
1591
|
+
let s = typeof i == "string" ? i : i.source;
|
|
1592
|
+
return s = s.replace(m.caret, "$1"), t = t.replace(r, s), n;
|
|
1460
1593
|
},
|
|
1461
1594
|
getRegex: () => new RegExp(t, e)
|
|
1462
1595
|
};
|
|
@@ -1513,83 +1646,83 @@ var m = {
|
|
|
1513
1646
|
spaceLine: /^ +$/gm,
|
|
1514
1647
|
notSpaceStart: /^\S*/,
|
|
1515
1648
|
endingNewline: /\n$/,
|
|
1516
|
-
listItemRegex:
|
|
1517
|
-
nextBulletRegex:
|
|
1518
|
-
hrRegex:
|
|
1519
|
-
fencesBeginRegex:
|
|
1520
|
-
headingBeginRegex:
|
|
1521
|
-
htmlBeginRegex:
|
|
1649
|
+
listItemRegex: l => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1650
|
+
nextBulletRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1651
|
+
hrRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
1652
|
+
fencesBeginRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`),
|
|
1653
|
+
headingBeginRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}#`),
|
|
1654
|
+
htmlBeginRegex: l => new RegExp(`^ {0,${Math.min(3, l - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
1522
1655
|
},
|
|
1523
1656
|
xe = /^(?:[ \t]*(?:\n|$))+/,
|
|
1524
1657
|
be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1658
|
+
Re = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1659
|
+
C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
1660
|
+
Oe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1528
1661
|
j = /(?:[*+-]|\d{1,9}[.)])/,
|
|
1529
|
-
|
|
1530
|
-
ie = h(
|
|
1531
|
-
|
|
1662
|
+
se = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1663
|
+
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(),
|
|
1664
|
+
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(),
|
|
1532
1665
|
F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
1533
|
-
|
|
1666
|
+
we = /^[^\n]+/,
|
|
1534
1667
|
Q = /(?!\s*\])(?:\\.|[^\[\]\\])+/,
|
|
1535
|
-
|
|
1536
|
-
|
|
1668
|
+
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(),
|
|
1669
|
+
Pe = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex(),
|
|
1537
1670
|
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",
|
|
1538
1671
|
U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/,
|
|
1539
|
-
|
|
1540
|
-
oe = h(F).replace("hr",
|
|
1541
|
-
|
|
1672
|
+
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(),
|
|
1673
|
+
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(),
|
|
1674
|
+
$e = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(),
|
|
1542
1675
|
K = {
|
|
1543
|
-
blockquote:
|
|
1676
|
+
blockquote: $e,
|
|
1544
1677
|
code: be,
|
|
1545
|
-
def:
|
|
1546
|
-
fences:
|
|
1547
|
-
heading:
|
|
1548
|
-
hr:
|
|
1549
|
-
html:
|
|
1678
|
+
def: ye,
|
|
1679
|
+
fences: Re,
|
|
1680
|
+
heading: Oe,
|
|
1681
|
+
hr: C,
|
|
1682
|
+
html: Se,
|
|
1550
1683
|
lheading: ie,
|
|
1551
|
-
list:
|
|
1684
|
+
list: Pe,
|
|
1552
1685
|
newline: xe,
|
|
1553
1686
|
paragraph: oe,
|
|
1554
|
-
table:
|
|
1555
|
-
text:
|
|
1687
|
+
table: E,
|
|
1688
|
+
text: we
|
|
1556
1689
|
},
|
|
1557
|
-
|
|
1558
|
-
|
|
1690
|
+
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(),
|
|
1691
|
+
_e = {
|
|
1559
1692
|
...K,
|
|
1560
|
-
lheading:
|
|
1561
|
-
table:
|
|
1562
|
-
paragraph: h(F).replace("hr",
|
|
1693
|
+
lheading: Te,
|
|
1694
|
+
table: re,
|
|
1695
|
+
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()
|
|
1563
1696
|
},
|
|
1564
|
-
|
|
1697
|
+
Le = {
|
|
1565
1698
|
...K,
|
|
1566
1699
|
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(),
|
|
1567
1700
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1568
1701
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1569
|
-
fences:
|
|
1702
|
+
fences: E,
|
|
1570
1703
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1571
|
-
paragraph: h(F).replace("hr",
|
|
1704
|
+
paragraph: h(F).replace("hr", C).replace("heading", ` *#{1,6} *[^
|
|
1572
1705
|
]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
1573
1706
|
},
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1707
|
+
Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1708
|
+
ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1709
|
+
ae = /^( {2,}|\\)\n(?!\s*$)/,
|
|
1710
|
+
Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1578
1711
|
D = /[\p{P}\p{S}]/u,
|
|
1579
1712
|
X = /[\s\p{P}\p{S}]/u,
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
Be = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,
|
|
1713
|
+
le = /[^\s\p{P}\p{S}]/u,
|
|
1714
|
+
Ee = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, X).getRegex(),
|
|
1715
|
+
ue = /(?!~)[\p{P}\p{S}]/u,
|
|
1716
|
+
Ce = /(?!~)[\s\p{P}\p{S}]/u,
|
|
1717
|
+
Ie = /(?:[^\s\p{P}\p{S}]|~)/u,
|
|
1718
|
+
Be = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,
|
|
1586
1719
|
pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,
|
|
1587
1720
|
qe = h(pe, "u").replace(/punct/g, D).getRegex(),
|
|
1588
|
-
ve = h(pe, "u").replace(/punct/g,
|
|
1589
|
-
|
|
1590
|
-
De = h(
|
|
1591
|
-
Ze = h(
|
|
1592
|
-
Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g,
|
|
1721
|
+
ve = h(pe, "u").replace(/punct/g, ue).getRegex(),
|
|
1722
|
+
ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",
|
|
1723
|
+
De = h(ce, "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, X).replace(/punct/g, D).getRegex(),
|
|
1724
|
+
Ze = h(ce, "gu").replace(/notPunctSpace/g, Ie).replace(/punctSpace/g, Ce).replace(/punct/g, ue).getRegex(),
|
|
1725
|
+
Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, le).replace(/punctSpace/g, X).replace(/punct/g, D).getRegex(),
|
|
1593
1726
|
He = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(),
|
|
1594
1727
|
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(),
|
|
1595
1728
|
je = h(U).replace("(?:-->|$)", "-->").getRegex(),
|
|
@@ -1597,28 +1730,28 @@ var m = {
|
|
|
1597
1730
|
q = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,
|
|
1598
1731
|
Qe = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),
|
|
1599
1732
|
he = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex(),
|
|
1600
|
-
|
|
1601
|
-
Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink",
|
|
1733
|
+
de = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex(),
|
|
1734
|
+
Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", de).getRegex(),
|
|
1602
1735
|
W = {
|
|
1603
|
-
_backpedal:
|
|
1736
|
+
_backpedal: E,
|
|
1604
1737
|
anyPunctuation: He,
|
|
1605
1738
|
autolink: Ne,
|
|
1606
1739
|
blockSkip: Be,
|
|
1607
|
-
br:
|
|
1608
|
-
code:
|
|
1609
|
-
del:
|
|
1740
|
+
br: ae,
|
|
1741
|
+
code: ze,
|
|
1742
|
+
del: E,
|
|
1610
1743
|
emStrongLDelim: qe,
|
|
1611
1744
|
emStrongRDelimAst: De,
|
|
1612
1745
|
emStrongRDelimUnd: Ge,
|
|
1613
|
-
escape:
|
|
1746
|
+
escape: Me,
|
|
1614
1747
|
link: Qe,
|
|
1615
|
-
nolink:
|
|
1616
|
-
punctuation:
|
|
1748
|
+
nolink: de,
|
|
1749
|
+
punctuation: Ee,
|
|
1617
1750
|
reflink: he,
|
|
1618
1751
|
reflinkSearch: Ue,
|
|
1619
1752
|
tag: Fe,
|
|
1620
|
-
text:
|
|
1621
|
-
url:
|
|
1753
|
+
text: Ae,
|
|
1754
|
+
url: E
|
|
1622
1755
|
},
|
|
1623
1756
|
Ke = {
|
|
1624
1757
|
...W,
|
|
@@ -1636,15 +1769,15 @@ var m = {
|
|
|
1636
1769
|
},
|
|
1637
1770
|
Xe = {
|
|
1638
1771
|
...N,
|
|
1639
|
-
br: h(
|
|
1772
|
+
br: h(ae).replace("{2,}", "*").getRegex(),
|
|
1640
1773
|
text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1641
1774
|
},
|
|
1642
|
-
|
|
1775
|
+
I = {
|
|
1643
1776
|
normal: K,
|
|
1644
|
-
gfm:
|
|
1645
|
-
pedantic:
|
|
1777
|
+
gfm: _e,
|
|
1778
|
+
pedantic: Le
|
|
1646
1779
|
},
|
|
1647
|
-
|
|
1780
|
+
M = {
|
|
1648
1781
|
normal: W,
|
|
1649
1782
|
gfm: N,
|
|
1650
1783
|
breaks: Xe,
|
|
@@ -1657,84 +1790,84 @@ var We = {
|
|
|
1657
1790
|
'"': """,
|
|
1658
1791
|
"'": "'"
|
|
1659
1792
|
},
|
|
1660
|
-
|
|
1661
|
-
function
|
|
1793
|
+
ke = l => We[l];
|
|
1794
|
+
function w(l, e) {
|
|
1662
1795
|
if (e) {
|
|
1663
|
-
if (m.escapeTest.test(
|
|
1664
|
-
} else if (m.escapeTestNoEncode.test(
|
|
1665
|
-
return
|
|
1796
|
+
if (m.escapeTest.test(l)) return l.replace(m.escapeReplace, ke);
|
|
1797
|
+
} else if (m.escapeTestNoEncode.test(l)) return l.replace(m.escapeReplaceNoEncode, ke);
|
|
1798
|
+
return l;
|
|
1666
1799
|
}
|
|
1667
|
-
function J(
|
|
1800
|
+
function J(l) {
|
|
1668
1801
|
try {
|
|
1669
|
-
|
|
1802
|
+
l = encodeURI(l).replace(m.percentDecode, "%");
|
|
1670
1803
|
} catch {
|
|
1671
1804
|
return null;
|
|
1672
1805
|
}
|
|
1673
|
-
return
|
|
1806
|
+
return l;
|
|
1674
1807
|
}
|
|
1675
|
-
function V(
|
|
1676
|
-
let t =
|
|
1677
|
-
let
|
|
1678
|
-
|
|
1679
|
-
for (; --
|
|
1680
|
-
return
|
|
1808
|
+
function V(l, e) {
|
|
1809
|
+
let t = l.replace(m.findPipe, (i, s, o) => {
|
|
1810
|
+
let a = false,
|
|
1811
|
+
u = s;
|
|
1812
|
+
for (; --u >= 0 && o[u] === "\\";) a = !a;
|
|
1813
|
+
return a ? "|" : " |";
|
|
1681
1814
|
}),
|
|
1682
1815
|
n = t.split(m.splitPipe),
|
|
1683
|
-
|
|
1816
|
+
r = 0;
|
|
1684
1817
|
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("");
|
|
1685
|
-
for (;
|
|
1818
|
+
for (; r < n.length; r++) n[r] = n[r].trim().replace(m.slashPipe, "|");
|
|
1686
1819
|
return n;
|
|
1687
1820
|
}
|
|
1688
|
-
function
|
|
1689
|
-
let n =
|
|
1821
|
+
function z(l, e, t) {
|
|
1822
|
+
let n = l.length;
|
|
1690
1823
|
if (n === 0) return "";
|
|
1691
|
-
let
|
|
1692
|
-
for (;
|
|
1693
|
-
let i =
|
|
1694
|
-
if (i === e && true)
|
|
1824
|
+
let r = 0;
|
|
1825
|
+
for (; r < n;) {
|
|
1826
|
+
let i = l.charAt(n - r - 1);
|
|
1827
|
+
if (i === e && true) r++;else break;
|
|
1695
1828
|
}
|
|
1696
|
-
return
|
|
1829
|
+
return l.slice(0, n - r);
|
|
1697
1830
|
}
|
|
1698
|
-
function
|
|
1699
|
-
if (
|
|
1831
|
+
function ge(l, e) {
|
|
1832
|
+
if (l.indexOf(e[1]) === -1) return -1;
|
|
1700
1833
|
let t = 0;
|
|
1701
|
-
for (let n = 0; n <
|
|
1834
|
+
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;
|
|
1702
1835
|
return t > 0 ? -2 : -1;
|
|
1703
1836
|
}
|
|
1704
|
-
function
|
|
1837
|
+
function fe(l, e, t, n, r) {
|
|
1705
1838
|
let i = e.href,
|
|
1706
|
-
|
|
1707
|
-
o =
|
|
1839
|
+
s = e.title || null,
|
|
1840
|
+
o = l[1].replace(r.other.outputLinkReplace, "$1");
|
|
1708
1841
|
n.state.inLink = true;
|
|
1709
|
-
let
|
|
1710
|
-
type:
|
|
1842
|
+
let a = {
|
|
1843
|
+
type: l[0].charAt(0) === "!" ? "image" : "link",
|
|
1711
1844
|
raw: t,
|
|
1712
1845
|
href: i,
|
|
1713
|
-
title:
|
|
1846
|
+
title: s,
|
|
1714
1847
|
text: o,
|
|
1715
1848
|
tokens: n.inlineTokens(o)
|
|
1716
1849
|
};
|
|
1717
|
-
return n.state.inLink = false,
|
|
1850
|
+
return n.state.inLink = false, a;
|
|
1718
1851
|
}
|
|
1719
|
-
function Je(
|
|
1720
|
-
let n =
|
|
1852
|
+
function Je(l, e, t) {
|
|
1853
|
+
let n = l.match(t.other.indentCodeCompensation);
|
|
1721
1854
|
if (n === null) return e;
|
|
1722
|
-
let
|
|
1855
|
+
let r = n[1];
|
|
1723
1856
|
return e.split(`
|
|
1724
1857
|
`).map(i => {
|
|
1725
|
-
let
|
|
1726
|
-
if (
|
|
1727
|
-
let [o] =
|
|
1728
|
-
return o.length >=
|
|
1858
|
+
let s = i.match(t.other.beginningSpace);
|
|
1859
|
+
if (s === null) return i;
|
|
1860
|
+
let [o] = s;
|
|
1861
|
+
return o.length >= r.length ? i.slice(r.length) : i;
|
|
1729
1862
|
}).join(`
|
|
1730
1863
|
`);
|
|
1731
1864
|
}
|
|
1732
|
-
var
|
|
1865
|
+
var y = class {
|
|
1733
1866
|
options;
|
|
1734
1867
|
rules;
|
|
1735
1868
|
lexer;
|
|
1736
1869
|
constructor(e) {
|
|
1737
|
-
this.options = e ||
|
|
1870
|
+
this.options = e || O;
|
|
1738
1871
|
}
|
|
1739
1872
|
space(e) {
|
|
1740
1873
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -1751,7 +1884,7 @@ var S = class {
|
|
|
1751
1884
|
type: "code",
|
|
1752
1885
|
raw: t[0],
|
|
1753
1886
|
codeBlockStyle: "indented",
|
|
1754
|
-
text: this.options.pedantic ? n :
|
|
1887
|
+
text: this.options.pedantic ? n : z(n, `
|
|
1755
1888
|
`)
|
|
1756
1889
|
};
|
|
1757
1890
|
}
|
|
@@ -1760,12 +1893,12 @@ var S = class {
|
|
|
1760
1893
|
let t = this.rules.block.fences.exec(e);
|
|
1761
1894
|
if (t) {
|
|
1762
1895
|
let n = t[0],
|
|
1763
|
-
|
|
1896
|
+
r = Je(n, t[3] || "", this.rules);
|
|
1764
1897
|
return {
|
|
1765
1898
|
type: "code",
|
|
1766
1899
|
raw: n,
|
|
1767
1900
|
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
1768
|
-
text:
|
|
1901
|
+
text: r
|
|
1769
1902
|
};
|
|
1770
1903
|
}
|
|
1771
1904
|
}
|
|
@@ -1774,8 +1907,8 @@ var S = class {
|
|
|
1774
1907
|
if (t) {
|
|
1775
1908
|
let n = t[2].trim();
|
|
1776
1909
|
if (this.rules.other.endingHash.test(n)) {
|
|
1777
|
-
let
|
|
1778
|
-
(this.options.pedantic || !
|
|
1910
|
+
let r = z(n, "#");
|
|
1911
|
+
(this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
|
|
1779
1912
|
}
|
|
1780
1913
|
return {
|
|
1781
1914
|
type: "heading",
|
|
@@ -1790,59 +1923,59 @@ var S = class {
|
|
|
1790
1923
|
let t = this.rules.block.hr.exec(e);
|
|
1791
1924
|
if (t) return {
|
|
1792
1925
|
type: "hr",
|
|
1793
|
-
raw:
|
|
1926
|
+
raw: z(t[0], `
|
|
1794
1927
|
`)
|
|
1795
1928
|
};
|
|
1796
1929
|
}
|
|
1797
1930
|
blockquote(e) {
|
|
1798
1931
|
let t = this.rules.block.blockquote.exec(e);
|
|
1799
1932
|
if (t) {
|
|
1800
|
-
let n =
|
|
1933
|
+
let n = z(t[0], `
|
|
1801
1934
|
`).split(`
|
|
1802
1935
|
`),
|
|
1803
|
-
|
|
1936
|
+
r = "",
|
|
1804
1937
|
i = "",
|
|
1805
|
-
|
|
1938
|
+
s = [];
|
|
1806
1939
|
for (; n.length > 0;) {
|
|
1807
1940
|
let o = false,
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
for (
|
|
1811
|
-
n = n.slice(
|
|
1812
|
-
let p =
|
|
1941
|
+
a = [],
|
|
1942
|
+
u;
|
|
1943
|
+
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;
|
|
1944
|
+
n = n.slice(u);
|
|
1945
|
+
let p = a.join(`
|
|
1813
1946
|
`),
|
|
1814
|
-
|
|
1947
|
+
c = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1815
1948
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1816
|
-
|
|
1949
|
+
r = r ? `${r}
|
|
1817
1950
|
${p}` : p, i = i ? `${i}
|
|
1818
|
-
${
|
|
1819
|
-
let
|
|
1820
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(
|
|
1821
|
-
let
|
|
1822
|
-
if (
|
|
1823
|
-
if (
|
|
1824
|
-
let x =
|
|
1825
|
-
|
|
1951
|
+
${c}` : c;
|
|
1952
|
+
let f = this.lexer.state.top;
|
|
1953
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = f, n.length === 0) break;
|
|
1954
|
+
let k = s.at(-1);
|
|
1955
|
+
if (k?.type === "code") break;
|
|
1956
|
+
if (k?.type === "blockquote") {
|
|
1957
|
+
let x = k,
|
|
1958
|
+
g = x.raw + `
|
|
1826
1959
|
` + n.join(`
|
|
1827
1960
|
`),
|
|
1828
|
-
|
|
1829
|
-
|
|
1961
|
+
T = this.blockquote(g);
|
|
1962
|
+
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;
|
|
1830
1963
|
break;
|
|
1831
|
-
} else if (
|
|
1832
|
-
let x =
|
|
1833
|
-
|
|
1964
|
+
} else if (k?.type === "list") {
|
|
1965
|
+
let x = k,
|
|
1966
|
+
g = x.raw + `
|
|
1834
1967
|
` + n.join(`
|
|
1835
1968
|
`),
|
|
1836
|
-
|
|
1837
|
-
|
|
1969
|
+
T = this.list(g);
|
|
1970
|
+
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(`
|
|
1838
1971
|
`);
|
|
1839
1972
|
continue;
|
|
1840
1973
|
}
|
|
1841
1974
|
}
|
|
1842
1975
|
return {
|
|
1843
1976
|
type: "blockquote",
|
|
1844
|
-
raw:
|
|
1845
|
-
tokens:
|
|
1977
|
+
raw: r,
|
|
1978
|
+
tokens: s,
|
|
1846
1979
|
text: i
|
|
1847
1980
|
};
|
|
1848
1981
|
}
|
|
@@ -1851,74 +1984,74 @@ ${u}` : u;
|
|
|
1851
1984
|
let t = this.rules.block.list.exec(e);
|
|
1852
1985
|
if (t) {
|
|
1853
1986
|
let n = t[1].trim(),
|
|
1854
|
-
|
|
1987
|
+
r = n.length > 1,
|
|
1855
1988
|
i = {
|
|
1856
1989
|
type: "list",
|
|
1857
1990
|
raw: "",
|
|
1858
|
-
ordered:
|
|
1859
|
-
start:
|
|
1991
|
+
ordered: r,
|
|
1992
|
+
start: r ? +n.slice(0, -1) : "",
|
|
1860
1993
|
loose: false,
|
|
1861
1994
|
items: []
|
|
1862
1995
|
};
|
|
1863
|
-
n =
|
|
1864
|
-
let
|
|
1996
|
+
n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
|
|
1997
|
+
let s = this.rules.other.listItemRegex(n),
|
|
1865
1998
|
o = false;
|
|
1866
1999
|
for (; e;) {
|
|
1867
|
-
let
|
|
2000
|
+
let u = false,
|
|
1868
2001
|
p = "",
|
|
1869
|
-
|
|
1870
|
-
if (!(t =
|
|
2002
|
+
c = "";
|
|
2003
|
+
if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
1871
2004
|
p = t[0], e = e.substring(p.length);
|
|
1872
|
-
let
|
|
2005
|
+
let f = t[2].split(`
|
|
1873
2006
|
`, 1)[0].replace(this.rules.other.listReplaceTabs, Z => " ".repeat(3 * Z.length)),
|
|
1874
|
-
|
|
2007
|
+
k = e.split(`
|
|
1875
2008
|
`, 1)[0],
|
|
1876
|
-
x = !
|
|
1877
|
-
|
|
1878
|
-
if (this.options.pedantic ? (
|
|
1879
|
-
`, e = e.substring(
|
|
1880
|
-
let Z = this.rules.other.nextBulletRegex(
|
|
1881
|
-
ee = this.rules.other.hrRegex(
|
|
1882
|
-
te = this.rules.other.fencesBeginRegex(
|
|
1883
|
-
ne = this.rules.other.headingBeginRegex(
|
|
1884
|
-
me = this.rules.other.htmlBeginRegex(
|
|
2009
|
+
x = !f.trim(),
|
|
2010
|
+
g = 0;
|
|
2011
|
+
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 + `
|
|
2012
|
+
`, e = e.substring(k.length + 1), u = true), !u) {
|
|
2013
|
+
let Z = this.rules.other.nextBulletRegex(g),
|
|
2014
|
+
ee = this.rules.other.hrRegex(g),
|
|
2015
|
+
te = this.rules.other.fencesBeginRegex(g),
|
|
2016
|
+
ne = this.rules.other.headingBeginRegex(g),
|
|
2017
|
+
me = this.rules.other.htmlBeginRegex(g);
|
|
1885
2018
|
for (; e;) {
|
|
1886
2019
|
let G = e.split(`
|
|
1887
2020
|
`, 1)[0],
|
|
1888
|
-
|
|
1889
|
-
if (
|
|
1890
|
-
if (
|
|
1891
|
-
` +
|
|
1892
|
-
if (x ||
|
|
1893
|
-
|
|
1894
|
-
` +
|
|
2021
|
+
A;
|
|
2022
|
+
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;
|
|
2023
|
+
if (A.search(this.rules.other.nonSpaceChar) >= g || !k.trim()) c += `
|
|
2024
|
+
` + A.slice(g);else {
|
|
2025
|
+
if (x || f.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(f) || ne.test(f) || ee.test(f)) break;
|
|
2026
|
+
c += `
|
|
2027
|
+
` + k;
|
|
1895
2028
|
}
|
|
1896
|
-
!x && !
|
|
1897
|
-
`, e = e.substring(G.length + 1),
|
|
2029
|
+
!x && !k.trim() && (x = true), p += G + `
|
|
2030
|
+
`, e = e.substring(G.length + 1), f = A.slice(g);
|
|
1898
2031
|
}
|
|
1899
2032
|
}
|
|
1900
2033
|
i.loose || (o ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true));
|
|
1901
|
-
let
|
|
2034
|
+
let T = null,
|
|
1902
2035
|
Y;
|
|
1903
|
-
this.options.gfm && (
|
|
2036
|
+
this.options.gfm && (T = this.rules.other.listIsTask.exec(c), T && (Y = T[0] !== "[ ] ", c = c.replace(this.rules.other.listReplaceTask, ""))), i.items.push({
|
|
1904
2037
|
type: "list_item",
|
|
1905
2038
|
raw: p,
|
|
1906
|
-
task: !!
|
|
2039
|
+
task: !!T,
|
|
1907
2040
|
checked: Y,
|
|
1908
2041
|
loose: false,
|
|
1909
|
-
text:
|
|
2042
|
+
text: c,
|
|
1910
2043
|
tokens: []
|
|
1911
2044
|
}), i.raw += p;
|
|
1912
2045
|
}
|
|
1913
|
-
let
|
|
1914
|
-
if (
|
|
2046
|
+
let a = i.items.at(-1);
|
|
2047
|
+
if (a) a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();else return;
|
|
1915
2048
|
i.raw = i.raw.trimEnd();
|
|
1916
|
-
for (let
|
|
1917
|
-
let p = i.items[
|
|
1918
|
-
|
|
1919
|
-
i.loose =
|
|
2049
|
+
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) {
|
|
2050
|
+
let p = i.items[u].tokens.filter(f => f.type === "space"),
|
|
2051
|
+
c = p.length > 0 && p.some(f => this.rules.other.anyLine.test(f.raw));
|
|
2052
|
+
i.loose = c;
|
|
1920
2053
|
}
|
|
1921
|
-
if (i.loose) for (let
|
|
2054
|
+
if (i.loose) for (let u = 0; u < i.items.length; u++) i.items[u].loose = true;
|
|
1922
2055
|
return i;
|
|
1923
2056
|
}
|
|
1924
2057
|
}
|
|
@@ -1936,13 +2069,13 @@ ${u}` : u;
|
|
|
1936
2069
|
let t = this.rules.block.def.exec(e);
|
|
1937
2070
|
if (t) {
|
|
1938
2071
|
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
1939
|
-
|
|
2072
|
+
r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "",
|
|
1940
2073
|
i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
1941
2074
|
return {
|
|
1942
2075
|
type: "def",
|
|
1943
2076
|
tag: n,
|
|
1944
2077
|
raw: t[0],
|
|
1945
|
-
href:
|
|
2078
|
+
href: r,
|
|
1946
2079
|
title: i
|
|
1947
2080
|
};
|
|
1948
2081
|
}
|
|
@@ -1951,31 +2084,31 @@ ${u}` : u;
|
|
|
1951
2084
|
let t = this.rules.block.table.exec(e);
|
|
1952
2085
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
1953
2086
|
let n = V(t[1]),
|
|
1954
|
-
|
|
2087
|
+
r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"),
|
|
1955
2088
|
i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
1956
2089
|
`) : [],
|
|
1957
|
-
|
|
2090
|
+
s = {
|
|
1958
2091
|
type: "table",
|
|
1959
2092
|
raw: t[0],
|
|
1960
2093
|
header: [],
|
|
1961
2094
|
align: [],
|
|
1962
2095
|
rows: []
|
|
1963
2096
|
};
|
|
1964
|
-
if (n.length ===
|
|
1965
|
-
for (let o of
|
|
1966
|
-
for (let o = 0; o < n.length; o++)
|
|
2097
|
+
if (n.length === r.length) {
|
|
2098
|
+
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);
|
|
2099
|
+
for (let o = 0; o < n.length; o++) s.header.push({
|
|
1967
2100
|
text: n[o],
|
|
1968
2101
|
tokens: this.lexer.inline(n[o]),
|
|
1969
2102
|
header: true,
|
|
1970
|
-
align:
|
|
2103
|
+
align: s.align[o]
|
|
1971
2104
|
});
|
|
1972
|
-
for (let o of i)
|
|
1973
|
-
text:
|
|
1974
|
-
tokens: this.lexer.inline(
|
|
2105
|
+
for (let o of i) s.rows.push(V(o, s.header.length).map((a, u) => ({
|
|
2106
|
+
text: a,
|
|
2107
|
+
tokens: this.lexer.inline(a),
|
|
1975
2108
|
header: false,
|
|
1976
|
-
align:
|
|
2109
|
+
align: s.align[u]
|
|
1977
2110
|
})));
|
|
1978
|
-
return
|
|
2111
|
+
return s;
|
|
1979
2112
|
}
|
|
1980
2113
|
}
|
|
1981
2114
|
lheading(e) {
|
|
@@ -2035,24 +2168,24 @@ ${u}` : u;
|
|
|
2035
2168
|
let n = t[2].trim();
|
|
2036
2169
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
2037
2170
|
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
2038
|
-
let
|
|
2039
|
-
if ((n.length -
|
|
2171
|
+
let s = z(n.slice(0, -1), "\\");
|
|
2172
|
+
if ((n.length - s.length) % 2 === 0) return;
|
|
2040
2173
|
} else {
|
|
2041
|
-
let
|
|
2042
|
-
if (
|
|
2043
|
-
if (
|
|
2044
|
-
let
|
|
2045
|
-
t[2] = t[2].substring(0,
|
|
2174
|
+
let s = ge(t[2], "()");
|
|
2175
|
+
if (s === -2) return;
|
|
2176
|
+
if (s > -1) {
|
|
2177
|
+
let a = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
|
|
2178
|
+
t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, a).trim(), t[3] = "";
|
|
2046
2179
|
}
|
|
2047
2180
|
}
|
|
2048
|
-
let
|
|
2181
|
+
let r = t[2],
|
|
2049
2182
|
i = "";
|
|
2050
2183
|
if (this.options.pedantic) {
|
|
2051
|
-
let
|
|
2052
|
-
|
|
2184
|
+
let s = this.rules.other.pedanticHrefTitle.exec(r);
|
|
2185
|
+
s && (r = s[1], i = s[3]);
|
|
2053
2186
|
} else i = t[3] ? t[3].slice(1, -1) : "";
|
|
2054
|
-
return
|
|
2055
|
-
href:
|
|
2187
|
+
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, {
|
|
2188
|
+
href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
2056
2189
|
title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
|
|
2057
2190
|
}, t[0], this.lexer, this.rules);
|
|
2058
2191
|
}
|
|
@@ -2060,55 +2193,55 @@ ${u}` : u;
|
|
|
2060
2193
|
reflink(e, t) {
|
|
2061
2194
|
let n;
|
|
2062
2195
|
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
2063
|
-
let
|
|
2064
|
-
i = t[
|
|
2196
|
+
let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
2197
|
+
i = t[r.toLowerCase()];
|
|
2065
2198
|
if (!i) {
|
|
2066
|
-
let
|
|
2199
|
+
let s = n[0].charAt(0);
|
|
2067
2200
|
return {
|
|
2068
2201
|
type: "text",
|
|
2069
|
-
raw:
|
|
2070
|
-
text:
|
|
2202
|
+
raw: s,
|
|
2203
|
+
text: s
|
|
2071
2204
|
};
|
|
2072
2205
|
}
|
|
2073
|
-
return
|
|
2206
|
+
return fe(n, i, n[0], this.lexer, this.rules);
|
|
2074
2207
|
}
|
|
2075
2208
|
}
|
|
2076
2209
|
emStrong(e, t, n = "") {
|
|
2077
|
-
let
|
|
2078
|
-
if (!
|
|
2079
|
-
if (!(
|
|
2080
|
-
let
|
|
2210
|
+
let r = this.rules.inline.emStrongLDelim.exec(e);
|
|
2211
|
+
if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
2212
|
+
if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2213
|
+
let s = [...r[0]].length - 1,
|
|
2081
2214
|
o,
|
|
2082
|
-
|
|
2083
|
-
|
|
2215
|
+
a,
|
|
2216
|
+
u = s,
|
|
2084
2217
|
p = 0,
|
|
2085
|
-
|
|
2086
|
-
for (
|
|
2087
|
-
if (o =
|
|
2088
|
-
if (
|
|
2089
|
-
|
|
2218
|
+
c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
2219
|
+
for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) != null;) {
|
|
2220
|
+
if (o = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !o) continue;
|
|
2221
|
+
if (a = [...o].length, r[3] || r[4]) {
|
|
2222
|
+
u += a;
|
|
2090
2223
|
continue;
|
|
2091
|
-
} else if ((
|
|
2092
|
-
p +=
|
|
2224
|
+
} else if ((r[5] || r[6]) && s % 3 && !((s + a) % 3)) {
|
|
2225
|
+
p += a;
|
|
2093
2226
|
continue;
|
|
2094
2227
|
}
|
|
2095
|
-
if (
|
|
2096
|
-
|
|
2097
|
-
let
|
|
2098
|
-
|
|
2099
|
-
if (Math.min(
|
|
2100
|
-
let
|
|
2228
|
+
if (u -= a, u > 0) continue;
|
|
2229
|
+
a = Math.min(a, a + u + p);
|
|
2230
|
+
let f = [...r[0]][0].length,
|
|
2231
|
+
k = e.slice(0, s + r.index + f + a);
|
|
2232
|
+
if (Math.min(s, a) % 2) {
|
|
2233
|
+
let g = k.slice(1, -1);
|
|
2101
2234
|
return {
|
|
2102
2235
|
type: "em",
|
|
2103
|
-
raw:
|
|
2104
|
-
text:
|
|
2105
|
-
tokens: this.lexer.inlineTokens(
|
|
2236
|
+
raw: k,
|
|
2237
|
+
text: g,
|
|
2238
|
+
tokens: this.lexer.inlineTokens(g)
|
|
2106
2239
|
};
|
|
2107
2240
|
}
|
|
2108
|
-
let x =
|
|
2241
|
+
let x = k.slice(2, -2);
|
|
2109
2242
|
return {
|
|
2110
2243
|
type: "strong",
|
|
2111
|
-
raw:
|
|
2244
|
+
raw: k,
|
|
2112
2245
|
text: x,
|
|
2113
2246
|
tokens: this.lexer.inlineTokens(x)
|
|
2114
2247
|
};
|
|
@@ -2119,9 +2252,9 @@ ${u}` : u;
|
|
|
2119
2252
|
let t = this.rules.inline.code.exec(e);
|
|
2120
2253
|
if (t) {
|
|
2121
2254
|
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "),
|
|
2122
|
-
|
|
2255
|
+
r = this.rules.other.nonSpaceChar.test(n),
|
|
2123
2256
|
i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
2124
|
-
return
|
|
2257
|
+
return r && i && (n = n.substring(1, n.length - 1)), {
|
|
2125
2258
|
type: "codespan",
|
|
2126
2259
|
raw: t[0],
|
|
2127
2260
|
text: n
|
|
@@ -2147,12 +2280,12 @@ ${u}` : u;
|
|
|
2147
2280
|
autolink(e) {
|
|
2148
2281
|
let t = this.rules.inline.autolink.exec(e);
|
|
2149
2282
|
if (t) {
|
|
2150
|
-
let n,
|
|
2151
|
-
return t[2] === "@" ? (n = t[1],
|
|
2283
|
+
let n, r;
|
|
2284
|
+
return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), {
|
|
2152
2285
|
type: "link",
|
|
2153
2286
|
raw: t[0],
|
|
2154
2287
|
text: n,
|
|
2155
|
-
href:
|
|
2288
|
+
href: r,
|
|
2156
2289
|
tokens: [{
|
|
2157
2290
|
type: "text",
|
|
2158
2291
|
raw: n,
|
|
@@ -2164,17 +2297,17 @@ ${u}` : u;
|
|
|
2164
2297
|
url(e) {
|
|
2165
2298
|
let t;
|
|
2166
2299
|
if (t = this.rules.inline.url.exec(e)) {
|
|
2167
|
-
let n,
|
|
2168
|
-
if (t[2] === "@") n = t[0],
|
|
2300
|
+
let n, r;
|
|
2301
|
+
if (t[2] === "@") n = t[0], r = "mailto:" + n;else {
|
|
2169
2302
|
let i;
|
|
2170
2303
|
do i = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? ""; while (i !== t[0]);
|
|
2171
|
-
n = t[0], t[1] === "www." ?
|
|
2304
|
+
n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
2172
2305
|
}
|
|
2173
2306
|
return {
|
|
2174
2307
|
type: "link",
|
|
2175
2308
|
raw: t[0],
|
|
2176
2309
|
text: n,
|
|
2177
|
-
href:
|
|
2310
|
+
href: r,
|
|
2178
2311
|
tokens: [{
|
|
2179
2312
|
type: "text",
|
|
2180
2313
|
raw: n,
|
|
@@ -2196,36 +2329,36 @@ ${u}` : u;
|
|
|
2196
2329
|
}
|
|
2197
2330
|
}
|
|
2198
2331
|
};
|
|
2199
|
-
var b = class
|
|
2332
|
+
var b = class l {
|
|
2200
2333
|
tokens;
|
|
2201
2334
|
options;
|
|
2202
2335
|
state;
|
|
2203
2336
|
tokenizer;
|
|
2204
2337
|
inlineQueue;
|
|
2205
2338
|
constructor(e) {
|
|
2206
|
-
this.tokens = [], this.tokens.links = Object.create(null), this.options = e ||
|
|
2339
|
+
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 = {
|
|
2207
2340
|
inLink: false,
|
|
2208
2341
|
inRawBlock: false,
|
|
2209
2342
|
top: true
|
|
2210
2343
|
};
|
|
2211
2344
|
let t = {
|
|
2212
2345
|
other: m,
|
|
2213
|
-
block:
|
|
2214
|
-
inline:
|
|
2346
|
+
block: I.normal,
|
|
2347
|
+
inline: M.normal
|
|
2215
2348
|
};
|
|
2216
|
-
this.options.pedantic ? (t.block =
|
|
2349
|
+
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;
|
|
2217
2350
|
}
|
|
2218
2351
|
static get rules() {
|
|
2219
2352
|
return {
|
|
2220
|
-
block:
|
|
2221
|
-
inline:
|
|
2353
|
+
block: I,
|
|
2354
|
+
inline: M
|
|
2222
2355
|
};
|
|
2223
2356
|
}
|
|
2224
2357
|
static lex(e, t) {
|
|
2225
|
-
return new
|
|
2358
|
+
return new l(t).lex(e);
|
|
2226
2359
|
}
|
|
2227
2360
|
static lexInline(e, t) {
|
|
2228
|
-
return new
|
|
2361
|
+
return new l(t).inlineTokens(e);
|
|
2229
2362
|
}
|
|
2230
2363
|
lex(e) {
|
|
2231
2364
|
e = e.replace(m.carriageReturn, `
|
|
@@ -2238,100 +2371,100 @@ var b = class a {
|
|
|
2238
2371
|
}
|
|
2239
2372
|
blockTokens(e, t = [], n = false) {
|
|
2240
2373
|
for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e;) {
|
|
2241
|
-
let
|
|
2242
|
-
if (this.options.extensions?.block?.some(
|
|
2374
|
+
let r;
|
|
2375
|
+
if (this.options.extensions?.block?.some(s => (r = s.call({
|
|
2243
2376
|
lexer: this
|
|
2244
|
-
}, e, t)) ? (e = e.substring(
|
|
2245
|
-
if (
|
|
2246
|
-
e = e.substring(
|
|
2247
|
-
let
|
|
2248
|
-
|
|
2249
|
-
` : t.push(
|
|
2377
|
+
}, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
2378
|
+
if (r = this.tokenizer.space(e)) {
|
|
2379
|
+
e = e.substring(r.raw.length);
|
|
2380
|
+
let s = t.at(-1);
|
|
2381
|
+
r.raw.length === 1 && s !== void 0 ? s.raw += `
|
|
2382
|
+
` : t.push(r);
|
|
2250
2383
|
continue;
|
|
2251
2384
|
}
|
|
2252
|
-
if (
|
|
2253
|
-
e = e.substring(
|
|
2254
|
-
let
|
|
2255
|
-
|
|
2256
|
-
` +
|
|
2257
|
-
` +
|
|
2385
|
+
if (r = this.tokenizer.code(e)) {
|
|
2386
|
+
e = e.substring(r.raw.length);
|
|
2387
|
+
let s = t.at(-1);
|
|
2388
|
+
s?.type === "paragraph" || s?.type === "text" ? (s.raw += `
|
|
2389
|
+
` + r.raw, s.text += `
|
|
2390
|
+
` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
|
|
2258
2391
|
continue;
|
|
2259
2392
|
}
|
|
2260
|
-
if (
|
|
2261
|
-
e = e.substring(
|
|
2393
|
+
if (r = this.tokenizer.fences(e)) {
|
|
2394
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2262
2395
|
continue;
|
|
2263
2396
|
}
|
|
2264
|
-
if (
|
|
2265
|
-
e = e.substring(
|
|
2397
|
+
if (r = this.tokenizer.heading(e)) {
|
|
2398
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2266
2399
|
continue;
|
|
2267
2400
|
}
|
|
2268
|
-
if (
|
|
2269
|
-
e = e.substring(
|
|
2401
|
+
if (r = this.tokenizer.hr(e)) {
|
|
2402
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2270
2403
|
continue;
|
|
2271
2404
|
}
|
|
2272
|
-
if (
|
|
2273
|
-
e = e.substring(
|
|
2405
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
2406
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2274
2407
|
continue;
|
|
2275
2408
|
}
|
|
2276
|
-
if (
|
|
2277
|
-
e = e.substring(
|
|
2409
|
+
if (r = this.tokenizer.list(e)) {
|
|
2410
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2278
2411
|
continue;
|
|
2279
2412
|
}
|
|
2280
|
-
if (
|
|
2281
|
-
e = e.substring(
|
|
2413
|
+
if (r = this.tokenizer.html(e)) {
|
|
2414
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2282
2415
|
continue;
|
|
2283
2416
|
}
|
|
2284
|
-
if (
|
|
2285
|
-
e = e.substring(
|
|
2286
|
-
let
|
|
2287
|
-
|
|
2288
|
-
` +
|
|
2289
|
-
` +
|
|
2290
|
-
href:
|
|
2291
|
-
title:
|
|
2417
|
+
if (r = this.tokenizer.def(e)) {
|
|
2418
|
+
e = e.substring(r.raw.length);
|
|
2419
|
+
let s = t.at(-1);
|
|
2420
|
+
s?.type === "paragraph" || s?.type === "text" ? (s.raw += `
|
|
2421
|
+
` + r.raw, s.text += `
|
|
2422
|
+
` + r.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
|
|
2423
|
+
href: r.href,
|
|
2424
|
+
title: r.title
|
|
2292
2425
|
});
|
|
2293
2426
|
continue;
|
|
2294
2427
|
}
|
|
2295
|
-
if (
|
|
2296
|
-
e = e.substring(
|
|
2428
|
+
if (r = this.tokenizer.table(e)) {
|
|
2429
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2297
2430
|
continue;
|
|
2298
2431
|
}
|
|
2299
|
-
if (
|
|
2300
|
-
e = e.substring(
|
|
2432
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
2433
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2301
2434
|
continue;
|
|
2302
2435
|
}
|
|
2303
2436
|
let i = e;
|
|
2304
2437
|
if (this.options.extensions?.startBlock) {
|
|
2305
|
-
let
|
|
2438
|
+
let s = 1 / 0,
|
|
2306
2439
|
o = e.slice(1),
|
|
2307
|
-
|
|
2308
|
-
this.options.extensions.startBlock.forEach(
|
|
2309
|
-
|
|
2440
|
+
a;
|
|
2441
|
+
this.options.extensions.startBlock.forEach(u => {
|
|
2442
|
+
a = u.call({
|
|
2310
2443
|
lexer: this
|
|
2311
|
-
}, o), typeof
|
|
2312
|
-
}),
|
|
2444
|
+
}, o), typeof a == "number" && a >= 0 && (s = Math.min(s, a));
|
|
2445
|
+
}), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
|
|
2313
2446
|
}
|
|
2314
|
-
if (this.state.top && (
|
|
2315
|
-
let
|
|
2316
|
-
n &&
|
|
2317
|
-
` +
|
|
2318
|
-
` +
|
|
2447
|
+
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
2448
|
+
let s = t.at(-1);
|
|
2449
|
+
n && s?.type === "paragraph" ? (s.raw += `
|
|
2450
|
+
` + r.raw, s.text += `
|
|
2451
|
+
` + 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);
|
|
2319
2452
|
continue;
|
|
2320
2453
|
}
|
|
2321
|
-
if (
|
|
2322
|
-
e = e.substring(
|
|
2323
|
-
let
|
|
2324
|
-
|
|
2325
|
-
` +
|
|
2326
|
-
` +
|
|
2454
|
+
if (r = this.tokenizer.text(e)) {
|
|
2455
|
+
e = e.substring(r.raw.length);
|
|
2456
|
+
let s = t.at(-1);
|
|
2457
|
+
s?.type === "text" ? (s.raw += `
|
|
2458
|
+
` + r.raw, s.text += `
|
|
2459
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
|
|
2327
2460
|
continue;
|
|
2328
2461
|
}
|
|
2329
2462
|
if (e) {
|
|
2330
|
-
let
|
|
2463
|
+
let s = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2331
2464
|
if (this.options.silent) {
|
|
2332
|
-
console.error(
|
|
2465
|
+
console.error(s);
|
|
2333
2466
|
break;
|
|
2334
|
-
} else throw new Error(
|
|
2467
|
+
} else throw new Error(s);
|
|
2335
2468
|
}
|
|
2336
2469
|
}
|
|
2337
2470
|
return this.state.top = true, t;
|
|
@@ -2344,19 +2477,19 @@ var b = class a {
|
|
|
2344
2477
|
}
|
|
2345
2478
|
inlineTokens(e, t = []) {
|
|
2346
2479
|
let n = e,
|
|
2347
|
-
|
|
2480
|
+
r = null;
|
|
2348
2481
|
if (this.tokens.links) {
|
|
2349
2482
|
let o = Object.keys(this.tokens.links);
|
|
2350
|
-
if (o.length > 0) for (; (
|
|
2483
|
+
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));
|
|
2351
2484
|
}
|
|
2352
|
-
for (; (
|
|
2353
|
-
for (; (
|
|
2485
|
+
for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null;) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
2486
|
+
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);
|
|
2354
2487
|
let i = false,
|
|
2355
|
-
|
|
2488
|
+
s = "";
|
|
2356
2489
|
for (; e;) {
|
|
2357
|
-
i || (
|
|
2490
|
+
i || (s = ""), i = false;
|
|
2358
2491
|
let o;
|
|
2359
|
-
if (this.options.extensions?.inline?.some(
|
|
2492
|
+
if (this.options.extensions?.inline?.some(u => (o = u.call({
|
|
2360
2493
|
lexer: this
|
|
2361
2494
|
}, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
2362
2495
|
if (o = this.tokenizer.escape(e)) {
|
|
@@ -2373,11 +2506,11 @@ var b = class a {
|
|
|
2373
2506
|
}
|
|
2374
2507
|
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
2375
2508
|
e = e.substring(o.raw.length);
|
|
2376
|
-
let
|
|
2377
|
-
o.type === "text" &&
|
|
2509
|
+
let u = t.at(-1);
|
|
2510
|
+
o.type === "text" && u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : t.push(o);
|
|
2378
2511
|
continue;
|
|
2379
2512
|
}
|
|
2380
|
-
if (o = this.tokenizer.emStrong(e, n,
|
|
2513
|
+
if (o = this.tokenizer.emStrong(e, n, s)) {
|
|
2381
2514
|
e = e.substring(o.raw.length), t.push(o);
|
|
2382
2515
|
continue;
|
|
2383
2516
|
}
|
|
@@ -2401,39 +2534,39 @@ var b = class a {
|
|
|
2401
2534
|
e = e.substring(o.raw.length), t.push(o);
|
|
2402
2535
|
continue;
|
|
2403
2536
|
}
|
|
2404
|
-
let
|
|
2537
|
+
let a = e;
|
|
2405
2538
|
if (this.options.extensions?.startInline) {
|
|
2406
|
-
let
|
|
2539
|
+
let u = 1 / 0,
|
|
2407
2540
|
p = e.slice(1),
|
|
2408
|
-
|
|
2409
|
-
this.options.extensions.startInline.forEach(
|
|
2410
|
-
|
|
2541
|
+
c;
|
|
2542
|
+
this.options.extensions.startInline.forEach(f => {
|
|
2543
|
+
c = f.call({
|
|
2411
2544
|
lexer: this
|
|
2412
|
-
}, p), typeof
|
|
2413
|
-
}),
|
|
2545
|
+
}, p), typeof c == "number" && c >= 0 && (u = Math.min(u, c));
|
|
2546
|
+
}), u < 1 / 0 && u >= 0 && (a = e.substring(0, u + 1));
|
|
2414
2547
|
}
|
|
2415
|
-
if (o = this.tokenizer.inlineText(
|
|
2416
|
-
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (
|
|
2417
|
-
let
|
|
2418
|
-
|
|
2548
|
+
if (o = this.tokenizer.inlineText(a)) {
|
|
2549
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (s = o.raw.slice(-1)), i = true;
|
|
2550
|
+
let u = t.at(-1);
|
|
2551
|
+
u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : t.push(o);
|
|
2419
2552
|
continue;
|
|
2420
2553
|
}
|
|
2421
2554
|
if (e) {
|
|
2422
|
-
let
|
|
2555
|
+
let u = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2423
2556
|
if (this.options.silent) {
|
|
2424
|
-
console.error(
|
|
2557
|
+
console.error(u);
|
|
2425
2558
|
break;
|
|
2426
|
-
} else throw new Error(
|
|
2559
|
+
} else throw new Error(u);
|
|
2427
2560
|
}
|
|
2428
2561
|
}
|
|
2429
2562
|
return t;
|
|
2430
2563
|
}
|
|
2431
2564
|
};
|
|
2432
|
-
var
|
|
2565
|
+
var P = class {
|
|
2433
2566
|
options;
|
|
2434
2567
|
parser;
|
|
2435
2568
|
constructor(e) {
|
|
2436
|
-
this.options = e ||
|
|
2569
|
+
this.options = e || O;
|
|
2437
2570
|
}
|
|
2438
2571
|
space(e) {
|
|
2439
2572
|
return "";
|
|
@@ -2443,11 +2576,11 @@ var $ = class {
|
|
|
2443
2576
|
lang: t,
|
|
2444
2577
|
escaped: n
|
|
2445
2578
|
}) {
|
|
2446
|
-
let
|
|
2579
|
+
let r = (t || "").match(m.notSpaceStart)?.[0],
|
|
2447
2580
|
i = e.replace(m.endingNewline, "") + `
|
|
2448
2581
|
`;
|
|
2449
|
-
return
|
|
2450
|
-
` : "<pre><code>" + (n ? i :
|
|
2582
|
+
return r ? '<pre><code class="language-' + w(r) + '">' + (n ? i : w(i, true)) + `</code></pre>
|
|
2583
|
+
` : "<pre><code>" + (n ? i : w(i, true)) + `</code></pre>
|
|
2451
2584
|
`;
|
|
2452
2585
|
}
|
|
2453
2586
|
blockquote({
|
|
@@ -2476,15 +2609,15 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2476
2609
|
list(e) {
|
|
2477
2610
|
let t = e.ordered,
|
|
2478
2611
|
n = e.start,
|
|
2479
|
-
|
|
2612
|
+
r = "";
|
|
2480
2613
|
for (let o = 0; o < e.items.length; o++) {
|
|
2481
|
-
let
|
|
2482
|
-
|
|
2614
|
+
let a = e.items[o];
|
|
2615
|
+
r += this.listitem(a);
|
|
2483
2616
|
}
|
|
2484
2617
|
let i = t ? "ol" : "ul",
|
|
2485
|
-
|
|
2486
|
-
return "<" + i +
|
|
2487
|
-
` +
|
|
2618
|
+
s = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
2619
|
+
return "<" + i + s + `>
|
|
2620
|
+
` + r + "</" + i + `>
|
|
2488
2621
|
`;
|
|
2489
2622
|
}
|
|
2490
2623
|
listitem(e) {
|
|
@@ -2493,7 +2626,7 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2493
2626
|
let n = this.checkbox({
|
|
2494
2627
|
checked: !!e.checked
|
|
2495
2628
|
});
|
|
2496
|
-
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 + " " +
|
|
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 + " " + w(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = true)) : e.tokens.unshift({
|
|
2497
2630
|
type: "text",
|
|
2498
2631
|
raw: n + " ",
|
|
2499
2632
|
text: n + " ",
|
|
@@ -2521,19 +2654,19 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2521
2654
|
t += this.tablerow({
|
|
2522
2655
|
text: n
|
|
2523
2656
|
});
|
|
2524
|
-
let
|
|
2657
|
+
let r = "";
|
|
2525
2658
|
for (let i = 0; i < e.rows.length; i++) {
|
|
2526
|
-
let
|
|
2659
|
+
let s = e.rows[i];
|
|
2527
2660
|
n = "";
|
|
2528
|
-
for (let o = 0; o <
|
|
2529
|
-
|
|
2661
|
+
for (let o = 0; o < s.length; o++) n += this.tablecell(s[o]);
|
|
2662
|
+
r += this.tablerow({
|
|
2530
2663
|
text: n
|
|
2531
2664
|
});
|
|
2532
2665
|
}
|
|
2533
|
-
return
|
|
2666
|
+
return r && (r = `<tbody>${r}</tbody>`), `<table>
|
|
2534
2667
|
<thead>
|
|
2535
2668
|
` + t + `</thead>
|
|
2536
|
-
` +
|
|
2669
|
+
` + r + `</table>
|
|
2537
2670
|
`;
|
|
2538
2671
|
}
|
|
2539
2672
|
tablerow({
|
|
@@ -2562,7 +2695,7 @@ ${e}</tr>
|
|
|
2562
2695
|
codespan({
|
|
2563
2696
|
text: e
|
|
2564
2697
|
}) {
|
|
2565
|
-
return `<code>${
|
|
2698
|
+
return `<code>${w(e, true)}</code>`;
|
|
2566
2699
|
}
|
|
2567
2700
|
br(e) {
|
|
2568
2701
|
return "<br>";
|
|
@@ -2577,31 +2710,31 @@ ${e}</tr>
|
|
|
2577
2710
|
title: t,
|
|
2578
2711
|
tokens: n
|
|
2579
2712
|
}) {
|
|
2580
|
-
let
|
|
2713
|
+
let r = this.parser.parseInline(n),
|
|
2581
2714
|
i = J(e);
|
|
2582
|
-
if (i === null) return
|
|
2715
|
+
if (i === null) return r;
|
|
2583
2716
|
e = i;
|
|
2584
|
-
let
|
|
2585
|
-
return t && (
|
|
2717
|
+
let s = '<a href="' + e + '"';
|
|
2718
|
+
return t && (s += ' title="' + w(t) + '"'), s += ">" + r + "</a>", s;
|
|
2586
2719
|
}
|
|
2587
2720
|
image({
|
|
2588
2721
|
href: e,
|
|
2589
2722
|
title: t,
|
|
2590
2723
|
text: n,
|
|
2591
|
-
tokens:
|
|
2724
|
+
tokens: r
|
|
2592
2725
|
}) {
|
|
2593
|
-
|
|
2726
|
+
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
2594
2727
|
let i = J(e);
|
|
2595
|
-
if (i === null) return
|
|
2728
|
+
if (i === null) return w(n);
|
|
2596
2729
|
e = i;
|
|
2597
|
-
let
|
|
2598
|
-
return t && (
|
|
2730
|
+
let s = `<img src="${e}" alt="${n}"`;
|
|
2731
|
+
return t && (s += ` title="${w(t)}"`), s += ">", s;
|
|
2599
2732
|
}
|
|
2600
2733
|
text(e) {
|
|
2601
|
-
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text :
|
|
2734
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : w(e.text);
|
|
2602
2735
|
}
|
|
2603
2736
|
};
|
|
2604
|
-
var
|
|
2737
|
+
var S = class {
|
|
2605
2738
|
strong({
|
|
2606
2739
|
text: e
|
|
2607
2740
|
}) {
|
|
@@ -2646,102 +2779,102 @@ var _ = class {
|
|
|
2646
2779
|
return "";
|
|
2647
2780
|
}
|
|
2648
2781
|
};
|
|
2649
|
-
var
|
|
2782
|
+
var R = class l {
|
|
2650
2783
|
options;
|
|
2651
2784
|
renderer;
|
|
2652
2785
|
textRenderer;
|
|
2653
2786
|
constructor(e) {
|
|
2654
|
-
this.options = e ||
|
|
2787
|
+
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();
|
|
2655
2788
|
}
|
|
2656
2789
|
static parse(e, t) {
|
|
2657
|
-
return new
|
|
2790
|
+
return new l(t).parse(e);
|
|
2658
2791
|
}
|
|
2659
2792
|
static parseInline(e, t) {
|
|
2660
|
-
return new
|
|
2793
|
+
return new l(t).parseInline(e);
|
|
2661
2794
|
}
|
|
2662
2795
|
parse(e, t = true) {
|
|
2663
2796
|
let n = "";
|
|
2664
|
-
for (let
|
|
2665
|
-
let i = e[
|
|
2797
|
+
for (let r = 0; r < e.length; r++) {
|
|
2798
|
+
let i = e[r];
|
|
2666
2799
|
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2667
2800
|
let o = i,
|
|
2668
|
-
|
|
2801
|
+
a = this.options.extensions.renderers[o.type].call({
|
|
2669
2802
|
parser: this
|
|
2670
2803
|
}, o);
|
|
2671
|
-
if (
|
|
2672
|
-
n +=
|
|
2804
|
+
if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(o.type)) {
|
|
2805
|
+
n += a || "";
|
|
2673
2806
|
continue;
|
|
2674
2807
|
}
|
|
2675
2808
|
}
|
|
2676
|
-
let
|
|
2677
|
-
switch (
|
|
2809
|
+
let s = i;
|
|
2810
|
+
switch (s.type) {
|
|
2678
2811
|
case "space":
|
|
2679
2812
|
{
|
|
2680
|
-
n += this.renderer.space(
|
|
2813
|
+
n += this.renderer.space(s);
|
|
2681
2814
|
continue;
|
|
2682
2815
|
}
|
|
2683
2816
|
case "hr":
|
|
2684
2817
|
{
|
|
2685
|
-
n += this.renderer.hr(
|
|
2818
|
+
n += this.renderer.hr(s);
|
|
2686
2819
|
continue;
|
|
2687
2820
|
}
|
|
2688
2821
|
case "heading":
|
|
2689
2822
|
{
|
|
2690
|
-
n += this.renderer.heading(
|
|
2823
|
+
n += this.renderer.heading(s);
|
|
2691
2824
|
continue;
|
|
2692
2825
|
}
|
|
2693
2826
|
case "code":
|
|
2694
2827
|
{
|
|
2695
|
-
n += this.renderer.code(
|
|
2828
|
+
n += this.renderer.code(s);
|
|
2696
2829
|
continue;
|
|
2697
2830
|
}
|
|
2698
2831
|
case "table":
|
|
2699
2832
|
{
|
|
2700
|
-
n += this.renderer.table(
|
|
2833
|
+
n += this.renderer.table(s);
|
|
2701
2834
|
continue;
|
|
2702
2835
|
}
|
|
2703
2836
|
case "blockquote":
|
|
2704
2837
|
{
|
|
2705
|
-
n += this.renderer.blockquote(
|
|
2838
|
+
n += this.renderer.blockquote(s);
|
|
2706
2839
|
continue;
|
|
2707
2840
|
}
|
|
2708
2841
|
case "list":
|
|
2709
2842
|
{
|
|
2710
|
-
n += this.renderer.list(
|
|
2843
|
+
n += this.renderer.list(s);
|
|
2711
2844
|
continue;
|
|
2712
2845
|
}
|
|
2713
2846
|
case "html":
|
|
2714
2847
|
{
|
|
2715
|
-
n += this.renderer.html(
|
|
2848
|
+
n += this.renderer.html(s);
|
|
2716
2849
|
continue;
|
|
2717
2850
|
}
|
|
2718
2851
|
case "paragraph":
|
|
2719
2852
|
{
|
|
2720
|
-
n += this.renderer.paragraph(
|
|
2853
|
+
n += this.renderer.paragraph(s);
|
|
2721
2854
|
continue;
|
|
2722
2855
|
}
|
|
2723
2856
|
case "text":
|
|
2724
2857
|
{
|
|
2725
|
-
let o =
|
|
2726
|
-
|
|
2727
|
-
for (;
|
|
2858
|
+
let o = s,
|
|
2859
|
+
a = this.renderer.text(o);
|
|
2860
|
+
for (; r + 1 < e.length && e[r + 1].type === "text";) o = e[++r], a += `
|
|
2728
2861
|
` + this.renderer.text(o);
|
|
2729
2862
|
t ? n += this.renderer.paragraph({
|
|
2730
2863
|
type: "paragraph",
|
|
2731
|
-
raw:
|
|
2732
|
-
text:
|
|
2864
|
+
raw: a,
|
|
2865
|
+
text: a,
|
|
2733
2866
|
tokens: [{
|
|
2734
2867
|
type: "text",
|
|
2735
|
-
raw:
|
|
2736
|
-
text:
|
|
2868
|
+
raw: a,
|
|
2869
|
+
text: a,
|
|
2737
2870
|
escaped: true
|
|
2738
2871
|
}]
|
|
2739
|
-
}) : n +=
|
|
2872
|
+
}) : n += a;
|
|
2740
2873
|
continue;
|
|
2741
2874
|
}
|
|
2742
2875
|
default:
|
|
2743
2876
|
{
|
|
2744
|
-
let o = 'Token with "' +
|
|
2877
|
+
let o = 'Token with "' + s.type + '" type was not found.';
|
|
2745
2878
|
if (this.options.silent) return console.error(o), "";
|
|
2746
2879
|
throw new Error(o);
|
|
2747
2880
|
}
|
|
@@ -2751,8 +2884,8 @@ var T = class a {
|
|
|
2751
2884
|
}
|
|
2752
2885
|
parseInline(e, t = this.renderer) {
|
|
2753
2886
|
let n = "";
|
|
2754
|
-
for (let
|
|
2755
|
-
let i = e[
|
|
2887
|
+
for (let r = 0; r < e.length; r++) {
|
|
2888
|
+
let i = e[r];
|
|
2756
2889
|
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2757
2890
|
let o = this.options.extensions.renderers[i.type].call({
|
|
2758
2891
|
parser: this
|
|
@@ -2762,61 +2895,61 @@ var T = class a {
|
|
|
2762
2895
|
continue;
|
|
2763
2896
|
}
|
|
2764
2897
|
}
|
|
2765
|
-
let
|
|
2766
|
-
switch (
|
|
2898
|
+
let s = i;
|
|
2899
|
+
switch (s.type) {
|
|
2767
2900
|
case "escape":
|
|
2768
2901
|
{
|
|
2769
|
-
n += t.text(
|
|
2902
|
+
n += t.text(s);
|
|
2770
2903
|
break;
|
|
2771
2904
|
}
|
|
2772
2905
|
case "html":
|
|
2773
2906
|
{
|
|
2774
|
-
n += t.html(
|
|
2907
|
+
n += t.html(s);
|
|
2775
2908
|
break;
|
|
2776
2909
|
}
|
|
2777
2910
|
case "link":
|
|
2778
2911
|
{
|
|
2779
|
-
n += t.link(
|
|
2912
|
+
n += t.link(s);
|
|
2780
2913
|
break;
|
|
2781
2914
|
}
|
|
2782
2915
|
case "image":
|
|
2783
2916
|
{
|
|
2784
|
-
n += t.image(
|
|
2917
|
+
n += t.image(s);
|
|
2785
2918
|
break;
|
|
2786
2919
|
}
|
|
2787
2920
|
case "strong":
|
|
2788
2921
|
{
|
|
2789
|
-
n += t.strong(
|
|
2922
|
+
n += t.strong(s);
|
|
2790
2923
|
break;
|
|
2791
2924
|
}
|
|
2792
2925
|
case "em":
|
|
2793
2926
|
{
|
|
2794
|
-
n += t.em(
|
|
2927
|
+
n += t.em(s);
|
|
2795
2928
|
break;
|
|
2796
2929
|
}
|
|
2797
2930
|
case "codespan":
|
|
2798
2931
|
{
|
|
2799
|
-
n += t.codespan(
|
|
2932
|
+
n += t.codespan(s);
|
|
2800
2933
|
break;
|
|
2801
2934
|
}
|
|
2802
2935
|
case "br":
|
|
2803
2936
|
{
|
|
2804
|
-
n += t.br(
|
|
2937
|
+
n += t.br(s);
|
|
2805
2938
|
break;
|
|
2806
2939
|
}
|
|
2807
2940
|
case "del":
|
|
2808
2941
|
{
|
|
2809
|
-
n += t.del(
|
|
2942
|
+
n += t.del(s);
|
|
2810
2943
|
break;
|
|
2811
2944
|
}
|
|
2812
2945
|
case "text":
|
|
2813
2946
|
{
|
|
2814
|
-
n += t.text(
|
|
2947
|
+
n += t.text(s);
|
|
2815
2948
|
break;
|
|
2816
2949
|
}
|
|
2817
2950
|
default:
|
|
2818
2951
|
{
|
|
2819
|
-
let o = 'Token with "' +
|
|
2952
|
+
let o = 'Token with "' + s.type + '" type was not found.';
|
|
2820
2953
|
if (this.options.silent) return console.error(o), "";
|
|
2821
2954
|
throw new Error(o);
|
|
2822
2955
|
}
|
|
@@ -2825,11 +2958,11 @@ var T = class a {
|
|
|
2825
2958
|
return n;
|
|
2826
2959
|
}
|
|
2827
2960
|
};
|
|
2828
|
-
var
|
|
2961
|
+
var $ = class {
|
|
2829
2962
|
options;
|
|
2830
2963
|
block;
|
|
2831
2964
|
constructor(e) {
|
|
2832
|
-
this.options = e ||
|
|
2965
|
+
this.options = e || O;
|
|
2833
2966
|
}
|
|
2834
2967
|
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2835
2968
|
preprocess(e) {
|
|
@@ -2845,44 +2978,44 @@ var L = class {
|
|
|
2845
2978
|
return this.block ? b.lex : b.lexInline;
|
|
2846
2979
|
}
|
|
2847
2980
|
provideParser() {
|
|
2848
|
-
return this.block ?
|
|
2981
|
+
return this.block ? R.parse : R.parseInline;
|
|
2849
2982
|
}
|
|
2850
2983
|
};
|
|
2851
2984
|
var B = class {
|
|
2852
|
-
defaults =
|
|
2985
|
+
defaults = L();
|
|
2853
2986
|
options = this.setOptions;
|
|
2854
2987
|
parse = this.parseMarkdown(true);
|
|
2855
2988
|
parseInline = this.parseMarkdown(false);
|
|
2856
|
-
Parser =
|
|
2857
|
-
Renderer =
|
|
2858
|
-
TextRenderer =
|
|
2989
|
+
Parser = R;
|
|
2990
|
+
Renderer = P;
|
|
2991
|
+
TextRenderer = S;
|
|
2859
2992
|
Lexer = b;
|
|
2860
|
-
Tokenizer =
|
|
2861
|
-
Hooks =
|
|
2993
|
+
Tokenizer = y;
|
|
2994
|
+
Hooks = $;
|
|
2862
2995
|
constructor(...e) {
|
|
2863
2996
|
this.use(...e);
|
|
2864
2997
|
}
|
|
2865
2998
|
walkTokens(e, t) {
|
|
2866
2999
|
let n = [];
|
|
2867
|
-
for (let
|
|
3000
|
+
for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
|
|
2868
3001
|
case "table":
|
|
2869
3002
|
{
|
|
2870
|
-
let i =
|
|
2871
|
-
for (let
|
|
2872
|
-
for (let
|
|
3003
|
+
let i = r;
|
|
3004
|
+
for (let s of i.header) n = n.concat(this.walkTokens(s.tokens, t));
|
|
3005
|
+
for (let s of i.rows) for (let o of s) n = n.concat(this.walkTokens(o.tokens, t));
|
|
2873
3006
|
break;
|
|
2874
3007
|
}
|
|
2875
3008
|
case "list":
|
|
2876
3009
|
{
|
|
2877
|
-
let i =
|
|
3010
|
+
let i = r;
|
|
2878
3011
|
n = n.concat(this.walkTokens(i.items, t));
|
|
2879
3012
|
break;
|
|
2880
3013
|
}
|
|
2881
3014
|
default:
|
|
2882
3015
|
{
|
|
2883
|
-
let i =
|
|
2884
|
-
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach(
|
|
2885
|
-
let o = i[
|
|
3016
|
+
let i = r;
|
|
3017
|
+
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach(s => {
|
|
3018
|
+
let o = i[s].flat(1 / 0);
|
|
2886
3019
|
n = n.concat(this.walkTokens(o, t));
|
|
2887
3020
|
}) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
|
|
2888
3021
|
}
|
|
@@ -2895,84 +3028,84 @@ var B = class {
|
|
|
2895
3028
|
childTokens: {}
|
|
2896
3029
|
};
|
|
2897
3030
|
return e.forEach(n => {
|
|
2898
|
-
let
|
|
3031
|
+
let r = {
|
|
2899
3032
|
...n
|
|
2900
3033
|
};
|
|
2901
|
-
if (
|
|
3034
|
+
if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach(i => {
|
|
2902
3035
|
if (!i.name) throw new Error("extension name required");
|
|
2903
3036
|
if ("renderer" in i) {
|
|
2904
|
-
let
|
|
2905
|
-
|
|
2906
|
-
let
|
|
2907
|
-
return
|
|
3037
|
+
let s = t.renderers[i.name];
|
|
3038
|
+
s ? t.renderers[i.name] = function (...o) {
|
|
3039
|
+
let a = i.renderer.apply(this, o);
|
|
3040
|
+
return a === false && (a = s.apply(this, o)), a;
|
|
2908
3041
|
} : t.renderers[i.name] = i.renderer;
|
|
2909
3042
|
}
|
|
2910
3043
|
if ("tokenizer" in i) {
|
|
2911
3044
|
if (!i.level || i.level !== "block" && i.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
2912
|
-
let
|
|
2913
|
-
|
|
3045
|
+
let s = t[i.level];
|
|
3046
|
+
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]));
|
|
2914
3047
|
}
|
|
2915
3048
|
"childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
|
|
2916
|
-
}),
|
|
2917
|
-
let i = this.defaults.renderer || new
|
|
2918
|
-
for (let
|
|
2919
|
-
if (!(
|
|
2920
|
-
if (["options", "parser"].includes(
|
|
2921
|
-
let o =
|
|
2922
|
-
|
|
2923
|
-
|
|
3049
|
+
}), r.extensions = t), n.renderer) {
|
|
3050
|
+
let i = this.defaults.renderer || new P(this.defaults);
|
|
3051
|
+
for (let s in n.renderer) {
|
|
3052
|
+
if (!(s in i)) throw new Error(`renderer '${s}' does not exist`);
|
|
3053
|
+
if (["options", "parser"].includes(s)) continue;
|
|
3054
|
+
let o = s,
|
|
3055
|
+
a = n.renderer[o],
|
|
3056
|
+
u = i[o];
|
|
2924
3057
|
i[o] = (...p) => {
|
|
2925
|
-
let
|
|
2926
|
-
return
|
|
3058
|
+
let c = a.apply(i, p);
|
|
3059
|
+
return c === false && (c = u.apply(i, p)), c || "";
|
|
2927
3060
|
};
|
|
2928
3061
|
}
|
|
2929
|
-
|
|
3062
|
+
r.renderer = i;
|
|
2930
3063
|
}
|
|
2931
3064
|
if (n.tokenizer) {
|
|
2932
|
-
let i = this.defaults.tokenizer || new
|
|
2933
|
-
for (let
|
|
2934
|
-
if (!(
|
|
2935
|
-
if (["options", "rules", "lexer"].includes(
|
|
2936
|
-
let o =
|
|
2937
|
-
|
|
2938
|
-
|
|
3065
|
+
let i = this.defaults.tokenizer || new y(this.defaults);
|
|
3066
|
+
for (let s in n.tokenizer) {
|
|
3067
|
+
if (!(s in i)) throw new Error(`tokenizer '${s}' does not exist`);
|
|
3068
|
+
if (["options", "rules", "lexer"].includes(s)) continue;
|
|
3069
|
+
let o = s,
|
|
3070
|
+
a = n.tokenizer[o],
|
|
3071
|
+
u = i[o];
|
|
2939
3072
|
i[o] = (...p) => {
|
|
2940
|
-
let
|
|
2941
|
-
return
|
|
3073
|
+
let c = a.apply(i, p);
|
|
3074
|
+
return c === false && (c = u.apply(i, p)), c;
|
|
2942
3075
|
};
|
|
2943
3076
|
}
|
|
2944
|
-
|
|
3077
|
+
r.tokenizer = i;
|
|
2945
3078
|
}
|
|
2946
3079
|
if (n.hooks) {
|
|
2947
|
-
let i = this.defaults.hooks || new
|
|
2948
|
-
for (let
|
|
2949
|
-
if (!(
|
|
2950
|
-
if (["options", "block"].includes(
|
|
2951
|
-
let o =
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
if (this.defaults.async) return Promise.resolve(
|
|
2956
|
-
let
|
|
2957
|
-
return
|
|
3080
|
+
let i = this.defaults.hooks || new $();
|
|
3081
|
+
for (let s in n.hooks) {
|
|
3082
|
+
if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
|
|
3083
|
+
if (["options", "block"].includes(s)) continue;
|
|
3084
|
+
let o = s,
|
|
3085
|
+
a = n.hooks[o],
|
|
3086
|
+
u = i[o];
|
|
3087
|
+
$.passThroughHooks.has(s) ? i[o] = p => {
|
|
3088
|
+
if (this.defaults.async) return Promise.resolve(a.call(i, p)).then(f => u.call(i, f));
|
|
3089
|
+
let c = a.call(i, p);
|
|
3090
|
+
return u.call(i, c);
|
|
2958
3091
|
} : i[o] = (...p) => {
|
|
2959
|
-
let
|
|
2960
|
-
return
|
|
3092
|
+
let c = a.apply(i, p);
|
|
3093
|
+
return c === false && (c = u.apply(i, p)), c;
|
|
2961
3094
|
};
|
|
2962
3095
|
}
|
|
2963
|
-
|
|
3096
|
+
r.hooks = i;
|
|
2964
3097
|
}
|
|
2965
3098
|
if (n.walkTokens) {
|
|
2966
3099
|
let i = this.defaults.walkTokens,
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
let
|
|
2970
|
-
return
|
|
3100
|
+
s = n.walkTokens;
|
|
3101
|
+
r.walkTokens = function (o) {
|
|
3102
|
+
let a = [];
|
|
3103
|
+
return a.push(s.call(this, o)), i && (a = a.concat(i.call(this, o))), a;
|
|
2971
3104
|
};
|
|
2972
3105
|
}
|
|
2973
3106
|
this.defaults = {
|
|
2974
3107
|
...this.defaults,
|
|
2975
|
-
...
|
|
3108
|
+
...r
|
|
2976
3109
|
};
|
|
2977
3110
|
}), this;
|
|
2978
3111
|
}
|
|
@@ -2986,31 +3119,31 @@ var B = class {
|
|
|
2986
3119
|
return b.lex(e, t ?? this.defaults);
|
|
2987
3120
|
}
|
|
2988
3121
|
parser(e, t) {
|
|
2989
|
-
return
|
|
3122
|
+
return R.parse(e, t ?? this.defaults);
|
|
2990
3123
|
}
|
|
2991
3124
|
parseMarkdown(e) {
|
|
2992
|
-
return (n,
|
|
3125
|
+
return (n, r) => {
|
|
2993
3126
|
let i = {
|
|
2994
|
-
...
|
|
3127
|
+
...r
|
|
2995
3128
|
},
|
|
2996
|
-
|
|
3129
|
+
s = {
|
|
2997
3130
|
...this.defaults,
|
|
2998
3131
|
...i
|
|
2999
3132
|
},
|
|
3000
|
-
o = this.onError(!!
|
|
3133
|
+
o = this.onError(!!s.silent, !!s.async);
|
|
3001
3134
|
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."));
|
|
3002
3135
|
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
3003
3136
|
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
3004
|
-
|
|
3005
|
-
let
|
|
3006
|
-
|
|
3007
|
-
if (
|
|
3137
|
+
s.hooks && (s.hooks.options = s, s.hooks.block = e);
|
|
3138
|
+
let a = s.hooks ? s.hooks.provideLexer() : e ? b.lex : b.lexInline,
|
|
3139
|
+
u = s.hooks ? s.hooks.provideParser() : e ? R.parse : R.parseInline;
|
|
3140
|
+
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);
|
|
3008
3141
|
try {
|
|
3009
|
-
|
|
3010
|
-
let p =
|
|
3011
|
-
|
|
3012
|
-
let
|
|
3013
|
-
return
|
|
3142
|
+
s.hooks && (n = s.hooks.preprocess(n));
|
|
3143
|
+
let p = a(n, s);
|
|
3144
|
+
s.hooks && (p = s.hooks.processAllTokens(p)), s.walkTokens && this.walkTokens(p, s.walkTokens);
|
|
3145
|
+
let c = u(p, s);
|
|
3146
|
+
return s.hooks && (c = s.hooks.postprocess(c)), c;
|
|
3014
3147
|
} catch (p) {
|
|
3015
3148
|
return o(p);
|
|
3016
3149
|
}
|
|
@@ -3020,51 +3153,48 @@ var B = class {
|
|
|
3020
3153
|
return n => {
|
|
3021
3154
|
if (n.message += `
|
|
3022
3155
|
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
3023
|
-
let
|
|
3024
|
-
return t ? Promise.resolve(
|
|
3156
|
+
let r = "<p>An error occurred:</p><pre>" + w(n.message + "", true) + "</pre>";
|
|
3157
|
+
return t ? Promise.resolve(r) : r;
|
|
3025
3158
|
}
|
|
3026
3159
|
if (t) return Promise.reject(n);
|
|
3027
3160
|
throw n;
|
|
3028
3161
|
};
|
|
3029
3162
|
}
|
|
3030
3163
|
};
|
|
3031
|
-
var
|
|
3032
|
-
function
|
|
3033
|
-
return
|
|
3164
|
+
var _ = new B();
|
|
3165
|
+
function d(l, e) {
|
|
3166
|
+
return _.parse(l, e);
|
|
3034
3167
|
}
|
|
3035
|
-
|
|
3036
|
-
return
|
|
3037
|
-
};
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
return
|
|
3042
|
-
};
|
|
3043
|
-
|
|
3044
|
-
return
|
|
3045
|
-
};
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3168
|
+
d.options = d.setOptions = function (l) {
|
|
3169
|
+
return _.setOptions(l), d.defaults = _.defaults, H(d.defaults), d;
|
|
3170
|
+
};
|
|
3171
|
+
d.getDefaults = L;
|
|
3172
|
+
d.defaults = O;
|
|
3173
|
+
d.use = function (...l) {
|
|
3174
|
+
return _.use(...l), d.defaults = _.defaults, H(d.defaults), d;
|
|
3175
|
+
};
|
|
3176
|
+
d.walkTokens = function (l, e) {
|
|
3177
|
+
return _.walkTokens(l, e);
|
|
3178
|
+
};
|
|
3179
|
+
d.parseInline = _.parseInline;
|
|
3180
|
+
d.Parser = R;
|
|
3181
|
+
d.parser = R.parse;
|
|
3182
|
+
d.Renderer = P;
|
|
3183
|
+
d.TextRenderer = S;
|
|
3184
|
+
d.Lexer = b;
|
|
3185
|
+
d.lexer = b.lex;
|
|
3186
|
+
d.Tokenizer = y;
|
|
3187
|
+
d.Hooks = $;
|
|
3188
|
+
d.parse = d;
|
|
3056
3189
|
|
|
3057
3190
|
const renderMarkdown = async (markdown, options = {}) => {
|
|
3058
|
-
const html = await
|
|
3191
|
+
const html = await d(markdown, {});
|
|
3059
3192
|
return html;
|
|
3060
3193
|
};
|
|
3061
3194
|
|
|
3062
|
-
const terminate = () => {
|
|
3063
|
-
globalThis.close();
|
|
3064
|
-
};
|
|
3065
|
-
|
|
3066
3195
|
const commandMap = {
|
|
3067
3196
|
'Markdown.getVirtualDom': getMarkdownVirtualDom,
|
|
3197
|
+
'Markdown.handleMessagePort': handleMessagePort,
|
|
3068
3198
|
'Markdown.render': renderMarkdown,
|
|
3069
3199
|
'Markdown.terminate': terminate,
|
|
3070
3200
|
// deprecated
|
|
@@ -3110,8 +3240,7 @@ const {
|
|
|
3110
3240
|
set: set$3} = create(RendererWorker$1);
|
|
3111
3241
|
const RendererWorker = {
|
|
3112
3242
|
__proto__: null,
|
|
3113
|
-
set: set$3
|
|
3114
|
-
};
|
|
3243
|
+
set: set$3};
|
|
3115
3244
|
|
|
3116
3245
|
const {
|
|
3117
3246
|
set
|