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