@isdk/mdast-plus 0.1.2 → 0.2.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/README.cn.md +69 -22
- package/README.md +69 -22
- package/dist/index.d.mts +564 -199
- package/dist/index.d.ts +564 -199
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/README.md +69 -22
- package/docs/_media/CONTRIBUTING.md +53 -24
- package/docs/_media/README.cn.md +69 -22
- package/docs/classes/MdastBasePipeline.md +416 -0
- package/docs/classes/MdastPipeline.md +611 -0
- package/docs/enumerations/PipelineStage.md +62 -0
- package/docs/functions/astCompiler.md +25 -0
- package/docs/functions/jsonParser.md +24 -0
- package/docs/functions/mdast.md +4 -4
- package/docs/globals.md +17 -10
- package/docs/interfaces/MdastDataOrigin.md +8 -8
- package/docs/interfaces/MdastFormat.md +71 -0
- package/docs/interfaces/MdastMark.md +4 -4
- package/docs/interfaces/MdastPlugin.md +57 -25
- package/docs/interfaces/MdastSub.md +4 -4
- package/docs/interfaces/MdastSup.md +4 -4
- package/docs/interfaces/ReadabilityOptions.md +33 -0
- package/docs/type-aliases/PipelineStageName.md +13 -0
- package/docs/variables/DefaultPipelineStage.md +13 -0
- package/docs/variables/astFormat.md +15 -0
- package/docs/variables/htmlFormat.md +6 -4
- package/docs/variables/htmlReadability.md +13 -0
- package/docs/variables/htmlReadabilityPlugin.md +27 -0
- package/docs/variables/htmlReadabilityPlugins.md +13 -0
- package/docs/variables/markdownFormat.md +6 -4
- package/docs/variables/restoreReadabilityMetaPlugin.md +49 -0
- package/package.json +18 -9
- package/docs/classes/FluentProcessor.md +0 -210
- package/docs/functions/htmlStringify.md +0 -23
- package/docs/functions/markdownCommon.md +0 -23
- package/docs/interfaces/ConvertResult.md +0 -39
- package/docs/interfaces/MdastAsset.md +0 -41
- package/docs/interfaces/MdastFormatDefinition.md +0 -51
- package/docs/interfaces/MdastReader.md +0 -41
- package/docs/interfaces/MdastTransformer.md +0 -33
- package/docs/interfaces/MdastWriter.md +0 -47
- package/docs/type-aliases/Stage.md +0 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Plugin, Processor } from 'unified';
|
|
2
|
+
import { VFileCompatible, VFile } from 'vfile';
|
|
3
|
+
|
|
1
4
|
// ## Interfaces
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
* }
|
|
20
23
|
* ```
|
|
21
24
|
*/
|
|
22
|
-
interface Data$
|
|
25
|
+
interface Data$2 {}
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* One place in a source file.
|
|
@@ -67,7 +70,7 @@ interface Position {
|
|
|
67
70
|
* But for example in markdown, a `thematicBreak` (`***`), is neither literal
|
|
68
71
|
* nor parent, but still a node.
|
|
69
72
|
*/
|
|
70
|
-
interface Node$
|
|
73
|
+
interface Node$2 {
|
|
71
74
|
/**
|
|
72
75
|
* Node type.
|
|
73
76
|
*/
|
|
@@ -76,7 +79,7 @@ interface Node$1 {
|
|
|
76
79
|
/**
|
|
77
80
|
* Info from the ecosystem.
|
|
78
81
|
*/
|
|
79
|
-
data?: Data$
|
|
82
|
+
data?: Data$2 | undefined;
|
|
80
83
|
|
|
81
84
|
/**
|
|
82
85
|
* Position of a node in a source document.
|
|
@@ -95,11 +98,11 @@ interface Node$1 {
|
|
|
95
98
|
* For example, in XML, an element is a parent of different things, such as
|
|
96
99
|
* comments, text, and further elements.
|
|
97
100
|
*/
|
|
98
|
-
interface Parent$
|
|
101
|
+
interface Parent$2 extends Node$2 {
|
|
99
102
|
/**
|
|
100
103
|
* List of children.
|
|
101
104
|
*/
|
|
102
|
-
children: Node$
|
|
105
|
+
children: Node$2[];
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
// ## Enumeration
|
|
@@ -229,7 +232,7 @@ interface Resource {
|
|
|
229
232
|
* }
|
|
230
233
|
* ```
|
|
231
234
|
*/
|
|
232
|
-
interface Data extends Data$
|
|
235
|
+
interface Data$1 extends Data$2 {}
|
|
233
236
|
|
|
234
237
|
// ## Content maps
|
|
235
238
|
|
|
@@ -367,7 +370,7 @@ interface PhrasingContentMap {
|
|
|
367
370
|
link: Link;
|
|
368
371
|
linkReference: LinkReference;
|
|
369
372
|
strong: Strong;
|
|
370
|
-
text: Text;
|
|
373
|
+
text: Text$1;
|
|
371
374
|
}
|
|
372
375
|
|
|
373
376
|
/**
|
|
@@ -376,7 +379,7 @@ interface PhrasingContentMap {
|
|
|
376
379
|
* To register custom mdast nodes, add them to {@link RootContentMap}.
|
|
377
380
|
* They will be automatically added here.
|
|
378
381
|
*/
|
|
379
|
-
type RootContent = RootContentMap[keyof RootContentMap];
|
|
382
|
+
type RootContent$1 = RootContentMap$1[keyof RootContentMap$1];
|
|
380
383
|
|
|
381
384
|
/**
|
|
382
385
|
* Registry of all mdast nodes that can occur as children of {@link Root}.
|
|
@@ -397,7 +400,7 @@ type RootContent = RootContentMap[keyof RootContentMap];
|
|
|
397
400
|
*
|
|
398
401
|
* For a union of all {@link Root} children, see {@link RootContent}.
|
|
399
402
|
*/
|
|
400
|
-
interface RootContentMap {
|
|
403
|
+
interface RootContentMap$1 {
|
|
401
404
|
blockquote: Blockquote;
|
|
402
405
|
break: Break;
|
|
403
406
|
code: Code;
|
|
@@ -420,7 +423,7 @@ interface RootContentMap {
|
|
|
420
423
|
table: Table;
|
|
421
424
|
tableCell: TableCell;
|
|
422
425
|
tableRow: TableRow;
|
|
423
|
-
text: Text;
|
|
426
|
+
text: Text$1;
|
|
424
427
|
thematicBreak: ThematicBreak;
|
|
425
428
|
yaml: Yaml;
|
|
426
429
|
}
|
|
@@ -492,7 +495,7 @@ interface TableContentMap {
|
|
|
492
495
|
*
|
|
493
496
|
* For a union of all registered mdast literals, see {@link Literals}.
|
|
494
497
|
*/
|
|
495
|
-
interface Literal extends Node {
|
|
498
|
+
interface Literal$1 extends Node$1 {
|
|
496
499
|
/**
|
|
497
500
|
* Plain-text value.
|
|
498
501
|
*/
|
|
@@ -512,11 +515,11 @@ interface Literal extends Node {
|
|
|
512
515
|
*
|
|
513
516
|
* For a union of all registered mdast nodes, see {@link Nodes}.
|
|
514
517
|
*/
|
|
515
|
-
interface Node extends Node$
|
|
518
|
+
interface Node$1 extends Node$2 {
|
|
516
519
|
/**
|
|
517
520
|
* Info from the ecosystem.
|
|
518
521
|
*/
|
|
519
|
-
data?: Data | undefined;
|
|
522
|
+
data?: Data$1 | undefined;
|
|
520
523
|
}
|
|
521
524
|
|
|
522
525
|
/**
|
|
@@ -526,11 +529,11 @@ interface Node extends Node$1 {
|
|
|
526
529
|
*
|
|
527
530
|
* For a union of all registered mdast parents, see {@link Parents}.
|
|
528
531
|
*/
|
|
529
|
-
interface Parent extends Node {
|
|
532
|
+
interface Parent$1 extends Node$1 {
|
|
530
533
|
/**
|
|
531
534
|
* List of children.
|
|
532
535
|
*/
|
|
533
|
-
children: RootContent[];
|
|
536
|
+
children: RootContent$1[];
|
|
534
537
|
}
|
|
535
538
|
|
|
536
539
|
// ## Concrete nodes
|
|
@@ -538,7 +541,7 @@ interface Parent extends Node {
|
|
|
538
541
|
/**
|
|
539
542
|
* Markdown block quote.
|
|
540
543
|
*/
|
|
541
|
-
interface Blockquote extends Parent {
|
|
544
|
+
interface Blockquote extends Parent$1 {
|
|
542
545
|
/**
|
|
543
546
|
* Node type of mdast block quote.
|
|
544
547
|
*/
|
|
@@ -556,12 +559,12 @@ interface Blockquote extends Parent {
|
|
|
556
559
|
/**
|
|
557
560
|
* Info associated with mdast block quote nodes by the ecosystem.
|
|
558
561
|
*/
|
|
559
|
-
interface BlockquoteData extends Data {}
|
|
562
|
+
interface BlockquoteData extends Data$1 {}
|
|
560
563
|
|
|
561
564
|
/**
|
|
562
565
|
* Markdown break.
|
|
563
566
|
*/
|
|
564
|
-
interface Break extends Node {
|
|
567
|
+
interface Break extends Node$1 {
|
|
565
568
|
/**
|
|
566
569
|
* Node type of mdast break.
|
|
567
570
|
*/
|
|
@@ -575,12 +578,12 @@ interface Break extends Node {
|
|
|
575
578
|
/**
|
|
576
579
|
* Info associated with mdast break nodes by the ecosystem.
|
|
577
580
|
*/
|
|
578
|
-
interface BreakData extends Data {}
|
|
581
|
+
interface BreakData extends Data$1 {}
|
|
579
582
|
|
|
580
583
|
/**
|
|
581
584
|
* Markdown code (flow) (block).
|
|
582
585
|
*/
|
|
583
|
-
interface Code extends Literal {
|
|
586
|
+
interface Code extends Literal$1 {
|
|
584
587
|
/**
|
|
585
588
|
* Node type of mdast code (flow).
|
|
586
589
|
*/
|
|
@@ -604,12 +607,12 @@ interface Code extends Literal {
|
|
|
604
607
|
/**
|
|
605
608
|
* Info associated with mdast code (flow) (block) nodes by the ecosystem.
|
|
606
609
|
*/
|
|
607
|
-
interface CodeData extends Data {}
|
|
610
|
+
interface CodeData extends Data$1 {}
|
|
608
611
|
|
|
609
612
|
/**
|
|
610
613
|
* Markdown definition.
|
|
611
614
|
*/
|
|
612
|
-
interface Definition extends Node, Association, Resource {
|
|
615
|
+
interface Definition extends Node$1, Association, Resource {
|
|
613
616
|
/**
|
|
614
617
|
* Node type of mdast definition.
|
|
615
618
|
*/
|
|
@@ -623,12 +626,12 @@ interface Definition extends Node, Association, Resource {
|
|
|
623
626
|
/**
|
|
624
627
|
* Info associated with mdast definition nodes by the ecosystem.
|
|
625
628
|
*/
|
|
626
|
-
interface DefinitionData extends Data {}
|
|
629
|
+
interface DefinitionData extends Data$1 {}
|
|
627
630
|
|
|
628
631
|
/**
|
|
629
632
|
* Markdown GFM delete (strikethrough).
|
|
630
633
|
*/
|
|
631
|
-
interface Delete extends Parent {
|
|
634
|
+
interface Delete extends Parent$1 {
|
|
632
635
|
/**
|
|
633
636
|
* Node type of mdast GFM delete.
|
|
634
637
|
*/
|
|
@@ -646,12 +649,12 @@ interface Delete extends Parent {
|
|
|
646
649
|
/**
|
|
647
650
|
* Info associated with mdast GFM delete nodes by the ecosystem.
|
|
648
651
|
*/
|
|
649
|
-
interface DeleteData extends Data {}
|
|
652
|
+
interface DeleteData extends Data$1 {}
|
|
650
653
|
|
|
651
654
|
/**
|
|
652
655
|
* Markdown emphasis.
|
|
653
656
|
*/
|
|
654
|
-
interface Emphasis extends Parent {
|
|
657
|
+
interface Emphasis extends Parent$1 {
|
|
655
658
|
/**
|
|
656
659
|
* Node type of mdast emphasis.
|
|
657
660
|
*/
|
|
@@ -669,12 +672,12 @@ interface Emphasis extends Parent {
|
|
|
669
672
|
/**
|
|
670
673
|
* Info associated with mdast emphasis nodes by the ecosystem.
|
|
671
674
|
*/
|
|
672
|
-
interface EmphasisData extends Data {}
|
|
675
|
+
interface EmphasisData extends Data$1 {}
|
|
673
676
|
|
|
674
677
|
/**
|
|
675
678
|
* Markdown GFM footnote definition.
|
|
676
679
|
*/
|
|
677
|
-
interface FootnoteDefinition extends Parent, Association {
|
|
680
|
+
interface FootnoteDefinition extends Parent$1, Association {
|
|
678
681
|
/**
|
|
679
682
|
* Node type of mdast GFM footnote definition.
|
|
680
683
|
*/
|
|
@@ -692,12 +695,12 @@ interface FootnoteDefinition extends Parent, Association {
|
|
|
692
695
|
/**
|
|
693
696
|
* Info associated with mdast GFM footnote definition nodes by the ecosystem.
|
|
694
697
|
*/
|
|
695
|
-
interface FootnoteDefinitionData extends Data {}
|
|
698
|
+
interface FootnoteDefinitionData extends Data$1 {}
|
|
696
699
|
|
|
697
700
|
/**
|
|
698
701
|
* Markdown GFM footnote reference.
|
|
699
702
|
*/
|
|
700
|
-
interface FootnoteReference extends Association, Node {
|
|
703
|
+
interface FootnoteReference extends Association, Node$1 {
|
|
701
704
|
/**
|
|
702
705
|
* Node type of mdast GFM footnote reference.
|
|
703
706
|
*/
|
|
@@ -711,12 +714,12 @@ interface FootnoteReference extends Association, Node {
|
|
|
711
714
|
/**
|
|
712
715
|
* Info associated with mdast GFM footnote reference nodes by the ecosystem.
|
|
713
716
|
*/
|
|
714
|
-
interface FootnoteReferenceData extends Data {}
|
|
717
|
+
interface FootnoteReferenceData extends Data$1 {}
|
|
715
718
|
|
|
716
719
|
/**
|
|
717
720
|
* Markdown heading.
|
|
718
721
|
*/
|
|
719
|
-
interface Heading extends Parent {
|
|
722
|
+
interface Heading extends Parent$1 {
|
|
720
723
|
/**
|
|
721
724
|
* Node type of mdast heading.
|
|
722
725
|
*/
|
|
@@ -740,12 +743,12 @@ interface Heading extends Parent {
|
|
|
740
743
|
/**
|
|
741
744
|
* Info associated with mdast heading nodes by the ecosystem.
|
|
742
745
|
*/
|
|
743
|
-
interface HeadingData extends Data {}
|
|
746
|
+
interface HeadingData extends Data$1 {}
|
|
744
747
|
|
|
745
748
|
/**
|
|
746
749
|
* Markdown HTML.
|
|
747
750
|
*/
|
|
748
|
-
interface Html extends Literal {
|
|
751
|
+
interface Html extends Literal$1 {
|
|
749
752
|
/**
|
|
750
753
|
* Node type of mdast HTML.
|
|
751
754
|
*/
|
|
@@ -759,12 +762,12 @@ interface Html extends Literal {
|
|
|
759
762
|
/**
|
|
760
763
|
* Info associated with mdast HTML nodes by the ecosystem.
|
|
761
764
|
*/
|
|
762
|
-
interface HtmlData extends Data {}
|
|
765
|
+
interface HtmlData extends Data$1 {}
|
|
763
766
|
|
|
764
767
|
/**
|
|
765
768
|
* Markdown image.
|
|
766
769
|
*/
|
|
767
|
-
interface Image extends Alternative, Node, Resource {
|
|
770
|
+
interface Image extends Alternative, Node$1, Resource {
|
|
768
771
|
/**
|
|
769
772
|
* Node type of mdast image.
|
|
770
773
|
*/
|
|
@@ -778,12 +781,12 @@ interface Image extends Alternative, Node, Resource {
|
|
|
778
781
|
/**
|
|
779
782
|
* Info associated with mdast image nodes by the ecosystem.
|
|
780
783
|
*/
|
|
781
|
-
interface ImageData extends Data {}
|
|
784
|
+
interface ImageData extends Data$1 {}
|
|
782
785
|
|
|
783
786
|
/**
|
|
784
787
|
* Markdown image reference.
|
|
785
788
|
*/
|
|
786
|
-
interface ImageReference extends Alternative, Node, Reference {
|
|
789
|
+
interface ImageReference extends Alternative, Node$1, Reference {
|
|
787
790
|
/**
|
|
788
791
|
* Node type of mdast image reference.
|
|
789
792
|
*/
|
|
@@ -797,12 +800,12 @@ interface ImageReference extends Alternative, Node, Reference {
|
|
|
797
800
|
/**
|
|
798
801
|
* Info associated with mdast image reference nodes by the ecosystem.
|
|
799
802
|
*/
|
|
800
|
-
interface ImageReferenceData extends Data {}
|
|
803
|
+
interface ImageReferenceData extends Data$1 {}
|
|
801
804
|
|
|
802
805
|
/**
|
|
803
806
|
* Markdown code (text) (inline).
|
|
804
807
|
*/
|
|
805
|
-
interface InlineCode extends Literal {
|
|
808
|
+
interface InlineCode extends Literal$1 {
|
|
806
809
|
/**
|
|
807
810
|
* Node type of mdast code (text).
|
|
808
811
|
*/
|
|
@@ -816,12 +819,12 @@ interface InlineCode extends Literal {
|
|
|
816
819
|
/**
|
|
817
820
|
* Info associated with mdast code (text) (inline) nodes by the ecosystem.
|
|
818
821
|
*/
|
|
819
|
-
interface InlineCodeData extends Data {}
|
|
822
|
+
interface InlineCodeData extends Data$1 {}
|
|
820
823
|
|
|
821
824
|
/**
|
|
822
825
|
* Markdown link.
|
|
823
826
|
*/
|
|
824
|
-
interface Link extends Parent, Resource {
|
|
827
|
+
interface Link extends Parent$1, Resource {
|
|
825
828
|
/**
|
|
826
829
|
* Node type of mdast link.
|
|
827
830
|
*/
|
|
@@ -839,12 +842,12 @@ interface Link extends Parent, Resource {
|
|
|
839
842
|
/**
|
|
840
843
|
* Info associated with mdast link nodes by the ecosystem.
|
|
841
844
|
*/
|
|
842
|
-
interface LinkData extends Data {}
|
|
845
|
+
interface LinkData extends Data$1 {}
|
|
843
846
|
|
|
844
847
|
/**
|
|
845
848
|
* Markdown link reference.
|
|
846
849
|
*/
|
|
847
|
-
interface LinkReference extends Parent, Reference {
|
|
850
|
+
interface LinkReference extends Parent$1, Reference {
|
|
848
851
|
/**
|
|
849
852
|
* Node type of mdast link reference.
|
|
850
853
|
*/
|
|
@@ -862,12 +865,12 @@ interface LinkReference extends Parent, Reference {
|
|
|
862
865
|
/**
|
|
863
866
|
* Info associated with mdast link reference nodes by the ecosystem.
|
|
864
867
|
*/
|
|
865
|
-
interface LinkReferenceData extends Data {}
|
|
868
|
+
interface LinkReferenceData extends Data$1 {}
|
|
866
869
|
|
|
867
870
|
/**
|
|
868
871
|
* Markdown list.
|
|
869
872
|
*/
|
|
870
|
-
interface List extends Parent {
|
|
873
|
+
interface List extends Parent$1 {
|
|
871
874
|
/**
|
|
872
875
|
* Node type of mdast list.
|
|
873
876
|
*/
|
|
@@ -899,12 +902,12 @@ interface List extends Parent {
|
|
|
899
902
|
/**
|
|
900
903
|
* Info associated with mdast list nodes by the ecosystem.
|
|
901
904
|
*/
|
|
902
|
-
interface ListData extends Data {}
|
|
905
|
+
interface ListData extends Data$1 {}
|
|
903
906
|
|
|
904
907
|
/**
|
|
905
908
|
* Markdown list item.
|
|
906
909
|
*/
|
|
907
|
-
interface ListItem extends Parent {
|
|
910
|
+
interface ListItem extends Parent$1 {
|
|
908
911
|
/**
|
|
909
912
|
* Node type of mdast list item.
|
|
910
913
|
*/
|
|
@@ -934,12 +937,12 @@ interface ListItem extends Parent {
|
|
|
934
937
|
/**
|
|
935
938
|
* Info associated with mdast list item nodes by the ecosystem.
|
|
936
939
|
*/
|
|
937
|
-
interface ListItemData extends Data {}
|
|
940
|
+
interface ListItemData extends Data$1 {}
|
|
938
941
|
|
|
939
942
|
/**
|
|
940
943
|
* Markdown paragraph.
|
|
941
944
|
*/
|
|
942
|
-
interface Paragraph extends Parent {
|
|
945
|
+
interface Paragraph extends Parent$1 {
|
|
943
946
|
/**
|
|
944
947
|
* Node type of mdast paragraph.
|
|
945
948
|
*/
|
|
@@ -957,14 +960,14 @@ interface Paragraph extends Parent {
|
|
|
957
960
|
/**
|
|
958
961
|
* Info associated with mdast paragraph nodes by the ecosystem.
|
|
959
962
|
*/
|
|
960
|
-
interface ParagraphData extends Data {}
|
|
963
|
+
interface ParagraphData extends Data$1 {}
|
|
961
964
|
|
|
962
965
|
/**
|
|
963
966
|
* Document fragment or a whole document.
|
|
964
967
|
*
|
|
965
968
|
* Should be used as the root of a tree and must not be used as a child.
|
|
966
969
|
*/
|
|
967
|
-
interface Root extends Parent {
|
|
970
|
+
interface Root$1 extends Parent$1 {
|
|
968
971
|
/**
|
|
969
972
|
* Node type of mdast root.
|
|
970
973
|
*/
|
|
@@ -972,18 +975,18 @@ interface Root extends Parent {
|
|
|
972
975
|
/**
|
|
973
976
|
* Data associated with the mdast root.
|
|
974
977
|
*/
|
|
975
|
-
data?: RootData | undefined;
|
|
978
|
+
data?: RootData$1 | undefined;
|
|
976
979
|
}
|
|
977
980
|
|
|
978
981
|
/**
|
|
979
982
|
* Info associated with mdast root nodes by the ecosystem.
|
|
980
983
|
*/
|
|
981
|
-
interface RootData extends Data {}
|
|
984
|
+
interface RootData$1 extends Data$1 {}
|
|
982
985
|
|
|
983
986
|
/**
|
|
984
987
|
* Markdown strong.
|
|
985
988
|
*/
|
|
986
|
-
interface Strong extends Parent {
|
|
989
|
+
interface Strong extends Parent$1 {
|
|
987
990
|
/**
|
|
988
991
|
* Node type of mdast strong.
|
|
989
992
|
*/
|
|
@@ -1001,12 +1004,12 @@ interface Strong extends Parent {
|
|
|
1001
1004
|
/**
|
|
1002
1005
|
* Info associated with mdast strong nodes by the ecosystem.
|
|
1003
1006
|
*/
|
|
1004
|
-
interface StrongData extends Data {}
|
|
1007
|
+
interface StrongData extends Data$1 {}
|
|
1005
1008
|
|
|
1006
1009
|
/**
|
|
1007
1010
|
* Markdown GFM table.
|
|
1008
1011
|
*/
|
|
1009
|
-
interface Table extends Parent {
|
|
1012
|
+
interface Table extends Parent$1 {
|
|
1010
1013
|
/**
|
|
1011
1014
|
* Node type of mdast GFM table.
|
|
1012
1015
|
*/
|
|
@@ -1028,12 +1031,12 @@ interface Table extends Parent {
|
|
|
1028
1031
|
/**
|
|
1029
1032
|
* Info associated with mdast GFM table nodes by the ecosystem.
|
|
1030
1033
|
*/
|
|
1031
|
-
interface TableData extends Data {}
|
|
1034
|
+
interface TableData extends Data$1 {}
|
|
1032
1035
|
|
|
1033
1036
|
/**
|
|
1034
1037
|
* Markdown GFM table row.
|
|
1035
1038
|
*/
|
|
1036
|
-
interface TableRow extends Parent {
|
|
1039
|
+
interface TableRow extends Parent$1 {
|
|
1037
1040
|
/**
|
|
1038
1041
|
* Node type of mdast GFM table row.
|
|
1039
1042
|
*/
|
|
@@ -1051,12 +1054,12 @@ interface TableRow extends Parent {
|
|
|
1051
1054
|
/**
|
|
1052
1055
|
* Info associated with mdast GFM table row nodes by the ecosystem.
|
|
1053
1056
|
*/
|
|
1054
|
-
interface TableRowData extends Data {}
|
|
1057
|
+
interface TableRowData extends Data$1 {}
|
|
1055
1058
|
|
|
1056
1059
|
/**
|
|
1057
1060
|
* Markdown GFM table cell.
|
|
1058
1061
|
*/
|
|
1059
|
-
interface TableCell extends Parent {
|
|
1062
|
+
interface TableCell extends Parent$1 {
|
|
1060
1063
|
/**
|
|
1061
1064
|
* Node type of mdast GFM table cell.
|
|
1062
1065
|
*/
|
|
@@ -1074,12 +1077,12 @@ interface TableCell extends Parent {
|
|
|
1074
1077
|
/**
|
|
1075
1078
|
* Info associated with mdast GFM table cell nodes by the ecosystem.
|
|
1076
1079
|
*/
|
|
1077
|
-
interface TableCellData extends Data {}
|
|
1080
|
+
interface TableCellData extends Data$1 {}
|
|
1078
1081
|
|
|
1079
1082
|
/**
|
|
1080
1083
|
* Markdown text.
|
|
1081
1084
|
*/
|
|
1082
|
-
interface Text extends Literal {
|
|
1085
|
+
interface Text$1 extends Literal$1 {
|
|
1083
1086
|
/**
|
|
1084
1087
|
* Node type of mdast text.
|
|
1085
1088
|
*/
|
|
@@ -1087,18 +1090,18 @@ interface Text extends Literal {
|
|
|
1087
1090
|
/**
|
|
1088
1091
|
* Data associated with the mdast text.
|
|
1089
1092
|
*/
|
|
1090
|
-
data?: TextData | undefined;
|
|
1093
|
+
data?: TextData$1 | undefined;
|
|
1091
1094
|
}
|
|
1092
1095
|
|
|
1093
1096
|
/**
|
|
1094
1097
|
* Info associated with mdast text nodes by the ecosystem.
|
|
1095
1098
|
*/
|
|
1096
|
-
interface TextData extends Data {}
|
|
1099
|
+
interface TextData$1 extends Data$1 {}
|
|
1097
1100
|
|
|
1098
1101
|
/**
|
|
1099
1102
|
* Markdown thematic break (horizontal rule).
|
|
1100
1103
|
*/
|
|
1101
|
-
interface ThematicBreak extends Node {
|
|
1104
|
+
interface ThematicBreak extends Node$1 {
|
|
1102
1105
|
/**
|
|
1103
1106
|
* Node type of mdast thematic break.
|
|
1104
1107
|
*/
|
|
@@ -1112,12 +1115,12 @@ interface ThematicBreak extends Node {
|
|
|
1112
1115
|
/**
|
|
1113
1116
|
* Info associated with mdast thematic break nodes by the ecosystem.
|
|
1114
1117
|
*/
|
|
1115
|
-
interface ThematicBreakData extends Data {}
|
|
1118
|
+
interface ThematicBreakData extends Data$1 {}
|
|
1116
1119
|
|
|
1117
1120
|
/**
|
|
1118
1121
|
* Markdown YAML.
|
|
1119
1122
|
*/
|
|
1120
|
-
interface Yaml extends Literal {
|
|
1123
|
+
interface Yaml extends Literal$1 {
|
|
1121
1124
|
/**
|
|
1122
1125
|
* Node type of mdast YAML.
|
|
1123
1126
|
*/
|
|
@@ -1131,7 +1134,29 @@ interface Yaml extends Literal {
|
|
|
1131
1134
|
/**
|
|
1132
1135
|
* Info associated with mdast YAML nodes by the ecosystem.
|
|
1133
1136
|
*/
|
|
1134
|
-
interface YamlData extends Data {}
|
|
1137
|
+
interface YamlData extends Data$1 {}
|
|
1138
|
+
|
|
1139
|
+
// ## Interfaces
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Info associated with hast nodes by the ecosystem.
|
|
1143
|
+
*
|
|
1144
|
+
* This space is guaranteed to never be specified by unist or hast.
|
|
1145
|
+
* But you can use it in utilities and plugins to store data.
|
|
1146
|
+
*
|
|
1147
|
+
* This type can be augmented to register custom data.
|
|
1148
|
+
* For example:
|
|
1149
|
+
*
|
|
1150
|
+
* ```ts
|
|
1151
|
+
* declare module 'hast' {
|
|
1152
|
+
* interface Data {
|
|
1153
|
+
* // `someNode.data.myId` is typed as `number | undefined`
|
|
1154
|
+
* myId?: number | undefined
|
|
1155
|
+
* }
|
|
1156
|
+
* }
|
|
1157
|
+
* ```
|
|
1158
|
+
*/
|
|
1159
|
+
interface Data extends Data$2 {}
|
|
1135
1160
|
|
|
1136
1161
|
/**
|
|
1137
1162
|
* Info associated with an element.
|
|
@@ -1140,83 +1165,316 @@ interface Properties {
|
|
|
1140
1165
|
[PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
|
|
1141
1166
|
}
|
|
1142
1167
|
|
|
1168
|
+
// ## Content maps
|
|
1169
|
+
|
|
1143
1170
|
/**
|
|
1144
|
-
*
|
|
1171
|
+
* Union of registered hast nodes that can occur in {@link Element}.
|
|
1172
|
+
*
|
|
1173
|
+
* To register mote custom hast nodes, add them to {@link ElementContentMap}.
|
|
1174
|
+
* They will be automatically added here.
|
|
1145
1175
|
*/
|
|
1146
|
-
type
|
|
1176
|
+
type ElementContent = ElementContentMap[keyof ElementContentMap];
|
|
1177
|
+
|
|
1147
1178
|
/**
|
|
1148
|
-
*
|
|
1179
|
+
* Registry of all hast nodes that can occur as children of {@link Element}.
|
|
1180
|
+
*
|
|
1181
|
+
* For a union of all {@link Element} children, see {@link ElementContent}.
|
|
1149
1182
|
*/
|
|
1150
|
-
interface
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
stage?: Stage;
|
|
1155
|
-
/** Execution order within the stage (lower numbers run first) */
|
|
1156
|
-
order?: number;
|
|
1157
|
-
/** Transformation function */
|
|
1158
|
-
transform: (tree: Root, ctx: any) => Promise<void> | void;
|
|
1183
|
+
interface ElementContentMap {
|
|
1184
|
+
comment: Comment;
|
|
1185
|
+
element: Element;
|
|
1186
|
+
text: Text;
|
|
1159
1187
|
}
|
|
1188
|
+
|
|
1160
1189
|
/**
|
|
1161
|
-
*
|
|
1190
|
+
* Union of registered hast nodes that can occur in {@link Root}.
|
|
1191
|
+
*
|
|
1192
|
+
* To register custom hast nodes, add them to {@link RootContentMap}.
|
|
1193
|
+
* They will be automatically added here.
|
|
1162
1194
|
*/
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1195
|
+
type RootContent = RootContentMap[keyof RootContentMap];
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Registry of all hast nodes that can occur as children of {@link Root}.
|
|
1199
|
+
*
|
|
1200
|
+
* > 👉 **Note**: {@link Root} does not need to be an entire document.
|
|
1201
|
+
* > it can also be a fragment.
|
|
1202
|
+
*
|
|
1203
|
+
* For a union of all {@link Root} children, see {@link RootContent}.
|
|
1204
|
+
*/
|
|
1205
|
+
interface RootContentMap {
|
|
1206
|
+
comment: Comment;
|
|
1207
|
+
doctype: Doctype;
|
|
1208
|
+
element: Element;
|
|
1209
|
+
text: Text;
|
|
1168
1210
|
}
|
|
1211
|
+
|
|
1212
|
+
// ## Abstract nodes
|
|
1213
|
+
|
|
1169
1214
|
/**
|
|
1170
|
-
*
|
|
1215
|
+
* Abstract hast node.
|
|
1216
|
+
*
|
|
1217
|
+
* This interface is supposed to be extended.
|
|
1218
|
+
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
1219
|
+
* But for example in HTML, a `Doctype` is neither literal nor parent, but
|
|
1220
|
+
* still a node.
|
|
1221
|
+
*
|
|
1222
|
+
* To register custom hast nodes, add them to {@link RootContentMap} and other
|
|
1223
|
+
* places where relevant (such as {@link ElementContentMap}).
|
|
1224
|
+
*
|
|
1225
|
+
* For a union of all registered hast nodes, see {@link Nodes}.
|
|
1171
1226
|
*/
|
|
1172
|
-
interface
|
|
1173
|
-
/**
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
/** Raw content as bytes */
|
|
1178
|
-
bytes: Uint8Array;
|
|
1227
|
+
interface Node extends Node$2 {
|
|
1228
|
+
/**
|
|
1229
|
+
* Info from the ecosystem.
|
|
1230
|
+
*/
|
|
1231
|
+
data?: Data | undefined;
|
|
1179
1232
|
}
|
|
1233
|
+
|
|
1180
1234
|
/**
|
|
1181
|
-
*
|
|
1182
|
-
*
|
|
1235
|
+
* Abstract hast node that contains the smallest possible value.
|
|
1236
|
+
*
|
|
1237
|
+
* This interface is supposed to be extended if you make custom hast nodes.
|
|
1238
|
+
*
|
|
1239
|
+
* For a union of all registered hast literals, see {@link Literals}.
|
|
1183
1240
|
*/
|
|
1184
|
-
interface
|
|
1185
|
-
/**
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1241
|
+
interface Literal extends Node {
|
|
1242
|
+
/**
|
|
1243
|
+
* Plain-text value.
|
|
1244
|
+
*/
|
|
1245
|
+
value: string;
|
|
1189
1246
|
}
|
|
1247
|
+
|
|
1190
1248
|
/**
|
|
1191
|
-
*
|
|
1249
|
+
* Abstract hast node that contains other hast nodes (*children*).
|
|
1250
|
+
*
|
|
1251
|
+
* This interface is supposed to be extended if you make custom hast nodes.
|
|
1252
|
+
*
|
|
1253
|
+
* For a union of all registered hast parents, see {@link Parents}.
|
|
1254
|
+
*/
|
|
1255
|
+
interface Parent extends Node {
|
|
1256
|
+
/**
|
|
1257
|
+
* List of children.
|
|
1258
|
+
*/
|
|
1259
|
+
children: RootContent[];
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// ## Concrete nodes
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* HTML comment.
|
|
1266
|
+
*/
|
|
1267
|
+
interface Comment extends Literal {
|
|
1268
|
+
/**
|
|
1269
|
+
* Node type of HTML comments in hast.
|
|
1270
|
+
*/
|
|
1271
|
+
type: "comment";
|
|
1272
|
+
/**
|
|
1273
|
+
* Data associated with the comment.
|
|
1274
|
+
*/
|
|
1275
|
+
data?: CommentData | undefined;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Info associated with hast comments by the ecosystem.
|
|
1280
|
+
*/
|
|
1281
|
+
interface CommentData extends Data {}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* HTML document type.
|
|
1285
|
+
*/
|
|
1286
|
+
interface Doctype extends Node$2 {
|
|
1287
|
+
/**
|
|
1288
|
+
* Node type of HTML document types in hast.
|
|
1289
|
+
*/
|
|
1290
|
+
type: "doctype";
|
|
1291
|
+
/**
|
|
1292
|
+
* Data associated with the doctype.
|
|
1293
|
+
*/
|
|
1294
|
+
data?: DoctypeData | undefined;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* Info associated with hast doctypes by the ecosystem.
|
|
1299
|
+
*/
|
|
1300
|
+
interface DoctypeData extends Data {}
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* HTML element.
|
|
1304
|
+
*/
|
|
1305
|
+
interface Element extends Parent {
|
|
1306
|
+
/**
|
|
1307
|
+
* Node type of elements.
|
|
1308
|
+
*/
|
|
1309
|
+
type: "element";
|
|
1310
|
+
/**
|
|
1311
|
+
* Tag name (such as `'body'`) of the element.
|
|
1312
|
+
*/
|
|
1313
|
+
tagName: string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Info associated with the element.
|
|
1316
|
+
*/
|
|
1317
|
+
properties: Properties;
|
|
1318
|
+
/**
|
|
1319
|
+
* Children of element.
|
|
1320
|
+
*/
|
|
1321
|
+
children: ElementContent[];
|
|
1322
|
+
/**
|
|
1323
|
+
* When the `tagName` field is `'template'`, a `content` field can be
|
|
1324
|
+
* present.
|
|
1325
|
+
*/
|
|
1326
|
+
content?: Root | undefined;
|
|
1327
|
+
/**
|
|
1328
|
+
* Data associated with the element.
|
|
1329
|
+
*/
|
|
1330
|
+
data?: ElementData | undefined;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Info associated with hast elements by the ecosystem.
|
|
1335
|
+
*/
|
|
1336
|
+
interface ElementData extends Data {}
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Document fragment or a whole document.
|
|
1340
|
+
*
|
|
1341
|
+
* Should be used as the root of a tree and must not be used as a child.
|
|
1342
|
+
*
|
|
1343
|
+
* Can also be used as the value for the content field on a `'template'` element.
|
|
1344
|
+
*/
|
|
1345
|
+
interface Root extends Parent {
|
|
1346
|
+
/**
|
|
1347
|
+
* Node type of hast root.
|
|
1348
|
+
*/
|
|
1349
|
+
type: "root";
|
|
1350
|
+
/**
|
|
1351
|
+
* Children of root.
|
|
1352
|
+
*/
|
|
1353
|
+
children: RootContent[];
|
|
1354
|
+
/**
|
|
1355
|
+
* Data associated with the hast root.
|
|
1356
|
+
*/
|
|
1357
|
+
data?: RootData | undefined;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* Info associated with hast root nodes by the ecosystem.
|
|
1362
|
+
*/
|
|
1363
|
+
interface RootData extends Data {}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* HTML character data (plain text).
|
|
1367
|
+
*/
|
|
1368
|
+
interface Text extends Literal {
|
|
1369
|
+
/**
|
|
1370
|
+
* Node type of HTML character data (plain text) in hast.
|
|
1371
|
+
*/
|
|
1372
|
+
type: "text";
|
|
1373
|
+
/**
|
|
1374
|
+
* Data associated with the text.
|
|
1375
|
+
*/
|
|
1376
|
+
data?: TextData | undefined;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Info associated with hast texts by the ecosystem.
|
|
1381
|
+
*/
|
|
1382
|
+
interface TextData extends Data {}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* PipelineStage defines the execution order of plugins in the processing pipeline.
|
|
1386
|
+
* Plugins are sorted and executed in ascending order based on these stage values.
|
|
1387
|
+
*/
|
|
1388
|
+
declare enum PipelineStage {
|
|
1389
|
+
/** Initial stage for parsing raw input (e.g., string to AST). */
|
|
1390
|
+
parse = 0,
|
|
1391
|
+
/** Normalization stage for cleaning up and canonicalizing the AST (e.g., GFM, Directives). */
|
|
1392
|
+
normalize = 100,
|
|
1393
|
+
/** Transformation stage for semantic changes and custom high-level logic. */
|
|
1394
|
+
compile = 200,
|
|
1395
|
+
/** Finalization stage for preparing the AST for output (e.g., Sanitize, bridge to HAST). */
|
|
1396
|
+
finalize = 300,
|
|
1397
|
+
/** Final stage for serializing the AST to the target format result. */
|
|
1398
|
+
stringify = 400
|
|
1399
|
+
}
|
|
1400
|
+
/** The default stage assigned to a plugin if none is specified. */
|
|
1401
|
+
declare const DefaultPipelineStage = PipelineStage.compile;
|
|
1402
|
+
/** String names corresponding to the PipelineStage levels. */
|
|
1403
|
+
type PipelineStageName = keyof typeof PipelineStage;
|
|
1404
|
+
/**
|
|
1405
|
+
* Configuration for a plugin within the mdast-plus pipeline.
|
|
1406
|
+
* It wraps a standard unified plugin with execution metadata.
|
|
1407
|
+
*/
|
|
1408
|
+
interface MdastPlugin {
|
|
1409
|
+
/**
|
|
1410
|
+
* Optional name for the plugin.
|
|
1411
|
+
* Used for identification in overrides and logging.
|
|
1412
|
+
* If not provided, defaults to the plugin function's name.
|
|
1413
|
+
*/
|
|
1414
|
+
name?: string;
|
|
1415
|
+
/** The standard unified plugin (attacher) function. */
|
|
1416
|
+
plugin: Plugin<any[], any, any>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Arguments passed to the plugin.
|
|
1419
|
+
* MUST be an array of arguments (e.g., [optionsObject]).
|
|
1420
|
+
*/
|
|
1421
|
+
options?: any[];
|
|
1422
|
+
/** The stage in which this plugin should run. */
|
|
1423
|
+
stage?: PipelineStage | PipelineStageName;
|
|
1424
|
+
/** Execution priority within the same stage. Lower values run earlier. */
|
|
1425
|
+
order?: number;
|
|
1426
|
+
/**
|
|
1427
|
+
* If true, this plugin is considered the "main" plugin for its stage.
|
|
1428
|
+
* When multiple plugins exist in the same stage, a 'main' plugin will
|
|
1429
|
+
* replace the default (first) plugin of that stage.
|
|
1430
|
+
*/
|
|
1431
|
+
main?: boolean;
|
|
1432
|
+
/** Run this plugin before the named plugin (within the same stage). */
|
|
1433
|
+
before?: string;
|
|
1434
|
+
/** Run this plugin after the named plugin (within the same stage). */
|
|
1435
|
+
after?: string;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Defines a document format, encompassing its input (parsing) and output (serialization) strategies.
|
|
1439
|
+
*/
|
|
1440
|
+
interface MdastFormat {
|
|
1441
|
+
/** Unique identifier for the format (e.g., 'markdown', 'html'). */
|
|
1442
|
+
id: string;
|
|
1443
|
+
/** Human-readable title. */
|
|
1444
|
+
title?: string;
|
|
1445
|
+
/** File extensions associated with this format. */
|
|
1446
|
+
extensions?: string[];
|
|
1447
|
+
/** MIME types associated with this format. */
|
|
1448
|
+
mediaTypes?: string[];
|
|
1449
|
+
/** Plugins used for reading this format into a standard AST (Parser + Normalizer). */
|
|
1450
|
+
input?: MdastPlugin[];
|
|
1451
|
+
/** Plugins used for serializing the AST into this format (Finalizer + Stringifier). */
|
|
1452
|
+
output?: MdastPlugin[];
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Metadata capturing the origin of a node during conversion.
|
|
1192
1456
|
*/
|
|
1193
1457
|
interface MdastDataOrigin {
|
|
1194
|
-
/**
|
|
1458
|
+
/** The original source format. */
|
|
1195
1459
|
format: 'docx' | 'notion' | 'html' | 'markdown' | 'latex' | string;
|
|
1196
|
-
/**
|
|
1460
|
+
/** The raw content from the source before conversion. */
|
|
1197
1461
|
raw?: unknown;
|
|
1198
|
-
/** Hash
|
|
1462
|
+
/** Hash used for caching or change detection. */
|
|
1199
1463
|
hash?: string;
|
|
1200
1464
|
[k: string]: unknown;
|
|
1201
1465
|
}
|
|
1202
|
-
/**
|
|
1203
|
-
|
|
1204
|
-
*/
|
|
1205
|
-
interface MdastMark extends Parent$1 {
|
|
1466
|
+
/** Represents a highlighted text (mark) node in mdast. */
|
|
1467
|
+
interface MdastMark extends Parent$2 {
|
|
1206
1468
|
type: 'mark';
|
|
1207
1469
|
children: PhrasingContent[];
|
|
1208
1470
|
}
|
|
1209
|
-
/**
|
|
1210
|
-
|
|
1211
|
-
*/
|
|
1212
|
-
interface MdastSub extends Parent$1 {
|
|
1471
|
+
/** Represents a subscript text node in mdast. */
|
|
1472
|
+
interface MdastSub extends Parent$2 {
|
|
1213
1473
|
type: 'sub';
|
|
1214
1474
|
children: PhrasingContent[];
|
|
1215
1475
|
}
|
|
1216
|
-
/**
|
|
1217
|
-
|
|
1218
|
-
*/
|
|
1219
|
-
interface MdastSup extends Parent$1 {
|
|
1476
|
+
/** Represents a superscript text node in mdast. */
|
|
1477
|
+
interface MdastSup extends Parent$2 {
|
|
1220
1478
|
type: 'sup';
|
|
1221
1479
|
children: PhrasingContent[];
|
|
1222
1480
|
}
|
|
@@ -1228,6 +1486,14 @@ declare module 'mdast' {
|
|
|
1228
1486
|
hProperties?: Properties;
|
|
1229
1487
|
/** Source origin information */
|
|
1230
1488
|
_origin?: MdastDataOrigin;
|
|
1489
|
+
readability?: {
|
|
1490
|
+
title: string;
|
|
1491
|
+
byline: string;
|
|
1492
|
+
excerpt: string;
|
|
1493
|
+
siteName: string;
|
|
1494
|
+
lang: string;
|
|
1495
|
+
};
|
|
1496
|
+
[k: string]: any;
|
|
1231
1497
|
}
|
|
1232
1498
|
interface CodeData extends Data {
|
|
1233
1499
|
/** Title of the code block */
|
|
@@ -1249,128 +1515,227 @@ declare module 'mdast' {
|
|
|
1249
1515
|
sup: MdastSup;
|
|
1250
1516
|
}
|
|
1251
1517
|
}
|
|
1518
|
+
|
|
1252
1519
|
/**
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1520
|
+
* Base implementation of the fluent mdast processing pipeline.
|
|
1521
|
+
* Manages the plugin registry and the execution queue.
|
|
1255
1522
|
*/
|
|
1256
|
-
|
|
1523
|
+
declare class MdastBasePipeline {
|
|
1524
|
+
private static readonly registry;
|
|
1257
1525
|
/**
|
|
1258
|
-
*
|
|
1259
|
-
* @param
|
|
1526
|
+
* Registers a global document format.
|
|
1527
|
+
* @param format - The format definition to register.
|
|
1260
1528
|
*/
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
/**
|
|
1264
|
-
* Interface for transforming an mdast tree.
|
|
1265
|
-
*/
|
|
1266
|
-
interface MdastTransformer {
|
|
1529
|
+
static register(format: MdastFormat): void;
|
|
1267
1530
|
/**
|
|
1268
|
-
*
|
|
1269
|
-
* @param
|
|
1531
|
+
* Retrieves a registered format by its ID.
|
|
1532
|
+
* @param id - The format identifier.
|
|
1533
|
+
* @returns The format definition or undefined if not found.
|
|
1270
1534
|
*/
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
}
|
|
1276
|
-
/**
|
|
1277
|
-
* Interface for writing an mdast tree to an output format.
|
|
1278
|
-
* @template Output - Output type (default: string)
|
|
1279
|
-
*/
|
|
1280
|
-
interface MdastWriter<Output = string> {
|
|
1535
|
+
static getFormat(id: string): MdastFormat | undefined;
|
|
1536
|
+
protected input: VFileCompatible;
|
|
1537
|
+
protected queue: MdastPlugin[];
|
|
1538
|
+
protected _data: Record<string, any>;
|
|
1281
1539
|
/**
|
|
1282
|
-
*
|
|
1283
|
-
* @param
|
|
1284
|
-
* @param assets - Optional assets to include
|
|
1540
|
+
* Initializes a new pipeline instance with the given input.
|
|
1541
|
+
* @param input - Content to process (string, Buffer, VFile, or AST Node).
|
|
1285
1542
|
*/
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
/**
|
|
1295
|
-
|
|
1543
|
+
constructor(input: VFileCompatible);
|
|
1544
|
+
/**
|
|
1545
|
+
* Configures global data for the pipeline, which will be available to all plugins via this.data().
|
|
1546
|
+
* @param key - Data key or a record of multiple data entries.
|
|
1547
|
+
* @param value - Value to set (if key is a string).
|
|
1548
|
+
* @returns The pipeline instance for chaining.
|
|
1549
|
+
*/
|
|
1550
|
+
data(key: string | Record<string, any>, value?: any): this;
|
|
1551
|
+
/**
|
|
1552
|
+
* Instance-level access to the global format registry.
|
|
1553
|
+
*/
|
|
1554
|
+
getFormat(id: string): MdastFormat | undefined;
|
|
1555
|
+
/**
|
|
1556
|
+
* Resolves a format identifier or object to a valid MdastFormat.
|
|
1557
|
+
* @private
|
|
1558
|
+
*/
|
|
1559
|
+
private resolveFormat;
|
|
1560
|
+
/**
|
|
1561
|
+
* Normalizes a plugin entry for runtime execution.
|
|
1562
|
+
* @protected
|
|
1563
|
+
*/
|
|
1564
|
+
protected toRuntimeEntry(entry: MdastPlugin, defaultStage: PipelineStage, overrides?: Record<string, any>): MdastPlugin & {
|
|
1565
|
+
stage: PipelineStage;
|
|
1566
|
+
};
|
|
1567
|
+
/**
|
|
1568
|
+
* Ensures that input plugins (parser, normalizers) are present in the queue.
|
|
1569
|
+
* Adds implicit plugins if no parser is detected.
|
|
1570
|
+
* @protected
|
|
1571
|
+
*/
|
|
1572
|
+
protected ensureInputPlugins(queue: MdastPlugin[], overrides?: Record<string, any>, maxStage?: PipelineStage): void;
|
|
1296
1573
|
/**
|
|
1297
|
-
*
|
|
1298
|
-
* @param
|
|
1299
|
-
* @param
|
|
1574
|
+
* Configures the input format and adds its associated plugins to the pipeline.
|
|
1575
|
+
* @param fmt - Format ID or definition.
|
|
1576
|
+
* @param overrides - Optional map to override plugin options by plugin name.
|
|
1577
|
+
* @returns The pipeline instance for chaining.
|
|
1300
1578
|
*/
|
|
1301
|
-
|
|
1302
|
-
private processor;
|
|
1303
|
-
private input;
|
|
1304
|
-
private inputFormat;
|
|
1305
|
-
private plugins;
|
|
1306
|
-
private globalData;
|
|
1579
|
+
from(fmt: string | MdastFormat, overrides?: Record<string, any>): this;
|
|
1307
1580
|
/**
|
|
1308
|
-
*
|
|
1309
|
-
* @param
|
|
1581
|
+
* Processes the pipeline and serializes the result into the specified format.
|
|
1582
|
+
* @param fmt - Target format ID or definition.
|
|
1583
|
+
* @param overrides - Optional map to override plugin options.
|
|
1584
|
+
* @returns A promise resolving to a VFile containing the result.
|
|
1310
1585
|
*/
|
|
1311
|
-
|
|
1586
|
+
to(fmt: string | MdastFormat, overrides?: Record<string, any>): Promise<VFile>;
|
|
1312
1587
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
* @param
|
|
1588
|
+
* Adds a plugin or an array of plugins to the pipeline's compile stage.
|
|
1589
|
+
* @param plugin - The unified plugin function, a MdastPlugin object, or an array of them.
|
|
1590
|
+
* @param options - Arguments for the plugin(s).
|
|
1591
|
+
* @returns The pipeline instance for chaining.
|
|
1315
1592
|
*/
|
|
1316
|
-
|
|
1593
|
+
use(plugin: Plugin | MdastPlugin | (Plugin | MdastPlugin)[], ...options: any[]): this;
|
|
1317
1594
|
/**
|
|
1318
|
-
* Adds a plugin to the
|
|
1319
|
-
* @param
|
|
1595
|
+
* Adds a plugin or an array of plugins to the pipeline at a specific stage.
|
|
1596
|
+
* @param stage - The stage name or numeric value.
|
|
1597
|
+
* @param plugin - The unified plugin function, a MdastPlugin object, or an array of them.
|
|
1598
|
+
* @param options - Arguments for the plugin(s).
|
|
1599
|
+
* @returns The pipeline instance for chaining.
|
|
1320
1600
|
*/
|
|
1321
|
-
|
|
1601
|
+
useAt(stage: PipelineStageName, plugin: Plugin | MdastPlugin | (Plugin | MdastPlugin)[], ...options: any[]): this;
|
|
1322
1602
|
/**
|
|
1323
|
-
*
|
|
1324
|
-
* @param
|
|
1603
|
+
* Adds a plugin or an array of plugins to the pipeline. The stage is taken from the plugin object(s).
|
|
1604
|
+
* @param plugin - The MdastPlugin object or an array of them.
|
|
1605
|
+
* @param options - Arguments for the plugin(s) (overrides plugin.options if provided).
|
|
1606
|
+
* @returns The pipeline instance for chaining.
|
|
1325
1607
|
*/
|
|
1326
|
-
|
|
1608
|
+
useAt(plugin: MdastPlugin | (Plugin | MdastPlugin)[], ...options: any[]): this;
|
|
1327
1609
|
/**
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1330
|
-
* @
|
|
1610
|
+
* Sets the priority order for the most recently added plugin.
|
|
1611
|
+
* Plugins with lower order run earlier within the same stage.
|
|
1612
|
+
* @param order - Numeric priority.
|
|
1613
|
+
* @returns The pipeline instance for chaining.
|
|
1331
1614
|
*/
|
|
1332
|
-
|
|
1615
|
+
priority(order: number): this;
|
|
1333
1616
|
/**
|
|
1334
|
-
*
|
|
1335
|
-
* @
|
|
1617
|
+
* Assembles a unified processor based on the sorted plugin queue.
|
|
1618
|
+
* @protected
|
|
1619
|
+
*/
|
|
1620
|
+
protected assembleProcessor(queue: MdastPlugin[]): Processor;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Extended pipeline with convenience methods for common formats.
|
|
1624
|
+
*/
|
|
1625
|
+
declare class MdastPipeline extends MdastBasePipeline {
|
|
1626
|
+
/**
|
|
1627
|
+
* Finalizes the pipeline and returns the result as a Markdown string.
|
|
1336
1628
|
*/
|
|
1337
1629
|
toMarkdown(): Promise<string>;
|
|
1338
1630
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
* @returns A promise resolving to the HTML string
|
|
1631
|
+
* Finalizes the pipeline and returns a VFile containing the Markdown result.
|
|
1341
1632
|
*/
|
|
1342
|
-
|
|
1633
|
+
toMarkdownVFile(): Promise<VFile>;
|
|
1634
|
+
/**
|
|
1635
|
+
* Finalizes the pipeline and returns the result as an HTML string.
|
|
1636
|
+
*/
|
|
1637
|
+
toHtml(): Promise<string>;
|
|
1343
1638
|
/**
|
|
1344
|
-
*
|
|
1345
|
-
* @returns A promise resolving to the mdast Root node
|
|
1639
|
+
* Finalizes the pipeline and returns a VFile containing the HTML result.
|
|
1346
1640
|
*/
|
|
1347
|
-
|
|
1641
|
+
toHtmlVFile(): Promise<VFile>;
|
|
1642
|
+
/**
|
|
1643
|
+
* Finalizes the pipeline and returns the resulting AST (Root node).
|
|
1644
|
+
* @param options - Configuration for the extraction.
|
|
1645
|
+
* @param options.stage - Run the pipeline up to this stage only.
|
|
1646
|
+
* @param options.overrides - Map for plugin option overrides.
|
|
1647
|
+
*/
|
|
1648
|
+
toAst(options?: {
|
|
1649
|
+
stage?: PipelineStageName;
|
|
1650
|
+
overrides?: Record<string, any>;
|
|
1651
|
+
}): Promise<Root$1>;
|
|
1652
|
+
/** Alias for toHtml() */
|
|
1653
|
+
toHTML(): Promise<string>;
|
|
1654
|
+
/** Alias for toAst() */
|
|
1655
|
+
toAST(options?: {
|
|
1656
|
+
stage?: PipelineStageName;
|
|
1657
|
+
overrides?: Record<string, any>;
|
|
1658
|
+
}): Promise<Root$1>;
|
|
1348
1659
|
}
|
|
1349
1660
|
/**
|
|
1350
1661
|
* Entry point for the fluent mdast-plus API.
|
|
1351
1662
|
* @param input - The input content (string or mdast tree)
|
|
1352
1663
|
* @returns A FluentProcessor instance
|
|
1353
1664
|
*/
|
|
1354
|
-
declare function mdast(input:
|
|
1665
|
+
declare function mdast(input: VFileCompatible): MdastPipeline;
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* Markdown format definition.
|
|
1669
|
+
*
|
|
1670
|
+
* Supports GFM, Directives, Math, and Frontmatter.
|
|
1671
|
+
* Provides a bidirectional mapping between Markdown strings and mdast-plus ASTs.
|
|
1672
|
+
*/
|
|
1673
|
+
declare const markdownFormat: MdastFormat;
|
|
1355
1674
|
|
|
1356
1675
|
/**
|
|
1357
|
-
*
|
|
1676
|
+
* HTML format definition.
|
|
1677
|
+
*
|
|
1678
|
+
* Provides a bidirectional mapping between HTML strings and mdast-plus ASTs.
|
|
1679
|
+
* Includes built-in sanitization and support for table spans and image dimensions.
|
|
1680
|
+
*/
|
|
1681
|
+
declare const htmlFormat: MdastFormat;
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* Pass-through compiler that returns the AST as-is.
|
|
1685
|
+
* Essential for unified processes that should output an object (the AST)
|
|
1686
|
+
* instead of a serialized string.
|
|
1358
1687
|
*/
|
|
1359
|
-
declare function
|
|
1688
|
+
declare function astCompiler(this: any): void;
|
|
1360
1689
|
/**
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1690
|
+
* Parser for stringified JSON AST input.
|
|
1691
|
+
* Allows the pipeline to accept a JSON string and treat it as a unist tree.
|
|
1363
1692
|
*/
|
|
1364
|
-
declare
|
|
1693
|
+
declare function jsonParser(this: any): void;
|
|
1694
|
+
/**
|
|
1695
|
+
* AST (MDAST) format definition.
|
|
1696
|
+
* Supports reading from JSON strings and provides full normalization
|
|
1697
|
+
* through the standard mdast-plus plugin set.
|
|
1698
|
+
*/
|
|
1699
|
+
declare const astFormat: MdastFormat;
|
|
1365
1700
|
|
|
1701
|
+
interface ReadabilityOptions {
|
|
1702
|
+
enable?: boolean;
|
|
1703
|
+
readability?: Record<string, any>;
|
|
1704
|
+
jsdom?: Record<string, any>;
|
|
1705
|
+
}
|
|
1366
1706
|
/**
|
|
1367
|
-
*
|
|
1707
|
+
* A unified/rehype plugin that uses Mozilla's Readability to parse the input HTML.
|
|
1368
1708
|
*/
|
|
1369
|
-
declare
|
|
1709
|
+
declare const htmlReadability: Plugin<[(ReadabilityOptions | boolean)?], string, Root>;
|
|
1370
1710
|
/**
|
|
1371
|
-
*
|
|
1372
|
-
* Handles both parsing (HTML -> MDAST) and stringifying (MDAST -> HTML).
|
|
1711
|
+
* Pre-configured MdastPlugin for html-readability.
|
|
1373
1712
|
*/
|
|
1374
|
-
declare const
|
|
1713
|
+
declare const htmlReadabilityPlugin: {
|
|
1714
|
+
name: string;
|
|
1715
|
+
plugin: Plugin<[(boolean | ReadabilityOptions | undefined)?], string, Root>;
|
|
1716
|
+
stage: PipelineStage;
|
|
1717
|
+
};
|
|
1718
|
+
/**
|
|
1719
|
+
* Plugin to restore readability metadata after HAST to MDAST conversion.
|
|
1720
|
+
*/
|
|
1721
|
+
declare const restoreReadabilityMetaPlugin: {
|
|
1722
|
+
name: string;
|
|
1723
|
+
plugin: () => (tree: any, file: any) => void;
|
|
1724
|
+
stage: PipelineStage;
|
|
1725
|
+
after: string;
|
|
1726
|
+
};
|
|
1727
|
+
/**
|
|
1728
|
+
* Combined plugins for HTML readability.
|
|
1729
|
+
*/
|
|
1730
|
+
declare const htmlReadabilityPlugins: ({
|
|
1731
|
+
name: string;
|
|
1732
|
+
plugin: Plugin<[(boolean | ReadabilityOptions | undefined)?], string, Root>;
|
|
1733
|
+
stage: PipelineStage;
|
|
1734
|
+
} | {
|
|
1735
|
+
name: string;
|
|
1736
|
+
plugin: () => (tree: any, file: any) => void;
|
|
1737
|
+
stage: PipelineStage;
|
|
1738
|
+
after: string;
|
|
1739
|
+
})[];
|
|
1375
1740
|
|
|
1376
|
-
export {
|
|
1741
|
+
export { DefaultPipelineStage, MdastBasePipeline, type MdastDataOrigin, type MdastFormat, type MdastMark, MdastPipeline, type MdastPlugin, type MdastSub, type MdastSup, PipelineStage, type PipelineStageName, type ReadabilityOptions, astCompiler, astFormat, htmlFormat, htmlReadability, htmlReadabilityPlugin, htmlReadabilityPlugins, jsonParser, markdownFormat, mdast, restoreReadabilityMetaPlugin };
|