@lvce-editor/markdown-worker 1.5.0 → 1.7.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 +1646 -2292
- 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
|
};
|
|
@@ -344,22 +352,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
344
352
|
const wrap$f = global => {
|
|
345
353
|
return new IpcChildWithModuleWorker(global);
|
|
346
354
|
};
|
|
347
|
-
const withResolvers = () => {
|
|
348
|
-
let _resolve;
|
|
349
|
-
const promise = new Promise(resolve => {
|
|
350
|
-
_resolve = resolve;
|
|
351
|
-
});
|
|
352
|
-
return {
|
|
353
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
354
|
-
resolve: _resolve,
|
|
355
|
-
promise
|
|
356
|
-
};
|
|
357
|
-
};
|
|
358
355
|
const waitForFirstMessage = async port => {
|
|
359
356
|
const {
|
|
360
357
|
resolve,
|
|
361
358
|
promise
|
|
362
|
-
} = withResolvers();
|
|
359
|
+
} = Promise.withResolvers();
|
|
363
360
|
port.addEventListener('message', resolve, {
|
|
364
361
|
once: true
|
|
365
362
|
});
|
|
@@ -420,6 +417,100 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
420
417
|
listen: listen$6,
|
|
421
418
|
wrap: wrap$e
|
|
422
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
|
+
};
|
|
423
514
|
|
|
424
515
|
const Two = '2.0';
|
|
425
516
|
const create$4 = (method, params) => {
|
|
@@ -433,7 +524,7 @@ const callbacks = Object.create(null);
|
|
|
433
524
|
const set$1 = (id, fn) => {
|
|
434
525
|
callbacks[id] = fn;
|
|
435
526
|
};
|
|
436
|
-
const get = id => {
|
|
527
|
+
const get$1 = id => {
|
|
437
528
|
return callbacks[id];
|
|
438
529
|
};
|
|
439
530
|
const remove = id => {
|
|
@@ -522,6 +613,16 @@ const constructError = (message, type, name) => {
|
|
|
522
613
|
}
|
|
523
614
|
return new ErrorConstructor(message);
|
|
524
615
|
};
|
|
616
|
+
const joinLines = lines => {
|
|
617
|
+
return lines.join(NewLine);
|
|
618
|
+
};
|
|
619
|
+
const splitLines = lines => {
|
|
620
|
+
return lines.split(NewLine);
|
|
621
|
+
};
|
|
622
|
+
const getCurrentStack = () => {
|
|
623
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
624
|
+
return currentStack;
|
|
625
|
+
};
|
|
525
626
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
526
627
|
return string.indexOf(NewLine, startIndex);
|
|
527
628
|
};
|
|
@@ -532,19 +633,16 @@ const getParentStack = error => {
|
|
|
532
633
|
}
|
|
533
634
|
return parentStack;
|
|
534
635
|
};
|
|
535
|
-
const joinLines = lines => {
|
|
536
|
-
return lines.join(NewLine);
|
|
537
|
-
};
|
|
538
636
|
const MethodNotFound = -32601;
|
|
539
637
|
const Custom = -32001;
|
|
540
|
-
const splitLines = lines => {
|
|
541
|
-
return lines.split(NewLine);
|
|
542
|
-
};
|
|
543
638
|
const restoreJsonRpcError = error => {
|
|
639
|
+
const currentStack = getCurrentStack();
|
|
544
640
|
if (error && error instanceof Error) {
|
|
641
|
+
if (typeof error.stack === 'string') {
|
|
642
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
643
|
+
}
|
|
545
644
|
return error;
|
|
546
645
|
}
|
|
547
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
548
646
|
if (error && error.code && error.code === MethodNotFound) {
|
|
549
647
|
const restoredError = new JsonRpcError(error.message);
|
|
550
648
|
const parentStack = getParentStack(error);
|
|
@@ -606,7 +704,7 @@ const warn = (...args) => {
|
|
|
606
704
|
console.warn(...args);
|
|
607
705
|
};
|
|
608
706
|
const resolve = (id, response) => {
|
|
609
|
-
const fn = get(id);
|
|
707
|
+
const fn = get$1(id);
|
|
610
708
|
if (!fn) {
|
|
611
709
|
console.log(response);
|
|
612
710
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -625,6 +723,17 @@ const getErrorType = prettyError => {
|
|
|
625
723
|
}
|
|
626
724
|
return undefined;
|
|
627
725
|
};
|
|
726
|
+
const isAlreadyStack = line => {
|
|
727
|
+
return line.trim().startsWith('at ');
|
|
728
|
+
};
|
|
729
|
+
const getStack = prettyError => {
|
|
730
|
+
const stackString = prettyError.stack || '';
|
|
731
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
732
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
733
|
+
return stackString.slice(newLineIndex + 1);
|
|
734
|
+
}
|
|
735
|
+
return stackString;
|
|
736
|
+
};
|
|
628
737
|
const getErrorProperty = (error, prettyError) => {
|
|
629
738
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
630
739
|
return {
|
|
@@ -637,7 +746,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
637
746
|
code: Custom,
|
|
638
747
|
message: prettyError.message,
|
|
639
748
|
data: {
|
|
640
|
-
stack: prettyError
|
|
749
|
+
stack: getStack(prettyError),
|
|
641
750
|
codeFrame: prettyError.codeFrame,
|
|
642
751
|
type: getErrorType(prettyError),
|
|
643
752
|
code: prettyError.code,
|
|
@@ -645,20 +754,20 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
645
754
|
}
|
|
646
755
|
};
|
|
647
756
|
};
|
|
648
|
-
const create$1 = (
|
|
757
|
+
const create$1$1 = (id, error) => {
|
|
649
758
|
return {
|
|
650
759
|
jsonrpc: Two,
|
|
651
|
-
id
|
|
760
|
+
id,
|
|
652
761
|
error
|
|
653
762
|
};
|
|
654
763
|
};
|
|
655
|
-
const getErrorResponse = (
|
|
764
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
656
765
|
const prettyError = preparePrettyError(error);
|
|
657
766
|
logError(error, prettyError);
|
|
658
767
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
659
|
-
return create$1(
|
|
768
|
+
return create$1$1(id, errorProperty);
|
|
660
769
|
};
|
|
661
|
-
const create$
|
|
770
|
+
const create$6 = (message, result) => {
|
|
662
771
|
return {
|
|
663
772
|
jsonrpc: Two,
|
|
664
773
|
id: message.id,
|
|
@@ -667,14 +776,29 @@ const create$5 = (message, result) => {
|
|
|
667
776
|
};
|
|
668
777
|
const getSuccessResponse = (message, result) => {
|
|
669
778
|
const resultProperty = result ?? null;
|
|
670
|
-
return create$
|
|
779
|
+
return create$6(message, resultProperty);
|
|
780
|
+
};
|
|
781
|
+
const getErrorResponseSimple = (id, error) => {
|
|
782
|
+
return {
|
|
783
|
+
jsonrpc: Two,
|
|
784
|
+
id,
|
|
785
|
+
error: {
|
|
786
|
+
code: Custom,
|
|
787
|
+
// @ts-ignore
|
|
788
|
+
message: error.message,
|
|
789
|
+
data: error
|
|
790
|
+
}
|
|
791
|
+
};
|
|
671
792
|
};
|
|
672
793
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
673
794
|
try {
|
|
674
795
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
675
796
|
return getSuccessResponse(message, result);
|
|
676
797
|
} catch (error) {
|
|
677
|
-
|
|
798
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
799
|
+
return getErrorResponseSimple(message.id, error);
|
|
800
|
+
}
|
|
801
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
678
802
|
}
|
|
679
803
|
};
|
|
680
804
|
const defaultPreparePrettyError = error => {
|
|
@@ -729,7 +853,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
729
853
|
try {
|
|
730
854
|
ipc.send(response);
|
|
731
855
|
} catch (error) {
|
|
732
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
856
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
733
857
|
ipc.send(errorResponse);
|
|
734
858
|
}
|
|
735
859
|
return;
|
|
@@ -834,7 +958,27 @@ const listen$1 = async (module, options) => {
|
|
|
834
958
|
const ipc = module.wrap(rawIpc);
|
|
835
959
|
return ipc;
|
|
836
960
|
};
|
|
837
|
-
const create = async ({
|
|
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
|
+
};
|
|
981
|
+
const create$1 = async ({
|
|
838
982
|
commandMap
|
|
839
983
|
}) => {
|
|
840
984
|
// TODO create a commandMap per rpc instance
|
|
@@ -846,7 +990,84 @@ const create = async ({
|
|
|
846
990
|
};
|
|
847
991
|
const WebWorkerRpcClient = {
|
|
848
992
|
__proto__: null,
|
|
849
|
-
create
|
|
993
|
+
create: create$1
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
const terminate = () => {
|
|
997
|
+
globalThis.close();
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
const Div$1 = 4;
|
|
1001
|
+
const H1$1 = 5;
|
|
1002
|
+
const Span$1 = 8;
|
|
1003
|
+
const Text$1 = 12;
|
|
1004
|
+
const Img$1 = 17;
|
|
1005
|
+
const H2$1 = 22;
|
|
1006
|
+
const H3$1 = 23;
|
|
1007
|
+
const H4$1 = 24;
|
|
1008
|
+
const H5$1 = 25;
|
|
1009
|
+
const Article$1 = 27;
|
|
1010
|
+
const Aside$1 = 28;
|
|
1011
|
+
const Footer$1 = 29;
|
|
1012
|
+
const Header$1 = 30;
|
|
1013
|
+
const Nav$1 = 40;
|
|
1014
|
+
const Section$1 = 41;
|
|
1015
|
+
const Search$1 = 42;
|
|
1016
|
+
const Dd$1 = 43;
|
|
1017
|
+
const Dl$1 = 44;
|
|
1018
|
+
const Figcaption$1 = 45;
|
|
1019
|
+
const Figure$1 = 46;
|
|
1020
|
+
const Hr$1 = 47;
|
|
1021
|
+
const Li$1 = 48;
|
|
1022
|
+
const Ol$1 = 49;
|
|
1023
|
+
const P$2 = 50;
|
|
1024
|
+
const Pre$1 = 51;
|
|
1025
|
+
const A$2 = 53;
|
|
1026
|
+
const Abbr$1 = 54;
|
|
1027
|
+
const Br$1 = 55;
|
|
1028
|
+
const Cite$1 = 56;
|
|
1029
|
+
const Data$1 = 57;
|
|
1030
|
+
const Time$1 = 58;
|
|
1031
|
+
const Tfoot$1 = 59;
|
|
1032
|
+
const VirtualDomElements = {
|
|
1033
|
+
__proto__: null,
|
|
1034
|
+
A: A$2,
|
|
1035
|
+
Abbr: Abbr$1,
|
|
1036
|
+
Article: Article$1,
|
|
1037
|
+
Aside: Aside$1,
|
|
1038
|
+
Br: Br$1,
|
|
1039
|
+
Cite: Cite$1,
|
|
1040
|
+
Data: Data$1,
|
|
1041
|
+
Dd: Dd$1,
|
|
1042
|
+
Div: Div$1,
|
|
1043
|
+
Dl: Dl$1,
|
|
1044
|
+
Figcaption: Figcaption$1,
|
|
1045
|
+
Figure: Figure$1,
|
|
1046
|
+
Footer: Footer$1,
|
|
1047
|
+
H1: H1$1,
|
|
1048
|
+
H2: H2$1,
|
|
1049
|
+
H3: H3$1,
|
|
1050
|
+
H4: H4$1,
|
|
1051
|
+
H5: H5$1,
|
|
1052
|
+
Header: Header$1,
|
|
1053
|
+
Hr: Hr$1,
|
|
1054
|
+
Img: Img$1,
|
|
1055
|
+
Li: Li$1,
|
|
1056
|
+
Nav: Nav$1,
|
|
1057
|
+
Ol: Ol$1,
|
|
1058
|
+
P: P$2,
|
|
1059
|
+
Pre: Pre$1,
|
|
1060
|
+
Search: Search$1,
|
|
1061
|
+
Section: Section$1,
|
|
1062
|
+
Span: Span$1,
|
|
1063
|
+
Tfoot: Tfoot$1,
|
|
1064
|
+
Time: Time$1};
|
|
1065
|
+
const text = data => {
|
|
1066
|
+
return {
|
|
1067
|
+
type: Text$1,
|
|
1068
|
+
text: data,
|
|
1069
|
+
childCount: 0
|
|
1070
|
+
};
|
|
850
1071
|
};
|
|
851
1072
|
|
|
852
1073
|
const allowedMarkdownAttributes = ['src', 'id', 'className', 'title', 'alt', 'href', 'target', 'rel'];
|
|
@@ -870,137 +1091,104 @@ const getVirtualDomChildCount = markdownDom => {
|
|
|
870
1091
|
return stack.length;
|
|
871
1092
|
};
|
|
872
1093
|
|
|
873
|
-
const Div
|
|
874
|
-
const H1
|
|
875
|
-
const H2
|
|
876
|
-
const H3
|
|
877
|
-
const H4
|
|
878
|
-
const H5
|
|
879
|
-
const Img
|
|
880
|
-
const Span
|
|
881
|
-
const Article
|
|
882
|
-
const Aside
|
|
883
|
-
const Footer
|
|
884
|
-
const Header
|
|
885
|
-
const Nav
|
|
886
|
-
const Section
|
|
887
|
-
const Search
|
|
888
|
-
const Dd
|
|
889
|
-
const Dl
|
|
890
|
-
const Figcaption
|
|
891
|
-
const Figure
|
|
892
|
-
const Hr
|
|
893
|
-
const Li
|
|
894
|
-
const Ol
|
|
1094
|
+
const Div = 'div';
|
|
1095
|
+
const H1 = 'h1';
|
|
1096
|
+
const H2 = 'h2';
|
|
1097
|
+
const H3 = 'h3';
|
|
1098
|
+
const H4 = 'h4';
|
|
1099
|
+
const H5 = 'h5';
|
|
1100
|
+
const Img = 'img';
|
|
1101
|
+
const Span = 'span';
|
|
1102
|
+
const Article = 'article';
|
|
1103
|
+
const Aside = 'aside';
|
|
1104
|
+
const Footer = 'footer';
|
|
1105
|
+
const Header = 'header';
|
|
1106
|
+
const Nav = 'nav';
|
|
1107
|
+
const Section = 'section';
|
|
1108
|
+
const Search = 'search';
|
|
1109
|
+
const Dd = 'dd';
|
|
1110
|
+
const Dl = 'dl';
|
|
1111
|
+
const Figcaption = 'figcaption';
|
|
1112
|
+
const Figure = 'figure';
|
|
1113
|
+
const Hr = 'hr';
|
|
1114
|
+
const Li = 'li';
|
|
1115
|
+
const Ol = 'ol';
|
|
895
1116
|
const P$1 = 'p';
|
|
896
|
-
const Pre
|
|
1117
|
+
const Pre = 'pre';
|
|
897
1118
|
const A$1 = 'a';
|
|
898
|
-
const Abbr
|
|
899
|
-
const Br
|
|
900
|
-
const Cite
|
|
901
|
-
const Data
|
|
902
|
-
const Time
|
|
903
|
-
const Tfoot
|
|
904
|
-
|
|
905
|
-
const A = 53;
|
|
906
|
-
const Abbr = 54;
|
|
907
|
-
const Article = 27;
|
|
908
|
-
const Aside = 28;
|
|
909
|
-
const Br = 55;
|
|
910
|
-
const Cite = 56;
|
|
911
|
-
const Data = 57;
|
|
912
|
-
const Dd = 43;
|
|
913
|
-
const Div = 4;
|
|
914
|
-
const Dl = 44;
|
|
915
|
-
const Figcaption = 45;
|
|
916
|
-
const Figure = 46;
|
|
917
|
-
const Footer = 29;
|
|
918
|
-
const H1 = 5;
|
|
919
|
-
const H2 = 22;
|
|
920
|
-
const H3 = 23;
|
|
921
|
-
const H4 = 24;
|
|
922
|
-
const H5 = 25;
|
|
923
|
-
const Header = 30;
|
|
924
|
-
const Hr = 47;
|
|
925
|
-
const Img = 17;
|
|
926
|
-
const Li = 48;
|
|
927
|
-
const Nav = 40;
|
|
928
|
-
const Ol = 49;
|
|
929
|
-
const P = 50;
|
|
930
|
-
const Pre = 51;
|
|
931
|
-
const Search = 42;
|
|
932
|
-
const Section = 41;
|
|
933
|
-
const Span = 8;
|
|
934
|
-
const Text$1 = 12;
|
|
935
|
-
const Tfoot = 59;
|
|
936
|
-
const Time = 58;
|
|
1119
|
+
const Abbr = 'abbr';
|
|
1120
|
+
const Br = 'br';
|
|
1121
|
+
const Cite = 'cite';
|
|
1122
|
+
const Data = 'data';
|
|
1123
|
+
const Time = 'time';
|
|
1124
|
+
const Tfoot = 'tfoot';
|
|
937
1125
|
|
|
938
1126
|
const getVirtualDomTag = text => {
|
|
939
1127
|
switch (text) {
|
|
940
|
-
case H1
|
|
941
|
-
return H1;
|
|
942
|
-
case H2
|
|
943
|
-
return H2;
|
|
944
|
-
case H3
|
|
945
|
-
return H3;
|
|
946
|
-
case H4
|
|
947
|
-
return H4;
|
|
948
|
-
case H5
|
|
949
|
-
return H5;
|
|
950
|
-
case Div
|
|
951
|
-
return Div;
|
|
952
|
-
case Article
|
|
953
|
-
return Article;
|
|
954
|
-
case Aside
|
|
955
|
-
return Aside;
|
|
956
|
-
case Footer
|
|
957
|
-
return Footer;
|
|
958
|
-
case Header
|
|
959
|
-
return Header;
|
|
960
|
-
case Nav
|
|
961
|
-
return Nav;
|
|
962
|
-
case Section
|
|
963
|
-
return Section;
|
|
964
|
-
case Search
|
|
965
|
-
return Search;
|
|
966
|
-
case Dd
|
|
967
|
-
return Dd;
|
|
968
|
-
case Dl
|
|
969
|
-
return Dl;
|
|
970
|
-
case Figcaption
|
|
971
|
-
return Figcaption;
|
|
972
|
-
case Figure
|
|
973
|
-
return Figure;
|
|
974
|
-
case Hr
|
|
975
|
-
return Hr;
|
|
976
|
-
case Li
|
|
977
|
-
return Li;
|
|
978
|
-
case Ol
|
|
979
|
-
return Ol;
|
|
1128
|
+
case H1:
|
|
1129
|
+
return VirtualDomElements.H1;
|
|
1130
|
+
case H2:
|
|
1131
|
+
return VirtualDomElements.H2;
|
|
1132
|
+
case H3:
|
|
1133
|
+
return VirtualDomElements.H3;
|
|
1134
|
+
case H4:
|
|
1135
|
+
return VirtualDomElements.H4;
|
|
1136
|
+
case H5:
|
|
1137
|
+
return VirtualDomElements.H5;
|
|
1138
|
+
case Div:
|
|
1139
|
+
return VirtualDomElements.Div;
|
|
1140
|
+
case Article:
|
|
1141
|
+
return VirtualDomElements.Article;
|
|
1142
|
+
case Aside:
|
|
1143
|
+
return VirtualDomElements.Aside;
|
|
1144
|
+
case Footer:
|
|
1145
|
+
return VirtualDomElements.Footer;
|
|
1146
|
+
case Header:
|
|
1147
|
+
return VirtualDomElements.Header;
|
|
1148
|
+
case Nav:
|
|
1149
|
+
return VirtualDomElements.Nav;
|
|
1150
|
+
case Section:
|
|
1151
|
+
return VirtualDomElements.Section;
|
|
1152
|
+
case Search:
|
|
1153
|
+
return VirtualDomElements.Search;
|
|
1154
|
+
case Dd:
|
|
1155
|
+
return VirtualDomElements.Dd;
|
|
1156
|
+
case Dl:
|
|
1157
|
+
return VirtualDomElements.Dl;
|
|
1158
|
+
case Figcaption:
|
|
1159
|
+
return VirtualDomElements.Figcaption;
|
|
1160
|
+
case Figure:
|
|
1161
|
+
return VirtualDomElements.Figure;
|
|
1162
|
+
case Hr:
|
|
1163
|
+
return VirtualDomElements.Hr;
|
|
1164
|
+
case Li:
|
|
1165
|
+
return VirtualDomElements.Li;
|
|
1166
|
+
case Ol:
|
|
1167
|
+
return VirtualDomElements.Ol;
|
|
980
1168
|
case P$1:
|
|
981
|
-
return P;
|
|
982
|
-
case Pre
|
|
983
|
-
return Pre;
|
|
1169
|
+
return VirtualDomElements.P;
|
|
1170
|
+
case Pre:
|
|
1171
|
+
return VirtualDomElements.Pre;
|
|
984
1172
|
case A$1:
|
|
985
|
-
return A;
|
|
986
|
-
case Abbr
|
|
987
|
-
return Abbr;
|
|
988
|
-
case Br
|
|
989
|
-
return Br;
|
|
990
|
-
case Cite
|
|
991
|
-
return Cite;
|
|
992
|
-
case Data
|
|
993
|
-
return Data;
|
|
994
|
-
case Time
|
|
995
|
-
return Time;
|
|
996
|
-
case Tfoot
|
|
997
|
-
return Tfoot;
|
|
998
|
-
case Img
|
|
999
|
-
return Img;
|
|
1000
|
-
case Span
|
|
1001
|
-
return Span;
|
|
1173
|
+
return VirtualDomElements.A;
|
|
1174
|
+
case Abbr:
|
|
1175
|
+
return VirtualDomElements.Abbr;
|
|
1176
|
+
case Br:
|
|
1177
|
+
return VirtualDomElements.Br;
|
|
1178
|
+
case Cite:
|
|
1179
|
+
return VirtualDomElements.Cite;
|
|
1180
|
+
case Data:
|
|
1181
|
+
return VirtualDomElements.Data;
|
|
1182
|
+
case Time:
|
|
1183
|
+
return VirtualDomElements.Time;
|
|
1184
|
+
case Tfoot:
|
|
1185
|
+
return VirtualDomElements.Tfoot;
|
|
1186
|
+
case Img:
|
|
1187
|
+
return VirtualDomElements.Img;
|
|
1188
|
+
case Span:
|
|
1189
|
+
return VirtualDomElements.Span;
|
|
1002
1190
|
default:
|
|
1003
|
-
return Div;
|
|
1191
|
+
return VirtualDomElements.Div;
|
|
1004
1192
|
}
|
|
1005
1193
|
};
|
|
1006
1194
|
|
|
@@ -1029,7 +1217,7 @@ const CommentStart = 21;
|
|
|
1029
1217
|
|
|
1030
1218
|
const isSelfClosingTag = tag => {
|
|
1031
1219
|
switch (tag) {
|
|
1032
|
-
case Img
|
|
1220
|
+
case Img:
|
|
1033
1221
|
return true;
|
|
1034
1222
|
default:
|
|
1035
1223
|
return false;
|
|
@@ -1294,14 +1482,6 @@ const tokenizeHtml = text => {
|
|
|
1294
1482
|
return tokens;
|
|
1295
1483
|
};
|
|
1296
1484
|
|
|
1297
|
-
const text = data => {
|
|
1298
|
-
return {
|
|
1299
|
-
type: Text$1,
|
|
1300
|
-
text: data,
|
|
1301
|
-
childCount: 0
|
|
1302
|
-
};
|
|
1303
|
-
};
|
|
1304
|
-
|
|
1305
1485
|
const parseHtml = (html, allowedAttributes) => {
|
|
1306
1486
|
string(html);
|
|
1307
1487
|
array(allowedAttributes);
|
|
@@ -1357,7 +1537,7 @@ const getMarkdownVirtualDom = html => {
|
|
|
1357
1537
|
const childDom = parseHtml(html, allowedMarkdownAttributes);
|
|
1358
1538
|
const markdownChildCount = getVirtualDomChildCount(childDom);
|
|
1359
1539
|
return [{
|
|
1360
|
-
type: Div,
|
|
1540
|
+
type: VirtualDomElements.Div,
|
|
1361
1541
|
className: Markdown,
|
|
1362
1542
|
role: Document,
|
|
1363
1543
|
onContextMenu: HandleReadmeContextMenu,
|
|
@@ -1365,8 +1545,15 @@ const getMarkdownVirtualDom = html => {
|
|
|
1365
1545
|
}, ...childDom];
|
|
1366
1546
|
};
|
|
1367
1547
|
|
|
1548
|
+
const handleMessagePort = async (port, rpcId) => {
|
|
1549
|
+
await PlainMessagePortRpc.create({
|
|
1550
|
+
commandMap: {},
|
|
1551
|
+
messagePort: port
|
|
1552
|
+
});
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1368
1555
|
/**
|
|
1369
|
-
* marked
|
|
1556
|
+
* marked v16.0.0 - a markdown parser
|
|
1370
1557
|
* Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
|
|
1371
1558
|
* https://github.com/markedjs/marked
|
|
1372
1559
|
*/
|
|
@@ -1376,10 +1563,7 @@ const getMarkdownVirtualDom = html => {
|
|
|
1376
1563
|
* The code in this file is generated from files in ./src/
|
|
1377
1564
|
*/
|
|
1378
1565
|
|
|
1379
|
-
|
|
1380
|
-
* Gets the original marked default options.
|
|
1381
|
-
*/
|
|
1382
|
-
function _getDefaults() {
|
|
1566
|
+
function M() {
|
|
1383
1567
|
return {
|
|
1384
1568
|
async: false,
|
|
1385
1569
|
breaks: false,
|
|
@@ -1393,2491 +1577,1624 @@ function _getDefaults() {
|
|
|
1393
1577
|
walkTokens: null
|
|
1394
1578
|
};
|
|
1395
1579
|
}
|
|
1396
|
-
|
|
1397
|
-
function
|
|
1398
|
-
|
|
1580
|
+
var w = M();
|
|
1581
|
+
function H(a) {
|
|
1582
|
+
w = a;
|
|
1399
1583
|
}
|
|
1400
|
-
|
|
1584
|
+
var C = {
|
|
1401
1585
|
exec: () => null
|
|
1402
1586
|
};
|
|
1403
|
-
function
|
|
1404
|
-
let
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
return new RegExp(source, opt);
|
|
1414
|
-
}
|
|
1415
|
-
};
|
|
1416
|
-
return obj;
|
|
1587
|
+
function h(a, e = "") {
|
|
1588
|
+
let t = typeof a == "string" ? a : a.source,
|
|
1589
|
+
n = {
|
|
1590
|
+
replace: (s, i) => {
|
|
1591
|
+
let r = typeof i == "string" ? i : i.source;
|
|
1592
|
+
return r = r.replace(m.caret, "$1"), t = t.replace(s, r), n;
|
|
1593
|
+
},
|
|
1594
|
+
getRegex: () => new RegExp(t, e)
|
|
1595
|
+
};
|
|
1596
|
+
return n;
|
|
1417
1597
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
.replace(
|
|
1493
|
-
.getRegex()
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
1620
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
1621
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
1622
|
-
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>') // CDATA section
|
|
1623
|
-
.replace('comment', _inlineComment).replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
1624
|
-
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
1625
|
-
const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace('label', _inlineLabel).replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
1626
|
-
const reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace('label', _inlineLabel).replace('ref', _blockLabel).getRegex();
|
|
1627
|
-
const nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace('ref', _blockLabel).getRegex();
|
|
1628
|
-
const reflinkSearch = edit('reflink|nolink(?!\\()', 'g').replace('reflink', reflink).replace('nolink', nolink).getRegex();
|
|
1629
|
-
/**
|
|
1630
|
-
* Normal Inline Grammar
|
|
1631
|
-
*/
|
|
1632
|
-
const inlineNormal = {
|
|
1633
|
-
_backpedal: noopTest,
|
|
1634
|
-
// only used for GFM url
|
|
1635
|
-
anyPunctuation,
|
|
1636
|
-
autolink,
|
|
1637
|
-
blockSkip,
|
|
1638
|
-
br,
|
|
1639
|
-
code: inlineCode,
|
|
1640
|
-
del: noopTest,
|
|
1641
|
-
emStrongLDelim,
|
|
1642
|
-
emStrongRDelimAst,
|
|
1643
|
-
emStrongRDelimUnd,
|
|
1644
|
-
escape: escape$1,
|
|
1645
|
-
link,
|
|
1646
|
-
nolink,
|
|
1647
|
-
punctuation,
|
|
1648
|
-
reflink,
|
|
1649
|
-
reflinkSearch,
|
|
1650
|
-
tag,
|
|
1651
|
-
text: inlineText,
|
|
1652
|
-
url: noopTest
|
|
1653
|
-
};
|
|
1654
|
-
/**
|
|
1655
|
-
* Pedantic Inline Grammar
|
|
1656
|
-
*/
|
|
1657
|
-
const inlinePedantic = {
|
|
1658
|
-
...inlineNormal,
|
|
1659
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', _inlineLabel).getRegex(),
|
|
1660
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', _inlineLabel).getRegex()
|
|
1661
|
-
};
|
|
1662
|
-
/**
|
|
1663
|
-
* GFM Inline Grammar
|
|
1664
|
-
*/
|
|
1665
|
-
const inlineGfm = {
|
|
1666
|
-
...inlineNormal,
|
|
1667
|
-
emStrongRDelimAst: emStrongRDelimAstGfm,
|
|
1668
|
-
emStrongLDelim: emStrongLDelimGfm,
|
|
1669
|
-
url: edit(/^((?: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(),
|
|
1670
|
-
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1671
|
-
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
1672
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1673
|
-
};
|
|
1674
|
-
/**
|
|
1675
|
-
* GFM + Line Breaks Inline Grammar
|
|
1676
|
-
*/
|
|
1677
|
-
const inlineBreaks = {
|
|
1678
|
-
...inlineGfm,
|
|
1679
|
-
br: edit(br).replace('{2,}', '*').getRegex(),
|
|
1680
|
-
text: edit(inlineGfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
1681
|
-
};
|
|
1682
|
-
/**
|
|
1683
|
-
* exports
|
|
1684
|
-
*/
|
|
1685
|
-
const block = {
|
|
1686
|
-
normal: blockNormal,
|
|
1687
|
-
gfm: blockGfm,
|
|
1688
|
-
pedantic: blockPedantic
|
|
1689
|
-
};
|
|
1690
|
-
const inline = {
|
|
1691
|
-
normal: inlineNormal,
|
|
1692
|
-
gfm: inlineGfm,
|
|
1693
|
-
breaks: inlineBreaks,
|
|
1694
|
-
pedantic: inlinePedantic
|
|
1695
|
-
};
|
|
1696
|
-
|
|
1697
|
-
/**
|
|
1698
|
-
* Helpers
|
|
1699
|
-
*/
|
|
1700
|
-
const escapeReplacements = {
|
|
1701
|
-
'&': '&',
|
|
1702
|
-
'<': '<',
|
|
1703
|
-
'>': '>',
|
|
1704
|
-
'"': '"',
|
|
1705
|
-
"'": '''
|
|
1706
|
-
};
|
|
1707
|
-
const getEscapeReplacement = ch => escapeReplacements[ch];
|
|
1708
|
-
function escape(html, encode) {
|
|
1709
|
-
if (encode) {
|
|
1710
|
-
if (other.escapeTest.test(html)) {
|
|
1711
|
-
return html.replace(other.escapeReplace, getEscapeReplacement);
|
|
1712
|
-
}
|
|
1713
|
-
} else {
|
|
1714
|
-
if (other.escapeTestNoEncode.test(html)) {
|
|
1715
|
-
return html.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
return html;
|
|
1598
|
+
var m = {
|
|
1599
|
+
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
|
|
1600
|
+
outputLinkReplace: /\\([\[\]])/g,
|
|
1601
|
+
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
1602
|
+
beginningSpace: /^\s+/,
|
|
1603
|
+
endingHash: /#$/,
|
|
1604
|
+
startingSpaceChar: /^ /,
|
|
1605
|
+
endingSpaceChar: / $/,
|
|
1606
|
+
nonSpaceChar: /[^ ]/,
|
|
1607
|
+
newLineCharGlobal: /\n/g,
|
|
1608
|
+
tabCharGlobal: /\t/g,
|
|
1609
|
+
multipleSpaceGlobal: /\s+/g,
|
|
1610
|
+
blankLine: /^[ \t]*$/,
|
|
1611
|
+
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
|
|
1612
|
+
blockquoteStart: /^ {0,3}>/,
|
|
1613
|
+
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
|
|
1614
|
+
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
1615
|
+
listReplaceTabs: /^\t+/,
|
|
1616
|
+
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
1617
|
+
listIsTask: /^\[[ xX]\] /,
|
|
1618
|
+
listReplaceTask: /^\[[ xX]\] +/,
|
|
1619
|
+
anyLine: /\n.*\n/,
|
|
1620
|
+
hrefBrackets: /^<(.*)>$/,
|
|
1621
|
+
tableDelimiter: /[:|]/,
|
|
1622
|
+
tableAlignChars: /^\||\| *$/g,
|
|
1623
|
+
tableRowBlankLine: /\n[ \t]*$/,
|
|
1624
|
+
tableAlignRight: /^ *-+: *$/,
|
|
1625
|
+
tableAlignCenter: /^ *:-+: *$/,
|
|
1626
|
+
tableAlignLeft: /^ *:-+ *$/,
|
|
1627
|
+
startATag: /^<a /i,
|
|
1628
|
+
endATag: /^<\/a>/i,
|
|
1629
|
+
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
|
|
1630
|
+
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
|
|
1631
|
+
startAngleBracket: /^</,
|
|
1632
|
+
endAngleBracket: />$/,
|
|
1633
|
+
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
|
|
1634
|
+
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
|
|
1635
|
+
escapeTest: /[&<>"']/,
|
|
1636
|
+
escapeReplace: /[&<>"']/g,
|
|
1637
|
+
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
|
|
1638
|
+
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
|
|
1639
|
+
unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
|
|
1640
|
+
caret: /(^|[^\[])\^/g,
|
|
1641
|
+
percentDecode: /%25/g,
|
|
1642
|
+
findPipe: /\|/g,
|
|
1643
|
+
splitPipe: / \|/,
|
|
1644
|
+
slashPipe: /\\\|/g,
|
|
1645
|
+
carriageReturn: /\r\n|\r/g,
|
|
1646
|
+
spaceLine: /^ +$/gm,
|
|
1647
|
+
notSpaceStart: /^\S*/,
|
|
1648
|
+
endingNewline: /\n$/,
|
|
1649
|
+
listItemRegex: a => new RegExp(`^( {0,3}${a})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1650
|
+
nextBulletRegex: a => new RegExp(`^ {0,${Math.min(3, a - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
1651
|
+
hrRegex: a => new RegExp(`^ {0,${Math.min(3, a - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
1652
|
+
fencesBeginRegex: a => new RegExp(`^ {0,${Math.min(3, a - 1)}}(?:\`\`\`|~~~)`),
|
|
1653
|
+
headingBeginRegex: a => new RegExp(`^ {0,${Math.min(3, a - 1)}}#`),
|
|
1654
|
+
htmlBeginRegex: a => new RegExp(`^ {0,${Math.min(3, a - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
1655
|
+
},
|
|
1656
|
+
xe = /^(?:[ \t]*(?:\n|$))+/,
|
|
1657
|
+
be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,
|
|
1658
|
+
Te = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1659
|
+
I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
1660
|
+
we = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1661
|
+
j = /(?:[*+-]|\d{1,9}[.)])/,
|
|
1662
|
+
re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1663
|
+
ie = h(re).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
|
+
ye = h(re).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
|
+
F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
1666
|
+
Re = /^[^\n]+/,
|
|
1667
|
+
Q = /(?!\s*\])(?:\\.|[^\[\]\\])+/,
|
|
1668
|
+
Se = 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
|
+
$e = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex(),
|
|
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",
|
|
1671
|
+
U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/,
|
|
1672
|
+
_e = 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", I).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
|
+
Le = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(),
|
|
1675
|
+
K = {
|
|
1676
|
+
blockquote: Le,
|
|
1677
|
+
code: be,
|
|
1678
|
+
def: Se,
|
|
1679
|
+
fences: Te,
|
|
1680
|
+
heading: we,
|
|
1681
|
+
hr: I,
|
|
1682
|
+
html: _e,
|
|
1683
|
+
lheading: ie,
|
|
1684
|
+
list: $e,
|
|
1685
|
+
newline: xe,
|
|
1686
|
+
paragraph: oe,
|
|
1687
|
+
table: C,
|
|
1688
|
+
text: Re
|
|
1689
|
+
},
|
|
1690
|
+
se = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).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
|
+
ze = {
|
|
1692
|
+
...K,
|
|
1693
|
+
lheading: ye,
|
|
1694
|
+
table: se,
|
|
1695
|
+
paragraph: h(F).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).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
|
+
},
|
|
1697
|
+
Me = {
|
|
1698
|
+
...K,
|
|
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(),
|
|
1700
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1701
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1702
|
+
fences: C,
|
|
1703
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1704
|
+
paragraph: h(F).replace("hr", I).replace("heading", ` *#{1,6} *[^
|
|
1705
|
+
]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
1706
|
+
},
|
|
1707
|
+
Pe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1708
|
+
Ae = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1709
|
+
le = /^( {2,}|\\)\n(?!\s*$)/,
|
|
1710
|
+
Ee = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1711
|
+
D = /[\p{P}\p{S}]/u,
|
|
1712
|
+
X = /[\s\p{P}\p{S}]/u,
|
|
1713
|
+
ae = /[^\s\p{P}\p{S}]/u,
|
|
1714
|
+
Ce = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, X).getRegex(),
|
|
1715
|
+
ce = /(?!~)[\p{P}\p{S}]/u,
|
|
1716
|
+
Ie = /(?!~)[\s\p{P}\p{S}]/u,
|
|
1717
|
+
Oe = /(?:[^\s\p{P}\p{S}]|~)/u,
|
|
1718
|
+
Be = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,
|
|
1719
|
+
pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,
|
|
1720
|
+
qe = h(pe, "u").replace(/punct/g, D).getRegex(),
|
|
1721
|
+
ve = h(pe, "u").replace(/punct/g, ce).getRegex(),
|
|
1722
|
+
ue = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",
|
|
1723
|
+
De = h(ue, "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, X).replace(/punct/g, D).getRegex(),
|
|
1724
|
+
Ze = h(ue, "gu").replace(/notPunctSpace/g, Oe).replace(/punctSpace/g, Ie).replace(/punct/g, ce).getRegex(),
|
|
1725
|
+
Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, X).replace(/punct/g, D).getRegex(),
|
|
1726
|
+
He = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(),
|
|
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(),
|
|
1728
|
+
je = h(U).replace("(?:-->|$)", "-->").getRegex(),
|
|
1729
|
+
Fe = h("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),
|
|
1730
|
+
q = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,
|
|
1731
|
+
Qe = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),
|
|
1732
|
+
he = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex(),
|
|
1733
|
+
ke = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex(),
|
|
1734
|
+
Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex(),
|
|
1735
|
+
W = {
|
|
1736
|
+
_backpedal: C,
|
|
1737
|
+
anyPunctuation: He,
|
|
1738
|
+
autolink: Ne,
|
|
1739
|
+
blockSkip: Be,
|
|
1740
|
+
br: le,
|
|
1741
|
+
code: Ae,
|
|
1742
|
+
del: C,
|
|
1743
|
+
emStrongLDelim: qe,
|
|
1744
|
+
emStrongRDelimAst: De,
|
|
1745
|
+
emStrongRDelimUnd: Ge,
|
|
1746
|
+
escape: Pe,
|
|
1747
|
+
link: Qe,
|
|
1748
|
+
nolink: ke,
|
|
1749
|
+
punctuation: Ce,
|
|
1750
|
+
reflink: he,
|
|
1751
|
+
reflinkSearch: Ue,
|
|
1752
|
+
tag: Fe,
|
|
1753
|
+
text: Ee,
|
|
1754
|
+
url: C
|
|
1755
|
+
},
|
|
1756
|
+
Ke = {
|
|
1757
|
+
...W,
|
|
1758
|
+
link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(),
|
|
1759
|
+
reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex()
|
|
1760
|
+
},
|
|
1761
|
+
N = {
|
|
1762
|
+
...W,
|
|
1763
|
+
emStrongRDelimAst: Ze,
|
|
1764
|
+
emStrongLDelim: ve,
|
|
1765
|
+
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(),
|
|
1766
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1767
|
+
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
1768
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1769
|
+
},
|
|
1770
|
+
Xe = {
|
|
1771
|
+
...N,
|
|
1772
|
+
br: h(le).replace("{2,}", "*").getRegex(),
|
|
1773
|
+
text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1774
|
+
},
|
|
1775
|
+
O = {
|
|
1776
|
+
normal: K,
|
|
1777
|
+
gfm: ze,
|
|
1778
|
+
pedantic: Me
|
|
1779
|
+
},
|
|
1780
|
+
P = {
|
|
1781
|
+
normal: W,
|
|
1782
|
+
gfm: N,
|
|
1783
|
+
breaks: Xe,
|
|
1784
|
+
pedantic: Ke
|
|
1785
|
+
};
|
|
1786
|
+
var We = {
|
|
1787
|
+
"&": "&",
|
|
1788
|
+
"<": "<",
|
|
1789
|
+
">": ">",
|
|
1790
|
+
'"': """,
|
|
1791
|
+
"'": "'"
|
|
1792
|
+
},
|
|
1793
|
+
ge = a => We[a];
|
|
1794
|
+
function R(a, e) {
|
|
1795
|
+
if (e) {
|
|
1796
|
+
if (m.escapeTest.test(a)) return a.replace(m.escapeReplace, ge);
|
|
1797
|
+
} else if (m.escapeTestNoEncode.test(a)) return a.replace(m.escapeReplaceNoEncode, ge);
|
|
1798
|
+
return a;
|
|
1719
1799
|
}
|
|
1720
|
-
function
|
|
1800
|
+
function J(a) {
|
|
1721
1801
|
try {
|
|
1722
|
-
|
|
1802
|
+
a = encodeURI(a).replace(m.percentDecode, "%");
|
|
1723
1803
|
} catch {
|
|
1724
1804
|
return null;
|
|
1725
1805
|
}
|
|
1726
|
-
return
|
|
1806
|
+
return a;
|
|
1727
1807
|
}
|
|
1728
|
-
function
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
|
1735
|
-
if (escaped) {
|
|
1736
|
-
// odd number of slashes means | is escaped
|
|
1737
|
-
// so we leave it alone
|
|
1738
|
-
return '|';
|
|
1739
|
-
} else {
|
|
1740
|
-
// add space before unescaped |
|
|
1741
|
-
return ' |';
|
|
1742
|
-
}
|
|
1808
|
+
function V(a, e) {
|
|
1809
|
+
let t = a.replace(m.findPipe, (i, r, o) => {
|
|
1810
|
+
let l = false,
|
|
1811
|
+
c = r;
|
|
1812
|
+
for (; --c >= 0 && o[c] === "\\";) l = !l;
|
|
1813
|
+
return l ? "|" : " |";
|
|
1743
1814
|
}),
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
}
|
|
1750
|
-
if (cells.length > 0 && !cells.at(-1)?.trim()) {
|
|
1751
|
-
cells.pop();
|
|
1752
|
-
}
|
|
1753
|
-
if (count) {
|
|
1754
|
-
if (cells.length > count) {
|
|
1755
|
-
cells.splice(count);
|
|
1756
|
-
} else {
|
|
1757
|
-
while (cells.length < count) cells.push('');
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
for (; i < cells.length; i++) {
|
|
1761
|
-
// leading or trailing whitespace is ignored per the gfm spec
|
|
1762
|
-
cells[i] = cells[i].trim().replace(other.slashPipe, '|');
|
|
1763
|
-
}
|
|
1764
|
-
return cells;
|
|
1815
|
+
n = t.split(m.splitPipe),
|
|
1816
|
+
s = 0;
|
|
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("");
|
|
1818
|
+
for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
1819
|
+
return n;
|
|
1765
1820
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
const l = str.length;
|
|
1776
|
-
if (l === 0) {
|
|
1777
|
-
return '';
|
|
1778
|
-
}
|
|
1779
|
-
// Length of suffix matching the invert condition.
|
|
1780
|
-
let suffLen = 0;
|
|
1781
|
-
// Step left until we fail to match the invert condition.
|
|
1782
|
-
while (suffLen < l) {
|
|
1783
|
-
const currChar = str.charAt(l - suffLen - 1);
|
|
1784
|
-
if (currChar === c && true) {
|
|
1785
|
-
suffLen++;
|
|
1786
|
-
} else {
|
|
1787
|
-
break;
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return str.slice(0, l - suffLen);
|
|
1821
|
+
function A(a, e, t) {
|
|
1822
|
+
let n = a.length;
|
|
1823
|
+
if (n === 0) return "";
|
|
1824
|
+
let s = 0;
|
|
1825
|
+
for (; s < n;) {
|
|
1826
|
+
let i = a.charAt(n - s - 1);
|
|
1827
|
+
if (i === e && true) s++;else break;
|
|
1828
|
+
}
|
|
1829
|
+
return a.slice(0, n - s);
|
|
1791
1830
|
}
|
|
1792
|
-
function
|
|
1793
|
-
if (
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
for (let i = 0; i < str.length; i++) {
|
|
1798
|
-
if (str[i] === '\\') {
|
|
1799
|
-
i++;
|
|
1800
|
-
} else if (str[i] === b[0]) {
|
|
1801
|
-
level++;
|
|
1802
|
-
} else if (str[i] === b[1]) {
|
|
1803
|
-
level--;
|
|
1804
|
-
if (level < 0) {
|
|
1805
|
-
return i;
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
if (level > 0) {
|
|
1810
|
-
return -2;
|
|
1811
|
-
}
|
|
1812
|
-
return -1;
|
|
1831
|
+
function fe(a, e) {
|
|
1832
|
+
if (a.indexOf(e[1]) === -1) return -1;
|
|
1833
|
+
let t = 0;
|
|
1834
|
+
for (let n = 0; n < a.length; n++) if (a[n] === "\\") n++;else if (a[n] === e[0]) t++;else if (a[n] === e[1] && (t--, t < 0)) return n;
|
|
1835
|
+
return t > 0 ? -2 : -1;
|
|
1813
1836
|
}
|
|
1814
|
-
function
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
tokens: lexer.inlineTokens(text)
|
|
1827
|
-
};
|
|
1828
|
-
lexer.state.inLink = false;
|
|
1829
|
-
return token;
|
|
1830
|
-
}
|
|
1831
|
-
return {
|
|
1832
|
-
type: 'image',
|
|
1833
|
-
raw,
|
|
1834
|
-
href,
|
|
1835
|
-
title,
|
|
1836
|
-
text
|
|
1837
|
+
function de(a, e, t, n, s) {
|
|
1838
|
+
let i = e.href,
|
|
1839
|
+
r = e.title || null,
|
|
1840
|
+
o = a[1].replace(s.other.outputLinkReplace, "$1");
|
|
1841
|
+
n.state.inLink = true;
|
|
1842
|
+
let l = {
|
|
1843
|
+
type: a[0].charAt(0) === "!" ? "image" : "link",
|
|
1844
|
+
raw: t,
|
|
1845
|
+
href: i,
|
|
1846
|
+
title: r,
|
|
1847
|
+
text: o,
|
|
1848
|
+
tokens: n.inlineTokens(o)
|
|
1837
1849
|
};
|
|
1850
|
+
return n.state.inLink = false, l;
|
|
1838
1851
|
}
|
|
1839
|
-
function
|
|
1840
|
-
|
|
1841
|
-
if (
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
if (indentInNode.length >= indentToCode.length) {
|
|
1852
|
-
return node.slice(indentToCode.length);
|
|
1853
|
-
}
|
|
1854
|
-
return node;
|
|
1855
|
-
}).join('\n');
|
|
1852
|
+
function Je(a, e, t) {
|
|
1853
|
+
let n = a.match(t.other.indentCodeCompensation);
|
|
1854
|
+
if (n === null) return e;
|
|
1855
|
+
let s = n[1];
|
|
1856
|
+
return e.split(`
|
|
1857
|
+
`).map(i => {
|
|
1858
|
+
let r = i.match(t.other.beginningSpace);
|
|
1859
|
+
if (r === null) return i;
|
|
1860
|
+
let [o] = r;
|
|
1861
|
+
return o.length >= s.length ? i.slice(s.length) : i;
|
|
1862
|
+
}).join(`
|
|
1863
|
+
`);
|
|
1856
1864
|
}
|
|
1857
|
-
|
|
1858
|
-
* Tokenizer
|
|
1859
|
-
*/
|
|
1860
|
-
class _Tokenizer {
|
|
1865
|
+
var S = class {
|
|
1861
1866
|
options;
|
|
1862
|
-
rules;
|
|
1863
|
-
lexer;
|
|
1864
|
-
constructor(
|
|
1865
|
-
this.options =
|
|
1866
|
-
}
|
|
1867
|
-
space(
|
|
1868
|
-
|
|
1869
|
-
if (
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
};
|
|
1874
|
-
}
|
|
1867
|
+
rules;
|
|
1868
|
+
lexer;
|
|
1869
|
+
constructor(e) {
|
|
1870
|
+
this.options = e || w;
|
|
1871
|
+
}
|
|
1872
|
+
space(e) {
|
|
1873
|
+
let t = this.rules.block.newline.exec(e);
|
|
1874
|
+
if (t && t[0].length > 0) return {
|
|
1875
|
+
type: "space",
|
|
1876
|
+
raw: t[0]
|
|
1877
|
+
};
|
|
1875
1878
|
}
|
|
1876
|
-
code(
|
|
1877
|
-
|
|
1878
|
-
if (
|
|
1879
|
-
|
|
1879
|
+
code(e) {
|
|
1880
|
+
let t = this.rules.block.code.exec(e);
|
|
1881
|
+
if (t) {
|
|
1882
|
+
let n = t[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
1880
1883
|
return {
|
|
1881
|
-
type:
|
|
1882
|
-
raw:
|
|
1883
|
-
codeBlockStyle:
|
|
1884
|
-
text:
|
|
1884
|
+
type: "code",
|
|
1885
|
+
raw: t[0],
|
|
1886
|
+
codeBlockStyle: "indented",
|
|
1887
|
+
text: this.options.pedantic ? n : A(n, `
|
|
1888
|
+
`)
|
|
1885
1889
|
};
|
|
1886
1890
|
}
|
|
1887
1891
|
}
|
|
1888
|
-
fences(
|
|
1889
|
-
|
|
1890
|
-
if (
|
|
1891
|
-
|
|
1892
|
-
|
|
1892
|
+
fences(e) {
|
|
1893
|
+
let t = this.rules.block.fences.exec(e);
|
|
1894
|
+
if (t) {
|
|
1895
|
+
let n = t[0],
|
|
1896
|
+
s = Je(n, t[3] || "", this.rules);
|
|
1893
1897
|
return {
|
|
1894
|
-
type:
|
|
1895
|
-
raw,
|
|
1896
|
-
lang:
|
|
1897
|
-
text
|
|
1898
|
+
type: "code",
|
|
1899
|
+
raw: n,
|
|
1900
|
+
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
1901
|
+
text: s
|
|
1898
1902
|
};
|
|
1899
1903
|
}
|
|
1900
1904
|
}
|
|
1901
|
-
heading(
|
|
1902
|
-
|
|
1903
|
-
if (
|
|
1904
|
-
let
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
if (this.options.pedantic) {
|
|
1909
|
-
text = trimmed.trim();
|
|
1910
|
-
} else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
|
|
1911
|
-
// CommonMark requires space before trailing #s
|
|
1912
|
-
text = trimmed.trim();
|
|
1913
|
-
}
|
|
1905
|
+
heading(e) {
|
|
1906
|
+
let t = this.rules.block.heading.exec(e);
|
|
1907
|
+
if (t) {
|
|
1908
|
+
let n = t[2].trim();
|
|
1909
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
1910
|
+
let s = A(n, "#");
|
|
1911
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
1914
1912
|
}
|
|
1915
1913
|
return {
|
|
1916
|
-
type:
|
|
1917
|
-
raw:
|
|
1918
|
-
depth:
|
|
1919
|
-
text,
|
|
1920
|
-
tokens: this.lexer.inline(
|
|
1914
|
+
type: "heading",
|
|
1915
|
+
raw: t[0],
|
|
1916
|
+
depth: t[1].length,
|
|
1917
|
+
text: n,
|
|
1918
|
+
tokens: this.lexer.inline(n)
|
|
1921
1919
|
};
|
|
1922
1920
|
}
|
|
1923
1921
|
}
|
|
1924
|
-
hr(
|
|
1925
|
-
|
|
1926
|
-
if (
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
}
|
|
1922
|
+
hr(e) {
|
|
1923
|
+
let t = this.rules.block.hr.exec(e);
|
|
1924
|
+
if (t) return {
|
|
1925
|
+
type: "hr",
|
|
1926
|
+
raw: A(t[0], `
|
|
1927
|
+
`)
|
|
1928
|
+
};
|
|
1932
1929
|
}
|
|
1933
|
-
blockquote(
|
|
1934
|
-
|
|
1935
|
-
if (
|
|
1936
|
-
let
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
let
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
this.lexer.blockTokens(currentText, tokens, true);
|
|
1967
|
-
this.lexer.state.top = top;
|
|
1968
|
-
// if there is no continuation then we are done
|
|
1969
|
-
if (lines.length === 0) {
|
|
1970
|
-
break;
|
|
1971
|
-
}
|
|
1972
|
-
const lastToken = tokens.at(-1);
|
|
1973
|
-
if (lastToken?.type === 'code') {
|
|
1974
|
-
// blockquote continuation cannot be preceded by a code block
|
|
1930
|
+
blockquote(e) {
|
|
1931
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
1932
|
+
if (t) {
|
|
1933
|
+
let n = A(t[0], `
|
|
1934
|
+
`).split(`
|
|
1935
|
+
`),
|
|
1936
|
+
s = "",
|
|
1937
|
+
i = "",
|
|
1938
|
+
r = [];
|
|
1939
|
+
for (; n.length > 0;) {
|
|
1940
|
+
let o = false,
|
|
1941
|
+
l = [],
|
|
1942
|
+
c;
|
|
1943
|
+
for (c = 0; c < n.length; c++) if (this.rules.other.blockquoteStart.test(n[c])) l.push(n[c]), o = true;else if (!o) l.push(n[c]);else break;
|
|
1944
|
+
n = n.slice(c);
|
|
1945
|
+
let p = l.join(`
|
|
1946
|
+
`),
|
|
1947
|
+
u = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1948
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1949
|
+
s = s ? `${s}
|
|
1950
|
+
${p}` : p, i = i ? `${i}
|
|
1951
|
+
${u}` : u;
|
|
1952
|
+
let d = this.lexer.state.top;
|
|
1953
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(u, r, true), this.lexer.state.top = d, n.length === 0) break;
|
|
1954
|
+
let g = r.at(-1);
|
|
1955
|
+
if (g?.type === "code") break;
|
|
1956
|
+
if (g?.type === "blockquote") {
|
|
1957
|
+
let x = g,
|
|
1958
|
+
f = x.raw + `
|
|
1959
|
+
` + n.join(`
|
|
1960
|
+
`),
|
|
1961
|
+
y = this.blockquote(f);
|
|
1962
|
+
r[r.length - 1] = y, s = s.substring(0, s.length - x.raw.length) + y.raw, i = i.substring(0, i.length - x.text.length) + y.text;
|
|
1975
1963
|
break;
|
|
1976
|
-
} else if (
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
break;
|
|
1985
|
-
} else if (lastToken?.type === 'list') {
|
|
1986
|
-
// include continuation in nested list
|
|
1987
|
-
const oldToken = lastToken;
|
|
1988
|
-
const newText = oldToken.raw + '\n' + lines.join('\n');
|
|
1989
|
-
const newToken = this.list(newText);
|
|
1990
|
-
tokens[tokens.length - 1] = newToken;
|
|
1991
|
-
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
1992
|
-
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
1993
|
-
lines = newText.substring(tokens.at(-1).raw.length).split('\n');
|
|
1964
|
+
} else if (g?.type === "list") {
|
|
1965
|
+
let x = g,
|
|
1966
|
+
f = x.raw + `
|
|
1967
|
+
` + n.join(`
|
|
1968
|
+
`),
|
|
1969
|
+
y = this.list(f);
|
|
1970
|
+
r[r.length - 1] = y, s = s.substring(0, s.length - g.raw.length) + y.raw, i = i.substring(0, i.length - x.raw.length) + y.raw, n = f.substring(r.at(-1).raw.length).split(`
|
|
1971
|
+
`);
|
|
1994
1972
|
continue;
|
|
1995
1973
|
}
|
|
1996
1974
|
}
|
|
1997
1975
|
return {
|
|
1998
|
-
type:
|
|
1999
|
-
raw,
|
|
2000
|
-
tokens,
|
|
2001
|
-
text
|
|
1976
|
+
type: "blockquote",
|
|
1977
|
+
raw: s,
|
|
1978
|
+
tokens: r,
|
|
1979
|
+
text: i
|
|
2002
1980
|
};
|
|
2003
1981
|
}
|
|
2004
1982
|
}
|
|
2005
|
-
list(
|
|
2006
|
-
let
|
|
2007
|
-
if (
|
|
2008
|
-
let
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
let
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
if (this.rules.
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
2051
|
-
itemContents = line.slice(indent);
|
|
2052
|
-
indent += cap[1].length;
|
|
2053
|
-
}
|
|
2054
|
-
if (blankLine && this.rules.other.blankLine.test(nextLine)) {
|
|
2055
|
-
// Items begin with at most one blank line
|
|
2056
|
-
raw += nextLine + '\n';
|
|
2057
|
-
src = src.substring(nextLine.length + 1);
|
|
2058
|
-
endEarly = true;
|
|
2059
|
-
}
|
|
2060
|
-
if (!endEarly) {
|
|
2061
|
-
const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
|
|
2062
|
-
const hrRegex = this.rules.other.hrRegex(indent);
|
|
2063
|
-
const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
|
|
2064
|
-
const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
|
|
2065
|
-
const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
|
|
2066
|
-
// Check if following lines should be included in List Item
|
|
2067
|
-
while (src) {
|
|
2068
|
-
const rawLine = src.split('\n', 1)[0];
|
|
2069
|
-
let nextLineWithoutTabs;
|
|
2070
|
-
nextLine = rawLine;
|
|
2071
|
-
// Re-align to follow commonmark nesting rules
|
|
2072
|
-
if (this.options.pedantic) {
|
|
2073
|
-
nextLine = nextLine.replace(this.rules.other.listReplaceNesting, ' ');
|
|
2074
|
-
nextLineWithoutTabs = nextLine;
|
|
2075
|
-
} else {
|
|
2076
|
-
nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, ' ');
|
|
2077
|
-
}
|
|
2078
|
-
// End list item if found code fences
|
|
2079
|
-
if (fencesBeginRegex.test(nextLine)) {
|
|
2080
|
-
break;
|
|
2081
|
-
}
|
|
2082
|
-
// End list item if found start of new heading
|
|
2083
|
-
if (headingBeginRegex.test(nextLine)) {
|
|
2084
|
-
break;
|
|
2085
|
-
}
|
|
2086
|
-
// End list item if found start of html block
|
|
2087
|
-
if (htmlBeginRegex.test(nextLine)) {
|
|
2088
|
-
break;
|
|
2089
|
-
}
|
|
2090
|
-
// End list item if found start of new bullet
|
|
2091
|
-
if (nextBulletRegex.test(nextLine)) {
|
|
2092
|
-
break;
|
|
2093
|
-
}
|
|
2094
|
-
// Horizontal rule found
|
|
2095
|
-
if (hrRegex.test(nextLine)) {
|
|
2096
|
-
break;
|
|
2097
|
-
}
|
|
2098
|
-
if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
|
|
2099
|
-
// Dedent if possible
|
|
2100
|
-
itemContents += '\n' + nextLineWithoutTabs.slice(indent);
|
|
2101
|
-
} else {
|
|
2102
|
-
// not enough indentation
|
|
2103
|
-
if (blankLine) {
|
|
2104
|
-
break;
|
|
2105
|
-
}
|
|
2106
|
-
// paragraph continuation unless last line was a different block level element
|
|
2107
|
-
if (line.replace(this.rules.other.tabCharGlobal, ' ').search(this.rules.other.nonSpaceChar) >= 4) {
|
|
2108
|
-
// indented code block
|
|
2109
|
-
break;
|
|
2110
|
-
}
|
|
2111
|
-
if (fencesBeginRegex.test(line)) {
|
|
2112
|
-
break;
|
|
2113
|
-
}
|
|
2114
|
-
if (headingBeginRegex.test(line)) {
|
|
2115
|
-
break;
|
|
2116
|
-
}
|
|
2117
|
-
if (hrRegex.test(line)) {
|
|
2118
|
-
break;
|
|
2119
|
-
}
|
|
2120
|
-
itemContents += '\n' + nextLine;
|
|
2121
|
-
}
|
|
2122
|
-
if (!blankLine && !nextLine.trim()) {
|
|
2123
|
-
// Check if current line is blank
|
|
2124
|
-
blankLine = true;
|
|
1983
|
+
list(e) {
|
|
1984
|
+
let t = this.rules.block.list.exec(e);
|
|
1985
|
+
if (t) {
|
|
1986
|
+
let n = t[1].trim(),
|
|
1987
|
+
s = n.length > 1,
|
|
1988
|
+
i = {
|
|
1989
|
+
type: "list",
|
|
1990
|
+
raw: "",
|
|
1991
|
+
ordered: s,
|
|
1992
|
+
start: s ? +n.slice(0, -1) : "",
|
|
1993
|
+
loose: false,
|
|
1994
|
+
items: []
|
|
1995
|
+
};
|
|
1996
|
+
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
1997
|
+
let r = this.rules.other.listItemRegex(n),
|
|
1998
|
+
o = false;
|
|
1999
|
+
for (; e;) {
|
|
2000
|
+
let c = false,
|
|
2001
|
+
p = "",
|
|
2002
|
+
u = "";
|
|
2003
|
+
if (!(t = r.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
2004
|
+
p = t[0], e = e.substring(p.length);
|
|
2005
|
+
let d = t[2].split(`
|
|
2006
|
+
`, 1)[0].replace(this.rules.other.listReplaceTabs, Z => " ".repeat(3 * Z.length)),
|
|
2007
|
+
g = e.split(`
|
|
2008
|
+
`, 1)[0],
|
|
2009
|
+
x = !d.trim(),
|
|
2010
|
+
f = 0;
|
|
2011
|
+
if (this.options.pedantic ? (f = 2, u = d.trimStart()) : x ? f = t[1].length + 1 : (f = t[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, u = d.slice(f), f += t[1].length), x && this.rules.other.blankLine.test(g) && (p += g + `
|
|
2012
|
+
`, e = e.substring(g.length + 1), c = true), !c) {
|
|
2013
|
+
let Z = this.rules.other.nextBulletRegex(f),
|
|
2014
|
+
ee = this.rules.other.hrRegex(f),
|
|
2015
|
+
te = this.rules.other.fencesBeginRegex(f),
|
|
2016
|
+
ne = this.rules.other.headingBeginRegex(f),
|
|
2017
|
+
me = this.rules.other.htmlBeginRegex(f);
|
|
2018
|
+
for (; e;) {
|
|
2019
|
+
let G = e.split(`
|
|
2020
|
+
`, 1)[0],
|
|
2021
|
+
E;
|
|
2022
|
+
if (g = G, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), E = g) : E = g.replace(this.rules.other.tabCharGlobal, " "), te.test(g) || ne.test(g) || me.test(g) || Z.test(g) || ee.test(g)) break;
|
|
2023
|
+
if (E.search(this.rules.other.nonSpaceChar) >= f || !g.trim()) u += `
|
|
2024
|
+
` + E.slice(f);else {
|
|
2025
|
+
if (x || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(d) || ne.test(d) || ee.test(d)) break;
|
|
2026
|
+
u += `
|
|
2027
|
+
` + g;
|
|
2125
2028
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
line = nextLineWithoutTabs.slice(indent);
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
if (!list.loose) {
|
|
2132
|
-
// If the previous item ended with a blank line, the list is loose
|
|
2133
|
-
if (endsWithBlankLine) {
|
|
2134
|
-
list.loose = true;
|
|
2135
|
-
} else if (this.rules.other.doubleBlankLine.test(raw)) {
|
|
2136
|
-
endsWithBlankLine = true;
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
let istask = null;
|
|
2140
|
-
let ischecked;
|
|
2141
|
-
// Check for task list items
|
|
2142
|
-
if (this.options.gfm) {
|
|
2143
|
-
istask = this.rules.other.listIsTask.exec(itemContents);
|
|
2144
|
-
if (istask) {
|
|
2145
|
-
ischecked = istask[0] !== '[ ] ';
|
|
2146
|
-
itemContents = itemContents.replace(this.rules.other.listReplaceTask, '');
|
|
2029
|
+
!x && !g.trim() && (x = true), p += G + `
|
|
2030
|
+
`, e = e.substring(G.length + 1), d = E.slice(f);
|
|
2147
2031
|
}
|
|
2148
2032
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2033
|
+
i.loose || (o ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true));
|
|
2034
|
+
let y = null,
|
|
2035
|
+
Y;
|
|
2036
|
+
this.options.gfm && (y = this.rules.other.listIsTask.exec(u), y && (Y = y[0] !== "[ ] ", u = u.replace(this.rules.other.listReplaceTask, ""))), i.items.push({
|
|
2037
|
+
type: "list_item",
|
|
2038
|
+
raw: p,
|
|
2039
|
+
task: !!y,
|
|
2040
|
+
checked: Y,
|
|
2154
2041
|
loose: false,
|
|
2155
|
-
text:
|
|
2042
|
+
text: u,
|
|
2156
2043
|
tokens: []
|
|
2157
|
-
});
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
if (
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
}
|
|
2181
|
-
// Set all items to loose if list is loose
|
|
2182
|
-
if (list.loose) {
|
|
2183
|
-
for (let i = 0; i < list.items.length; i++) {
|
|
2184
|
-
list.items[i].loose = true;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
return list;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
html(src) {
|
|
2191
|
-
const cap = this.rules.block.html.exec(src);
|
|
2192
|
-
if (cap) {
|
|
2193
|
-
const token = {
|
|
2194
|
-
type: 'html',
|
|
2195
|
-
block: true,
|
|
2196
|
-
raw: cap[0],
|
|
2197
|
-
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
|
|
2198
|
-
text: cap[0]
|
|
2199
|
-
};
|
|
2200
|
-
return token;
|
|
2201
|
-
}
|
|
2044
|
+
}), i.raw += p;
|
|
2045
|
+
}
|
|
2046
|
+
let l = i.items.at(-1);
|
|
2047
|
+
if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();else return;
|
|
2048
|
+
i.raw = i.raw.trimEnd();
|
|
2049
|
+
for (let c = 0; c < i.items.length; c++) if (this.lexer.state.top = false, i.items[c].tokens = this.lexer.blockTokens(i.items[c].text, []), !i.loose) {
|
|
2050
|
+
let p = i.items[c].tokens.filter(d => d.type === "space"),
|
|
2051
|
+
u = p.length > 0 && p.some(d => this.rules.other.anyLine.test(d.raw));
|
|
2052
|
+
i.loose = u;
|
|
2053
|
+
}
|
|
2054
|
+
if (i.loose) for (let c = 0; c < i.items.length; c++) i.items[c].loose = true;
|
|
2055
|
+
return i;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
html(e) {
|
|
2059
|
+
let t = this.rules.block.html.exec(e);
|
|
2060
|
+
if (t) return {
|
|
2061
|
+
type: "html",
|
|
2062
|
+
block: true,
|
|
2063
|
+
raw: t[0],
|
|
2064
|
+
pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
|
|
2065
|
+
text: t[0]
|
|
2066
|
+
};
|
|
2202
2067
|
}
|
|
2203
|
-
def(
|
|
2204
|
-
|
|
2205
|
-
if (
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2068
|
+
def(e) {
|
|
2069
|
+
let t = this.rules.block.def.exec(e);
|
|
2070
|
+
if (t) {
|
|
2071
|
+
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
2072
|
+
s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "",
|
|
2073
|
+
i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
2209
2074
|
return {
|
|
2210
|
-
type:
|
|
2211
|
-
tag,
|
|
2212
|
-
raw:
|
|
2213
|
-
href,
|
|
2214
|
-
title
|
|
2075
|
+
type: "def",
|
|
2076
|
+
tag: n,
|
|
2077
|
+
raw: t[0],
|
|
2078
|
+
href: s,
|
|
2079
|
+
title: i
|
|
2215
2080
|
};
|
|
2216
2081
|
}
|
|
2217
2082
|
}
|
|
2218
|
-
table(
|
|
2219
|
-
|
|
2220
|
-
if (!
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
if (headers.length !== aligns.length) {
|
|
2238
|
-
// header and align columns must be equal, rows can be different.
|
|
2239
|
-
return;
|
|
2240
|
-
}
|
|
2241
|
-
for (const align of aligns) {
|
|
2242
|
-
if (this.rules.other.tableAlignRight.test(align)) {
|
|
2243
|
-
item.align.push('right');
|
|
2244
|
-
} else if (this.rules.other.tableAlignCenter.test(align)) {
|
|
2245
|
-
item.align.push('center');
|
|
2246
|
-
} else if (this.rules.other.tableAlignLeft.test(align)) {
|
|
2247
|
-
item.align.push('left');
|
|
2248
|
-
} else {
|
|
2249
|
-
item.align.push(null);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
for (let i = 0; i < headers.length; i++) {
|
|
2253
|
-
item.header.push({
|
|
2254
|
-
text: headers[i],
|
|
2255
|
-
tokens: this.lexer.inline(headers[i]),
|
|
2083
|
+
table(e) {
|
|
2084
|
+
let t = this.rules.block.table.exec(e);
|
|
2085
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
2086
|
+
let n = V(t[1]),
|
|
2087
|
+
s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"),
|
|
2088
|
+
i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
2089
|
+
`) : [],
|
|
2090
|
+
r = {
|
|
2091
|
+
type: "table",
|
|
2092
|
+
raw: t[0],
|
|
2093
|
+
header: [],
|
|
2094
|
+
align: [],
|
|
2095
|
+
rows: []
|
|
2096
|
+
};
|
|
2097
|
+
if (n.length === s.length) {
|
|
2098
|
+
for (let o of s) this.rules.other.tableAlignRight.test(o) ? r.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? r.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? r.align.push("left") : r.align.push(null);
|
|
2099
|
+
for (let o = 0; o < n.length; o++) r.header.push({
|
|
2100
|
+
text: n[o],
|
|
2101
|
+
tokens: this.lexer.inline(n[o]),
|
|
2256
2102
|
header: true,
|
|
2257
|
-
align:
|
|
2103
|
+
align: r.align[o]
|
|
2258
2104
|
});
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
return
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
raw: cap[0],
|
|
2278
|
-
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
2279
|
-
text: cap[1],
|
|
2280
|
-
tokens: this.lexer.inline(cap[1])
|
|
2281
|
-
};
|
|
2282
|
-
}
|
|
2105
|
+
for (let o of i) r.rows.push(V(o, r.header.length).map((l, c) => ({
|
|
2106
|
+
text: l,
|
|
2107
|
+
tokens: this.lexer.inline(l),
|
|
2108
|
+
header: false,
|
|
2109
|
+
align: r.align[c]
|
|
2110
|
+
})));
|
|
2111
|
+
return r;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
lheading(e) {
|
|
2115
|
+
let t = this.rules.block.lheading.exec(e);
|
|
2116
|
+
if (t) return {
|
|
2117
|
+
type: "heading",
|
|
2118
|
+
raw: t[0],
|
|
2119
|
+
depth: t[2].charAt(0) === "=" ? 1 : 2,
|
|
2120
|
+
text: t[1],
|
|
2121
|
+
tokens: this.lexer.inline(t[1])
|
|
2122
|
+
};
|
|
2283
2123
|
}
|
|
2284
|
-
paragraph(
|
|
2285
|
-
|
|
2286
|
-
if (
|
|
2287
|
-
|
|
2124
|
+
paragraph(e) {
|
|
2125
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
2126
|
+
if (t) {
|
|
2127
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
2128
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
2288
2129
|
return {
|
|
2289
|
-
type:
|
|
2290
|
-
raw:
|
|
2291
|
-
text,
|
|
2292
|
-
tokens: this.lexer.inline(
|
|
2130
|
+
type: "paragraph",
|
|
2131
|
+
raw: t[0],
|
|
2132
|
+
text: n,
|
|
2133
|
+
tokens: this.lexer.inline(n)
|
|
2293
2134
|
};
|
|
2294
2135
|
}
|
|
2295
2136
|
}
|
|
2296
|
-
text(
|
|
2297
|
-
|
|
2298
|
-
if (
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
};
|
|
2305
|
-
}
|
|
2137
|
+
text(e) {
|
|
2138
|
+
let t = this.rules.block.text.exec(e);
|
|
2139
|
+
if (t) return {
|
|
2140
|
+
type: "text",
|
|
2141
|
+
raw: t[0],
|
|
2142
|
+
text: t[0],
|
|
2143
|
+
tokens: this.lexer.inline(t[0])
|
|
2144
|
+
};
|
|
2306
2145
|
}
|
|
2307
|
-
escape(
|
|
2308
|
-
|
|
2309
|
-
if (
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
};
|
|
2315
|
-
}
|
|
2146
|
+
escape(e) {
|
|
2147
|
+
let t = this.rules.inline.escape.exec(e);
|
|
2148
|
+
if (t) return {
|
|
2149
|
+
type: "escape",
|
|
2150
|
+
raw: t[0],
|
|
2151
|
+
text: t[1]
|
|
2152
|
+
};
|
|
2316
2153
|
}
|
|
2317
|
-
tag(
|
|
2318
|
-
|
|
2319
|
-
if (
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
} else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
|
|
2328
|
-
this.lexer.state.inRawBlock = false;
|
|
2329
|
-
}
|
|
2330
|
-
return {
|
|
2331
|
-
type: 'html',
|
|
2332
|
-
raw: cap[0],
|
|
2333
|
-
inLink: this.lexer.state.inLink,
|
|
2334
|
-
inRawBlock: this.lexer.state.inRawBlock,
|
|
2335
|
-
block: false,
|
|
2336
|
-
text: cap[0]
|
|
2337
|
-
};
|
|
2338
|
-
}
|
|
2154
|
+
tag(e) {
|
|
2155
|
+
let t = this.rules.inline.tag.exec(e);
|
|
2156
|
+
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), {
|
|
2157
|
+
type: "html",
|
|
2158
|
+
raw: t[0],
|
|
2159
|
+
inLink: this.lexer.state.inLink,
|
|
2160
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
2161
|
+
block: false,
|
|
2162
|
+
text: t[0]
|
|
2163
|
+
};
|
|
2339
2164
|
}
|
|
2340
|
-
link(
|
|
2341
|
-
|
|
2342
|
-
if (
|
|
2343
|
-
|
|
2344
|
-
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
}
|
|
2349
|
-
// ending angle bracket cannot be escaped
|
|
2350
|
-
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
2351
|
-
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
2352
|
-
return;
|
|
2353
|
-
}
|
|
2165
|
+
link(e) {
|
|
2166
|
+
let t = this.rules.inline.link.exec(e);
|
|
2167
|
+
if (t) {
|
|
2168
|
+
let n = t[2].trim();
|
|
2169
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
2170
|
+
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
2171
|
+
let r = A(n.slice(0, -1), "\\");
|
|
2172
|
+
if ((n.length - r.length) % 2 === 0) return;
|
|
2354
2173
|
} else {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
if (
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
}
|
|
2361
|
-
if (lastParenIndex > -1) {
|
|
2362
|
-
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
2363
|
-
const linkLen = start + cap[1].length + lastParenIndex;
|
|
2364
|
-
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
2365
|
-
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
2366
|
-
cap[3] = '';
|
|
2174
|
+
let r = fe(t[2], "()");
|
|
2175
|
+
if (r === -2) return;
|
|
2176
|
+
if (r > -1) {
|
|
2177
|
+
let l = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + r;
|
|
2178
|
+
t[2] = t[2].substring(0, r), t[0] = t[0].substring(0, l).trim(), t[3] = "";
|
|
2367
2179
|
}
|
|
2368
2180
|
}
|
|
2369
|
-
let
|
|
2370
|
-
|
|
2181
|
+
let s = t[2],
|
|
2182
|
+
i = "";
|
|
2371
2183
|
if (this.options.pedantic) {
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
return outputLink(cap, {
|
|
2391
|
-
href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
|
|
2392
|
-
title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
|
|
2393
|
-
}, cap[0], this.lexer, this.rules);
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
reflink(src, links) {
|
|
2397
|
-
let cap;
|
|
2398
|
-
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
2399
|
-
const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, ' ');
|
|
2400
|
-
const link = links[linkString.toLowerCase()];
|
|
2401
|
-
if (!link) {
|
|
2402
|
-
const text = cap[0].charAt(0);
|
|
2184
|
+
let r = this.rules.other.pedanticHrefTitle.exec(s);
|
|
2185
|
+
r && (s = r[1], i = r[3]);
|
|
2186
|
+
} else i = t[3] ? t[3].slice(1, -1) : "";
|
|
2187
|
+
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), de(t, {
|
|
2188
|
+
href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
2189
|
+
title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
|
|
2190
|
+
}, t[0], this.lexer, this.rules);
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
reflink(e, t) {
|
|
2194
|
+
let n;
|
|
2195
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
2196
|
+
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
2197
|
+
i = t[s.toLowerCase()];
|
|
2198
|
+
if (!i) {
|
|
2199
|
+
let r = n[0].charAt(0);
|
|
2403
2200
|
return {
|
|
2404
|
-
type:
|
|
2405
|
-
raw:
|
|
2406
|
-
text
|
|
2201
|
+
type: "text",
|
|
2202
|
+
raw: r,
|
|
2203
|
+
text: r
|
|
2407
2204
|
};
|
|
2408
2205
|
}
|
|
2409
|
-
return
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
|
-
emStrong(
|
|
2413
|
-
let
|
|
2414
|
-
if (!match) return;
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
2430
|
-
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
2431
|
-
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
2432
|
-
rLength = [...rDelim].length;
|
|
2433
|
-
if (match[3] || match[4]) {
|
|
2434
|
-
// found another Left Delim
|
|
2435
|
-
delimTotal += rLength;
|
|
2206
|
+
return de(n, i, n[0], this.lexer, this.rules);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
emStrong(e, t, n = "") {
|
|
2210
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
2211
|
+
if (!s || s[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
2212
|
+
if (!(s[1] || s[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2213
|
+
let r = [...s[0]].length - 1,
|
|
2214
|
+
o,
|
|
2215
|
+
l,
|
|
2216
|
+
c = r,
|
|
2217
|
+
p = 0,
|
|
2218
|
+
u = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
2219
|
+
for (u.lastIndex = 0, t = t.slice(-1 * e.length + r); (s = u.exec(t)) != null;) {
|
|
2220
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
|
|
2221
|
+
if (l = [...o].length, s[3] || s[4]) {
|
|
2222
|
+
c += l;
|
|
2223
|
+
continue;
|
|
2224
|
+
} else if ((s[5] || s[6]) && r % 3 && !((r + l) % 3)) {
|
|
2225
|
+
p += l;
|
|
2436
2226
|
continue;
|
|
2437
|
-
} else if (match[5] || match[6]) {
|
|
2438
|
-
// either Left or Right Delim
|
|
2439
|
-
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
2440
|
-
midDelimTotal += rLength;
|
|
2441
|
-
continue; // CommonMark Emphasis Rules 9-10
|
|
2442
|
-
}
|
|
2443
2227
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
2451
|
-
// Create `em` if smallest delimiter has odd char count. *a***
|
|
2452
|
-
if (Math.min(lLength, rLength) % 2) {
|
|
2453
|
-
const text = raw.slice(1, -1);
|
|
2228
|
+
if (c -= l, c > 0) continue;
|
|
2229
|
+
l = Math.min(l, l + c + p);
|
|
2230
|
+
let d = [...s[0]][0].length,
|
|
2231
|
+
g = e.slice(0, r + s.index + d + l);
|
|
2232
|
+
if (Math.min(r, l) % 2) {
|
|
2233
|
+
let f = g.slice(1, -1);
|
|
2454
2234
|
return {
|
|
2455
|
-
type:
|
|
2456
|
-
raw,
|
|
2457
|
-
text,
|
|
2458
|
-
tokens: this.lexer.inlineTokens(
|
|
2235
|
+
type: "em",
|
|
2236
|
+
raw: g,
|
|
2237
|
+
text: f,
|
|
2238
|
+
tokens: this.lexer.inlineTokens(f)
|
|
2459
2239
|
};
|
|
2460
2240
|
}
|
|
2461
|
-
|
|
2462
|
-
const text = raw.slice(2, -2);
|
|
2241
|
+
let x = g.slice(2, -2);
|
|
2463
2242
|
return {
|
|
2464
|
-
type:
|
|
2465
|
-
raw,
|
|
2466
|
-
text,
|
|
2467
|
-
tokens: this.lexer.inlineTokens(
|
|
2243
|
+
type: "strong",
|
|
2244
|
+
raw: g,
|
|
2245
|
+
text: x,
|
|
2246
|
+
tokens: this.lexer.inlineTokens(x)
|
|
2468
2247
|
};
|
|
2469
2248
|
}
|
|
2470
2249
|
}
|
|
2471
2250
|
}
|
|
2472
|
-
codespan(
|
|
2473
|
-
|
|
2474
|
-
if (
|
|
2475
|
-
let
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
type: 'codespan',
|
|
2483
|
-
raw: cap[0],
|
|
2484
|
-
text
|
|
2251
|
+
codespan(e) {
|
|
2252
|
+
let t = this.rules.inline.code.exec(e);
|
|
2253
|
+
if (t) {
|
|
2254
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "),
|
|
2255
|
+
s = this.rules.other.nonSpaceChar.test(n),
|
|
2256
|
+
i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
2257
|
+
return s && i && (n = n.substring(1, n.length - 1)), {
|
|
2258
|
+
type: "codespan",
|
|
2259
|
+
raw: t[0],
|
|
2260
|
+
text: n
|
|
2485
2261
|
};
|
|
2486
2262
|
}
|
|
2487
2263
|
}
|
|
2488
|
-
br(
|
|
2489
|
-
|
|
2490
|
-
if (
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
};
|
|
2495
|
-
}
|
|
2264
|
+
br(e) {
|
|
2265
|
+
let t = this.rules.inline.br.exec(e);
|
|
2266
|
+
if (t) return {
|
|
2267
|
+
type: "br",
|
|
2268
|
+
raw: t[0]
|
|
2269
|
+
};
|
|
2496
2270
|
}
|
|
2497
|
-
del(
|
|
2498
|
-
|
|
2499
|
-
if (
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
};
|
|
2506
|
-
}
|
|
2271
|
+
del(e) {
|
|
2272
|
+
let t = this.rules.inline.del.exec(e);
|
|
2273
|
+
if (t) return {
|
|
2274
|
+
type: "del",
|
|
2275
|
+
raw: t[0],
|
|
2276
|
+
text: t[2],
|
|
2277
|
+
tokens: this.lexer.inlineTokens(t[2])
|
|
2278
|
+
};
|
|
2507
2279
|
}
|
|
2508
|
-
autolink(
|
|
2509
|
-
|
|
2510
|
-
if (
|
|
2511
|
-
let
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
href = text;
|
|
2518
|
-
}
|
|
2519
|
-
return {
|
|
2520
|
-
type: 'link',
|
|
2521
|
-
raw: cap[0],
|
|
2522
|
-
text,
|
|
2523
|
-
href,
|
|
2280
|
+
autolink(e) {
|
|
2281
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
2282
|
+
if (t) {
|
|
2283
|
+
let n, s;
|
|
2284
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), {
|
|
2285
|
+
type: "link",
|
|
2286
|
+
raw: t[0],
|
|
2287
|
+
text: n,
|
|
2288
|
+
href: s,
|
|
2524
2289
|
tokens: [{
|
|
2525
|
-
type:
|
|
2526
|
-
raw:
|
|
2527
|
-
text
|
|
2290
|
+
type: "text",
|
|
2291
|
+
raw: n,
|
|
2292
|
+
text: n
|
|
2528
2293
|
}]
|
|
2529
2294
|
};
|
|
2530
2295
|
}
|
|
2531
2296
|
}
|
|
2532
|
-
url(
|
|
2533
|
-
let
|
|
2534
|
-
if (
|
|
2535
|
-
let
|
|
2536
|
-
if (
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
// do extended autolink path validation
|
|
2541
|
-
let prevCapZero;
|
|
2542
|
-
do {
|
|
2543
|
-
prevCapZero = cap[0];
|
|
2544
|
-
cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? '';
|
|
2545
|
-
} while (prevCapZero !== cap[0]);
|
|
2546
|
-
text = cap[0];
|
|
2547
|
-
if (cap[1] === 'www.') {
|
|
2548
|
-
href = 'http://' + cap[0];
|
|
2549
|
-
} else {
|
|
2550
|
-
href = cap[0];
|
|
2551
|
-
}
|
|
2297
|
+
url(e) {
|
|
2298
|
+
let t;
|
|
2299
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
2300
|
+
let n, s;
|
|
2301
|
+
if (t[2] === "@") n = t[0], s = "mailto:" + n;else {
|
|
2302
|
+
let i;
|
|
2303
|
+
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." ? s = "http://" + t[0] : s = t[0];
|
|
2552
2305
|
}
|
|
2553
2306
|
return {
|
|
2554
|
-
type:
|
|
2555
|
-
raw:
|
|
2556
|
-
text,
|
|
2557
|
-
href,
|
|
2307
|
+
type: "link",
|
|
2308
|
+
raw: t[0],
|
|
2309
|
+
text: n,
|
|
2310
|
+
href: s,
|
|
2558
2311
|
tokens: [{
|
|
2559
|
-
type:
|
|
2560
|
-
raw:
|
|
2561
|
-
text
|
|
2312
|
+
type: "text",
|
|
2313
|
+
raw: n,
|
|
2314
|
+
text: n
|
|
2562
2315
|
}]
|
|
2563
2316
|
};
|
|
2564
2317
|
}
|
|
2565
2318
|
}
|
|
2566
|
-
inlineText(
|
|
2567
|
-
|
|
2568
|
-
if (
|
|
2569
|
-
|
|
2319
|
+
inlineText(e) {
|
|
2320
|
+
let t = this.rules.inline.text.exec(e);
|
|
2321
|
+
if (t) {
|
|
2322
|
+
let n = this.lexer.state.inRawBlock;
|
|
2570
2323
|
return {
|
|
2571
|
-
type:
|
|
2572
|
-
raw:
|
|
2573
|
-
text:
|
|
2574
|
-
escaped
|
|
2324
|
+
type: "text",
|
|
2325
|
+
raw: t[0],
|
|
2326
|
+
text: t[0],
|
|
2327
|
+
escaped: n
|
|
2575
2328
|
};
|
|
2576
2329
|
}
|
|
2577
2330
|
}
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2580
|
-
/**
|
|
2581
|
-
* Block Lexer
|
|
2582
|
-
*/
|
|
2583
|
-
class _Lexer {
|
|
2331
|
+
};
|
|
2332
|
+
var b = class a {
|
|
2584
2333
|
tokens;
|
|
2585
2334
|
options;
|
|
2586
2335
|
state;
|
|
2587
2336
|
tokenizer;
|
|
2588
2337
|
inlineQueue;
|
|
2589
|
-
constructor(
|
|
2590
|
-
|
|
2591
|
-
this.tokens = [];
|
|
2592
|
-
this.tokens.links = Object.create(null);
|
|
2593
|
-
this.options = options || _defaults;
|
|
2594
|
-
this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
|
|
2595
|
-
this.tokenizer = this.options.tokenizer;
|
|
2596
|
-
this.tokenizer.options = this.options;
|
|
2597
|
-
this.tokenizer.lexer = this;
|
|
2598
|
-
this.inlineQueue = [];
|
|
2599
|
-
this.state = {
|
|
2338
|
+
constructor(e) {
|
|
2339
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || w, this.options.tokenizer = this.options.tokenizer || new S(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
2600
2340
|
inLink: false,
|
|
2601
2341
|
inRawBlock: false,
|
|
2602
2342
|
top: true
|
|
2603
2343
|
};
|
|
2604
|
-
|
|
2605
|
-
other,
|
|
2606
|
-
block:
|
|
2607
|
-
inline:
|
|
2344
|
+
let t = {
|
|
2345
|
+
other: m,
|
|
2346
|
+
block: O.normal,
|
|
2347
|
+
inline: P.normal
|
|
2608
2348
|
};
|
|
2609
|
-
|
|
2610
|
-
rules.block = block.pedantic;
|
|
2611
|
-
rules.inline = inline.pedantic;
|
|
2612
|
-
} else if (this.options.gfm) {
|
|
2613
|
-
rules.block = block.gfm;
|
|
2614
|
-
if (this.options.breaks) {
|
|
2615
|
-
rules.inline = inline.breaks;
|
|
2616
|
-
} else {
|
|
2617
|
-
rules.inline = inline.gfm;
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
this.tokenizer.rules = rules;
|
|
2349
|
+
this.options.pedantic ? (t.block = O.pedantic, t.inline = P.pedantic) : this.options.gfm && (t.block = O.gfm, this.options.breaks ? t.inline = P.breaks : t.inline = P.gfm), this.tokenizer.rules = t;
|
|
2621
2350
|
}
|
|
2622
|
-
/**
|
|
2623
|
-
* Expose Rules
|
|
2624
|
-
*/
|
|
2625
2351
|
static get rules() {
|
|
2626
2352
|
return {
|
|
2627
|
-
block,
|
|
2628
|
-
inline
|
|
2353
|
+
block: O,
|
|
2354
|
+
inline: P
|
|
2629
2355
|
};
|
|
2630
2356
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
static
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
}
|
|
2658
|
-
blockTokens(src, tokens = [], lastParagraphClipped = false) {
|
|
2659
|
-
if (this.options.pedantic) {
|
|
2660
|
-
src = src.replace(other.tabCharGlobal, ' ').replace(other.spaceLine, '');
|
|
2661
|
-
}
|
|
2662
|
-
while (src) {
|
|
2663
|
-
let token;
|
|
2664
|
-
if (this.options.extensions?.block?.some(extTokenizer => {
|
|
2665
|
-
if (token = extTokenizer.call({
|
|
2666
|
-
lexer: this
|
|
2667
|
-
}, src, tokens)) {
|
|
2668
|
-
src = src.substring(token.raw.length);
|
|
2669
|
-
tokens.push(token);
|
|
2670
|
-
return true;
|
|
2671
|
-
}
|
|
2672
|
-
return false;
|
|
2673
|
-
})) {
|
|
2674
|
-
continue;
|
|
2675
|
-
}
|
|
2676
|
-
// newline
|
|
2677
|
-
if (token = this.tokenizer.space(src)) {
|
|
2678
|
-
src = src.substring(token.raw.length);
|
|
2679
|
-
const lastToken = tokens.at(-1);
|
|
2680
|
-
if (token.raw.length === 1 && lastToken !== undefined) {
|
|
2681
|
-
// if there's a single \n as a spacer, it's terminating the last line,
|
|
2682
|
-
// so move it there so that we don't get unnecessary paragraph tags
|
|
2683
|
-
lastToken.raw += '\n';
|
|
2684
|
-
} else {
|
|
2685
|
-
tokens.push(token);
|
|
2686
|
-
}
|
|
2357
|
+
static lex(e, t) {
|
|
2358
|
+
return new a(t).lex(e);
|
|
2359
|
+
}
|
|
2360
|
+
static lexInline(e, t) {
|
|
2361
|
+
return new a(t).inlineTokens(e);
|
|
2362
|
+
}
|
|
2363
|
+
lex(e) {
|
|
2364
|
+
e = e.replace(m.carriageReturn, `
|
|
2365
|
+
`), this.blockTokens(e, this.tokens);
|
|
2366
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
2367
|
+
let n = this.inlineQueue[t];
|
|
2368
|
+
this.inlineTokens(n.src, n.tokens);
|
|
2369
|
+
}
|
|
2370
|
+
return this.inlineQueue = [], this.tokens;
|
|
2371
|
+
}
|
|
2372
|
+
blockTokens(e, t = [], n = false) {
|
|
2373
|
+
for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e;) {
|
|
2374
|
+
let s;
|
|
2375
|
+
if (this.options.extensions?.block?.some(r => (s = r.call({
|
|
2376
|
+
lexer: this
|
|
2377
|
+
}, e, t)) ? (e = e.substring(s.raw.length), t.push(s), true) : false)) continue;
|
|
2378
|
+
if (s = this.tokenizer.space(e)) {
|
|
2379
|
+
e = e.substring(s.raw.length);
|
|
2380
|
+
let r = t.at(-1);
|
|
2381
|
+
s.raw.length === 1 && r !== void 0 ? r.raw += `
|
|
2382
|
+
` : t.push(s);
|
|
2687
2383
|
continue;
|
|
2688
2384
|
}
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
lastToken.raw += '\n' + token.raw;
|
|
2696
|
-
lastToken.text += '\n' + token.text;
|
|
2697
|
-
this.inlineQueue.at(-1).src = lastToken.text;
|
|
2698
|
-
} else {
|
|
2699
|
-
tokens.push(token);
|
|
2700
|
-
}
|
|
2385
|
+
if (s = this.tokenizer.code(e)) {
|
|
2386
|
+
e = e.substring(s.raw.length);
|
|
2387
|
+
let r = t.at(-1);
|
|
2388
|
+
r?.type === "paragraph" || r?.type === "text" ? (r.raw += `
|
|
2389
|
+
` + s.raw, r.text += `
|
|
2390
|
+
` + s.text, this.inlineQueue.at(-1).src = r.text) : t.push(s);
|
|
2701
2391
|
continue;
|
|
2702
2392
|
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
src = src.substring(token.raw.length);
|
|
2706
|
-
tokens.push(token);
|
|
2393
|
+
if (s = this.tokenizer.fences(e)) {
|
|
2394
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2707
2395
|
continue;
|
|
2708
2396
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
src = src.substring(token.raw.length);
|
|
2712
|
-
tokens.push(token);
|
|
2397
|
+
if (s = this.tokenizer.heading(e)) {
|
|
2398
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2713
2399
|
continue;
|
|
2714
2400
|
}
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
src = src.substring(token.raw.length);
|
|
2718
|
-
tokens.push(token);
|
|
2401
|
+
if (s = this.tokenizer.hr(e)) {
|
|
2402
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2719
2403
|
continue;
|
|
2720
2404
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
src = src.substring(token.raw.length);
|
|
2724
|
-
tokens.push(token);
|
|
2405
|
+
if (s = this.tokenizer.blockquote(e)) {
|
|
2406
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2725
2407
|
continue;
|
|
2726
2408
|
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
src = src.substring(token.raw.length);
|
|
2730
|
-
tokens.push(token);
|
|
2409
|
+
if (s = this.tokenizer.list(e)) {
|
|
2410
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2731
2411
|
continue;
|
|
2732
2412
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
src = src.substring(token.raw.length);
|
|
2736
|
-
tokens.push(token);
|
|
2413
|
+
if (s = this.tokenizer.html(e)) {
|
|
2414
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2737
2415
|
continue;
|
|
2738
2416
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
}
|
|
2748
|
-
this.tokens.links[token.tag] = {
|
|
2749
|
-
href: token.href,
|
|
2750
|
-
title: token.title
|
|
2751
|
-
};
|
|
2752
|
-
}
|
|
2417
|
+
if (s = this.tokenizer.def(e)) {
|
|
2418
|
+
e = e.substring(s.raw.length);
|
|
2419
|
+
let r = t.at(-1);
|
|
2420
|
+
r?.type === "paragraph" || r?.type === "text" ? (r.raw += `
|
|
2421
|
+
` + s.raw, r.text += `
|
|
2422
|
+
` + s.raw, this.inlineQueue.at(-1).src = r.text) : this.tokens.links[s.tag] || (this.tokens.links[s.tag] = {
|
|
2423
|
+
href: s.href,
|
|
2424
|
+
title: s.title
|
|
2425
|
+
});
|
|
2753
2426
|
continue;
|
|
2754
2427
|
}
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
src = src.substring(token.raw.length);
|
|
2758
|
-
tokens.push(token);
|
|
2428
|
+
if (s = this.tokenizer.table(e)) {
|
|
2429
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2759
2430
|
continue;
|
|
2760
2431
|
}
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
src = src.substring(token.raw.length);
|
|
2764
|
-
tokens.push(token);
|
|
2432
|
+
if (s = this.tokenizer.lheading(e)) {
|
|
2433
|
+
e = e.substring(s.raw.length), t.push(s);
|
|
2765
2434
|
continue;
|
|
2766
2435
|
}
|
|
2767
|
-
|
|
2768
|
-
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
2769
|
-
let cutSrc = src;
|
|
2436
|
+
let i = e;
|
|
2770
2437
|
if (this.options.extensions?.startBlock) {
|
|
2771
|
-
let
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
this.options.extensions.startBlock.forEach(
|
|
2775
|
-
|
|
2438
|
+
let r = 1 / 0,
|
|
2439
|
+
o = e.slice(1),
|
|
2440
|
+
l;
|
|
2441
|
+
this.options.extensions.startBlock.forEach(c => {
|
|
2442
|
+
l = c.call({
|
|
2776
2443
|
lexer: this
|
|
2777
|
-
},
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
}
|
|
2786
|
-
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
2787
|
-
const lastToken = tokens.at(-1);
|
|
2788
|
-
if (lastParagraphClipped && lastToken?.type === 'paragraph') {
|
|
2789
|
-
lastToken.raw += '\n' + token.raw;
|
|
2790
|
-
lastToken.text += '\n' + token.text;
|
|
2791
|
-
this.inlineQueue.pop();
|
|
2792
|
-
this.inlineQueue.at(-1).src = lastToken.text;
|
|
2793
|
-
} else {
|
|
2794
|
-
tokens.push(token);
|
|
2795
|
-
}
|
|
2796
|
-
lastParagraphClipped = cutSrc.length !== src.length;
|
|
2797
|
-
src = src.substring(token.raw.length);
|
|
2444
|
+
}, o), typeof l == "number" && l >= 0 && (r = Math.min(r, l));
|
|
2445
|
+
}), r < 1 / 0 && r >= 0 && (i = e.substring(0, r + 1));
|
|
2446
|
+
}
|
|
2447
|
+
if (this.state.top && (s = this.tokenizer.paragraph(i))) {
|
|
2448
|
+
let r = t.at(-1);
|
|
2449
|
+
n && r?.type === "paragraph" ? (r.raw += `
|
|
2450
|
+
` + s.raw, r.text += `
|
|
2451
|
+
` + s.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = r.text) : t.push(s), n = i.length !== e.length, e = e.substring(s.raw.length);
|
|
2798
2452
|
continue;
|
|
2799
2453
|
}
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
lastToken.text += '\n' + token.text;
|
|
2807
|
-
this.inlineQueue.pop();
|
|
2808
|
-
this.inlineQueue.at(-1).src = lastToken.text;
|
|
2809
|
-
} else {
|
|
2810
|
-
tokens.push(token);
|
|
2811
|
-
}
|
|
2454
|
+
if (s = this.tokenizer.text(e)) {
|
|
2455
|
+
e = e.substring(s.raw.length);
|
|
2456
|
+
let r = t.at(-1);
|
|
2457
|
+
r?.type === "text" ? (r.raw += `
|
|
2458
|
+
` + s.raw, r.text += `
|
|
2459
|
+
` + s.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = r.text) : t.push(s);
|
|
2812
2460
|
continue;
|
|
2813
2461
|
}
|
|
2814
|
-
if (
|
|
2815
|
-
|
|
2462
|
+
if (e) {
|
|
2463
|
+
let r = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2816
2464
|
if (this.options.silent) {
|
|
2817
|
-
console.error(
|
|
2465
|
+
console.error(r);
|
|
2818
2466
|
break;
|
|
2819
|
-
} else
|
|
2820
|
-
throw new Error(errMsg);
|
|
2821
|
-
}
|
|
2467
|
+
} else throw new Error(r);
|
|
2822
2468
|
}
|
|
2823
2469
|
}
|
|
2824
|
-
this.state.top = true;
|
|
2825
|
-
return tokens;
|
|
2470
|
+
return this.state.top = true, t;
|
|
2826
2471
|
}
|
|
2827
|
-
inline(
|
|
2828
|
-
this.inlineQueue.push({
|
|
2829
|
-
src,
|
|
2830
|
-
tokens
|
|
2831
|
-
});
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
*/
|
|
2837
|
-
inlineTokens(src, tokens = []) {
|
|
2838
|
-
// String with links masked to avoid interference with em and strong
|
|
2839
|
-
let maskedSrc = src;
|
|
2840
|
-
let match = null;
|
|
2841
|
-
// Mask out reflinks
|
|
2472
|
+
inline(e, t = []) {
|
|
2473
|
+
return this.inlineQueue.push({
|
|
2474
|
+
src: e,
|
|
2475
|
+
tokens: t
|
|
2476
|
+
}), t;
|
|
2477
|
+
}
|
|
2478
|
+
inlineTokens(e, t = []) {
|
|
2479
|
+
let n = e,
|
|
2480
|
+
s = null;
|
|
2842
2481
|
if (this.tokens.links) {
|
|
2843
|
-
|
|
2844
|
-
if (
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
2859
|
-
}
|
|
2860
|
-
let keepPrevChar = false;
|
|
2861
|
-
let prevChar = '';
|
|
2862
|
-
while (src) {
|
|
2863
|
-
if (!keepPrevChar) {
|
|
2864
|
-
prevChar = '';
|
|
2865
|
-
}
|
|
2866
|
-
keepPrevChar = false;
|
|
2867
|
-
let token;
|
|
2868
|
-
// extensions
|
|
2869
|
-
if (this.options.extensions?.inline?.some(extTokenizer => {
|
|
2870
|
-
if (token = extTokenizer.call({
|
|
2871
|
-
lexer: this
|
|
2872
|
-
}, src, tokens)) {
|
|
2873
|
-
src = src.substring(token.raw.length);
|
|
2874
|
-
tokens.push(token);
|
|
2875
|
-
return true;
|
|
2876
|
-
}
|
|
2877
|
-
return false;
|
|
2878
|
-
})) {
|
|
2879
|
-
continue;
|
|
2880
|
-
}
|
|
2881
|
-
// escape
|
|
2882
|
-
if (token = this.tokenizer.escape(src)) {
|
|
2883
|
-
src = src.substring(token.raw.length);
|
|
2884
|
-
tokens.push(token);
|
|
2482
|
+
let o = Object.keys(this.tokens.links);
|
|
2483
|
+
if (o.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null;) o.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
2484
|
+
}
|
|
2485
|
+
for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null;) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
2486
|
+
for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) != null;) n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
2487
|
+
let i = false,
|
|
2488
|
+
r = "";
|
|
2489
|
+
for (; e;) {
|
|
2490
|
+
i || (r = ""), i = false;
|
|
2491
|
+
let o;
|
|
2492
|
+
if (this.options.extensions?.inline?.some(c => (o = c.call({
|
|
2493
|
+
lexer: this
|
|
2494
|
+
}, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
2495
|
+
if (o = this.tokenizer.escape(e)) {
|
|
2496
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2885
2497
|
continue;
|
|
2886
2498
|
}
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
src = src.substring(token.raw.length);
|
|
2890
|
-
tokens.push(token);
|
|
2499
|
+
if (o = this.tokenizer.tag(e)) {
|
|
2500
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2891
2501
|
continue;
|
|
2892
2502
|
}
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
src = src.substring(token.raw.length);
|
|
2896
|
-
tokens.push(token);
|
|
2503
|
+
if (o = this.tokenizer.link(e)) {
|
|
2504
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2897
2505
|
continue;
|
|
2898
2506
|
}
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
if (token.type === 'text' && lastToken?.type === 'text') {
|
|
2904
|
-
lastToken.raw += token.raw;
|
|
2905
|
-
lastToken.text += token.text;
|
|
2906
|
-
} else {
|
|
2907
|
-
tokens.push(token);
|
|
2908
|
-
}
|
|
2507
|
+
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
2508
|
+
e = e.substring(o.raw.length);
|
|
2509
|
+
let c = t.at(-1);
|
|
2510
|
+
o.type === "text" && c?.type === "text" ? (c.raw += o.raw, c.text += o.text) : t.push(o);
|
|
2909
2511
|
continue;
|
|
2910
2512
|
}
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
src = src.substring(token.raw.length);
|
|
2914
|
-
tokens.push(token);
|
|
2513
|
+
if (o = this.tokenizer.emStrong(e, n, r)) {
|
|
2514
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2915
2515
|
continue;
|
|
2916
2516
|
}
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
src = src.substring(token.raw.length);
|
|
2920
|
-
tokens.push(token);
|
|
2517
|
+
if (o = this.tokenizer.codespan(e)) {
|
|
2518
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2921
2519
|
continue;
|
|
2922
2520
|
}
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
src = src.substring(token.raw.length);
|
|
2926
|
-
tokens.push(token);
|
|
2521
|
+
if (o = this.tokenizer.br(e)) {
|
|
2522
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2927
2523
|
continue;
|
|
2928
2524
|
}
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
src = src.substring(token.raw.length);
|
|
2932
|
-
tokens.push(token);
|
|
2525
|
+
if (o = this.tokenizer.del(e)) {
|
|
2526
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2933
2527
|
continue;
|
|
2934
2528
|
}
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
src = src.substring(token.raw.length);
|
|
2938
|
-
tokens.push(token);
|
|
2529
|
+
if (o = this.tokenizer.autolink(e)) {
|
|
2530
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2939
2531
|
continue;
|
|
2940
2532
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
src = src.substring(token.raw.length);
|
|
2944
|
-
tokens.push(token);
|
|
2533
|
+
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
2534
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2945
2535
|
continue;
|
|
2946
2536
|
}
|
|
2947
|
-
|
|
2948
|
-
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
2949
|
-
let cutSrc = src;
|
|
2537
|
+
let l = e;
|
|
2950
2538
|
if (this.options.extensions?.startInline) {
|
|
2951
|
-
let
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
this.options.extensions.startInline.forEach(
|
|
2955
|
-
|
|
2539
|
+
let c = 1 / 0,
|
|
2540
|
+
p = e.slice(1),
|
|
2541
|
+
u;
|
|
2542
|
+
this.options.extensions.startInline.forEach(d => {
|
|
2543
|
+
u = d.call({
|
|
2956
2544
|
lexer: this
|
|
2957
|
-
},
|
|
2958
|
-
|
|
2959
|
-
startIndex = Math.min(startIndex, tempStart);
|
|
2960
|
-
}
|
|
2961
|
-
});
|
|
2962
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
2963
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
2964
|
-
}
|
|
2545
|
+
}, p), typeof u == "number" && u >= 0 && (c = Math.min(c, u));
|
|
2546
|
+
}), c < 1 / 0 && c >= 0 && (l = e.substring(0, c + 1));
|
|
2965
2547
|
}
|
|
2966
|
-
if (
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
prevChar = token.raw.slice(-1);
|
|
2971
|
-
}
|
|
2972
|
-
keepPrevChar = true;
|
|
2973
|
-
const lastToken = tokens.at(-1);
|
|
2974
|
-
if (lastToken?.type === 'text') {
|
|
2975
|
-
lastToken.raw += token.raw;
|
|
2976
|
-
lastToken.text += token.text;
|
|
2977
|
-
} else {
|
|
2978
|
-
tokens.push(token);
|
|
2979
|
-
}
|
|
2548
|
+
if (o = this.tokenizer.inlineText(l)) {
|
|
2549
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), i = true;
|
|
2550
|
+
let c = t.at(-1);
|
|
2551
|
+
c?.type === "text" ? (c.raw += o.raw, c.text += o.text) : t.push(o);
|
|
2980
2552
|
continue;
|
|
2981
2553
|
}
|
|
2982
|
-
if (
|
|
2983
|
-
|
|
2554
|
+
if (e) {
|
|
2555
|
+
let c = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2984
2556
|
if (this.options.silent) {
|
|
2985
|
-
console.error(
|
|
2557
|
+
console.error(c);
|
|
2986
2558
|
break;
|
|
2987
|
-
} else
|
|
2988
|
-
throw new Error(errMsg);
|
|
2989
|
-
}
|
|
2559
|
+
} else throw new Error(c);
|
|
2990
2560
|
}
|
|
2991
2561
|
}
|
|
2992
|
-
return
|
|
2562
|
+
return t;
|
|
2993
2563
|
}
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
|
-
/**
|
|
2997
|
-
* Renderer
|
|
2998
|
-
*/
|
|
2999
|
-
class _Renderer {
|
|
2564
|
+
};
|
|
2565
|
+
var $ = class {
|
|
3000
2566
|
options;
|
|
3001
|
-
parser;
|
|
3002
|
-
constructor(
|
|
3003
|
-
this.options =
|
|
2567
|
+
parser;
|
|
2568
|
+
constructor(e) {
|
|
2569
|
+
this.options = e || w;
|
|
3004
2570
|
}
|
|
3005
|
-
space(
|
|
3006
|
-
return
|
|
2571
|
+
space(e) {
|
|
2572
|
+
return "";
|
|
3007
2573
|
}
|
|
3008
2574
|
code({
|
|
3009
|
-
text,
|
|
3010
|
-
lang,
|
|
3011
|
-
escaped
|
|
2575
|
+
text: e,
|
|
2576
|
+
lang: t,
|
|
2577
|
+
escaped: n
|
|
3012
2578
|
}) {
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
2579
|
+
let s = (t || "").match(m.notSpaceStart)?.[0],
|
|
2580
|
+
i = e.replace(m.endingNewline, "") + `
|
|
2581
|
+
`;
|
|
2582
|
+
return s ? '<pre><code class="language-' + R(s) + '">' + (n ? i : R(i, true)) + `</code></pre>
|
|
2583
|
+
` : "<pre><code>" + (n ? i : R(i, true)) + `</code></pre>
|
|
2584
|
+
`;
|
|
3019
2585
|
}
|
|
3020
2586
|
blockquote({
|
|
3021
|
-
tokens
|
|
2587
|
+
tokens: e
|
|
3022
2588
|
}) {
|
|
3023
|
-
|
|
3024
|
-
|
|
2589
|
+
return `<blockquote>
|
|
2590
|
+
${this.parser.parse(e)}</blockquote>
|
|
2591
|
+
`;
|
|
3025
2592
|
}
|
|
3026
2593
|
html({
|
|
3027
|
-
text
|
|
2594
|
+
text: e
|
|
3028
2595
|
}) {
|
|
3029
|
-
return
|
|
2596
|
+
return e;
|
|
3030
2597
|
}
|
|
3031
2598
|
heading({
|
|
3032
|
-
tokens,
|
|
3033
|
-
depth
|
|
2599
|
+
tokens: e,
|
|
2600
|
+
depth: t
|
|
3034
2601
|
}) {
|
|
3035
|
-
return `<h${
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
let
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
2602
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
2603
|
+
`;
|
|
2604
|
+
}
|
|
2605
|
+
hr(e) {
|
|
2606
|
+
return `<hr>
|
|
2607
|
+
`;
|
|
2608
|
+
}
|
|
2609
|
+
list(e) {
|
|
2610
|
+
let t = e.ordered,
|
|
2611
|
+
n = e.start,
|
|
2612
|
+
s = "";
|
|
2613
|
+
for (let o = 0; o < e.items.length; o++) {
|
|
2614
|
+
let l = e.items[o];
|
|
2615
|
+
s += this.listitem(l);
|
|
2616
|
+
}
|
|
2617
|
+
let i = t ? "ol" : "ul",
|
|
2618
|
+
r = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
2619
|
+
return "<" + i + r + `>
|
|
2620
|
+
` + s + "</" + i + `>
|
|
2621
|
+
`;
|
|
2622
|
+
}
|
|
2623
|
+
listitem(e) {
|
|
2624
|
+
let t = "";
|
|
2625
|
+
if (e.task) {
|
|
2626
|
+
let n = this.checkbox({
|
|
2627
|
+
checked: !!e.checked
|
|
3057
2628
|
});
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
}
|
|
3065
|
-
} else {
|
|
3066
|
-
item.tokens.unshift({
|
|
3067
|
-
type: 'text',
|
|
3068
|
-
raw: checkbox + ' ',
|
|
3069
|
-
text: checkbox + ' ',
|
|
3070
|
-
escaped: true
|
|
3071
|
-
});
|
|
3072
|
-
}
|
|
3073
|
-
} else {
|
|
3074
|
-
itemBody += checkbox + ' ';
|
|
3075
|
-
}
|
|
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 + " " + R(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = true)) : e.tokens.unshift({
|
|
2630
|
+
type: "text",
|
|
2631
|
+
raw: n + " ",
|
|
2632
|
+
text: n + " ",
|
|
2633
|
+
escaped: true
|
|
2634
|
+
}) : t += n + " ";
|
|
3076
2635
|
}
|
|
3077
|
-
|
|
3078
|
-
|
|
2636
|
+
return t += this.parser.parse(e.tokens, !!e.loose), `<li>${t}</li>
|
|
2637
|
+
`;
|
|
3079
2638
|
}
|
|
3080
2639
|
checkbox({
|
|
3081
|
-
checked
|
|
2640
|
+
checked: e
|
|
3082
2641
|
}) {
|
|
3083
|
-
return
|
|
2642
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
3084
2643
|
}
|
|
3085
2644
|
paragraph({
|
|
3086
|
-
tokens
|
|
2645
|
+
tokens: e
|
|
3087
2646
|
}) {
|
|
3088
|
-
return `<p>${this.parser.parseInline(
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
for (let
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
header += this.tablerow({
|
|
3098
|
-
text: cell
|
|
2647
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
2648
|
+
`;
|
|
2649
|
+
}
|
|
2650
|
+
table(e) {
|
|
2651
|
+
let t = "",
|
|
2652
|
+
n = "";
|
|
2653
|
+
for (let i = 0; i < e.header.length; i++) n += this.tablecell(e.header[i]);
|
|
2654
|
+
t += this.tablerow({
|
|
2655
|
+
text: n
|
|
3099
2656
|
});
|
|
3100
|
-
let
|
|
3101
|
-
for (let
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
for (let
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
body += this.tablerow({
|
|
3108
|
-
text: cell
|
|
2657
|
+
let s = "";
|
|
2658
|
+
for (let i = 0; i < e.rows.length; i++) {
|
|
2659
|
+
let r = e.rows[i];
|
|
2660
|
+
n = "";
|
|
2661
|
+
for (let o = 0; o < r.length; o++) n += this.tablecell(r[o]);
|
|
2662
|
+
s += this.tablerow({
|
|
2663
|
+
text: n
|
|
3109
2664
|
});
|
|
3110
2665
|
}
|
|
3111
|
-
|
|
3112
|
-
|
|
2666
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
2667
|
+
<thead>
|
|
2668
|
+
` + t + `</thead>
|
|
2669
|
+
` + s + `</table>
|
|
2670
|
+
`;
|
|
3113
2671
|
}
|
|
3114
2672
|
tablerow({
|
|
3115
|
-
text
|
|
2673
|
+
text: e
|
|
3116
2674
|
}) {
|
|
3117
|
-
return `<tr
|
|
2675
|
+
return `<tr>
|
|
2676
|
+
${e}</tr>
|
|
2677
|
+
`;
|
|
3118
2678
|
}
|
|
3119
|
-
tablecell(
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
2679
|
+
tablecell(e) {
|
|
2680
|
+
let t = this.parser.parseInline(e.tokens),
|
|
2681
|
+
n = e.header ? "th" : "td";
|
|
2682
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
2683
|
+
`;
|
|
3124
2684
|
}
|
|
3125
|
-
/**
|
|
3126
|
-
* span level renderer
|
|
3127
|
-
*/
|
|
3128
2685
|
strong({
|
|
3129
|
-
tokens
|
|
2686
|
+
tokens: e
|
|
3130
2687
|
}) {
|
|
3131
|
-
return `<strong>${this.parser.parseInline(
|
|
2688
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
3132
2689
|
}
|
|
3133
2690
|
em({
|
|
3134
|
-
tokens
|
|
2691
|
+
tokens: e
|
|
3135
2692
|
}) {
|
|
3136
|
-
return `<em>${this.parser.parseInline(
|
|
2693
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
3137
2694
|
}
|
|
3138
2695
|
codespan({
|
|
3139
|
-
text
|
|
2696
|
+
text: e
|
|
3140
2697
|
}) {
|
|
3141
|
-
return `<code>${
|
|
2698
|
+
return `<code>${R(e, true)}</code>`;
|
|
3142
2699
|
}
|
|
3143
|
-
br(
|
|
3144
|
-
return
|
|
2700
|
+
br(e) {
|
|
2701
|
+
return "<br>";
|
|
3145
2702
|
}
|
|
3146
2703
|
del({
|
|
3147
|
-
tokens
|
|
2704
|
+
tokens: e
|
|
3148
2705
|
}) {
|
|
3149
|
-
return `<del>${this.parser.parseInline(
|
|
2706
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
3150
2707
|
}
|
|
3151
2708
|
link({
|
|
3152
|
-
href,
|
|
3153
|
-
title,
|
|
3154
|
-
tokens
|
|
2709
|
+
href: e,
|
|
2710
|
+
title: t,
|
|
2711
|
+
tokens: n
|
|
3155
2712
|
}) {
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
if (
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
let out = '<a href="' + href + '"';
|
|
3163
|
-
if (title) {
|
|
3164
|
-
out += ' title="' + escape(title) + '"';
|
|
3165
|
-
}
|
|
3166
|
-
out += '>' + text + '</a>';
|
|
3167
|
-
return out;
|
|
2713
|
+
let s = this.parser.parseInline(n),
|
|
2714
|
+
i = J(e);
|
|
2715
|
+
if (i === null) return s;
|
|
2716
|
+
e = i;
|
|
2717
|
+
let r = '<a href="' + e + '"';
|
|
2718
|
+
return t && (r += ' title="' + R(t) + '"'), r += ">" + s + "</a>", r;
|
|
3168
2719
|
}
|
|
3169
2720
|
image({
|
|
3170
|
-
href,
|
|
3171
|
-
title,
|
|
3172
|
-
text
|
|
2721
|
+
href: e,
|
|
2722
|
+
title: t,
|
|
2723
|
+
text: n,
|
|
2724
|
+
tokens: s
|
|
3173
2725
|
}) {
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
if (title) {
|
|
3181
|
-
out += ` title="${escape(title)}"`;
|
|
3182
|
-
}
|
|
3183
|
-
out += '>';
|
|
3184
|
-
return out;
|
|
2726
|
+
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
2727
|
+
let i = J(e);
|
|
2728
|
+
if (i === null) return R(n);
|
|
2729
|
+
e = i;
|
|
2730
|
+
let r = `<img src="${e}" alt="${n}"`;
|
|
2731
|
+
return t && (r += ` title="${R(t)}"`), r += ">", r;
|
|
3185
2732
|
}
|
|
3186
|
-
text(
|
|
3187
|
-
return
|
|
2733
|
+
text(e) {
|
|
2734
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : R(e.text);
|
|
3188
2735
|
}
|
|
3189
|
-
}
|
|
3190
|
-
|
|
3191
|
-
/**
|
|
3192
|
-
* TextRenderer
|
|
3193
|
-
* returns only the textual part of the token
|
|
3194
|
-
*/
|
|
3195
|
-
class _TextRenderer {
|
|
3196
|
-
// no need for block level renderers
|
|
2736
|
+
};
|
|
2737
|
+
var _ = class {
|
|
3197
2738
|
strong({
|
|
3198
|
-
text
|
|
2739
|
+
text: e
|
|
3199
2740
|
}) {
|
|
3200
|
-
return
|
|
2741
|
+
return e;
|
|
3201
2742
|
}
|
|
3202
2743
|
em({
|
|
3203
|
-
text
|
|
2744
|
+
text: e
|
|
3204
2745
|
}) {
|
|
3205
|
-
return
|
|
2746
|
+
return e;
|
|
3206
2747
|
}
|
|
3207
2748
|
codespan({
|
|
3208
|
-
text
|
|
2749
|
+
text: e
|
|
3209
2750
|
}) {
|
|
3210
|
-
return
|
|
2751
|
+
return e;
|
|
3211
2752
|
}
|
|
3212
2753
|
del({
|
|
3213
|
-
text
|
|
2754
|
+
text: e
|
|
3214
2755
|
}) {
|
|
3215
|
-
return
|
|
2756
|
+
return e;
|
|
3216
2757
|
}
|
|
3217
2758
|
html({
|
|
3218
|
-
text
|
|
2759
|
+
text: e
|
|
3219
2760
|
}) {
|
|
3220
|
-
return
|
|
2761
|
+
return e;
|
|
3221
2762
|
}
|
|
3222
2763
|
text({
|
|
3223
|
-
text
|
|
2764
|
+
text: e
|
|
3224
2765
|
}) {
|
|
3225
|
-
return
|
|
2766
|
+
return e;
|
|
3226
2767
|
}
|
|
3227
2768
|
link({
|
|
3228
|
-
text
|
|
2769
|
+
text: e
|
|
3229
2770
|
}) {
|
|
3230
|
-
return
|
|
2771
|
+
return "" + e;
|
|
3231
2772
|
}
|
|
3232
2773
|
image({
|
|
3233
|
-
text
|
|
2774
|
+
text: e
|
|
3234
2775
|
}) {
|
|
3235
|
-
return
|
|
2776
|
+
return "" + e;
|
|
3236
2777
|
}
|
|
3237
2778
|
br() {
|
|
3238
|
-
return
|
|
2779
|
+
return "";
|
|
3239
2780
|
}
|
|
3240
|
-
}
|
|
3241
|
-
|
|
3242
|
-
/**
|
|
3243
|
-
* Parsing & Compiling
|
|
3244
|
-
*/
|
|
3245
|
-
class _Parser {
|
|
2781
|
+
};
|
|
2782
|
+
var T = class a {
|
|
3246
2783
|
options;
|
|
3247
2784
|
renderer;
|
|
3248
2785
|
textRenderer;
|
|
3249
|
-
constructor(
|
|
3250
|
-
this.options = options ||
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
return parser.parseInline(tokens);
|
|
3270
|
-
}
|
|
3271
|
-
/**
|
|
3272
|
-
* Parse Loop
|
|
3273
|
-
*/
|
|
3274
|
-
parse(tokens, top = true) {
|
|
3275
|
-
let out = '';
|
|
3276
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
3277
|
-
const anyToken = tokens[i];
|
|
3278
|
-
// Run any renderer extensions
|
|
3279
|
-
if (this.options.extensions?.renderers?.[anyToken.type]) {
|
|
3280
|
-
const genericToken = anyToken;
|
|
3281
|
-
const ret = this.options.extensions.renderers[genericToken.type].call({
|
|
3282
|
-
parser: this
|
|
3283
|
-
}, genericToken);
|
|
3284
|
-
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(genericToken.type)) {
|
|
3285
|
-
out += ret || '';
|
|
2786
|
+
constructor(e) {
|
|
2787
|
+
this.options = e || w, this.options.renderer = this.options.renderer || new $(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new _();
|
|
2788
|
+
}
|
|
2789
|
+
static parse(e, t) {
|
|
2790
|
+
return new a(t).parse(e);
|
|
2791
|
+
}
|
|
2792
|
+
static parseInline(e, t) {
|
|
2793
|
+
return new a(t).parseInline(e);
|
|
2794
|
+
}
|
|
2795
|
+
parse(e, t = true) {
|
|
2796
|
+
let n = "";
|
|
2797
|
+
for (let s = 0; s < e.length; s++) {
|
|
2798
|
+
let i = e[s];
|
|
2799
|
+
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2800
|
+
let o = i,
|
|
2801
|
+
l = this.options.extensions.renderers[o.type].call({
|
|
2802
|
+
parser: this
|
|
2803
|
+
}, o);
|
|
2804
|
+
if (l !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(o.type)) {
|
|
2805
|
+
n += l || "";
|
|
3286
2806
|
continue;
|
|
3287
2807
|
}
|
|
3288
2808
|
}
|
|
3289
|
-
|
|
3290
|
-
switch (
|
|
3291
|
-
case
|
|
2809
|
+
let r = i;
|
|
2810
|
+
switch (r.type) {
|
|
2811
|
+
case "space":
|
|
3292
2812
|
{
|
|
3293
|
-
|
|
2813
|
+
n += this.renderer.space(r);
|
|
3294
2814
|
continue;
|
|
3295
2815
|
}
|
|
3296
|
-
case
|
|
2816
|
+
case "hr":
|
|
3297
2817
|
{
|
|
3298
|
-
|
|
2818
|
+
n += this.renderer.hr(r);
|
|
3299
2819
|
continue;
|
|
3300
2820
|
}
|
|
3301
|
-
case
|
|
2821
|
+
case "heading":
|
|
3302
2822
|
{
|
|
3303
|
-
|
|
2823
|
+
n += this.renderer.heading(r);
|
|
3304
2824
|
continue;
|
|
3305
2825
|
}
|
|
3306
|
-
case
|
|
2826
|
+
case "code":
|
|
3307
2827
|
{
|
|
3308
|
-
|
|
2828
|
+
n += this.renderer.code(r);
|
|
3309
2829
|
continue;
|
|
3310
2830
|
}
|
|
3311
|
-
case
|
|
2831
|
+
case "table":
|
|
3312
2832
|
{
|
|
3313
|
-
|
|
2833
|
+
n += this.renderer.table(r);
|
|
3314
2834
|
continue;
|
|
3315
2835
|
}
|
|
3316
|
-
case
|
|
2836
|
+
case "blockquote":
|
|
3317
2837
|
{
|
|
3318
|
-
|
|
2838
|
+
n += this.renderer.blockquote(r);
|
|
3319
2839
|
continue;
|
|
3320
2840
|
}
|
|
3321
|
-
case
|
|
2841
|
+
case "list":
|
|
3322
2842
|
{
|
|
3323
|
-
|
|
2843
|
+
n += this.renderer.list(r);
|
|
3324
2844
|
continue;
|
|
3325
2845
|
}
|
|
3326
|
-
case
|
|
2846
|
+
case "html":
|
|
3327
2847
|
{
|
|
3328
|
-
|
|
2848
|
+
n += this.renderer.html(r);
|
|
3329
2849
|
continue;
|
|
3330
2850
|
}
|
|
3331
|
-
case
|
|
2851
|
+
case "paragraph":
|
|
3332
2852
|
{
|
|
3333
|
-
|
|
2853
|
+
n += this.renderer.paragraph(r);
|
|
3334
2854
|
continue;
|
|
3335
2855
|
}
|
|
3336
|
-
case
|
|
2856
|
+
case "text":
|
|
3337
2857
|
{
|
|
3338
|
-
let
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
escaped: true
|
|
3354
|
-
}]
|
|
3355
|
-
});
|
|
3356
|
-
} else {
|
|
3357
|
-
out += body;
|
|
3358
|
-
}
|
|
2858
|
+
let o = r,
|
|
2859
|
+
l = this.renderer.text(o);
|
|
2860
|
+
for (; s + 1 < e.length && e[s + 1].type === "text";) o = e[++s], l += `
|
|
2861
|
+
` + this.renderer.text(o);
|
|
2862
|
+
t ? n += this.renderer.paragraph({
|
|
2863
|
+
type: "paragraph",
|
|
2864
|
+
raw: l,
|
|
2865
|
+
text: l,
|
|
2866
|
+
tokens: [{
|
|
2867
|
+
type: "text",
|
|
2868
|
+
raw: l,
|
|
2869
|
+
text: l,
|
|
2870
|
+
escaped: true
|
|
2871
|
+
}]
|
|
2872
|
+
}) : n += l;
|
|
3359
2873
|
continue;
|
|
3360
2874
|
}
|
|
3361
2875
|
default:
|
|
3362
2876
|
{
|
|
3363
|
-
|
|
3364
|
-
if (this.options.silent)
|
|
3365
|
-
|
|
3366
|
-
return '';
|
|
3367
|
-
} else {
|
|
3368
|
-
throw new Error(errMsg);
|
|
3369
|
-
}
|
|
2877
|
+
let o = 'Token with "' + r.type + '" type was not found.';
|
|
2878
|
+
if (this.options.silent) return console.error(o), "";
|
|
2879
|
+
throw new Error(o);
|
|
3370
2880
|
}
|
|
3371
2881
|
}
|
|
3372
2882
|
}
|
|
3373
|
-
return
|
|
3374
|
-
}
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
const anyToken = tokens[i];
|
|
3382
|
-
// Run any renderer extensions
|
|
3383
|
-
if (this.options.extensions?.renderers?.[anyToken.type]) {
|
|
3384
|
-
const ret = this.options.extensions.renderers[anyToken.type].call({
|
|
2883
|
+
return n;
|
|
2884
|
+
}
|
|
2885
|
+
parseInline(e, t = this.renderer) {
|
|
2886
|
+
let n = "";
|
|
2887
|
+
for (let s = 0; s < e.length; s++) {
|
|
2888
|
+
let i = e[s];
|
|
2889
|
+
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2890
|
+
let o = this.options.extensions.renderers[i.type].call({
|
|
3385
2891
|
parser: this
|
|
3386
|
-
},
|
|
3387
|
-
if (
|
|
3388
|
-
|
|
2892
|
+
}, i);
|
|
2893
|
+
if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
2894
|
+
n += o || "";
|
|
3389
2895
|
continue;
|
|
3390
2896
|
}
|
|
3391
2897
|
}
|
|
3392
|
-
|
|
3393
|
-
switch (
|
|
3394
|
-
case
|
|
2898
|
+
let r = i;
|
|
2899
|
+
switch (r.type) {
|
|
2900
|
+
case "escape":
|
|
3395
2901
|
{
|
|
3396
|
-
|
|
2902
|
+
n += t.text(r);
|
|
3397
2903
|
break;
|
|
3398
2904
|
}
|
|
3399
|
-
case
|
|
2905
|
+
case "html":
|
|
3400
2906
|
{
|
|
3401
|
-
|
|
2907
|
+
n += t.html(r);
|
|
3402
2908
|
break;
|
|
3403
2909
|
}
|
|
3404
|
-
case
|
|
2910
|
+
case "link":
|
|
3405
2911
|
{
|
|
3406
|
-
|
|
2912
|
+
n += t.link(r);
|
|
3407
2913
|
break;
|
|
3408
2914
|
}
|
|
3409
|
-
case
|
|
2915
|
+
case "image":
|
|
3410
2916
|
{
|
|
3411
|
-
|
|
2917
|
+
n += t.image(r);
|
|
3412
2918
|
break;
|
|
3413
2919
|
}
|
|
3414
|
-
case
|
|
2920
|
+
case "strong":
|
|
3415
2921
|
{
|
|
3416
|
-
|
|
2922
|
+
n += t.strong(r);
|
|
3417
2923
|
break;
|
|
3418
2924
|
}
|
|
3419
|
-
case
|
|
2925
|
+
case "em":
|
|
3420
2926
|
{
|
|
3421
|
-
|
|
2927
|
+
n += t.em(r);
|
|
3422
2928
|
break;
|
|
3423
2929
|
}
|
|
3424
|
-
case
|
|
2930
|
+
case "codespan":
|
|
3425
2931
|
{
|
|
3426
|
-
|
|
2932
|
+
n += t.codespan(r);
|
|
3427
2933
|
break;
|
|
3428
2934
|
}
|
|
3429
|
-
case
|
|
2935
|
+
case "br":
|
|
3430
2936
|
{
|
|
3431
|
-
|
|
2937
|
+
n += t.br(r);
|
|
3432
2938
|
break;
|
|
3433
2939
|
}
|
|
3434
|
-
case
|
|
2940
|
+
case "del":
|
|
3435
2941
|
{
|
|
3436
|
-
|
|
2942
|
+
n += t.del(r);
|
|
3437
2943
|
break;
|
|
3438
2944
|
}
|
|
3439
|
-
case
|
|
2945
|
+
case "text":
|
|
3440
2946
|
{
|
|
3441
|
-
|
|
2947
|
+
n += t.text(r);
|
|
3442
2948
|
break;
|
|
3443
2949
|
}
|
|
3444
2950
|
default:
|
|
3445
2951
|
{
|
|
3446
|
-
|
|
3447
|
-
if (this.options.silent)
|
|
3448
|
-
|
|
3449
|
-
return '';
|
|
3450
|
-
} else {
|
|
3451
|
-
throw new Error(errMsg);
|
|
3452
|
-
}
|
|
2952
|
+
let o = 'Token with "' + r.type + '" type was not found.';
|
|
2953
|
+
if (this.options.silent) return console.error(o), "";
|
|
2954
|
+
throw new Error(o);
|
|
3453
2955
|
}
|
|
3454
2956
|
}
|
|
3455
2957
|
}
|
|
3456
|
-
return
|
|
2958
|
+
return n;
|
|
3457
2959
|
}
|
|
3458
|
-
}
|
|
3459
|
-
class
|
|
2960
|
+
};
|
|
2961
|
+
var L = class {
|
|
3460
2962
|
options;
|
|
3461
2963
|
block;
|
|
3462
|
-
constructor(
|
|
3463
|
-
this.options =
|
|
3464
|
-
}
|
|
3465
|
-
static passThroughHooks = new Set([
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
return
|
|
3471
|
-
}
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
postprocess(html) {
|
|
3476
|
-
return html;
|
|
3477
|
-
}
|
|
3478
|
-
/**
|
|
3479
|
-
* Process all tokens before walk tokens
|
|
3480
|
-
*/
|
|
3481
|
-
processAllTokens(tokens) {
|
|
3482
|
-
return tokens;
|
|
3483
|
-
}
|
|
3484
|
-
/**
|
|
3485
|
-
* Provide function to tokenize markdown
|
|
3486
|
-
*/
|
|
2964
|
+
constructor(e) {
|
|
2965
|
+
this.options = e || w;
|
|
2966
|
+
}
|
|
2967
|
+
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2968
|
+
preprocess(e) {
|
|
2969
|
+
return e;
|
|
2970
|
+
}
|
|
2971
|
+
postprocess(e) {
|
|
2972
|
+
return e;
|
|
2973
|
+
}
|
|
2974
|
+
processAllTokens(e) {
|
|
2975
|
+
return e;
|
|
2976
|
+
}
|
|
3487
2977
|
provideLexer() {
|
|
3488
|
-
return this.block ?
|
|
2978
|
+
return this.block ? b.lex : b.lexInline;
|
|
3489
2979
|
}
|
|
3490
|
-
/**
|
|
3491
|
-
* Provide function to parse tokens
|
|
3492
|
-
*/
|
|
3493
2980
|
provideParser() {
|
|
3494
|
-
return this.block ?
|
|
2981
|
+
return this.block ? T.parse : T.parseInline;
|
|
3495
2982
|
}
|
|
3496
|
-
}
|
|
3497
|
-
class
|
|
3498
|
-
defaults =
|
|
2983
|
+
};
|
|
2984
|
+
var B = class {
|
|
2985
|
+
defaults = M();
|
|
3499
2986
|
options = this.setOptions;
|
|
3500
2987
|
parse = this.parseMarkdown(true);
|
|
3501
2988
|
parseInline = this.parseMarkdown(false);
|
|
3502
|
-
Parser =
|
|
3503
|
-
Renderer =
|
|
3504
|
-
TextRenderer =
|
|
3505
|
-
Lexer =
|
|
3506
|
-
Tokenizer =
|
|
3507
|
-
Hooks =
|
|
3508
|
-
constructor(...
|
|
3509
|
-
this.use(...
|
|
3510
|
-
}
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
values = values.concat(this.walkTokens(listToken.items, callback));
|
|
3536
|
-
break;
|
|
3537
|
-
}
|
|
3538
|
-
default:
|
|
3539
|
-
{
|
|
3540
|
-
const genericToken = token;
|
|
3541
|
-
if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
|
|
3542
|
-
this.defaults.extensions.childTokens[genericToken.type].forEach(childTokens => {
|
|
3543
|
-
const tokens = genericToken[childTokens].flat(Infinity);
|
|
3544
|
-
values = values.concat(this.walkTokens(tokens, callback));
|
|
3545
|
-
});
|
|
3546
|
-
} else if (genericToken.tokens) {
|
|
3547
|
-
values = values.concat(this.walkTokens(genericToken.tokens, callback));
|
|
3548
|
-
}
|
|
3549
|
-
}
|
|
3550
|
-
}
|
|
2989
|
+
Parser = T;
|
|
2990
|
+
Renderer = $;
|
|
2991
|
+
TextRenderer = _;
|
|
2992
|
+
Lexer = b;
|
|
2993
|
+
Tokenizer = S;
|
|
2994
|
+
Hooks = L;
|
|
2995
|
+
constructor(...e) {
|
|
2996
|
+
this.use(...e);
|
|
2997
|
+
}
|
|
2998
|
+
walkTokens(e, t) {
|
|
2999
|
+
let n = [];
|
|
3000
|
+
for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
|
|
3001
|
+
case "table":
|
|
3002
|
+
{
|
|
3003
|
+
let i = s;
|
|
3004
|
+
for (let r of i.header) n = n.concat(this.walkTokens(r.tokens, t));
|
|
3005
|
+
for (let r of i.rows) for (let o of r) n = n.concat(this.walkTokens(o.tokens, t));
|
|
3006
|
+
break;
|
|
3007
|
+
}
|
|
3008
|
+
case "list":
|
|
3009
|
+
{
|
|
3010
|
+
let i = s;
|
|
3011
|
+
n = n.concat(this.walkTokens(i.items, t));
|
|
3012
|
+
break;
|
|
3013
|
+
}
|
|
3014
|
+
default:
|
|
3015
|
+
{
|
|
3016
|
+
let i = s;
|
|
3017
|
+
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach(r => {
|
|
3018
|
+
let o = i[r].flat(1 / 0);
|
|
3019
|
+
n = n.concat(this.walkTokens(o, t));
|
|
3020
|
+
}) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
|
|
3021
|
+
}
|
|
3551
3022
|
}
|
|
3552
|
-
return
|
|
3023
|
+
return n;
|
|
3553
3024
|
}
|
|
3554
|
-
use(...
|
|
3555
|
-
|
|
3025
|
+
use(...e) {
|
|
3026
|
+
let t = this.defaults.extensions || {
|
|
3556
3027
|
renderers: {},
|
|
3557
3028
|
childTokens: {}
|
|
3558
3029
|
};
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
...pack
|
|
3030
|
+
return e.forEach(n => {
|
|
3031
|
+
let s = {
|
|
3032
|
+
...n
|
|
3563
3033
|
};
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
}
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
|
|
3591
|
-
throw new Error("extension level must be 'block' or 'inline'");
|
|
3592
|
-
}
|
|
3593
|
-
const extLevel = extensions[ext.level];
|
|
3594
|
-
if (extLevel) {
|
|
3595
|
-
extLevel.unshift(ext.tokenizer);
|
|
3596
|
-
} else {
|
|
3597
|
-
extensions[ext.level] = [ext.tokenizer];
|
|
3598
|
-
}
|
|
3599
|
-
if (ext.start) {
|
|
3600
|
-
// Function to check for start of token
|
|
3601
|
-
if (ext.level === 'block') {
|
|
3602
|
-
if (extensions.startBlock) {
|
|
3603
|
-
extensions.startBlock.push(ext.start);
|
|
3604
|
-
} else {
|
|
3605
|
-
extensions.startBlock = [ext.start];
|
|
3606
|
-
}
|
|
3607
|
-
} else if (ext.level === 'inline') {
|
|
3608
|
-
if (extensions.startInline) {
|
|
3609
|
-
extensions.startInline.push(ext.start);
|
|
3610
|
-
} else {
|
|
3611
|
-
extensions.startInline = [ext.start];
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
}
|
|
3615
|
-
}
|
|
3616
|
-
if ('childTokens' in ext && ext.childTokens) {
|
|
3617
|
-
// Child tokens to be visited by walkTokens
|
|
3618
|
-
extensions.childTokens[ext.name] = ext.childTokens;
|
|
3619
|
-
}
|
|
3620
|
-
});
|
|
3621
|
-
opts.extensions = extensions;
|
|
3622
|
-
}
|
|
3623
|
-
// ==-- Parse "overwrite" extensions --== //
|
|
3624
|
-
if (pack.renderer) {
|
|
3625
|
-
const renderer = this.defaults.renderer || new _Renderer(this.defaults);
|
|
3626
|
-
for (const prop in pack.renderer) {
|
|
3627
|
-
if (!(prop in renderer)) {
|
|
3628
|
-
throw new Error(`renderer '${prop}' does not exist`);
|
|
3629
|
-
}
|
|
3630
|
-
if (['options', 'parser'].includes(prop)) {
|
|
3631
|
-
// ignore options property
|
|
3632
|
-
continue;
|
|
3633
|
-
}
|
|
3634
|
-
const rendererProp = prop;
|
|
3635
|
-
const rendererFunc = pack.renderer[rendererProp];
|
|
3636
|
-
const prevRenderer = renderer[rendererProp];
|
|
3637
|
-
// Replace renderer with func to run extension, but fall back if false
|
|
3638
|
-
renderer[rendererProp] = (...args) => {
|
|
3639
|
-
let ret = rendererFunc.apply(renderer, args);
|
|
3640
|
-
if (ret === false) {
|
|
3641
|
-
ret = prevRenderer.apply(renderer, args);
|
|
3642
|
-
}
|
|
3643
|
-
return ret || '';
|
|
3034
|
+
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach(i => {
|
|
3035
|
+
if (!i.name) throw new Error("extension name required");
|
|
3036
|
+
if ("renderer" in i) {
|
|
3037
|
+
let r = t.renderers[i.name];
|
|
3038
|
+
r ? t.renderers[i.name] = function (...o) {
|
|
3039
|
+
let l = i.renderer.apply(this, o);
|
|
3040
|
+
return l === false && (l = r.apply(this, o)), l;
|
|
3041
|
+
} : t.renderers[i.name] = i.renderer;
|
|
3042
|
+
}
|
|
3043
|
+
if ("tokenizer" in i) {
|
|
3044
|
+
if (!i.level || i.level !== "block" && i.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
3045
|
+
let r = t[i.level];
|
|
3046
|
+
r ? r.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
|
+
}
|
|
3048
|
+
"childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
|
|
3049
|
+
}), s.extensions = t), n.renderer) {
|
|
3050
|
+
let i = this.defaults.renderer || new $(this.defaults);
|
|
3051
|
+
for (let r in n.renderer) {
|
|
3052
|
+
if (!(r in i)) throw new Error(`renderer '${r}' does not exist`);
|
|
3053
|
+
if (["options", "parser"].includes(r)) continue;
|
|
3054
|
+
let o = r,
|
|
3055
|
+
l = n.renderer[o],
|
|
3056
|
+
c = i[o];
|
|
3057
|
+
i[o] = (...p) => {
|
|
3058
|
+
let u = l.apply(i, p);
|
|
3059
|
+
return u === false && (u = c.apply(i, p)), u || "";
|
|
3644
3060
|
};
|
|
3645
3061
|
}
|
|
3646
|
-
|
|
3647
|
-
}
|
|
3648
|
-
if (
|
|
3649
|
-
|
|
3650
|
-
for (
|
|
3651
|
-
if (!(
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
const tokenizerFunc = pack.tokenizer[tokenizerProp];
|
|
3660
|
-
const prevTokenizer = tokenizer[tokenizerProp];
|
|
3661
|
-
// Replace tokenizer with func to run extension, but fall back if false
|
|
3662
|
-
// @ts-expect-error cannot type tokenizer function dynamically
|
|
3663
|
-
tokenizer[tokenizerProp] = (...args) => {
|
|
3664
|
-
let ret = tokenizerFunc.apply(tokenizer, args);
|
|
3665
|
-
if (ret === false) {
|
|
3666
|
-
ret = prevTokenizer.apply(tokenizer, args);
|
|
3667
|
-
}
|
|
3668
|
-
return ret;
|
|
3062
|
+
s.renderer = i;
|
|
3063
|
+
}
|
|
3064
|
+
if (n.tokenizer) {
|
|
3065
|
+
let i = this.defaults.tokenizer || new S(this.defaults);
|
|
3066
|
+
for (let r in n.tokenizer) {
|
|
3067
|
+
if (!(r in i)) throw new Error(`tokenizer '${r}' does not exist`);
|
|
3068
|
+
if (["options", "rules", "lexer"].includes(r)) continue;
|
|
3069
|
+
let o = r,
|
|
3070
|
+
l = n.tokenizer[o],
|
|
3071
|
+
c = i[o];
|
|
3072
|
+
i[o] = (...p) => {
|
|
3073
|
+
let u = l.apply(i, p);
|
|
3074
|
+
return u === false && (u = c.apply(i, p)), u;
|
|
3669
3075
|
};
|
|
3670
3076
|
}
|
|
3671
|
-
|
|
3672
|
-
}
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
if (
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
hooks[hooksProp] = arg => {
|
|
3690
|
-
if (this.defaults.async) {
|
|
3691
|
-
return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
|
|
3692
|
-
return prevHook.call(hooks, ret);
|
|
3693
|
-
});
|
|
3694
|
-
}
|
|
3695
|
-
const ret = hooksFunc.call(hooks, arg);
|
|
3696
|
-
return prevHook.call(hooks, ret);
|
|
3697
|
-
};
|
|
3698
|
-
} else {
|
|
3699
|
-
// @ts-expect-error cannot type hook function dynamically
|
|
3700
|
-
hooks[hooksProp] = (...args) => {
|
|
3701
|
-
let ret = hooksFunc.apply(hooks, args);
|
|
3702
|
-
if (ret === false) {
|
|
3703
|
-
ret = prevHook.apply(hooks, args);
|
|
3704
|
-
}
|
|
3705
|
-
return ret;
|
|
3706
|
-
};
|
|
3707
|
-
}
|
|
3077
|
+
s.tokenizer = i;
|
|
3078
|
+
}
|
|
3079
|
+
if (n.hooks) {
|
|
3080
|
+
let i = this.defaults.hooks || new L();
|
|
3081
|
+
for (let r in n.hooks) {
|
|
3082
|
+
if (!(r in i)) throw new Error(`hook '${r}' does not exist`);
|
|
3083
|
+
if (["options", "block"].includes(r)) continue;
|
|
3084
|
+
let o = r,
|
|
3085
|
+
l = n.hooks[o],
|
|
3086
|
+
c = i[o];
|
|
3087
|
+
L.passThroughHooks.has(r) ? i[o] = p => {
|
|
3088
|
+
if (this.defaults.async) return Promise.resolve(l.call(i, p)).then(d => c.call(i, d));
|
|
3089
|
+
let u = l.call(i, p);
|
|
3090
|
+
return c.call(i, u);
|
|
3091
|
+
} : i[o] = (...p) => {
|
|
3092
|
+
let u = l.apply(i, p);
|
|
3093
|
+
return u === false && (u = c.apply(i, p)), u;
|
|
3094
|
+
};
|
|
3708
3095
|
}
|
|
3709
|
-
|
|
3096
|
+
s.hooks = i;
|
|
3710
3097
|
}
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
values.push(packWalktokens.call(this, token));
|
|
3718
|
-
if (walkTokens) {
|
|
3719
|
-
values = values.concat(walkTokens.call(this, token));
|
|
3720
|
-
}
|
|
3721
|
-
return values;
|
|
3098
|
+
if (n.walkTokens) {
|
|
3099
|
+
let i = this.defaults.walkTokens,
|
|
3100
|
+
r = n.walkTokens;
|
|
3101
|
+
s.walkTokens = function (o) {
|
|
3102
|
+
let l = [];
|
|
3103
|
+
return l.push(r.call(this, o)), i && (l = l.concat(i.call(this, o))), l;
|
|
3722
3104
|
};
|
|
3723
3105
|
}
|
|
3724
3106
|
this.defaults = {
|
|
3725
3107
|
...this.defaults,
|
|
3726
|
-
...
|
|
3108
|
+
...s
|
|
3727
3109
|
};
|
|
3728
|
-
});
|
|
3729
|
-
return this;
|
|
3110
|
+
}), this;
|
|
3730
3111
|
}
|
|
3731
|
-
setOptions(
|
|
3732
|
-
this.defaults = {
|
|
3112
|
+
setOptions(e) {
|
|
3113
|
+
return this.defaults = {
|
|
3733
3114
|
...this.defaults,
|
|
3734
|
-
...
|
|
3735
|
-
};
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
if (typeof src === 'undefined' || src === null) {
|
|
3761
|
-
return throwError(new Error('marked(): input parameter is undefined or null'));
|
|
3762
|
-
}
|
|
3763
|
-
if (typeof src !== 'string') {
|
|
3764
|
-
return throwError(new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'));
|
|
3765
|
-
}
|
|
3766
|
-
if (opt.hooks) {
|
|
3767
|
-
opt.hooks.options = opt;
|
|
3768
|
-
opt.hooks.block = blockType;
|
|
3769
|
-
}
|
|
3770
|
-
const lexer = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
3771
|
-
const parser = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
3772
|
-
if (opt.async) {
|
|
3773
|
-
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(src => lexer(src, opt)).then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then(tokens => parser(tokens, opt)).then(html => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
|
|
3774
|
-
}
|
|
3115
|
+
...e
|
|
3116
|
+
}, this;
|
|
3117
|
+
}
|
|
3118
|
+
lexer(e, t) {
|
|
3119
|
+
return b.lex(e, t ?? this.defaults);
|
|
3120
|
+
}
|
|
3121
|
+
parser(e, t) {
|
|
3122
|
+
return T.parse(e, t ?? this.defaults);
|
|
3123
|
+
}
|
|
3124
|
+
parseMarkdown(e) {
|
|
3125
|
+
return (n, s) => {
|
|
3126
|
+
let i = {
|
|
3127
|
+
...s
|
|
3128
|
+
},
|
|
3129
|
+
r = {
|
|
3130
|
+
...this.defaults,
|
|
3131
|
+
...i
|
|
3132
|
+
},
|
|
3133
|
+
o = this.onError(!!r.silent, !!r.async);
|
|
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."));
|
|
3135
|
+
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
3136
|
+
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
3137
|
+
r.hooks && (r.hooks.options = r, r.hooks.block = e);
|
|
3138
|
+
let l = r.hooks ? r.hooks.provideLexer() : e ? b.lex : b.lexInline,
|
|
3139
|
+
c = r.hooks ? r.hooks.provideParser() : e ? T.parse : T.parseInline;
|
|
3140
|
+
if (r.async) return Promise.resolve(r.hooks ? r.hooks.preprocess(n) : n).then(p => l(p, r)).then(p => r.hooks ? r.hooks.processAllTokens(p) : p).then(p => r.walkTokens ? Promise.all(this.walkTokens(p, r.walkTokens)).then(() => p) : p).then(p => c(p, r)).then(p => r.hooks ? r.hooks.postprocess(p) : p).catch(o);
|
|
3775
3141
|
try {
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
let
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
if (opt.walkTokens) {
|
|
3784
|
-
this.walkTokens(tokens, opt.walkTokens);
|
|
3785
|
-
}
|
|
3786
|
-
let html = parser(tokens, opt);
|
|
3787
|
-
if (opt.hooks) {
|
|
3788
|
-
html = opt.hooks.postprocess(html);
|
|
3789
|
-
}
|
|
3790
|
-
return html;
|
|
3791
|
-
} catch (e) {
|
|
3792
|
-
return throwError(e);
|
|
3142
|
+
r.hooks && (n = r.hooks.preprocess(n));
|
|
3143
|
+
let p = l(n, r);
|
|
3144
|
+
r.hooks && (p = r.hooks.processAllTokens(p)), r.walkTokens && this.walkTokens(p, r.walkTokens);
|
|
3145
|
+
let u = c(p, r);
|
|
3146
|
+
return r.hooks && (u = r.hooks.postprocess(u)), u;
|
|
3147
|
+
} catch (p) {
|
|
3148
|
+
return o(p);
|
|
3793
3149
|
}
|
|
3794
3150
|
};
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
if (async) {
|
|
3803
|
-
return Promise.resolve(msg);
|
|
3804
|
-
}
|
|
3805
|
-
return msg;
|
|
3806
|
-
}
|
|
3807
|
-
if (async) {
|
|
3808
|
-
return Promise.reject(e);
|
|
3151
|
+
}
|
|
3152
|
+
onError(e, t) {
|
|
3153
|
+
return n => {
|
|
3154
|
+
if (n.message += `
|
|
3155
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
3156
|
+
let s = "<p>An error occurred:</p><pre>" + R(n.message + "", true) + "</pre>";
|
|
3157
|
+
return t ? Promise.resolve(s) : s;
|
|
3809
3158
|
}
|
|
3810
|
-
|
|
3159
|
+
if (t) return Promise.reject(n);
|
|
3160
|
+
throw n;
|
|
3811
3161
|
};
|
|
3812
3162
|
}
|
|
3813
|
-
}
|
|
3814
|
-
const markedInstance = new Marked();
|
|
3815
|
-
function marked(src, opt) {
|
|
3816
|
-
return markedInstance.parse(src, opt);
|
|
3817
|
-
}
|
|
3818
|
-
/**
|
|
3819
|
-
* Sets the default options.
|
|
3820
|
-
*
|
|
3821
|
-
* @param options Hash of options
|
|
3822
|
-
*/
|
|
3823
|
-
marked.options = marked.setOptions = function (options) {
|
|
3824
|
-
markedInstance.setOptions(options);
|
|
3825
|
-
marked.defaults = markedInstance.defaults;
|
|
3826
|
-
changeDefaults(marked.defaults);
|
|
3827
|
-
return marked;
|
|
3828
|
-
};
|
|
3829
|
-
/**
|
|
3830
|
-
* Gets the original marked default options.
|
|
3831
|
-
*/
|
|
3832
|
-
marked.getDefaults = _getDefaults;
|
|
3833
|
-
marked.defaults = _defaults;
|
|
3834
|
-
/**
|
|
3835
|
-
* Use Extension
|
|
3836
|
-
*/
|
|
3837
|
-
marked.use = function (...args) {
|
|
3838
|
-
markedInstance.use(...args);
|
|
3839
|
-
marked.defaults = markedInstance.defaults;
|
|
3840
|
-
changeDefaults(marked.defaults);
|
|
3841
|
-
return marked;
|
|
3842
|
-
};
|
|
3843
|
-
/**
|
|
3844
|
-
* Run callback for every token
|
|
3845
|
-
*/
|
|
3846
|
-
marked.walkTokens = function (tokens, callback) {
|
|
3847
|
-
return markedInstance.walkTokens(tokens, callback);
|
|
3848
3163
|
};
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3164
|
+
var z = new B();
|
|
3165
|
+
function k(a, e) {
|
|
3166
|
+
return z.parse(a, e);
|
|
3167
|
+
}
|
|
3168
|
+
k.options = k.setOptions = function (a) {
|
|
3169
|
+
return z.setOptions(a), k.defaults = z.defaults, H(k.defaults), k;
|
|
3170
|
+
};
|
|
3171
|
+
k.getDefaults = M;
|
|
3172
|
+
k.defaults = w;
|
|
3173
|
+
k.use = function (...a) {
|
|
3174
|
+
return z.use(...a), k.defaults = z.defaults, H(k.defaults), k;
|
|
3175
|
+
};
|
|
3176
|
+
k.walkTokens = function (a, e) {
|
|
3177
|
+
return z.walkTokens(a, e);
|
|
3178
|
+
};
|
|
3179
|
+
k.parseInline = z.parseInline;
|
|
3180
|
+
k.Parser = T;
|
|
3181
|
+
k.parser = T.parse;
|
|
3182
|
+
k.Renderer = $;
|
|
3183
|
+
k.TextRenderer = _;
|
|
3184
|
+
k.Lexer = b;
|
|
3185
|
+
k.lexer = b.lex;
|
|
3186
|
+
k.Tokenizer = S;
|
|
3187
|
+
k.Hooks = L;
|
|
3188
|
+
k.parse = k;
|
|
3869
3189
|
|
|
3870
3190
|
const renderMarkdown = async (markdown, options = {}) => {
|
|
3871
|
-
const html = await
|
|
3191
|
+
const html = await k(markdown, {});
|
|
3872
3192
|
return html;
|
|
3873
3193
|
};
|
|
3874
3194
|
|
|
3875
|
-
const terminate = () => {
|
|
3876
|
-
globalThis.close();
|
|
3877
|
-
};
|
|
3878
|
-
|
|
3879
3195
|
const commandMap = {
|
|
3880
3196
|
'Markdown.getVirtualDom': getMarkdownVirtualDom,
|
|
3197
|
+
'Markdown.handleMessagePort': handleMessagePort,
|
|
3881
3198
|
'Markdown.render': renderMarkdown,
|
|
3882
3199
|
'Markdown.terminate': terminate,
|
|
3883
3200
|
// deprecated
|
|
@@ -3885,18 +3202,55 @@ const commandMap = {
|
|
|
3885
3202
|
'Markdown.getMarkDownVirtualDom': getMarkdownVirtualDom
|
|
3886
3203
|
};
|
|
3887
3204
|
|
|
3888
|
-
const RendererWorker = 1;
|
|
3889
|
-
|
|
3890
3205
|
const rpcs = Object.create(null);
|
|
3891
|
-
const set = (id, rpc) => {
|
|
3206
|
+
const set$g = (id, rpc) => {
|
|
3892
3207
|
rpcs[id] = rpc;
|
|
3893
3208
|
};
|
|
3209
|
+
const get = id => {
|
|
3210
|
+
return rpcs[id];
|
|
3211
|
+
};
|
|
3212
|
+
|
|
3213
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
3214
|
+
|
|
3215
|
+
const create = rpcId => {
|
|
3216
|
+
return {
|
|
3217
|
+
// @ts-ignore
|
|
3218
|
+
invoke(method, ...params) {
|
|
3219
|
+
const rpc = get(rpcId);
|
|
3220
|
+
// @ts-ignore
|
|
3221
|
+
return rpc.invoke(method, ...params);
|
|
3222
|
+
},
|
|
3223
|
+
// @ts-ignore
|
|
3224
|
+
invokeAndTransfer(method, ...params) {
|
|
3225
|
+
const rpc = get(rpcId);
|
|
3226
|
+
// @ts-ignore
|
|
3227
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
3228
|
+
},
|
|
3229
|
+
set(rpc) {
|
|
3230
|
+
set$g(rpcId, rpc);
|
|
3231
|
+
},
|
|
3232
|
+
async dispose() {
|
|
3233
|
+
const rpc = get(rpcId);
|
|
3234
|
+
await rpc.dispose();
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
};
|
|
3238
|
+
const RendererWorker$1 = 1;
|
|
3239
|
+
const {
|
|
3240
|
+
set: set$3} = create(RendererWorker$1);
|
|
3241
|
+
const RendererWorker = {
|
|
3242
|
+
__proto__: null,
|
|
3243
|
+
set: set$3};
|
|
3244
|
+
|
|
3245
|
+
const {
|
|
3246
|
+
set
|
|
3247
|
+
} = RendererWorker;
|
|
3894
3248
|
|
|
3895
3249
|
const listen = async () => {
|
|
3896
3250
|
const rpc = await WebWorkerRpcClient.create({
|
|
3897
3251
|
commandMap: commandMap
|
|
3898
3252
|
});
|
|
3899
|
-
set(
|
|
3253
|
+
set(rpc);
|
|
3900
3254
|
};
|
|
3901
3255
|
|
|
3902
3256
|
const main = async () => {
|