@lvce-editor/markdown-worker 3.0.0 → 4.0.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 +649 -529
- package/package.json +1 -1
|
@@ -90,6 +90,12 @@ const getType = value => {
|
|
|
90
90
|
return Unknown;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
const number = value => {
|
|
94
|
+
const type = getType(value);
|
|
95
|
+
if (type !== Number) {
|
|
96
|
+
throw new AssertionError('expected value to be of type number');
|
|
97
|
+
}
|
|
98
|
+
};
|
|
93
99
|
const array = value => {
|
|
94
100
|
const type = getType(value);
|
|
95
101
|
if (type !== Array$1) {
|
|
@@ -231,8 +237,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
231
237
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
232
238
|
const message = lines[messageIndex];
|
|
233
239
|
return {
|
|
234
|
-
|
|
235
|
-
|
|
240
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
241
|
+
message
|
|
236
242
|
};
|
|
237
243
|
};
|
|
238
244
|
const isModuleNotFoundError = stderr => {
|
|
@@ -255,14 +261,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
255
261
|
const getNativeModuleErrorMessage = stderr => {
|
|
256
262
|
const message = getMessageCodeBlock(stderr);
|
|
257
263
|
return {
|
|
258
|
-
|
|
259
|
-
|
|
264
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
265
|
+
message: `Incompatible native node module: ${message}`
|
|
260
266
|
};
|
|
261
267
|
};
|
|
262
268
|
const getModuleSyntaxError = () => {
|
|
263
269
|
return {
|
|
264
|
-
|
|
265
|
-
|
|
270
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
271
|
+
message: `ES Modules are not supported in electron`
|
|
266
272
|
};
|
|
267
273
|
};
|
|
268
274
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -281,8 +287,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
281
287
|
rest
|
|
282
288
|
} = getDetails(lines);
|
|
283
289
|
return {
|
|
284
|
-
message: actualMessage,
|
|
285
290
|
code: '',
|
|
291
|
+
message: actualMessage,
|
|
286
292
|
stack: rest
|
|
287
293
|
};
|
|
288
294
|
};
|
|
@@ -292,8 +298,8 @@ class IpcError extends VError {
|
|
|
292
298
|
if (stdout || stderr) {
|
|
293
299
|
// @ts-ignore
|
|
294
300
|
const {
|
|
295
|
-
message,
|
|
296
301
|
code,
|
|
302
|
+
message,
|
|
297
303
|
stack
|
|
298
304
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
299
305
|
const cause = new Error(message);
|
|
@@ -354,8 +360,8 @@ const wrap$f = global => {
|
|
|
354
360
|
};
|
|
355
361
|
const waitForFirstMessage = async port => {
|
|
356
362
|
const {
|
|
357
|
-
|
|
358
|
-
|
|
363
|
+
promise,
|
|
364
|
+
resolve
|
|
359
365
|
} = Promise.withResolvers();
|
|
360
366
|
port.addEventListener('message', resolve, {
|
|
361
367
|
once: true
|
|
@@ -375,8 +381,8 @@ const listen$6 = async () => {
|
|
|
375
381
|
const type = firstMessage.params[0];
|
|
376
382
|
if (type === 'message-port') {
|
|
377
383
|
parentIpc.send({
|
|
378
|
-
jsonrpc: '2.0',
|
|
379
384
|
id: firstMessage.id,
|
|
385
|
+
jsonrpc: '2.0',
|
|
380
386
|
result: null
|
|
381
387
|
});
|
|
382
388
|
parentIpc.dispose();
|
|
@@ -433,8 +439,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
433
439
|
};
|
|
434
440
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
435
441
|
const {
|
|
436
|
-
|
|
437
|
-
|
|
442
|
+
promise,
|
|
443
|
+
resolve
|
|
438
444
|
} = Promise.withResolvers();
|
|
439
445
|
const listenerMap = Object.create(null);
|
|
440
446
|
const cleanup = value => {
|
|
@@ -446,8 +452,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
446
452
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
447
453
|
const listener = event => {
|
|
448
454
|
cleanup({
|
|
449
|
-
|
|
450
|
-
|
|
455
|
+
event,
|
|
456
|
+
type
|
|
451
457
|
});
|
|
452
458
|
};
|
|
453
459
|
addListener(eventEmitter, event, listener);
|
|
@@ -456,9 +462,9 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
456
462
|
return promise;
|
|
457
463
|
};
|
|
458
464
|
const Message$1 = 3;
|
|
459
|
-
const create$5
|
|
460
|
-
|
|
461
|
-
|
|
465
|
+
const create$5 = async ({
|
|
466
|
+
isMessagePortOpen,
|
|
467
|
+
messagePort
|
|
462
468
|
}) => {
|
|
463
469
|
if (!isMessagePort(messagePort)) {
|
|
464
470
|
throw new IpcError('port must be of type MessagePort');
|
|
@@ -471,8 +477,8 @@ const create$5$1 = async ({
|
|
|
471
477
|
});
|
|
472
478
|
messagePort.start();
|
|
473
479
|
const {
|
|
474
|
-
|
|
475
|
-
|
|
480
|
+
event,
|
|
481
|
+
type
|
|
476
482
|
} = await eventPromise;
|
|
477
483
|
if (type !== Message$1) {
|
|
478
484
|
throw new IpcError('Failed to wait for ipc message');
|
|
@@ -507,61 +513,19 @@ const wrap$5 = messagePort => {
|
|
|
507
513
|
};
|
|
508
514
|
const IpcParentWithMessagePort$1 = {
|
|
509
515
|
__proto__: null,
|
|
510
|
-
create: create$5
|
|
516
|
+
create: create$5,
|
|
511
517
|
signal: signal$1,
|
|
512
518
|
wrap: wrap$5
|
|
513
519
|
};
|
|
514
520
|
|
|
515
|
-
const Two = '2.0';
|
|
516
|
-
const create$4 = (method, params) => {
|
|
517
|
-
return {
|
|
518
|
-
jsonrpc: Two,
|
|
519
|
-
method,
|
|
520
|
-
params
|
|
521
|
-
};
|
|
522
|
-
};
|
|
521
|
+
const Two$1 = '2.0';
|
|
523
522
|
const callbacks = Object.create(null);
|
|
524
|
-
const set$3 = (id, fn) => {
|
|
525
|
-
callbacks[id] = fn;
|
|
526
|
-
};
|
|
527
523
|
const get$1 = id => {
|
|
528
524
|
return callbacks[id];
|
|
529
525
|
};
|
|
530
526
|
const remove = id => {
|
|
531
527
|
delete callbacks[id];
|
|
532
528
|
};
|
|
533
|
-
let id = 0;
|
|
534
|
-
const create$3 = () => {
|
|
535
|
-
return ++id;
|
|
536
|
-
};
|
|
537
|
-
const registerPromise = () => {
|
|
538
|
-
const id = create$3();
|
|
539
|
-
const {
|
|
540
|
-
resolve,
|
|
541
|
-
promise
|
|
542
|
-
} = Promise.withResolvers();
|
|
543
|
-
set$3(id, resolve);
|
|
544
|
-
return {
|
|
545
|
-
id,
|
|
546
|
-
promise
|
|
547
|
-
};
|
|
548
|
-
};
|
|
549
|
-
const create$2 = (method, params) => {
|
|
550
|
-
const {
|
|
551
|
-
id,
|
|
552
|
-
promise
|
|
553
|
-
} = registerPromise();
|
|
554
|
-
const message = {
|
|
555
|
-
jsonrpc: Two,
|
|
556
|
-
method,
|
|
557
|
-
params,
|
|
558
|
-
id
|
|
559
|
-
};
|
|
560
|
-
return {
|
|
561
|
-
message,
|
|
562
|
-
promise
|
|
563
|
-
};
|
|
564
|
-
};
|
|
565
529
|
class JsonRpcError extends Error {
|
|
566
530
|
constructor(message) {
|
|
567
531
|
super(message);
|
|
@@ -755,9 +719,9 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
755
719
|
}
|
|
756
720
|
};
|
|
757
721
|
};
|
|
758
|
-
const create$1
|
|
722
|
+
const create$1 = (id, error) => {
|
|
759
723
|
return {
|
|
760
|
-
jsonrpc: Two,
|
|
724
|
+
jsonrpc: Two$1,
|
|
761
725
|
id,
|
|
762
726
|
error
|
|
763
727
|
};
|
|
@@ -766,22 +730,22 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
766
730
|
const prettyError = preparePrettyError(error);
|
|
767
731
|
logError(error, prettyError);
|
|
768
732
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
769
|
-
return create$1
|
|
733
|
+
return create$1(id, errorProperty);
|
|
770
734
|
};
|
|
771
|
-
const create$
|
|
735
|
+
const create$3 = (message, result) => {
|
|
772
736
|
return {
|
|
773
|
-
jsonrpc: Two,
|
|
737
|
+
jsonrpc: Two$1,
|
|
774
738
|
id: message.id,
|
|
775
739
|
result: result ?? null
|
|
776
740
|
};
|
|
777
741
|
};
|
|
778
742
|
const getSuccessResponse = (message, result) => {
|
|
779
743
|
const resultProperty = result ?? null;
|
|
780
|
-
return create$
|
|
744
|
+
return create$3(message, resultProperty);
|
|
781
745
|
};
|
|
782
746
|
const getErrorResponseSimple = (id, error) => {
|
|
783
747
|
return {
|
|
784
|
-
jsonrpc: Two,
|
|
748
|
+
jsonrpc: Two$1,
|
|
785
749
|
id,
|
|
786
750
|
error: {
|
|
787
751
|
code: Custom,
|
|
@@ -868,29 +832,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
868
832
|
}
|
|
869
833
|
throw new JsonRpcError('unexpected message');
|
|
870
834
|
};
|
|
871
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
872
|
-
const {
|
|
873
|
-
message,
|
|
874
|
-
promise
|
|
875
|
-
} = create$2(method, params);
|
|
876
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
877
|
-
ipc.sendAndTransfer(message);
|
|
878
|
-
} else {
|
|
879
|
-
ipc.send(message);
|
|
880
|
-
}
|
|
881
|
-
const responseMessage = await promise;
|
|
882
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
883
|
-
};
|
|
884
|
-
const send = (transport, method, ...params) => {
|
|
885
|
-
const message = create$4(method, params);
|
|
886
|
-
transport.send(message);
|
|
887
|
-
};
|
|
888
|
-
const invoke$1 = (ipc, method, ...params) => {
|
|
889
|
-
return invokeHelper(ipc, method, params, false);
|
|
890
|
-
};
|
|
891
|
-
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
892
|
-
return invokeHelper(ipc, method, params, true);
|
|
893
|
-
};
|
|
894
835
|
|
|
895
836
|
class CommandNotFoundError extends Error {
|
|
896
837
|
constructor(command) {
|
|
@@ -913,24 +854,87 @@ const execute = (command, ...args) => {
|
|
|
913
854
|
return fn(...args);
|
|
914
855
|
};
|
|
915
856
|
|
|
857
|
+
const Two = '2.0';
|
|
858
|
+
const create$p = (method, params) => {
|
|
859
|
+
return {
|
|
860
|
+
jsonrpc: Two,
|
|
861
|
+
method,
|
|
862
|
+
params
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
const create$o = (id, method, params) => {
|
|
866
|
+
const message = {
|
|
867
|
+
id,
|
|
868
|
+
jsonrpc: Two,
|
|
869
|
+
method,
|
|
870
|
+
params
|
|
871
|
+
};
|
|
872
|
+
return message;
|
|
873
|
+
};
|
|
874
|
+
let id = 0;
|
|
875
|
+
const create$n = () => {
|
|
876
|
+
return ++id;
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
880
|
+
|
|
881
|
+
const registerPromise = map => {
|
|
882
|
+
const id = create$n();
|
|
883
|
+
const {
|
|
884
|
+
promise,
|
|
885
|
+
resolve
|
|
886
|
+
} = Promise.withResolvers();
|
|
887
|
+
map[id] = resolve;
|
|
888
|
+
return {
|
|
889
|
+
id,
|
|
890
|
+
promise
|
|
891
|
+
};
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
// @ts-ignore
|
|
895
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
896
|
+
const {
|
|
897
|
+
id,
|
|
898
|
+
promise
|
|
899
|
+
} = registerPromise(callbacks);
|
|
900
|
+
const message = create$o(id, method, params);
|
|
901
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
902
|
+
ipc.sendAndTransfer(message);
|
|
903
|
+
} else {
|
|
904
|
+
ipc.send(message);
|
|
905
|
+
}
|
|
906
|
+
const responseMessage = await promise;
|
|
907
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
908
|
+
};
|
|
916
909
|
const createRpc = ipc => {
|
|
910
|
+
const callbacks = Object.create(null);
|
|
911
|
+
ipc._resolve = (id, response) => {
|
|
912
|
+
const fn = callbacks[id];
|
|
913
|
+
if (!fn) {
|
|
914
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
fn(response);
|
|
918
|
+
delete callbacks[id];
|
|
919
|
+
};
|
|
917
920
|
const rpc = {
|
|
921
|
+
async dispose() {
|
|
922
|
+
await ipc?.dispose();
|
|
923
|
+
},
|
|
924
|
+
invoke(method, ...params) {
|
|
925
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
926
|
+
},
|
|
927
|
+
invokeAndTransfer(method, ...params) {
|
|
928
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
929
|
+
},
|
|
918
930
|
// @ts-ignore
|
|
919
931
|
ipc,
|
|
920
932
|
/**
|
|
921
933
|
* @deprecated
|
|
922
934
|
*/
|
|
923
935
|
send(method, ...params) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
invoke(method, ...params) {
|
|
927
|
-
return invoke$1(ipc, method, ...params);
|
|
928
|
-
},
|
|
929
|
-
invokeAndTransfer(method, ...params) {
|
|
930
|
-
return invokeAndTransfer$1(ipc, method, ...params);
|
|
931
|
-
},
|
|
932
|
-
async dispose() {
|
|
933
|
-
await ipc?.dispose();
|
|
936
|
+
const message = create$p(method, params);
|
|
937
|
+
ipc.send(message);
|
|
934
938
|
}
|
|
935
939
|
};
|
|
936
940
|
return rpc;
|
|
@@ -947,7 +951,7 @@ const logError = () => {
|
|
|
947
951
|
const handleMessage = event => {
|
|
948
952
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
949
953
|
const actualExecute = event?.target?.execute || execute;
|
|
950
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
954
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
951
955
|
};
|
|
952
956
|
const handleIpc = ipc => {
|
|
953
957
|
if ('addEventListener' in ipc) {
|
|
@@ -965,15 +969,16 @@ const listen$1 = async (module, options) => {
|
|
|
965
969
|
const ipc = module.wrap(rawIpc);
|
|
966
970
|
return ipc;
|
|
967
971
|
};
|
|
968
|
-
const create$
|
|
972
|
+
const create$7 = async ({
|
|
969
973
|
commandMap,
|
|
974
|
+
isMessagePortOpen = true,
|
|
970
975
|
messagePort
|
|
971
976
|
}) => {
|
|
972
977
|
// TODO create a commandMap per rpc instance
|
|
973
978
|
register(commandMap);
|
|
974
979
|
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
975
|
-
|
|
976
|
-
|
|
980
|
+
isMessagePortOpen,
|
|
981
|
+
messagePort
|
|
977
982
|
});
|
|
978
983
|
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
979
984
|
handleIpc(ipc);
|
|
@@ -983,9 +988,9 @@ const create$5 = async ({
|
|
|
983
988
|
};
|
|
984
989
|
const PlainMessagePortRpc = {
|
|
985
990
|
__proto__: null,
|
|
986
|
-
create: create$
|
|
991
|
+
create: create$7
|
|
987
992
|
};
|
|
988
|
-
const create$
|
|
993
|
+
const create$2 = async ({
|
|
989
994
|
commandMap
|
|
990
995
|
}) => {
|
|
991
996
|
// TODO create a commandMap per rpc instance
|
|
@@ -997,7 +1002,7 @@ const create$1 = async ({
|
|
|
997
1002
|
};
|
|
998
1003
|
const WebWorkerRpcClient = {
|
|
999
1004
|
__proto__: null,
|
|
1000
|
-
create: create$
|
|
1005
|
+
create: create$2
|
|
1001
1006
|
};
|
|
1002
1007
|
const createMockRpc = ({
|
|
1003
1008
|
commandMap
|
|
@@ -1012,9 +1017,9 @@ const createMockRpc = ({
|
|
|
1012
1017
|
return command(...params);
|
|
1013
1018
|
};
|
|
1014
1019
|
const mockRpc = {
|
|
1020
|
+
invocations,
|
|
1015
1021
|
invoke,
|
|
1016
|
-
invokeAndTransfer: invoke
|
|
1017
|
-
invocations
|
|
1022
|
+
invokeAndTransfer: invoke
|
|
1018
1023
|
};
|
|
1019
1024
|
return mockRpc;
|
|
1020
1025
|
};
|
|
@@ -1056,9 +1061,6 @@ const Data$1 = 57;
|
|
|
1056
1061
|
const Time$1 = 58;
|
|
1057
1062
|
const Tfoot$1 = 59;
|
|
1058
1063
|
|
|
1059
|
-
const DebugWorker = 55;
|
|
1060
|
-
const RendererWorker$1 = 1;
|
|
1061
|
-
|
|
1062
1064
|
const text = data => {
|
|
1063
1065
|
return {
|
|
1064
1066
|
type: Text$1,
|
|
@@ -1073,8 +1075,6 @@ const Document = 'document';
|
|
|
1073
1075
|
|
|
1074
1076
|
const Markdown = 'Markdown';
|
|
1075
1077
|
|
|
1076
|
-
const HandleReadmeContextMenu = 'handleReadmeContextMenu';
|
|
1077
|
-
|
|
1078
1078
|
const getVirtualDomChildCount = markdownDom => {
|
|
1079
1079
|
const max = markdownDom.length - 1;
|
|
1080
1080
|
let stack = [];
|
|
@@ -1533,14 +1533,16 @@ const parseHtml = (html, allowedAttributes) => {
|
|
|
1533
1533
|
return dom;
|
|
1534
1534
|
};
|
|
1535
1535
|
|
|
1536
|
-
const getMarkdownVirtualDom = html
|
|
1536
|
+
const getMarkdownVirtualDom = (html, {
|
|
1537
|
+
onContextMenu = undefined
|
|
1538
|
+
} = {}) => {
|
|
1537
1539
|
string(html);
|
|
1538
1540
|
const childDom = parseHtml(html, allowedMarkdownAttributes);
|
|
1539
1541
|
const markdownChildCount = getVirtualDomChildCount(childDom);
|
|
1540
1542
|
return [{
|
|
1541
1543
|
childCount: markdownChildCount,
|
|
1542
1544
|
className: Markdown,
|
|
1543
|
-
onContextMenu
|
|
1545
|
+
onContextMenu,
|
|
1544
1546
|
role: Document,
|
|
1545
1547
|
type: Div$1
|
|
1546
1548
|
}, ...childDom];
|
|
@@ -1554,8 +1556,9 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
1554
1556
|
};
|
|
1555
1557
|
|
|
1556
1558
|
/**
|
|
1557
|
-
* marked
|
|
1558
|
-
* Copyright (c)
|
|
1559
|
+
* marked v17.0.1 - a markdown parser
|
|
1560
|
+
* Copyright (c) 2018-2025, MarkedJS. (MIT License)
|
|
1561
|
+
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
|
|
1559
1562
|
* https://github.com/markedjs/marked
|
|
1560
1563
|
*/
|
|
1561
1564
|
|
|
@@ -1579,13 +1582,13 @@ function L() {
|
|
|
1579
1582
|
};
|
|
1580
1583
|
}
|
|
1581
1584
|
var T = L();
|
|
1582
|
-
function
|
|
1585
|
+
function Z(u) {
|
|
1583
1586
|
T = u;
|
|
1584
1587
|
}
|
|
1585
|
-
var
|
|
1588
|
+
var C = {
|
|
1586
1589
|
exec: () => null
|
|
1587
1590
|
};
|
|
1588
|
-
function
|
|
1591
|
+
function k(u, e = "") {
|
|
1589
1592
|
let t = typeof u == "string" ? u : u.source,
|
|
1590
1593
|
n = {
|
|
1591
1594
|
replace: (r, i) => {
|
|
@@ -1596,7 +1599,14 @@ function h(u, e = "") {
|
|
|
1596
1599
|
};
|
|
1597
1600
|
return n;
|
|
1598
1601
|
}
|
|
1599
|
-
var
|
|
1602
|
+
var me = (() => {
|
|
1603
|
+
try {
|
|
1604
|
+
return !!new RegExp("(?<=1)(?<!1)");
|
|
1605
|
+
} catch {
|
|
1606
|
+
return false;
|
|
1607
|
+
}
|
|
1608
|
+
})(),
|
|
1609
|
+
m = {
|
|
1600
1610
|
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
|
|
1601
1611
|
outputLinkReplace: /\\([\[\]])/g,
|
|
1602
1612
|
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
@@ -1615,8 +1625,9 @@ var m = {
|
|
|
1615
1625
|
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
1616
1626
|
listReplaceTabs: /^\t+/,
|
|
1617
1627
|
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
1618
|
-
listIsTask: /^\[[ xX]\] /,
|
|
1628
|
+
listIsTask: /^\[[ xX]\] +\S/,
|
|
1619
1629
|
listReplaceTask: /^\[[ xX]\] +/,
|
|
1630
|
+
listTaskCheckbox: /\[[ xX]\]/,
|
|
1620
1631
|
anyLine: /\n.*\n/,
|
|
1621
1632
|
hrefBrackets: /^<(.*)>$/,
|
|
1622
1633
|
tableDelimiter: /[:|]/,
|
|
@@ -1654,152 +1665,152 @@ var m = {
|
|
|
1654
1665
|
headingBeginRegex: u => new RegExp(`^ {0,${Math.min(3, u - 1)}}#`),
|
|
1655
1666
|
htmlBeginRegex: u => new RegExp(`^ {0,${Math.min(3, u - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
1656
1667
|
},
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1668
|
+
xe = /^(?:[ \t]*(?:\n|$))+/,
|
|
1669
|
+
be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,
|
|
1670
|
+
Re = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
1671
|
+
I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
1672
|
+
Te = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
1673
|
+
N = /(?:[*+-]|\d{1,9}[.)])/,
|
|
1674
|
+
re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1675
|
+
se = k(re).replace(/bull/g, N).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(),
|
|
1676
|
+
Oe = k(re).replace(/bull/g, N).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(),
|
|
1677
|
+
Q = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
1678
|
+
we = /^[^\n]+/,
|
|
1679
|
+
F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,
|
|
1680
|
+
ye = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),
|
|
1681
|
+
Pe = k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, N).getRegex(),
|
|
1671
1682
|
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",
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
blockquote:
|
|
1678
|
-
code:
|
|
1679
|
-
def:
|
|
1680
|
-
fences:
|
|
1681
|
-
heading:
|
|
1682
|
-
hr:
|
|
1683
|
-
html:
|
|
1684
|
-
lheading:
|
|
1685
|
-
list:
|
|
1686
|
-
newline:
|
|
1687
|
-
paragraph:
|
|
1688
|
-
table:
|
|
1689
|
-
text:
|
|
1683
|
+
j = /<!--(?:-?>|[\s\S]*?(?:-->|$))/,
|
|
1684
|
+
Se = k("^ {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", j).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),
|
|
1685
|
+
ie = k(Q).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(),
|
|
1686
|
+
$e = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ie).getRegex(),
|
|
1687
|
+
U = {
|
|
1688
|
+
blockquote: $e,
|
|
1689
|
+
code: be,
|
|
1690
|
+
def: ye,
|
|
1691
|
+
fences: Re,
|
|
1692
|
+
heading: Te,
|
|
1693
|
+
hr: I,
|
|
1694
|
+
html: Se,
|
|
1695
|
+
lheading: se,
|
|
1696
|
+
list: Pe,
|
|
1697
|
+
newline: xe,
|
|
1698
|
+
paragraph: ie,
|
|
1699
|
+
table: C,
|
|
1700
|
+
text: we
|
|
1690
1701
|
},
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
...
|
|
1694
|
-
lheading:
|
|
1695
|
-
table:
|
|
1696
|
-
paragraph:
|
|
1702
|
+
te = k("^ *([^\\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(),
|
|
1703
|
+
_e = {
|
|
1704
|
+
...U,
|
|
1705
|
+
lheading: Oe,
|
|
1706
|
+
table: te,
|
|
1707
|
+
paragraph: k(Q).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", te).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()
|
|
1697
1708
|
},
|
|
1698
|
-
|
|
1699
|
-
...
|
|
1700
|
-
html:
|
|
1709
|
+
Le = {
|
|
1710
|
+
...U,
|
|
1711
|
+
html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", j).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(),
|
|
1701
1712
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
1702
1713
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
1703
|
-
fences:
|
|
1714
|
+
fences: C,
|
|
1704
1715
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
1705
|
-
paragraph:
|
|
1706
|
-
]`).replace("lheading",
|
|
1716
|
+
paragraph: k(Q).replace("hr", I).replace("heading", ` *#{1,6} *[^
|
|
1717
|
+
]`).replace("lheading", se).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
1707
1718
|
},
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1719
|
+
Me = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
1720
|
+
ze = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
1721
|
+
oe = /^( {2,}|\\)\n(?!\s*$)/,
|
|
1722
|
+
Ae = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
1712
1723
|
D = /[\p{P}\p{S}]/u,
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1724
|
+
K = /[\s\p{P}\p{S}]/u,
|
|
1725
|
+
ae = /[^\s\p{P}\p{S}]/u,
|
|
1726
|
+
Ce = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, K).getRegex(),
|
|
1727
|
+
le = /(?!~)[\p{P}\p{S}]/u,
|
|
1728
|
+
Ie = /(?!~)[\s\p{P}\p{S}]/u,
|
|
1729
|
+
Ee = /(?:[^\s\p{P}\p{S}]|~)/u,
|
|
1730
|
+
Be = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", me ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(),
|
|
1731
|
+
ue = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,
|
|
1732
|
+
qe = k(ue, "u").replace(/punct/g, D).getRegex(),
|
|
1733
|
+
ve = k(ue, "u").replace(/punct/g, le).getRegex(),
|
|
1734
|
+
pe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",
|
|
1735
|
+
De = k(pe, "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, D).getRegex(),
|
|
1736
|
+
He = k(pe, "gu").replace(/notPunctSpace/g, Ee).replace(/punctSpace/g, Ie).replace(/punct/g, le).getRegex(),
|
|
1737
|
+
Ze = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, K).replace(/punct/g, D).getRegex(),
|
|
1738
|
+
Ge = k(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(),
|
|
1739
|
+
Ne = k(/^<(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(),
|
|
1740
|
+
Qe = k(j).replace("(?:-->|$)", "-->").getRegex(),
|
|
1741
|
+
Fe = k("^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", Qe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),
|
|
1731
1742
|
q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
_backpedal:
|
|
1739
|
-
anyPunctuation:
|
|
1740
|
-
autolink:
|
|
1741
|
-
blockSkip:
|
|
1742
|
-
br:
|
|
1743
|
-
code:
|
|
1744
|
-
del:
|
|
1745
|
-
emStrongLDelim:
|
|
1746
|
-
emStrongRDelimAst:
|
|
1747
|
-
emStrongRDelimUnd:
|
|
1748
|
-
escape:
|
|
1749
|
-
link:
|
|
1750
|
-
nolink:
|
|
1751
|
-
punctuation:
|
|
1752
|
-
reflink:
|
|
1753
|
-
reflinkSearch:
|
|
1754
|
-
tag:
|
|
1755
|
-
text:
|
|
1756
|
-
url:
|
|
1743
|
+
je = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),
|
|
1744
|
+
ce = k(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex(),
|
|
1745
|
+
he = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex(),
|
|
1746
|
+
Ue = k("reflink|nolink(?!\\()", "g").replace("reflink", ce).replace("nolink", he).getRegex(),
|
|
1747
|
+
ne = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,
|
|
1748
|
+
W = {
|
|
1749
|
+
_backpedal: C,
|
|
1750
|
+
anyPunctuation: Ge,
|
|
1751
|
+
autolink: Ne,
|
|
1752
|
+
blockSkip: Be,
|
|
1753
|
+
br: oe,
|
|
1754
|
+
code: ze,
|
|
1755
|
+
del: C,
|
|
1756
|
+
emStrongLDelim: qe,
|
|
1757
|
+
emStrongRDelimAst: De,
|
|
1758
|
+
emStrongRDelimUnd: Ze,
|
|
1759
|
+
escape: Me,
|
|
1760
|
+
link: je,
|
|
1761
|
+
nolink: he,
|
|
1762
|
+
punctuation: Ce,
|
|
1763
|
+
reflink: ce,
|
|
1764
|
+
reflinkSearch: Ue,
|
|
1765
|
+
tag: Fe,
|
|
1766
|
+
text: Ae,
|
|
1767
|
+
url: C
|
|
1757
1768
|
},
|
|
1758
|
-
|
|
1759
|
-
...
|
|
1760
|
-
link:
|
|
1761
|
-
reflink:
|
|
1769
|
+
Ke = {
|
|
1770
|
+
...W,
|
|
1771
|
+
link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(),
|
|
1772
|
+
reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex()
|
|
1762
1773
|
},
|
|
1763
|
-
|
|
1764
|
-
...
|
|
1765
|
-
emStrongRDelimAst:
|
|
1766
|
-
emStrongLDelim:
|
|
1767
|
-
url:
|
|
1774
|
+
G = {
|
|
1775
|
+
...W,
|
|
1776
|
+
emStrongRDelimAst: He,
|
|
1777
|
+
emStrongLDelim: ve,
|
|
1778
|
+
url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ne).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
1768
1779
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1769
1780
|
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
|
|
1770
|
-
text:
|
|
1781
|
+
text: k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ne).getRegex()
|
|
1771
1782
|
},
|
|
1772
|
-
|
|
1773
|
-
...
|
|
1774
|
-
br:
|
|
1775
|
-
text:
|
|
1783
|
+
We = {
|
|
1784
|
+
...G,
|
|
1785
|
+
br: k(oe).replace("{2,}", "*").getRegex(),
|
|
1786
|
+
text: k(G.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1776
1787
|
},
|
|
1777
|
-
|
|
1778
|
-
normal:
|
|
1779
|
-
gfm:
|
|
1780
|
-
pedantic:
|
|
1788
|
+
E = {
|
|
1789
|
+
normal: U,
|
|
1790
|
+
gfm: _e,
|
|
1791
|
+
pedantic: Le
|
|
1781
1792
|
},
|
|
1782
1793
|
M = {
|
|
1783
|
-
normal:
|
|
1784
|
-
gfm:
|
|
1785
|
-
breaks:
|
|
1786
|
-
pedantic:
|
|
1794
|
+
normal: W,
|
|
1795
|
+
gfm: G,
|
|
1796
|
+
breaks: We,
|
|
1797
|
+
pedantic: Ke
|
|
1787
1798
|
};
|
|
1788
|
-
var
|
|
1799
|
+
var Xe = {
|
|
1789
1800
|
"&": "&",
|
|
1790
1801
|
"<": "<",
|
|
1791
1802
|
">": ">",
|
|
1792
1803
|
'"': """,
|
|
1793
1804
|
"'": "'"
|
|
1794
1805
|
},
|
|
1795
|
-
|
|
1806
|
+
ke = u => Xe[u];
|
|
1796
1807
|
function w(u, e) {
|
|
1797
1808
|
if (e) {
|
|
1798
|
-
if (m.escapeTest.test(u)) return u.replace(m.escapeReplace,
|
|
1799
|
-
} else if (m.escapeTestNoEncode.test(u)) return u.replace(m.escapeReplaceNoEncode,
|
|
1809
|
+
if (m.escapeTest.test(u)) return u.replace(m.escapeReplace, ke);
|
|
1810
|
+
} else if (m.escapeTestNoEncode.test(u)) return u.replace(m.escapeReplaceNoEncode, ke);
|
|
1800
1811
|
return u;
|
|
1801
1812
|
}
|
|
1802
|
-
function
|
|
1813
|
+
function X(u) {
|
|
1803
1814
|
try {
|
|
1804
1815
|
u = encodeURI(u).replace(m.percentDecode, "%");
|
|
1805
1816
|
} catch {
|
|
@@ -1807,12 +1818,12 @@ function J(u) {
|
|
|
1807
1818
|
}
|
|
1808
1819
|
return u;
|
|
1809
1820
|
}
|
|
1810
|
-
function
|
|
1811
|
-
let t = u.replace(m.findPipe, (i, s,
|
|
1812
|
-
let
|
|
1821
|
+
function J(u, e) {
|
|
1822
|
+
let t = u.replace(m.findPipe, (i, s, a) => {
|
|
1823
|
+
let o = false,
|
|
1813
1824
|
l = s;
|
|
1814
|
-
for (; --l >= 0 &&
|
|
1815
|
-
return
|
|
1825
|
+
for (; --l >= 0 && a[l] === "\\";) o = !o;
|
|
1826
|
+
return o ? "|" : " |";
|
|
1816
1827
|
}),
|
|
1817
1828
|
n = t.split(m.splitPipe),
|
|
1818
1829
|
r = 0;
|
|
@@ -1830,28 +1841,28 @@ function z(u, e, t) {
|
|
|
1830
1841
|
}
|
|
1831
1842
|
return u.slice(0, n - r);
|
|
1832
1843
|
}
|
|
1833
|
-
function
|
|
1844
|
+
function de(u, e) {
|
|
1834
1845
|
if (u.indexOf(e[1]) === -1) return -1;
|
|
1835
1846
|
let t = 0;
|
|
1836
1847
|
for (let n = 0; n < u.length; n++) if (u[n] === "\\") n++;else if (u[n] === e[0]) t++;else if (u[n] === e[1] && (t--, t < 0)) return n;
|
|
1837
1848
|
return t > 0 ? -2 : -1;
|
|
1838
1849
|
}
|
|
1839
|
-
function
|
|
1850
|
+
function ge(u, e, t, n, r) {
|
|
1840
1851
|
let i = e.href,
|
|
1841
1852
|
s = e.title || null,
|
|
1842
|
-
|
|
1853
|
+
a = u[1].replace(r.other.outputLinkReplace, "$1");
|
|
1843
1854
|
n.state.inLink = true;
|
|
1844
|
-
let
|
|
1855
|
+
let o = {
|
|
1845
1856
|
type: u[0].charAt(0) === "!" ? "image" : "link",
|
|
1846
1857
|
raw: t,
|
|
1847
1858
|
href: i,
|
|
1848
1859
|
title: s,
|
|
1849
|
-
text:
|
|
1850
|
-
tokens: n.inlineTokens(
|
|
1860
|
+
text: a,
|
|
1861
|
+
tokens: n.inlineTokens(a)
|
|
1851
1862
|
};
|
|
1852
|
-
return n.state.inLink = false,
|
|
1863
|
+
return n.state.inLink = false, o;
|
|
1853
1864
|
}
|
|
1854
|
-
function
|
|
1865
|
+
function Je(u, e, t) {
|
|
1855
1866
|
let n = u.match(t.other.indentCodeCompensation);
|
|
1856
1867
|
if (n === null) return e;
|
|
1857
1868
|
let r = n[1];
|
|
@@ -1859,8 +1870,8 @@ function Ve(u, e, t) {
|
|
|
1859
1870
|
`).map(i => {
|
|
1860
1871
|
let s = i.match(t.other.beginningSpace);
|
|
1861
1872
|
if (s === null) return i;
|
|
1862
|
-
let [
|
|
1863
|
-
return
|
|
1873
|
+
let [a] = s;
|
|
1874
|
+
return a.length >= r.length ? i.slice(r.length) : i;
|
|
1864
1875
|
}).join(`
|
|
1865
1876
|
`);
|
|
1866
1877
|
}
|
|
@@ -1895,7 +1906,7 @@ var y = class {
|
|
|
1895
1906
|
let t = this.rules.block.fences.exec(e);
|
|
1896
1907
|
if (t) {
|
|
1897
1908
|
let n = t[0],
|
|
1898
|
-
r =
|
|
1909
|
+
r = Je(n, t[3] || "", this.rules);
|
|
1899
1910
|
return {
|
|
1900
1911
|
type: "code",
|
|
1901
1912
|
raw: n,
|
|
@@ -1939,37 +1950,37 @@ var y = class {
|
|
|
1939
1950
|
i = "",
|
|
1940
1951
|
s = [];
|
|
1941
1952
|
for (; n.length > 0;) {
|
|
1942
|
-
let
|
|
1943
|
-
|
|
1953
|
+
let a = false,
|
|
1954
|
+
o = [],
|
|
1944
1955
|
l;
|
|
1945
|
-
for (l = 0; l < n.length; l++) if (this.rules.other.blockquoteStart.test(n[l]))
|
|
1956
|
+
for (l = 0; l < n.length; l++) if (this.rules.other.blockquoteStart.test(n[l])) o.push(n[l]), a = true;else if (!a) o.push(n[l]);else break;
|
|
1946
1957
|
n = n.slice(l);
|
|
1947
|
-
let
|
|
1958
|
+
let p = o.join(`
|
|
1948
1959
|
`),
|
|
1949
|
-
|
|
1960
|
+
c = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1950
1961
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1951
1962
|
r = r ? `${r}
|
|
1952
|
-
${
|
|
1953
|
-
${
|
|
1963
|
+
${p}` : p, i = i ? `${i}
|
|
1964
|
+
${c}` : c;
|
|
1954
1965
|
let g = this.lexer.state.top;
|
|
1955
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(
|
|
1956
|
-
let
|
|
1957
|
-
if (
|
|
1958
|
-
if (
|
|
1959
|
-
let R =
|
|
1966
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = g, n.length === 0) break;
|
|
1967
|
+
let h = s.at(-1);
|
|
1968
|
+
if (h?.type === "code") break;
|
|
1969
|
+
if (h?.type === "blockquote") {
|
|
1970
|
+
let R = h,
|
|
1960
1971
|
f = R.raw + `
|
|
1961
1972
|
` + n.join(`
|
|
1962
1973
|
`),
|
|
1963
1974
|
O = this.blockquote(f);
|
|
1964
1975
|
s[s.length - 1] = O, r = r.substring(0, r.length - R.raw.length) + O.raw, i = i.substring(0, i.length - R.text.length) + O.text;
|
|
1965
1976
|
break;
|
|
1966
|
-
} else if (
|
|
1967
|
-
let R =
|
|
1977
|
+
} else if (h?.type === "list") {
|
|
1978
|
+
let R = h,
|
|
1968
1979
|
f = R.raw + `
|
|
1969
1980
|
` + n.join(`
|
|
1970
1981
|
`),
|
|
1971
1982
|
O = this.list(f);
|
|
1972
|
-
s[s.length - 1] = O, r = r.substring(0, r.length -
|
|
1983
|
+
s[s.length - 1] = O, r = r.substring(0, r.length - h.raw.length) + O.raw, i = i.substring(0, i.length - R.raw.length) + O.raw, n = f.substring(s.at(-1).raw.length).split(`
|
|
1973
1984
|
`);
|
|
1974
1985
|
continue;
|
|
1975
1986
|
}
|
|
@@ -1997,63 +2008,87 @@ ${p}` : p;
|
|
|
1997
2008
|
};
|
|
1998
2009
|
n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
|
|
1999
2010
|
let s = this.rules.other.listItemRegex(n),
|
|
2000
|
-
|
|
2011
|
+
a = false;
|
|
2001
2012
|
for (; e;) {
|
|
2002
2013
|
let l = false,
|
|
2003
|
-
|
|
2004
|
-
|
|
2014
|
+
p = "",
|
|
2015
|
+
c = "";
|
|
2005
2016
|
if (!(t = s.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
2006
|
-
|
|
2017
|
+
p = t[0], e = e.substring(p.length);
|
|
2007
2018
|
let g = t[2].split(`
|
|
2008
|
-
`, 1)[0].replace(this.rules.other.listReplaceTabs,
|
|
2009
|
-
|
|
2019
|
+
`, 1)[0].replace(this.rules.other.listReplaceTabs, O => " ".repeat(3 * O.length)),
|
|
2020
|
+
h = e.split(`
|
|
2010
2021
|
`, 1)[0],
|
|
2011
2022
|
R = !g.trim(),
|
|
2012
2023
|
f = 0;
|
|
2013
|
-
if (this.options.pedantic ? (f = 2,
|
|
2014
|
-
`, e = e.substring(
|
|
2015
|
-
let
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2024
|
+
if (this.options.pedantic ? (f = 2, c = g.trimStart()) : R ? f = t[1].length + 1 : (f = t[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = g.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (p += h + `
|
|
2025
|
+
`, e = e.substring(h.length + 1), l = true), !l) {
|
|
2026
|
+
let O = this.rules.other.nextBulletRegex(f),
|
|
2027
|
+
V = this.rules.other.hrRegex(f),
|
|
2028
|
+
Y = this.rules.other.fencesBeginRegex(f),
|
|
2029
|
+
ee = this.rules.other.headingBeginRegex(f),
|
|
2030
|
+
fe = this.rules.other.htmlBeginRegex(f);
|
|
2020
2031
|
for (; e;) {
|
|
2021
|
-
let
|
|
2032
|
+
let H = e.split(`
|
|
2022
2033
|
`, 1)[0],
|
|
2023
2034
|
A;
|
|
2024
|
-
if (
|
|
2025
|
-
if (A.search(this.rules.other.nonSpaceChar) >= f || !
|
|
2035
|
+
if (h = H, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), A = h) : A = h.replace(this.rules.other.tabCharGlobal, " "), Y.test(h) || ee.test(h) || fe.test(h) || O.test(h) || V.test(h)) break;
|
|
2036
|
+
if (A.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) c += `
|
|
2026
2037
|
` + A.slice(f);else {
|
|
2027
|
-
if (R || g.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 ||
|
|
2028
|
-
|
|
2029
|
-
` +
|
|
2038
|
+
if (R || g.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Y.test(g) || ee.test(g) || V.test(g)) break;
|
|
2039
|
+
c += `
|
|
2040
|
+
` + h;
|
|
2030
2041
|
}
|
|
2031
|
-
!R && !
|
|
2032
|
-
`, e = e.substring(
|
|
2042
|
+
!R && !h.trim() && (R = true), p += H + `
|
|
2043
|
+
`, e = e.substring(H.length + 1), g = A.slice(f);
|
|
2033
2044
|
}
|
|
2034
2045
|
}
|
|
2035
|
-
i.loose || (
|
|
2036
|
-
let O = null,
|
|
2037
|
-
Y;
|
|
2038
|
-
this.options.gfm && (O = this.rules.other.listIsTask.exec(p), O && (Y = O[0] !== "[ ] ", p = p.replace(this.rules.other.listReplaceTask, ""))), i.items.push({
|
|
2046
|
+
i.loose || (a ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (a = true)), i.items.push({
|
|
2039
2047
|
type: "list_item",
|
|
2040
|
-
raw:
|
|
2041
|
-
task: !!
|
|
2042
|
-
checked: Y,
|
|
2048
|
+
raw: p,
|
|
2049
|
+
task: !!this.options.gfm && this.rules.other.listIsTask.test(c),
|
|
2043
2050
|
loose: false,
|
|
2044
|
-
text:
|
|
2051
|
+
text: c,
|
|
2045
2052
|
tokens: []
|
|
2046
|
-
}), i.raw +=
|
|
2053
|
+
}), i.raw += p;
|
|
2047
2054
|
}
|
|
2048
|
-
let
|
|
2049
|
-
if (
|
|
2055
|
+
let o = i.items.at(-1);
|
|
2056
|
+
if (o) o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();else return;
|
|
2050
2057
|
i.raw = i.raw.trimEnd();
|
|
2051
|
-
for (let l
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2058
|
+
for (let l of i.items) {
|
|
2059
|
+
if (this.lexer.state.top = false, l.tokens = this.lexer.blockTokens(l.text, []), l.task) {
|
|
2060
|
+
if (l.text = l.text.replace(this.rules.other.listReplaceTask, ""), l.tokens[0]?.type === "text" || l.tokens[0]?.type === "paragraph") {
|
|
2061
|
+
l.tokens[0].raw = l.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), l.tokens[0].text = l.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
|
|
2062
|
+
for (let c = this.lexer.inlineQueue.length - 1; c >= 0; c--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)) {
|
|
2063
|
+
this.lexer.inlineQueue[c].src = this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask, "");
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
let p = this.rules.other.listTaskCheckbox.exec(l.raw);
|
|
2068
|
+
if (p) {
|
|
2069
|
+
let c = {
|
|
2070
|
+
type: "checkbox",
|
|
2071
|
+
raw: p[0] + " ",
|
|
2072
|
+
checked: p[0] !== "[ ]"
|
|
2073
|
+
};
|
|
2074
|
+
l.checked = c.checked, i.loose ? l.tokens[0] && ["paragraph", "text"].includes(l.tokens[0].type) && "tokens" in l.tokens[0] && l.tokens[0].tokens ? (l.tokens[0].raw = c.raw + l.tokens[0].raw, l.tokens[0].text = c.raw + l.tokens[0].text, l.tokens[0].tokens.unshift(c)) : l.tokens.unshift({
|
|
2075
|
+
type: "paragraph",
|
|
2076
|
+
raw: c.raw,
|
|
2077
|
+
text: c.raw,
|
|
2078
|
+
tokens: [c]
|
|
2079
|
+
}) : l.tokens.unshift(c);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
if (!i.loose) {
|
|
2083
|
+
let p = l.tokens.filter(g => g.type === "space"),
|
|
2084
|
+
c = p.length > 0 && p.some(g => this.rules.other.anyLine.test(g.raw));
|
|
2085
|
+
i.loose = c;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
if (i.loose) for (let l of i.items) {
|
|
2089
|
+
l.loose = true;
|
|
2090
|
+
for (let p of l.tokens) p.type === "text" && (p.type = "paragraph");
|
|
2055
2091
|
}
|
|
2056
|
-
if (i.loose) for (let l = 0; l < i.items.length; l++) i.items[l].loose = true;
|
|
2057
2092
|
return i;
|
|
2058
2093
|
}
|
|
2059
2094
|
}
|
|
@@ -2085,7 +2120,7 @@ ${p}` : p;
|
|
|
2085
2120
|
table(e) {
|
|
2086
2121
|
let t = this.rules.block.table.exec(e);
|
|
2087
2122
|
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
2088
|
-
let n =
|
|
2123
|
+
let n = J(t[1]),
|
|
2089
2124
|
r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"),
|
|
2090
2125
|
i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
2091
2126
|
`) : [],
|
|
@@ -2097,16 +2132,16 @@ ${p}` : p;
|
|
|
2097
2132
|
rows: []
|
|
2098
2133
|
};
|
|
2099
2134
|
if (n.length === r.length) {
|
|
2100
|
-
for (let
|
|
2101
|
-
for (let
|
|
2102
|
-
text: n[
|
|
2103
|
-
tokens: this.lexer.inline(n[
|
|
2135
|
+
for (let a of r) this.rules.other.tableAlignRight.test(a) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? s.align.push("left") : s.align.push(null);
|
|
2136
|
+
for (let a = 0; a < n.length; a++) s.header.push({
|
|
2137
|
+
text: n[a],
|
|
2138
|
+
tokens: this.lexer.inline(n[a]),
|
|
2104
2139
|
header: true,
|
|
2105
|
-
align: s.align[
|
|
2140
|
+
align: s.align[a]
|
|
2106
2141
|
});
|
|
2107
|
-
for (let
|
|
2108
|
-
text:
|
|
2109
|
-
tokens: this.lexer.inline(
|
|
2142
|
+
for (let a of i) s.rows.push(J(a, s.header.length).map((o, l) => ({
|
|
2143
|
+
text: o,
|
|
2144
|
+
tokens: this.lexer.inline(o),
|
|
2110
2145
|
header: false,
|
|
2111
2146
|
align: s.align[l]
|
|
2112
2147
|
})));
|
|
@@ -2173,11 +2208,11 @@ ${p}` : p;
|
|
|
2173
2208
|
let s = z(n.slice(0, -1), "\\");
|
|
2174
2209
|
if ((n.length - s.length) % 2 === 0) return;
|
|
2175
2210
|
} else {
|
|
2176
|
-
let s =
|
|
2211
|
+
let s = de(t[2], "()");
|
|
2177
2212
|
if (s === -2) return;
|
|
2178
2213
|
if (s > -1) {
|
|
2179
|
-
let
|
|
2180
|
-
t[2] = t[2].substring(0, s), t[0] = t[0].substring(0,
|
|
2214
|
+
let o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
|
|
2215
|
+
t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, o).trim(), t[3] = "";
|
|
2181
2216
|
}
|
|
2182
2217
|
}
|
|
2183
2218
|
let r = t[2],
|
|
@@ -2186,7 +2221,7 @@ ${p}` : p;
|
|
|
2186
2221
|
let s = this.rules.other.pedanticHrefTitle.exec(r);
|
|
2187
2222
|
s && (r = s[1], i = s[3]);
|
|
2188
2223
|
} else i = t[3] ? t[3].slice(1, -1) : "";
|
|
2189
|
-
return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)),
|
|
2224
|
+
return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), ge(t, {
|
|
2190
2225
|
href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
2191
2226
|
title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
|
|
2192
2227
|
}, t[0], this.lexer, this.rules);
|
|
@@ -2205,7 +2240,7 @@ ${p}` : p;
|
|
|
2205
2240
|
text: s
|
|
2206
2241
|
};
|
|
2207
2242
|
}
|
|
2208
|
-
return
|
|
2243
|
+
return ge(n, i, n[0], this.lexer, this.rules);
|
|
2209
2244
|
}
|
|
2210
2245
|
}
|
|
2211
2246
|
emStrong(e, t, n = "") {
|
|
@@ -2213,37 +2248,37 @@ ${p}` : p;
|
|
|
2213
2248
|
if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
2214
2249
|
if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2215
2250
|
let s = [...r[0]].length - 1,
|
|
2216
|
-
o,
|
|
2217
2251
|
a,
|
|
2252
|
+
o,
|
|
2218
2253
|
l = s,
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
for (
|
|
2222
|
-
if (
|
|
2223
|
-
if (
|
|
2224
|
-
l +=
|
|
2254
|
+
p = 0,
|
|
2255
|
+
c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
2256
|
+
for (c.lastIndex = 0, t = t.slice(-1 * e.length + s); (r = c.exec(t)) != null;) {
|
|
2257
|
+
if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
|
|
2258
|
+
if (o = [...a].length, r[3] || r[4]) {
|
|
2259
|
+
l += o;
|
|
2225
2260
|
continue;
|
|
2226
|
-
} else if ((r[5] || r[6]) && s % 3 && !((s +
|
|
2227
|
-
|
|
2261
|
+
} else if ((r[5] || r[6]) && s % 3 && !((s + o) % 3)) {
|
|
2262
|
+
p += o;
|
|
2228
2263
|
continue;
|
|
2229
2264
|
}
|
|
2230
|
-
if (l -=
|
|
2231
|
-
|
|
2265
|
+
if (l -= o, l > 0) continue;
|
|
2266
|
+
o = Math.min(o, o + l + p);
|
|
2232
2267
|
let g = [...r[0]][0].length,
|
|
2233
|
-
|
|
2234
|
-
if (Math.min(s,
|
|
2235
|
-
let f =
|
|
2268
|
+
h = e.slice(0, s + r.index + g + o);
|
|
2269
|
+
if (Math.min(s, o) % 2) {
|
|
2270
|
+
let f = h.slice(1, -1);
|
|
2236
2271
|
return {
|
|
2237
2272
|
type: "em",
|
|
2238
|
-
raw:
|
|
2273
|
+
raw: h,
|
|
2239
2274
|
text: f,
|
|
2240
2275
|
tokens: this.lexer.inlineTokens(f)
|
|
2241
2276
|
};
|
|
2242
2277
|
}
|
|
2243
|
-
let R =
|
|
2278
|
+
let R = h.slice(2, -2);
|
|
2244
2279
|
return {
|
|
2245
2280
|
type: "strong",
|
|
2246
|
-
raw:
|
|
2281
|
+
raw: h,
|
|
2247
2282
|
text: R,
|
|
2248
2283
|
tokens: this.lexer.inlineTokens(R)
|
|
2249
2284
|
};
|
|
@@ -2335,8 +2370,8 @@ var x = class u {
|
|
|
2335
2370
|
tokens;
|
|
2336
2371
|
options;
|
|
2337
2372
|
state;
|
|
2338
|
-
tokenizer;
|
|
2339
2373
|
inlineQueue;
|
|
2374
|
+
tokenizer;
|
|
2340
2375
|
constructor(e) {
|
|
2341
2376
|
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
2342
2377
|
inLink: false,
|
|
@@ -2345,14 +2380,14 @@ var x = class u {
|
|
|
2345
2380
|
};
|
|
2346
2381
|
let t = {
|
|
2347
2382
|
other: m,
|
|
2348
|
-
block:
|
|
2383
|
+
block: E.normal,
|
|
2349
2384
|
inline: M.normal
|
|
2350
2385
|
};
|
|
2351
|
-
this.options.pedantic ? (t.block =
|
|
2386
|
+
this.options.pedantic ? (t.block = E.pedantic, t.inline = M.pedantic) : this.options.gfm && (t.block = E.gfm, this.options.breaks ? t.inline = M.breaks : t.inline = M.gfm), this.tokenizer.rules = t;
|
|
2352
2387
|
}
|
|
2353
2388
|
static get rules() {
|
|
2354
2389
|
return {
|
|
2355
|
-
block:
|
|
2390
|
+
block: E,
|
|
2356
2391
|
inline: M
|
|
2357
2392
|
};
|
|
2358
2393
|
}
|
|
@@ -2440,12 +2475,12 @@ var x = class u {
|
|
|
2440
2475
|
let i = e;
|
|
2441
2476
|
if (this.options.extensions?.startBlock) {
|
|
2442
2477
|
let s = 1 / 0,
|
|
2443
|
-
|
|
2444
|
-
|
|
2478
|
+
a = e.slice(1),
|
|
2479
|
+
o;
|
|
2445
2480
|
this.options.extensions.startBlock.forEach(l => {
|
|
2446
|
-
|
|
2481
|
+
o = l.call({
|
|
2447
2482
|
lexer: this
|
|
2448
|
-
},
|
|
2483
|
+
}, a), typeof o == "number" && o >= 0 && (s = Math.min(s, o));
|
|
2449
2484
|
}), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
|
|
2450
2485
|
}
|
|
2451
2486
|
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
@@ -2489,16 +2524,17 @@ var x = class u {
|
|
|
2489
2524
|
if (o.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null;) o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
2490
2525
|
}
|
|
2491
2526
|
for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null;) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
2492
|
-
|
|
2527
|
+
let i;
|
|
2528
|
+
for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null;) i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
2493
2529
|
n = this.options.hooks?.emStrongMask?.call({
|
|
2494
2530
|
lexer: this
|
|
2495
2531
|
}, n) ?? n;
|
|
2496
|
-
let
|
|
2497
|
-
|
|
2532
|
+
let s = false,
|
|
2533
|
+
a = "";
|
|
2498
2534
|
for (; e;) {
|
|
2499
|
-
|
|
2535
|
+
s || (a = ""), s = false;
|
|
2500
2536
|
let o;
|
|
2501
|
-
if (this.options.extensions?.inline?.some(
|
|
2537
|
+
if (this.options.extensions?.inline?.some(p => (o = p.call({
|
|
2502
2538
|
lexer: this
|
|
2503
2539
|
}, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
2504
2540
|
if (o = this.tokenizer.escape(e)) {
|
|
@@ -2515,11 +2551,11 @@ var x = class u {
|
|
|
2515
2551
|
}
|
|
2516
2552
|
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
2517
2553
|
e = e.substring(o.raw.length);
|
|
2518
|
-
let
|
|
2519
|
-
o.type === "text" &&
|
|
2554
|
+
let p = t.at(-1);
|
|
2555
|
+
o.type === "text" && p?.type === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
|
|
2520
2556
|
continue;
|
|
2521
2557
|
}
|
|
2522
|
-
if (o = this.tokenizer.emStrong(e, n,
|
|
2558
|
+
if (o = this.tokenizer.emStrong(e, n, a)) {
|
|
2523
2559
|
e = e.substring(o.raw.length), t.push(o);
|
|
2524
2560
|
continue;
|
|
2525
2561
|
}
|
|
@@ -2543,29 +2579,29 @@ var x = class u {
|
|
|
2543
2579
|
e = e.substring(o.raw.length), t.push(o);
|
|
2544
2580
|
continue;
|
|
2545
2581
|
}
|
|
2546
|
-
let
|
|
2582
|
+
let l = e;
|
|
2547
2583
|
if (this.options.extensions?.startInline) {
|
|
2548
|
-
let
|
|
2584
|
+
let p = 1 / 0,
|
|
2549
2585
|
c = e.slice(1),
|
|
2550
|
-
|
|
2551
|
-
this.options.extensions.startInline.forEach(
|
|
2552
|
-
|
|
2586
|
+
g;
|
|
2587
|
+
this.options.extensions.startInline.forEach(h => {
|
|
2588
|
+
g = h.call({
|
|
2553
2589
|
lexer: this
|
|
2554
|
-
}, c), typeof
|
|
2555
|
-
}),
|
|
2590
|
+
}, c), typeof g == "number" && g >= 0 && (p = Math.min(p, g));
|
|
2591
|
+
}), p < 1 / 0 && p >= 0 && (l = e.substring(0, p + 1));
|
|
2556
2592
|
}
|
|
2557
|
-
if (o = this.tokenizer.inlineText(
|
|
2558
|
-
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (
|
|
2559
|
-
let
|
|
2560
|
-
|
|
2593
|
+
if (o = this.tokenizer.inlineText(l)) {
|
|
2594
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), s = true;
|
|
2595
|
+
let p = t.at(-1);
|
|
2596
|
+
p?.type === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
|
|
2561
2597
|
continue;
|
|
2562
2598
|
}
|
|
2563
2599
|
if (e) {
|
|
2564
|
-
let
|
|
2600
|
+
let p = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
2565
2601
|
if (this.options.silent) {
|
|
2566
|
-
console.error(
|
|
2602
|
+
console.error(p);
|
|
2567
2603
|
break;
|
|
2568
|
-
} else throw new Error(
|
|
2604
|
+
} else throw new Error(p);
|
|
2569
2605
|
}
|
|
2570
2606
|
}
|
|
2571
2607
|
return t;
|
|
@@ -2622,9 +2658,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2622
2658
|
let t = e.ordered,
|
|
2623
2659
|
n = e.start,
|
|
2624
2660
|
r = "";
|
|
2625
|
-
for (let
|
|
2626
|
-
let
|
|
2627
|
-
r += this.listitem(
|
|
2661
|
+
for (let a = 0; a < e.items.length; a++) {
|
|
2662
|
+
let o = e.items[a];
|
|
2663
|
+
r += this.listitem(o);
|
|
2628
2664
|
}
|
|
2629
2665
|
let i = t ? "ol" : "ul",
|
|
2630
2666
|
s = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
@@ -2633,25 +2669,13 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2633
2669
|
`;
|
|
2634
2670
|
}
|
|
2635
2671
|
listitem(e) {
|
|
2636
|
-
|
|
2637
|
-
if (e.task) {
|
|
2638
|
-
let n = this.checkbox({
|
|
2639
|
-
checked: !!e.checked
|
|
2640
|
-
});
|
|
2641
|
-
e.loose ? e.tokens[0]?.type === "paragraph" ? (e.tokens[0].text = n + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = n + " " + w(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = true)) : e.tokens.unshift({
|
|
2642
|
-
type: "text",
|
|
2643
|
-
raw: n + " ",
|
|
2644
|
-
text: n + " ",
|
|
2645
|
-
escaped: true
|
|
2646
|
-
}) : t += n + " ";
|
|
2647
|
-
}
|
|
2648
|
-
return t += this.parser.parse(e.tokens, !!e.loose), `<li>${t}</li>
|
|
2672
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
2649
2673
|
`;
|
|
2650
2674
|
}
|
|
2651
2675
|
checkbox({
|
|
2652
2676
|
checked: e
|
|
2653
2677
|
}) {
|
|
2654
|
-
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
2678
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
2655
2679
|
}
|
|
2656
2680
|
paragraph({
|
|
2657
2681
|
tokens: e
|
|
@@ -2670,7 +2694,7 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2670
2694
|
for (let i = 0; i < e.rows.length; i++) {
|
|
2671
2695
|
let s = e.rows[i];
|
|
2672
2696
|
n = "";
|
|
2673
|
-
for (let
|
|
2697
|
+
for (let a = 0; a < s.length; a++) n += this.tablecell(s[a]);
|
|
2674
2698
|
r += this.tablerow({
|
|
2675
2699
|
text: n
|
|
2676
2700
|
});
|
|
@@ -2723,7 +2747,7 @@ ${e}</tr>
|
|
|
2723
2747
|
tokens: n
|
|
2724
2748
|
}) {
|
|
2725
2749
|
let r = this.parser.parseInline(n),
|
|
2726
|
-
i =
|
|
2750
|
+
i = X(e);
|
|
2727
2751
|
if (i === null) return r;
|
|
2728
2752
|
e = i;
|
|
2729
2753
|
let s = '<a href="' + e + '"';
|
|
@@ -2736,7 +2760,7 @@ ${e}</tr>
|
|
|
2736
2760
|
tokens: r
|
|
2737
2761
|
}) {
|
|
2738
2762
|
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
2739
|
-
let i =
|
|
2763
|
+
let i = X(e);
|
|
2740
2764
|
if (i === null) return w(n);
|
|
2741
2765
|
e = i;
|
|
2742
2766
|
let s = `<img src="${e}" alt="${n}"`;
|
|
@@ -2790,6 +2814,11 @@ var $ = class {
|
|
|
2790
2814
|
br() {
|
|
2791
2815
|
return "";
|
|
2792
2816
|
}
|
|
2817
|
+
checkbox({
|
|
2818
|
+
raw: e
|
|
2819
|
+
}) {
|
|
2820
|
+
return e;
|
|
2821
|
+
}
|
|
2793
2822
|
};
|
|
2794
2823
|
var b = class u {
|
|
2795
2824
|
options;
|
|
@@ -2804,111 +2833,102 @@ var b = class u {
|
|
|
2804
2833
|
static parseInline(e, t) {
|
|
2805
2834
|
return new u(t).parseInline(e);
|
|
2806
2835
|
}
|
|
2807
|
-
parse(e
|
|
2808
|
-
let
|
|
2809
|
-
for (let
|
|
2810
|
-
let
|
|
2811
|
-
if (this.options.extensions?.renderers?.[
|
|
2812
|
-
let
|
|
2813
|
-
a = this.options.extensions.renderers[
|
|
2836
|
+
parse(e) {
|
|
2837
|
+
let t = "";
|
|
2838
|
+
for (let n = 0; n < e.length; n++) {
|
|
2839
|
+
let r = e[n];
|
|
2840
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
2841
|
+
let s = r,
|
|
2842
|
+
a = this.options.extensions.renderers[s.type].call({
|
|
2814
2843
|
parser: this
|
|
2815
|
-
},
|
|
2816
|
-
if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(
|
|
2817
|
-
|
|
2844
|
+
}, s);
|
|
2845
|
+
if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(s.type)) {
|
|
2846
|
+
t += a || "";
|
|
2818
2847
|
continue;
|
|
2819
2848
|
}
|
|
2820
2849
|
}
|
|
2821
|
-
let
|
|
2822
|
-
switch (
|
|
2850
|
+
let i = r;
|
|
2851
|
+
switch (i.type) {
|
|
2823
2852
|
case "space":
|
|
2824
2853
|
{
|
|
2825
|
-
|
|
2826
|
-
|
|
2854
|
+
t += this.renderer.space(i);
|
|
2855
|
+
break;
|
|
2827
2856
|
}
|
|
2828
2857
|
case "hr":
|
|
2829
2858
|
{
|
|
2830
|
-
|
|
2831
|
-
|
|
2859
|
+
t += this.renderer.hr(i);
|
|
2860
|
+
break;
|
|
2832
2861
|
}
|
|
2833
2862
|
case "heading":
|
|
2834
2863
|
{
|
|
2835
|
-
|
|
2836
|
-
|
|
2864
|
+
t += this.renderer.heading(i);
|
|
2865
|
+
break;
|
|
2837
2866
|
}
|
|
2838
2867
|
case "code":
|
|
2839
2868
|
{
|
|
2840
|
-
|
|
2841
|
-
|
|
2869
|
+
t += this.renderer.code(i);
|
|
2870
|
+
break;
|
|
2842
2871
|
}
|
|
2843
2872
|
case "table":
|
|
2844
2873
|
{
|
|
2845
|
-
|
|
2846
|
-
|
|
2874
|
+
t += this.renderer.table(i);
|
|
2875
|
+
break;
|
|
2847
2876
|
}
|
|
2848
2877
|
case "blockquote":
|
|
2849
2878
|
{
|
|
2850
|
-
|
|
2851
|
-
|
|
2879
|
+
t += this.renderer.blockquote(i);
|
|
2880
|
+
break;
|
|
2852
2881
|
}
|
|
2853
2882
|
case "list":
|
|
2854
2883
|
{
|
|
2855
|
-
|
|
2856
|
-
|
|
2884
|
+
t += this.renderer.list(i);
|
|
2885
|
+
break;
|
|
2886
|
+
}
|
|
2887
|
+
case "checkbox":
|
|
2888
|
+
{
|
|
2889
|
+
t += this.renderer.checkbox(i);
|
|
2890
|
+
break;
|
|
2857
2891
|
}
|
|
2858
2892
|
case "html":
|
|
2859
2893
|
{
|
|
2860
|
-
|
|
2861
|
-
|
|
2894
|
+
t += this.renderer.html(i);
|
|
2895
|
+
break;
|
|
2862
2896
|
}
|
|
2863
2897
|
case "def":
|
|
2864
2898
|
{
|
|
2865
|
-
|
|
2866
|
-
|
|
2899
|
+
t += this.renderer.def(i);
|
|
2900
|
+
break;
|
|
2867
2901
|
}
|
|
2868
2902
|
case "paragraph":
|
|
2869
2903
|
{
|
|
2870
|
-
|
|
2871
|
-
|
|
2904
|
+
t += this.renderer.paragraph(i);
|
|
2905
|
+
break;
|
|
2872
2906
|
}
|
|
2873
2907
|
case "text":
|
|
2874
2908
|
{
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
for (; r + 1 < e.length && e[r + 1].type === "text";) o = e[++r], a += `
|
|
2878
|
-
` + this.renderer.text(o);
|
|
2879
|
-
t ? n += this.renderer.paragraph({
|
|
2880
|
-
type: "paragraph",
|
|
2881
|
-
raw: a,
|
|
2882
|
-
text: a,
|
|
2883
|
-
tokens: [{
|
|
2884
|
-
type: "text",
|
|
2885
|
-
raw: a,
|
|
2886
|
-
text: a,
|
|
2887
|
-
escaped: true
|
|
2888
|
-
}]
|
|
2889
|
-
}) : n += a;
|
|
2890
|
-
continue;
|
|
2909
|
+
t += this.renderer.text(i);
|
|
2910
|
+
break;
|
|
2891
2911
|
}
|
|
2892
2912
|
default:
|
|
2893
2913
|
{
|
|
2894
|
-
let
|
|
2895
|
-
if (this.options.silent) return console.error(
|
|
2896
|
-
throw new Error(
|
|
2914
|
+
let s = 'Token with "' + i.type + '" type was not found.';
|
|
2915
|
+
if (this.options.silent) return console.error(s), "";
|
|
2916
|
+
throw new Error(s);
|
|
2897
2917
|
}
|
|
2898
2918
|
}
|
|
2899
2919
|
}
|
|
2900
|
-
return
|
|
2920
|
+
return t;
|
|
2901
2921
|
}
|
|
2902
2922
|
parseInline(e, t = this.renderer) {
|
|
2903
2923
|
let n = "";
|
|
2904
2924
|
for (let r = 0; r < e.length; r++) {
|
|
2905
2925
|
let i = e[r];
|
|
2906
2926
|
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2907
|
-
let
|
|
2927
|
+
let a = this.options.extensions.renderers[i.type].call({
|
|
2908
2928
|
parser: this
|
|
2909
2929
|
}, i);
|
|
2910
|
-
if (
|
|
2911
|
-
n +=
|
|
2930
|
+
if (a !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
2931
|
+
n += a || "";
|
|
2912
2932
|
continue;
|
|
2913
2933
|
}
|
|
2914
2934
|
}
|
|
@@ -2934,6 +2954,11 @@ var b = class u {
|
|
|
2934
2954
|
n += t.image(s);
|
|
2935
2955
|
break;
|
|
2936
2956
|
}
|
|
2957
|
+
case "checkbox":
|
|
2958
|
+
{
|
|
2959
|
+
n += t.checkbox(s);
|
|
2960
|
+
break;
|
|
2961
|
+
}
|
|
2937
2962
|
case "strong":
|
|
2938
2963
|
{
|
|
2939
2964
|
n += t.strong(s);
|
|
@@ -2966,9 +2991,9 @@ var b = class u {
|
|
|
2966
2991
|
}
|
|
2967
2992
|
default:
|
|
2968
2993
|
{
|
|
2969
|
-
let
|
|
2970
|
-
if (this.options.silent) return console.error(
|
|
2971
|
-
throw new Error(
|
|
2994
|
+
let a = 'Token with "' + s.type + '" type was not found.';
|
|
2995
|
+
if (this.options.silent) return console.error(a), "";
|
|
2996
|
+
throw new Error(a);
|
|
2972
2997
|
}
|
|
2973
2998
|
}
|
|
2974
2999
|
}
|
|
@@ -3023,7 +3048,7 @@ var B = class {
|
|
|
3023
3048
|
{
|
|
3024
3049
|
let i = r;
|
|
3025
3050
|
for (let s of i.header) n = n.concat(this.walkTokens(s.tokens, t));
|
|
3026
|
-
for (let s of i.rows) for (let
|
|
3051
|
+
for (let s of i.rows) for (let a of s) n = n.concat(this.walkTokens(a.tokens, t));
|
|
3027
3052
|
break;
|
|
3028
3053
|
}
|
|
3029
3054
|
case "list":
|
|
@@ -3036,8 +3061,8 @@ var B = class {
|
|
|
3036
3061
|
{
|
|
3037
3062
|
let i = r;
|
|
3038
3063
|
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach(s => {
|
|
3039
|
-
let
|
|
3040
|
-
n = n.concat(this.walkTokens(
|
|
3064
|
+
let a = i[s].flat(1 / 0);
|
|
3065
|
+
n = n.concat(this.walkTokens(a, t));
|
|
3041
3066
|
}) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
|
|
3042
3067
|
}
|
|
3043
3068
|
}
|
|
@@ -3056,9 +3081,9 @@ var B = class {
|
|
|
3056
3081
|
if (!i.name) throw new Error("extension name required");
|
|
3057
3082
|
if ("renderer" in i) {
|
|
3058
3083
|
let s = t.renderers[i.name];
|
|
3059
|
-
s ? t.renderers[i.name] = function (...
|
|
3060
|
-
let
|
|
3061
|
-
return
|
|
3084
|
+
s ? t.renderers[i.name] = function (...a) {
|
|
3085
|
+
let o = i.renderer.apply(this, a);
|
|
3086
|
+
return o === false && (o = s.apply(this, a)), o;
|
|
3062
3087
|
} : t.renderers[i.name] = i.renderer;
|
|
3063
3088
|
}
|
|
3064
3089
|
if ("tokenizer" in i) {
|
|
@@ -3072,12 +3097,12 @@ var B = class {
|
|
|
3072
3097
|
for (let s in n.renderer) {
|
|
3073
3098
|
if (!(s in i)) throw new Error(`renderer '${s}' does not exist`);
|
|
3074
3099
|
if (["options", "parser"].includes(s)) continue;
|
|
3075
|
-
let
|
|
3076
|
-
|
|
3077
|
-
l = i[
|
|
3078
|
-
i[
|
|
3079
|
-
let
|
|
3080
|
-
return
|
|
3100
|
+
let a = s,
|
|
3101
|
+
o = n.renderer[a],
|
|
3102
|
+
l = i[a];
|
|
3103
|
+
i[a] = (...p) => {
|
|
3104
|
+
let c = o.apply(i, p);
|
|
3105
|
+
return c === false && (c = l.apply(i, p)), c || "";
|
|
3081
3106
|
};
|
|
3082
3107
|
}
|
|
3083
3108
|
r.renderer = i;
|
|
@@ -3087,12 +3112,12 @@ var B = class {
|
|
|
3087
3112
|
for (let s in n.tokenizer) {
|
|
3088
3113
|
if (!(s in i)) throw new Error(`tokenizer '${s}' does not exist`);
|
|
3089
3114
|
if (["options", "rules", "lexer"].includes(s)) continue;
|
|
3090
|
-
let
|
|
3091
|
-
|
|
3092
|
-
l = i[
|
|
3093
|
-
i[
|
|
3094
|
-
let
|
|
3095
|
-
return
|
|
3115
|
+
let a = s,
|
|
3116
|
+
o = n.tokenizer[a],
|
|
3117
|
+
l = i[a];
|
|
3118
|
+
i[a] = (...p) => {
|
|
3119
|
+
let c = o.apply(i, p);
|
|
3120
|
+
return c === false && (c = l.apply(i, p)), c;
|
|
3096
3121
|
};
|
|
3097
3122
|
}
|
|
3098
3123
|
r.tokenizer = i;
|
|
@@ -3102,23 +3127,23 @@ var B = class {
|
|
|
3102
3127
|
for (let s in n.hooks) {
|
|
3103
3128
|
if (!(s in i)) throw new Error(`hook '${s}' does not exist`);
|
|
3104
3129
|
if (["options", "block"].includes(s)) continue;
|
|
3105
|
-
let
|
|
3106
|
-
|
|
3107
|
-
l = i[
|
|
3108
|
-
S.passThroughHooks.has(s) ? i[
|
|
3130
|
+
let a = s,
|
|
3131
|
+
o = n.hooks[a],
|
|
3132
|
+
l = i[a];
|
|
3133
|
+
S.passThroughHooks.has(s) ? i[a] = p => {
|
|
3109
3134
|
if (this.defaults.async && S.passThroughHooksRespectAsync.has(s)) return (async () => {
|
|
3110
|
-
let g = await
|
|
3135
|
+
let g = await o.call(i, p);
|
|
3111
3136
|
return l.call(i, g);
|
|
3112
3137
|
})();
|
|
3113
|
-
let
|
|
3114
|
-
return l.call(i,
|
|
3115
|
-
} : i[
|
|
3138
|
+
let c = o.call(i, p);
|
|
3139
|
+
return l.call(i, c);
|
|
3140
|
+
} : i[a] = (...p) => {
|
|
3116
3141
|
if (this.defaults.async) return (async () => {
|
|
3117
|
-
let g = await
|
|
3118
|
-
return g === false && (g = await l.apply(i,
|
|
3142
|
+
let g = await o.apply(i, p);
|
|
3143
|
+
return g === false && (g = await l.apply(i, p)), g;
|
|
3119
3144
|
})();
|
|
3120
|
-
let
|
|
3121
|
-
return
|
|
3145
|
+
let c = o.apply(i, p);
|
|
3146
|
+
return c === false && (c = l.apply(i, p)), c;
|
|
3122
3147
|
};
|
|
3123
3148
|
}
|
|
3124
3149
|
r.hooks = i;
|
|
@@ -3126,9 +3151,9 @@ var B = class {
|
|
|
3126
3151
|
if (n.walkTokens) {
|
|
3127
3152
|
let i = this.defaults.walkTokens,
|
|
3128
3153
|
s = n.walkTokens;
|
|
3129
|
-
r.walkTokens = function (
|
|
3130
|
-
let
|
|
3131
|
-
return
|
|
3154
|
+
r.walkTokens = function (a) {
|
|
3155
|
+
let o = [];
|
|
3156
|
+
return o.push(s.call(this, a)), i && (o = o.concat(i.call(this, a))), o;
|
|
3132
3157
|
};
|
|
3133
3158
|
}
|
|
3134
3159
|
this.defaults = {
|
|
@@ -3158,26 +3183,26 @@ var B = class {
|
|
|
3158
3183
|
...this.defaults,
|
|
3159
3184
|
...i
|
|
3160
3185
|
},
|
|
3161
|
-
|
|
3162
|
-
if (this.defaults.async === true && i.async === false) return
|
|
3163
|
-
if (typeof n > "u" || n === null) return
|
|
3164
|
-
if (typeof n != "string") return
|
|
3186
|
+
a = this.onError(!!s.silent, !!s.async);
|
|
3187
|
+
if (this.defaults.async === true && i.async === false) return a(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."));
|
|
3188
|
+
if (typeof n > "u" || n === null) return a(new Error("marked(): input parameter is undefined or null"));
|
|
3189
|
+
if (typeof n != "string") return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
3165
3190
|
if (s.hooks && (s.hooks.options = s, s.hooks.block = e), s.async) return (async () => {
|
|
3166
|
-
let
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
s.walkTokens && (await Promise.all(this.walkTokens(
|
|
3170
|
-
let
|
|
3171
|
-
return s.hooks ? await s.hooks.postprocess(
|
|
3172
|
-
})().catch(
|
|
3191
|
+
let o = s.hooks ? await s.hooks.preprocess(n) : n,
|
|
3192
|
+
p = await (s.hooks ? await s.hooks.provideLexer() : e ? x.lex : x.lexInline)(o, s),
|
|
3193
|
+
c = s.hooks ? await s.hooks.processAllTokens(p) : p;
|
|
3194
|
+
s.walkTokens && (await Promise.all(this.walkTokens(c, s.walkTokens)));
|
|
3195
|
+
let h = await (s.hooks ? await s.hooks.provideParser() : e ? b.parse : b.parseInline)(c, s);
|
|
3196
|
+
return s.hooks ? await s.hooks.postprocess(h) : h;
|
|
3197
|
+
})().catch(a);
|
|
3173
3198
|
try {
|
|
3174
3199
|
s.hooks && (n = s.hooks.preprocess(n));
|
|
3175
3200
|
let l = (s.hooks ? s.hooks.provideLexer() : e ? x.lex : x.lexInline)(n, s);
|
|
3176
3201
|
s.hooks && (l = s.hooks.processAllTokens(l)), s.walkTokens && this.walkTokens(l, s.walkTokens);
|
|
3177
|
-
let
|
|
3178
|
-
return s.hooks && (
|
|
3179
|
-
} catch (
|
|
3180
|
-
return o
|
|
3202
|
+
let c = (s.hooks ? s.hooks.provideParser() : e ? b.parse : b.parseInline)(l, s);
|
|
3203
|
+
return s.hooks && (c = s.hooks.postprocess(c)), c;
|
|
3204
|
+
} catch (o) {
|
|
3205
|
+
return a(o);
|
|
3181
3206
|
}
|
|
3182
3207
|
};
|
|
3183
3208
|
}
|
|
@@ -3194,30 +3219,43 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
3194
3219
|
}
|
|
3195
3220
|
};
|
|
3196
3221
|
var _ = new B();
|
|
3197
|
-
function
|
|
3222
|
+
function d(u, e) {
|
|
3198
3223
|
return _.parse(u, e);
|
|
3199
3224
|
}
|
|
3200
|
-
|
|
3201
|
-
return _.setOptions(u),
|
|
3225
|
+
d.options = d.setOptions = function (u) {
|
|
3226
|
+
return _.setOptions(u), d.defaults = _.defaults, Z(d.defaults), d;
|
|
3202
3227
|
};
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
return _.use(...u),
|
|
3228
|
+
d.getDefaults = L;
|
|
3229
|
+
d.defaults = T;
|
|
3230
|
+
d.use = function (...u) {
|
|
3231
|
+
return _.use(...u), d.defaults = _.defaults, Z(d.defaults), d;
|
|
3207
3232
|
};
|
|
3208
|
-
|
|
3233
|
+
d.walkTokens = function (u, e) {
|
|
3209
3234
|
return _.walkTokens(u, e);
|
|
3210
3235
|
};
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3236
|
+
d.parseInline = _.parseInline;
|
|
3237
|
+
d.Parser = b;
|
|
3238
|
+
d.parser = b.parse;
|
|
3239
|
+
d.Renderer = P;
|
|
3240
|
+
d.TextRenderer = $;
|
|
3241
|
+
d.Lexer = x;
|
|
3242
|
+
d.lexer = x.lex;
|
|
3243
|
+
d.Tokenizer = y;
|
|
3244
|
+
d.Hooks = S;
|
|
3245
|
+
d.parse = d;
|
|
3246
|
+
|
|
3247
|
+
const joinUrl = (relativePath, baseUrl) => {
|
|
3248
|
+
if (relativePath.startsWith('http:') || relativePath.startsWith('https:')) {
|
|
3249
|
+
return relativePath;
|
|
3250
|
+
}
|
|
3251
|
+
if (relativePath.startsWith('./')) {
|
|
3252
|
+
if (baseUrl.endsWith('/')) {
|
|
3253
|
+
return `${baseUrl}${relativePath.slice(2)}`;
|
|
3254
|
+
}
|
|
3255
|
+
return `${baseUrl}/${relativePath.slice(2)}`;
|
|
3256
|
+
}
|
|
3257
|
+
return `${baseUrl}/${relativePath}`;
|
|
3258
|
+
};
|
|
3221
3259
|
|
|
3222
3260
|
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
3223
3261
|
const RE_LINK_START = /^<a /;
|
|
@@ -3237,12 +3275,12 @@ const renderMarkdown$1 = async (markdown, options = {}) => {
|
|
|
3237
3275
|
if (baseUrl) {
|
|
3238
3276
|
const imageRenderer = renderer.image.bind(renderer);
|
|
3239
3277
|
renderer.image = image => {
|
|
3240
|
-
image.href =
|
|
3278
|
+
image.href = joinUrl(image.href, baseUrl);
|
|
3241
3279
|
const html = imageRenderer(image);
|
|
3242
3280
|
return html;
|
|
3243
3281
|
};
|
|
3244
3282
|
}
|
|
3245
|
-
const html = await
|
|
3283
|
+
const html = await d(markdown, {
|
|
3246
3284
|
renderer
|
|
3247
3285
|
});
|
|
3248
3286
|
return html;
|
|
@@ -3258,6 +3296,11 @@ const commandMap = {
|
|
|
3258
3296
|
'Markdown.terminate': terminate
|
|
3259
3297
|
};
|
|
3260
3298
|
|
|
3299
|
+
const Script = 2;
|
|
3300
|
+
|
|
3301
|
+
const DebugWorker = 55;
|
|
3302
|
+
const RendererWorker$1 = 1;
|
|
3303
|
+
|
|
3261
3304
|
const rpcs = Object.create(null);
|
|
3262
3305
|
const set$2 = (id, rpc) => {
|
|
3263
3306
|
rpcs[id] = rpc;
|
|
@@ -3268,6 +3311,10 @@ const get = id => {
|
|
|
3268
3311
|
|
|
3269
3312
|
const create = rpcId => {
|
|
3270
3313
|
return {
|
|
3314
|
+
async dispose() {
|
|
3315
|
+
const rpc = get(rpcId);
|
|
3316
|
+
await rpc.dispose();
|
|
3317
|
+
},
|
|
3271
3318
|
// @ts-ignore
|
|
3272
3319
|
invoke(method, ...params) {
|
|
3273
3320
|
const rpc = get(rpcId);
|
|
@@ -3282,19 +3329,15 @@ const create = rpcId => {
|
|
|
3282
3329
|
},
|
|
3283
3330
|
set(rpc) {
|
|
3284
3331
|
set$2(rpcId, rpc);
|
|
3285
|
-
},
|
|
3286
|
-
async dispose() {
|
|
3287
|
-
const rpc = get(rpcId);
|
|
3288
|
-
await rpc.dispose();
|
|
3289
3332
|
}
|
|
3290
3333
|
};
|
|
3291
3334
|
};
|
|
3292
3335
|
|
|
3293
3336
|
const {
|
|
3337
|
+
dispose,
|
|
3294
3338
|
invoke,
|
|
3295
3339
|
invokeAndTransfer,
|
|
3296
|
-
set: set$1
|
|
3297
|
-
dispose
|
|
3340
|
+
set: set$1
|
|
3298
3341
|
} = create(RendererWorker$1);
|
|
3299
3342
|
const searchFileHtml = async uri => {
|
|
3300
3343
|
return invoke('ExtensionHost.searchFileWithHtml', uri);
|
|
@@ -3302,9 +3345,20 @@ const searchFileHtml = async uri => {
|
|
|
3302
3345
|
const getFilePathElectron = async file => {
|
|
3303
3346
|
return invoke('FileSystemHandle.getFilePathElectron', file);
|
|
3304
3347
|
};
|
|
3348
|
+
/**
|
|
3349
|
+
* @deprecated
|
|
3350
|
+
*/
|
|
3305
3351
|
const showContextMenu = async (x, y, id, ...args) => {
|
|
3306
3352
|
return invoke('ContextMenu.show', x, y, id, ...args);
|
|
3307
3353
|
};
|
|
3354
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
3355
|
+
number(uid);
|
|
3356
|
+
number(menuId);
|
|
3357
|
+
number(x);
|
|
3358
|
+
number(y);
|
|
3359
|
+
// @ts-ignore
|
|
3360
|
+
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
3361
|
+
};
|
|
3308
3362
|
const getElectronVersion = async () => {
|
|
3309
3363
|
return invoke('Process.getElectronVersion');
|
|
3310
3364
|
};
|
|
@@ -3396,6 +3450,9 @@ const handleDebugChange = async params => {
|
|
|
3396
3450
|
const getFolderIcon = async options => {
|
|
3397
3451
|
return invoke('IconTheme.getFolderIcon', options);
|
|
3398
3452
|
};
|
|
3453
|
+
const handleWorkspaceRefresh = async () => {
|
|
3454
|
+
return invoke('Layout.handleWorkspaceRefresh');
|
|
3455
|
+
};
|
|
3399
3456
|
const closeWidget = async widgetId => {
|
|
3400
3457
|
return invoke('Viewlet.closeWidget', widgetId);
|
|
3401
3458
|
};
|
|
@@ -3420,6 +3477,9 @@ const getKeyBindings = async () => {
|
|
|
3420
3477
|
const writeClipBoardText = async text => {
|
|
3421
3478
|
await invoke('ClipBoard.writeText', /* text */text);
|
|
3422
3479
|
};
|
|
3480
|
+
const readClipBoardText = async () => {
|
|
3481
|
+
return invoke('ClipBoard.readText');
|
|
3482
|
+
};
|
|
3423
3483
|
const writeClipBoardImage = async blob => {
|
|
3424
3484
|
// @ts-ignore
|
|
3425
3485
|
await invoke('ClipBoard.writeImage', /* text */blob);
|
|
@@ -3444,8 +3504,8 @@ const getIcons = async requests => {
|
|
|
3444
3504
|
const icons = await invoke('IconTheme.getIcons', requests);
|
|
3445
3505
|
return icons;
|
|
3446
3506
|
};
|
|
3447
|
-
const activateByEvent = event => {
|
|
3448
|
-
return invoke('ExtensionHostManagement.activateByEvent', event);
|
|
3507
|
+
const activateByEvent = (event, assetDir, platform) => {
|
|
3508
|
+
return invoke('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
3449
3509
|
};
|
|
3450
3510
|
const setAdditionalFocus = focusKey => {
|
|
3451
3511
|
// @ts-ignore
|
|
@@ -3463,6 +3523,33 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
3463
3523
|
// @ts-ignore
|
|
3464
3524
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
3465
3525
|
};
|
|
3526
|
+
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
3527
|
+
const command = 'TextMeasurement.handleMessagePort';
|
|
3528
|
+
// @ts-ignore
|
|
3529
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
3530
|
+
};
|
|
3531
|
+
const sendMessagePortToSourceControlWorker = async port => {
|
|
3532
|
+
const command = 'SourceControl.handleMessagePort';
|
|
3533
|
+
// @ts-ignore
|
|
3534
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
3535
|
+
};
|
|
3536
|
+
const sendMessagePortToSharedProcess = async port => {
|
|
3537
|
+
const command = 'HandleElectronMessagePort.handleElectronMessagePort';
|
|
3538
|
+
// @ts-ignore
|
|
3539
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, 0);
|
|
3540
|
+
};
|
|
3541
|
+
const sendMessagePortToFileSystemProcess = async (port, rpcId) => {
|
|
3542
|
+
const command = 'HandleMessagePortForFileSystemProcess.handleMessagePortForFileSystemProcess';
|
|
3543
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSharedProcess', port, command, rpcId);
|
|
3544
|
+
};
|
|
3545
|
+
const sendMessagePortToIframeWorker = async (port, rpcId) => {
|
|
3546
|
+
const command = 'Iframes.handleMessagePort';
|
|
3547
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
3548
|
+
};
|
|
3549
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
3550
|
+
const command = 'Extensions.handleMessagePort';
|
|
3551
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
3552
|
+
};
|
|
3466
3553
|
const getPreference = async key => {
|
|
3467
3554
|
return await invoke('Preferences.get', key);
|
|
3468
3555
|
};
|
|
@@ -3528,13 +3615,29 @@ const installExtension = async id => {
|
|
|
3528
3615
|
// @ts-ignore
|
|
3529
3616
|
return invoke('ExtensionManagement.install', id);
|
|
3530
3617
|
};
|
|
3618
|
+
const minimizeWindow = async () => {
|
|
3619
|
+
// @ts-ignore
|
|
3620
|
+
return invoke('ElectronWindow.minimize');
|
|
3621
|
+
};
|
|
3622
|
+
const unmaximizeWindow = async () => {
|
|
3623
|
+
// @ts-ignore
|
|
3624
|
+
return invoke('ElectronWindow.unmaximize');
|
|
3625
|
+
};
|
|
3626
|
+
const maximizeWindow = async () => {
|
|
3627
|
+
// @ts-ignore
|
|
3628
|
+
return invoke('ElectronWindow.maximize');
|
|
3629
|
+
};
|
|
3630
|
+
const closeWindow = async () => {
|
|
3631
|
+
// @ts-ignore
|
|
3632
|
+
return invoke('ElectronWindow.close');
|
|
3633
|
+
};
|
|
3531
3634
|
const openExtensionSearch = async () => {
|
|
3532
3635
|
// @ts-ignore
|
|
3533
3636
|
return invoke('SideBar.openViewlet', 'Extensions');
|
|
3534
3637
|
};
|
|
3535
3638
|
const setExtensionsSearchValue = async searchValue => {
|
|
3536
3639
|
// @ts-ignore
|
|
3537
|
-
return invoke('Extensions.handleInput', searchValue);
|
|
3640
|
+
return invoke('Extensions.handleInput', searchValue, Script);
|
|
3538
3641
|
};
|
|
3539
3642
|
const openExternal = async uri => {
|
|
3540
3643
|
// @ts-ignore
|
|
@@ -3556,6 +3659,9 @@ const getLogsDir = async () => {
|
|
|
3556
3659
|
// @ts-ignore
|
|
3557
3660
|
return invoke('PlatformPaths.getLogsDir');
|
|
3558
3661
|
};
|
|
3662
|
+
const measureTextBlockHeight = async (actualInput, fontFamily, fontSize, lineHeightPx, width) => {
|
|
3663
|
+
return invoke(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
3664
|
+
};
|
|
3559
3665
|
const registerMockRpc = commandMap => {
|
|
3560
3666
|
const mockRpc = createMockRpc({
|
|
3561
3667
|
commandMap
|
|
@@ -3569,6 +3675,7 @@ const RendererWorker = {
|
|
|
3569
3675
|
activateByEvent,
|
|
3570
3676
|
applyBulkReplacement,
|
|
3571
3677
|
closeWidget,
|
|
3678
|
+
closeWindow,
|
|
3572
3679
|
confirm,
|
|
3573
3680
|
disableExtension,
|
|
3574
3681
|
dispose,
|
|
@@ -3602,15 +3709,20 @@ const RendererWorker = {
|
|
|
3602
3709
|
handleDebugPaused,
|
|
3603
3710
|
handleDebugResumed,
|
|
3604
3711
|
handleDebugScriptParsed,
|
|
3712
|
+
handleWorkspaceRefresh,
|
|
3605
3713
|
installExtension,
|
|
3606
3714
|
invoke,
|
|
3607
3715
|
invokeAndTransfer,
|
|
3716
|
+
maximizeWindow,
|
|
3717
|
+
measureTextBlockHeight,
|
|
3718
|
+
minimizeWindow,
|
|
3608
3719
|
openExtensionSearch,
|
|
3609
3720
|
openExternal,
|
|
3610
3721
|
openNativeFolder,
|
|
3611
3722
|
openUri,
|
|
3612
3723
|
openUrl,
|
|
3613
3724
|
openWidget,
|
|
3725
|
+
readClipBoardText,
|
|
3614
3726
|
readFile,
|
|
3615
3727
|
registerMockRpc,
|
|
3616
3728
|
registerWebViewInterceptor,
|
|
@@ -3622,12 +3734,18 @@ const RendererWorker = {
|
|
|
3622
3734
|
sendMessagePortToEditorWorker,
|
|
3623
3735
|
sendMessagePortToErrorWorker,
|
|
3624
3736
|
sendMessagePortToExtensionHostWorker,
|
|
3737
|
+
sendMessagePortToExtensionManagementWorker,
|
|
3738
|
+
sendMessagePortToFileSystemProcess,
|
|
3625
3739
|
sendMessagePortToFileSystemWorker,
|
|
3626
3740
|
sendMessagePortToIconThemeWorker,
|
|
3741
|
+
sendMessagePortToIframeWorker,
|
|
3627
3742
|
sendMessagePortToMarkdownWorker,
|
|
3628
3743
|
sendMessagePortToRendererProcess,
|
|
3629
3744
|
sendMessagePortToSearchProcess,
|
|
3745
|
+
sendMessagePortToSharedProcess,
|
|
3746
|
+
sendMessagePortToSourceControlWorker,
|
|
3630
3747
|
sendMessagePortToSyntaxHighlightingWorker,
|
|
3748
|
+
sendMessagePortToTextMeasurementWorker,
|
|
3631
3749
|
set: set$1,
|
|
3632
3750
|
setAdditionalFocus,
|
|
3633
3751
|
setColorTheme,
|
|
@@ -3636,10 +3754,12 @@ const RendererWorker = {
|
|
|
3636
3754
|
setWebViewPort,
|
|
3637
3755
|
setWorkspacePath,
|
|
3638
3756
|
showContextMenu,
|
|
3757
|
+
showContextMenu2,
|
|
3639
3758
|
showErrorDialog,
|
|
3640
3759
|
showMessageBox,
|
|
3641
3760
|
showSaveFilePicker,
|
|
3642
3761
|
uninstallExtension,
|
|
3762
|
+
unmaximizeWindow,
|
|
3643
3763
|
unregisterWebViewInterceptor,
|
|
3644
3764
|
writeClipBoardImage,
|
|
3645
3765
|
writeClipBoardText
|