@asciidoctor/core 4.0.2 → 4.0.3
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/build/browser/index.js +148 -6
- package/build/node/index.cjs +148 -6
- package/package.json +2 -1
- package/src/document.js +4 -0
- package/src/extensions.js +143 -5
- package/src/index.js +4 -0
- package/types/extensions.d.ts +390 -14
- package/types/index.d.cts +4 -0
- package/types/index.d.ts +4 -0
package/types/extensions.d.ts
CHANGED
|
@@ -323,11 +323,19 @@ export class IncludeProcessor extends Processor {
|
|
|
323
323
|
*/
|
|
324
324
|
process(document: Document, reader: Reader, target: string, attributes: Record<string, string>): void;
|
|
325
325
|
/**
|
|
326
|
-
*
|
|
326
|
+
* Decide whether this include processor handles the given target.
|
|
327
|
+
*
|
|
328
|
+
* Override this method in a subclass. The override may accept either just the
|
|
329
|
+
* target string (Ruby-style, arity 1) or both the document and the target
|
|
330
|
+
* (arity 2) — an arity-1 override is adapted at registration time so the
|
|
331
|
+
* parser can always invoke it as `handles(doc, target)`. The first parameter
|
|
332
|
+
* is therefore typed `Document | string` so both override shapes type-check.
|
|
333
|
+
*
|
|
334
|
+
* @param {Document|string} doc - The document being parsed, or (for a Ruby-style arity-1 override) the include target.
|
|
327
335
|
* @param {string} target - The target of the include directive.
|
|
328
336
|
* @returns {boolean} true if this processor handles the given target.
|
|
329
337
|
*/
|
|
330
|
-
handles(doc: Document, target: string): boolean;
|
|
338
|
+
handles(doc: Document | string, target: string): boolean;
|
|
331
339
|
}
|
|
332
340
|
export namespace IncludeProcessor {
|
|
333
341
|
export { IncludeProcessorDsl as DSL };
|
|
@@ -585,10 +593,48 @@ export class Registry {
|
|
|
585
593
|
* this.process(function (doc, reader) { ... })
|
|
586
594
|
* })
|
|
587
595
|
*
|
|
596
|
+
* @overload
|
|
597
|
+
* @param {typeof Preprocessor} processor - A Preprocessor subclass or instance.
|
|
598
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
599
|
+
*
|
|
600
|
+
* @overload
|
|
601
|
+
* @param {(this: PreprocessorDslInterface) => void} fn - Registration function bound to the preprocessor DSL.
|
|
602
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
603
|
+
*
|
|
604
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
605
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
606
|
+
*/
|
|
607
|
+
preprocessor(processor: typeof Preprocessor): ProcessorExtension;
|
|
608
|
+
/**
|
|
609
|
+
* Register a Preprocessor with the extension registry.
|
|
610
|
+
*
|
|
611
|
+
* The processor may be:
|
|
612
|
+
* - A Preprocessor subclass (constructor function)
|
|
613
|
+
* - An instance of a Preprocessor subclass
|
|
614
|
+
* - A Function that configures the processor via the DSL (block style)
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* // class style
|
|
618
|
+
* preprocessor(FrontMatterPreprocessor)
|
|
619
|
+
* // instance style
|
|
620
|
+
* preprocessor(new FrontMatterPreprocessor())
|
|
621
|
+
* // block style
|
|
622
|
+
* preprocessor(function () {
|
|
623
|
+
* this.process(function (doc, reader) { ... })
|
|
624
|
+
* })
|
|
625
|
+
*
|
|
626
|
+
* @overload
|
|
627
|
+
* @param {typeof Preprocessor} processor - A Preprocessor subclass or instance.
|
|
628
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
629
|
+
*
|
|
630
|
+
* @overload
|
|
631
|
+
* @param {(this: PreprocessorDslInterface) => void} fn - Registration function bound to the preprocessor DSL.
|
|
632
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
633
|
+
*
|
|
588
634
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
589
635
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
590
636
|
*/
|
|
591
|
-
preprocessor(
|
|
637
|
+
preprocessor(fn: (this: PreprocessorDslInterface) => void): ProcessorExtension;
|
|
592
638
|
/**
|
|
593
639
|
* Return the registered Preprocessor extensions, or null if none.
|
|
594
640
|
*
|
|
@@ -604,10 +650,33 @@ export class Registry {
|
|
|
604
650
|
/**
|
|
605
651
|
* Register a TreeProcessor with the extension registry.
|
|
606
652
|
*
|
|
653
|
+
* @overload
|
|
654
|
+
* @param {typeof TreeProcessor} processor - A TreeProcessor subclass or instance.
|
|
655
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
656
|
+
*
|
|
657
|
+
* @overload
|
|
658
|
+
* @param {(this: TreeProcessorDslInterface) => void} fn - Registration function bound to the tree processor DSL.
|
|
659
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
660
|
+
*
|
|
607
661
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
608
662
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
609
663
|
*/
|
|
610
|
-
treeProcessor(
|
|
664
|
+
treeProcessor(processor: typeof TreeProcessor): ProcessorExtension;
|
|
665
|
+
/**
|
|
666
|
+
* Register a TreeProcessor with the extension registry.
|
|
667
|
+
*
|
|
668
|
+
* @overload
|
|
669
|
+
* @param {typeof TreeProcessor} processor - A TreeProcessor subclass or instance.
|
|
670
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
671
|
+
*
|
|
672
|
+
* @overload
|
|
673
|
+
* @param {(this: TreeProcessorDslInterface) => void} fn - Registration function bound to the tree processor DSL.
|
|
674
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
675
|
+
*
|
|
676
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
677
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
678
|
+
*/
|
|
679
|
+
treeProcessor(fn: (this: TreeProcessorDslInterface) => void): ProcessorExtension;
|
|
611
680
|
/** @deprecated Alias for {@link treeProcessor}. */
|
|
612
681
|
treeprocessor(...args: any[]): ProcessorExtension;
|
|
613
682
|
/** Alias for {@link treeProcessor} (snake_case for prefer() / Registry method dispatch). */
|
|
@@ -631,10 +700,33 @@ export class Registry {
|
|
|
631
700
|
/**
|
|
632
701
|
* Register a Postprocessor with the extension registry.
|
|
633
702
|
*
|
|
703
|
+
* @overload
|
|
704
|
+
* @param {typeof Postprocessor} processor - A Postprocessor subclass or instance.
|
|
705
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
706
|
+
*
|
|
707
|
+
* @overload
|
|
708
|
+
* @param {(this: PostprocessorDslInterface) => void} fn - Registration function bound to the postprocessor DSL.
|
|
709
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
710
|
+
*
|
|
711
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
712
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
713
|
+
*/
|
|
714
|
+
postprocessor(processor: typeof Postprocessor): ProcessorExtension;
|
|
715
|
+
/**
|
|
716
|
+
* Register a Postprocessor with the extension registry.
|
|
717
|
+
*
|
|
718
|
+
* @overload
|
|
719
|
+
* @param {typeof Postprocessor} processor - A Postprocessor subclass or instance.
|
|
720
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
721
|
+
*
|
|
722
|
+
* @overload
|
|
723
|
+
* @param {(this: PostprocessorDslInterface) => void} fn - Registration function bound to the postprocessor DSL.
|
|
724
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
725
|
+
*
|
|
634
726
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
635
727
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
636
728
|
*/
|
|
637
|
-
postprocessor(
|
|
729
|
+
postprocessor(fn: (this: PostprocessorDslInterface) => void): ProcessorExtension;
|
|
638
730
|
/**
|
|
639
731
|
* Return the registered Postprocessor extensions, or null if none.
|
|
640
732
|
*
|
|
@@ -650,10 +742,33 @@ export class Registry {
|
|
|
650
742
|
/**
|
|
651
743
|
* Register an IncludeProcessor with the extension registry.
|
|
652
744
|
*
|
|
745
|
+
* @overload
|
|
746
|
+
* @param {typeof IncludeProcessor} processor - An IncludeProcessor subclass or instance.
|
|
747
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
748
|
+
*
|
|
749
|
+
* @overload
|
|
750
|
+
* @param {(this: IncludeProcessorDslInterface) => void} fn - Registration function bound to the include processor DSL.
|
|
751
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
752
|
+
*
|
|
653
753
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
654
754
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
655
755
|
*/
|
|
656
|
-
includeProcessor(
|
|
756
|
+
includeProcessor(processor: typeof IncludeProcessor): ProcessorExtension;
|
|
757
|
+
/**
|
|
758
|
+
* Register an IncludeProcessor with the extension registry.
|
|
759
|
+
*
|
|
760
|
+
* @overload
|
|
761
|
+
* @param {typeof IncludeProcessor} processor - An IncludeProcessor subclass or instance.
|
|
762
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
763
|
+
*
|
|
764
|
+
* @overload
|
|
765
|
+
* @param {(this: IncludeProcessorDslInterface) => void} fn - Registration function bound to the include processor DSL.
|
|
766
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
767
|
+
*
|
|
768
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
769
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
770
|
+
*/
|
|
771
|
+
includeProcessor(fn: (this: IncludeProcessorDslInterface) => void): ProcessorExtension;
|
|
657
772
|
/**
|
|
658
773
|
* Return the registered IncludeProcessor extensions, or null if none.
|
|
659
774
|
*
|
|
@@ -671,10 +786,33 @@ export class Registry {
|
|
|
671
786
|
/**
|
|
672
787
|
* Register a DocinfoProcessor with the extension registry.
|
|
673
788
|
*
|
|
789
|
+
* @overload
|
|
790
|
+
* @param {typeof DocinfoProcessor} processor - A DocinfoProcessor subclass or instance.
|
|
791
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
792
|
+
*
|
|
793
|
+
* @overload
|
|
794
|
+
* @param {(this: DocinfoProcessorDslInterface) => void} fn - Registration function bound to the docinfo processor DSL.
|
|
795
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
796
|
+
*
|
|
797
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
798
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
799
|
+
*/
|
|
800
|
+
docinfoProcessor(processor: typeof DocinfoProcessor): ProcessorExtension;
|
|
801
|
+
/**
|
|
802
|
+
* Register a DocinfoProcessor with the extension registry.
|
|
803
|
+
*
|
|
804
|
+
* @overload
|
|
805
|
+
* @param {typeof DocinfoProcessor} processor - A DocinfoProcessor subclass or instance.
|
|
806
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
807
|
+
*
|
|
808
|
+
* @overload
|
|
809
|
+
* @param {(this: DocinfoProcessorDslInterface) => void} fn - Registration function bound to the docinfo processor DSL.
|
|
810
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
811
|
+
*
|
|
674
812
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
675
813
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
676
814
|
*/
|
|
677
|
-
docinfoProcessor(
|
|
815
|
+
docinfoProcessor(fn: (this: DocinfoProcessorDslInterface) => void): ProcessorExtension;
|
|
678
816
|
/**
|
|
679
817
|
* Check whether any DocinfoProcessor extensions have been registered.
|
|
680
818
|
*
|
|
@@ -709,10 +847,96 @@ export class Registry {
|
|
|
709
847
|
* this.process(function (parent, reader, attrs) { ... })
|
|
710
848
|
* })
|
|
711
849
|
*
|
|
850
|
+
* @overload
|
|
851
|
+
* @param {typeof BlockProcessor} processor - A BlockProcessor subclass.
|
|
852
|
+
* @param {string} [name] - Optional explicit block name.
|
|
853
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
854
|
+
*
|
|
855
|
+
* @overload
|
|
856
|
+
* @param {string} name - The block name.
|
|
857
|
+
* @param {(this: BlockProcessorDslInterface) => void} fn - Registration function bound to the block DSL.
|
|
858
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
859
|
+
*
|
|
860
|
+
* @overload
|
|
861
|
+
* @param {(this: BlockProcessorDslInterface) => void} fn - Registration function bound to the block DSL.
|
|
862
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
863
|
+
*
|
|
712
864
|
* @param {...*} args - Class constructor, instance, block function, or name + one of those.
|
|
713
865
|
* @returns {ProcessorExtension} an Extension proxy object.
|
|
714
866
|
*/
|
|
715
|
-
block(
|
|
867
|
+
block(processor: typeof BlockProcessor, name?: string): ProcessorExtension;
|
|
868
|
+
/**
|
|
869
|
+
* Register a BlockProcessor with the extension registry.
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* // class style
|
|
873
|
+
* block(ShoutBlock)
|
|
874
|
+
* // class style with explicit name
|
|
875
|
+
* block(ShoutBlock, 'shout')
|
|
876
|
+
* // block style
|
|
877
|
+
* block(function () {
|
|
878
|
+
* this.named('shout')
|
|
879
|
+
* this.process(function (parent, reader, attrs) { ... })
|
|
880
|
+
* })
|
|
881
|
+
* // block style with explicit name
|
|
882
|
+
* block('shout', function () {
|
|
883
|
+
* this.process(function (parent, reader, attrs) { ... })
|
|
884
|
+
* })
|
|
885
|
+
*
|
|
886
|
+
* @overload
|
|
887
|
+
* @param {typeof BlockProcessor} processor - A BlockProcessor subclass.
|
|
888
|
+
* @param {string} [name] - Optional explicit block name.
|
|
889
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
890
|
+
*
|
|
891
|
+
* @overload
|
|
892
|
+
* @param {string} name - The block name.
|
|
893
|
+
* @param {(this: BlockProcessorDslInterface) => void} fn - Registration function bound to the block DSL.
|
|
894
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
895
|
+
*
|
|
896
|
+
* @overload
|
|
897
|
+
* @param {(this: BlockProcessorDslInterface) => void} fn - Registration function bound to the block DSL.
|
|
898
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
899
|
+
*
|
|
900
|
+
* @param {...*} args - Class constructor, instance, block function, or name + one of those.
|
|
901
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
902
|
+
*/
|
|
903
|
+
block(name: string, fn: (this: BlockProcessorDslInterface) => void): ProcessorExtension;
|
|
904
|
+
/**
|
|
905
|
+
* Register a BlockProcessor with the extension registry.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* // class style
|
|
909
|
+
* block(ShoutBlock)
|
|
910
|
+
* // class style with explicit name
|
|
911
|
+
* block(ShoutBlock, 'shout')
|
|
912
|
+
* // block style
|
|
913
|
+
* block(function () {
|
|
914
|
+
* this.named('shout')
|
|
915
|
+
* this.process(function (parent, reader, attrs) { ... })
|
|
916
|
+
* })
|
|
917
|
+
* // block style with explicit name
|
|
918
|
+
* block('shout', function () {
|
|
919
|
+
* this.process(function (parent, reader, attrs) { ... })
|
|
920
|
+
* })
|
|
921
|
+
*
|
|
922
|
+
* @overload
|
|
923
|
+
* @param {typeof BlockProcessor} processor - A BlockProcessor subclass.
|
|
924
|
+
* @param {string} [name] - Optional explicit block name.
|
|
925
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
926
|
+
*
|
|
927
|
+
* @overload
|
|
928
|
+
* @param {string} name - The block name.
|
|
929
|
+
* @param {(this: BlockProcessorDslInterface) => void} fn - Registration function bound to the block DSL.
|
|
930
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
931
|
+
*
|
|
932
|
+
* @overload
|
|
933
|
+
* @param {(this: BlockProcessorDslInterface) => void} fn - Registration function bound to the block DSL.
|
|
934
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
935
|
+
*
|
|
936
|
+
* @param {...*} args - Class constructor, instance, block function, or name + one of those.
|
|
937
|
+
* @returns {ProcessorExtension} an Extension proxy object.
|
|
938
|
+
*/
|
|
939
|
+
block(fn: (this: BlockProcessorDslInterface) => void): ProcessorExtension;
|
|
716
940
|
/**
|
|
717
941
|
* Check whether any BlockProcessor extensions have been registered.
|
|
718
942
|
*
|
|
@@ -743,10 +967,66 @@ export class Registry {
|
|
|
743
967
|
/**
|
|
744
968
|
* Register a BlockMacroProcessor with the extension registry.
|
|
745
969
|
*
|
|
970
|
+
* @overload
|
|
971
|
+
* @param {typeof BlockMacroProcessor} processor - A BlockMacroProcessor subclass.
|
|
972
|
+
* @param {string} [name] - Optional explicit macro name.
|
|
973
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
974
|
+
*
|
|
975
|
+
* @overload
|
|
976
|
+
* @param {string} name - The macro name.
|
|
977
|
+
* @param {(this: BlockMacroProcessorDslInterface) => void} fn - Registration function bound to the block macro DSL.
|
|
978
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
979
|
+
*
|
|
980
|
+
* @overload
|
|
981
|
+
* @param {(this: BlockMacroProcessorDslInterface) => void} fn - Registration function bound to the block macro DSL.
|
|
982
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
983
|
+
*
|
|
746
984
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
747
985
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
748
986
|
*/
|
|
749
|
-
blockMacro(
|
|
987
|
+
blockMacro(processor: typeof BlockMacroProcessor, name?: string): ProcessorExtension;
|
|
988
|
+
/**
|
|
989
|
+
* Register a BlockMacroProcessor with the extension registry.
|
|
990
|
+
*
|
|
991
|
+
* @overload
|
|
992
|
+
* @param {typeof BlockMacroProcessor} processor - A BlockMacroProcessor subclass.
|
|
993
|
+
* @param {string} [name] - Optional explicit macro name.
|
|
994
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
995
|
+
*
|
|
996
|
+
* @overload
|
|
997
|
+
* @param {string} name - The macro name.
|
|
998
|
+
* @param {(this: BlockMacroProcessorDslInterface) => void} fn - Registration function bound to the block macro DSL.
|
|
999
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1000
|
+
*
|
|
1001
|
+
* @overload
|
|
1002
|
+
* @param {(this: BlockMacroProcessorDslInterface) => void} fn - Registration function bound to the block macro DSL.
|
|
1003
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1004
|
+
*
|
|
1005
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
1006
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1007
|
+
*/
|
|
1008
|
+
blockMacro(name: string, fn: (this: BlockMacroProcessorDslInterface) => void): ProcessorExtension;
|
|
1009
|
+
/**
|
|
1010
|
+
* Register a BlockMacroProcessor with the extension registry.
|
|
1011
|
+
*
|
|
1012
|
+
* @overload
|
|
1013
|
+
* @param {typeof BlockMacroProcessor} processor - A BlockMacroProcessor subclass.
|
|
1014
|
+
* @param {string} [name] - Optional explicit macro name.
|
|
1015
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1016
|
+
*
|
|
1017
|
+
* @overload
|
|
1018
|
+
* @param {string} name - The macro name.
|
|
1019
|
+
* @param {(this: BlockMacroProcessorDslInterface) => void} fn - Registration function bound to the block macro DSL.
|
|
1020
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1021
|
+
*
|
|
1022
|
+
* @overload
|
|
1023
|
+
* @param {(this: BlockMacroProcessorDslInterface) => void} fn - Registration function bound to the block macro DSL.
|
|
1024
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1025
|
+
*
|
|
1026
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
1027
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1028
|
+
*/
|
|
1029
|
+
blockMacro(fn: (this: BlockMacroProcessorDslInterface) => void): ProcessorExtension;
|
|
750
1030
|
/** @deprecated Alias for {@link blockMacro}. */
|
|
751
1031
|
block_macro(...args: any[]): ProcessorExtension;
|
|
752
1032
|
/**
|
|
@@ -778,10 +1058,66 @@ export class Registry {
|
|
|
778
1058
|
/**
|
|
779
1059
|
* Register an InlineMacroProcessor with the extension registry.
|
|
780
1060
|
*
|
|
1061
|
+
* @overload
|
|
1062
|
+
* @param {typeof InlineMacroProcessor} processor - An InlineMacroProcessor subclass.
|
|
1063
|
+
* @param {string} [name] - Optional explicit macro name.
|
|
1064
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1065
|
+
*
|
|
1066
|
+
* @overload
|
|
1067
|
+
* @param {string} name - The macro name.
|
|
1068
|
+
* @param {(this: InlineMacroProcessorDslInterface) => void} fn - Registration function bound to the inline macro DSL.
|
|
1069
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1070
|
+
*
|
|
1071
|
+
* @overload
|
|
1072
|
+
* @param {(this: InlineMacroProcessorDslInterface) => void} fn - Registration function bound to the inline macro DSL.
|
|
1073
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1074
|
+
*
|
|
781
1075
|
* @param {...*} args - Class constructor, instance, or block function.
|
|
782
1076
|
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
783
1077
|
*/
|
|
784
|
-
inlineMacro(
|
|
1078
|
+
inlineMacro(processor: typeof InlineMacroProcessor, name?: string): ProcessorExtension;
|
|
1079
|
+
/**
|
|
1080
|
+
* Register an InlineMacroProcessor with the extension registry.
|
|
1081
|
+
*
|
|
1082
|
+
* @overload
|
|
1083
|
+
* @param {typeof InlineMacroProcessor} processor - An InlineMacroProcessor subclass.
|
|
1084
|
+
* @param {string} [name] - Optional explicit macro name.
|
|
1085
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1086
|
+
*
|
|
1087
|
+
* @overload
|
|
1088
|
+
* @param {string} name - The macro name.
|
|
1089
|
+
* @param {(this: InlineMacroProcessorDslInterface) => void} fn - Registration function bound to the inline macro DSL.
|
|
1090
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1091
|
+
*
|
|
1092
|
+
* @overload
|
|
1093
|
+
* @param {(this: InlineMacroProcessorDslInterface) => void} fn - Registration function bound to the inline macro DSL.
|
|
1094
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1095
|
+
*
|
|
1096
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
1097
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1098
|
+
*/
|
|
1099
|
+
inlineMacro(name: string, fn: (this: InlineMacroProcessorDslInterface) => void): ProcessorExtension;
|
|
1100
|
+
/**
|
|
1101
|
+
* Register an InlineMacroProcessor with the extension registry.
|
|
1102
|
+
*
|
|
1103
|
+
* @overload
|
|
1104
|
+
* @param {typeof InlineMacroProcessor} processor - An InlineMacroProcessor subclass.
|
|
1105
|
+
* @param {string} [name] - Optional explicit macro name.
|
|
1106
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1107
|
+
*
|
|
1108
|
+
* @overload
|
|
1109
|
+
* @param {string} name - The macro name.
|
|
1110
|
+
* @param {(this: InlineMacroProcessorDslInterface) => void} fn - Registration function bound to the inline macro DSL.
|
|
1111
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1112
|
+
*
|
|
1113
|
+
* @overload
|
|
1114
|
+
* @param {(this: InlineMacroProcessorDslInterface) => void} fn - Registration function bound to the inline macro DSL.
|
|
1115
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1116
|
+
*
|
|
1117
|
+
* @param {...*} args - Class constructor, instance, or block function.
|
|
1118
|
+
* @returns {ProcessorExtension} the Extension stored in the registry.
|
|
1119
|
+
*/
|
|
1120
|
+
inlineMacro(fn: (this: InlineMacroProcessorDslInterface) => void): ProcessorExtension;
|
|
785
1121
|
/** @deprecated Alias for {@link inlineMacro}. */
|
|
786
1122
|
inline_macro(...args: any[]): ProcessorExtension;
|
|
787
1123
|
/**
|
|
@@ -1074,6 +1410,24 @@ export type DocumentProcessorDslInterface = ProcessorDslInterface & {
|
|
|
1074
1410
|
prefer(): void;
|
|
1075
1411
|
prepend(): void;
|
|
1076
1412
|
};
|
|
1413
|
+
/**
|
|
1414
|
+
* DSL interface for preprocessors.
|
|
1415
|
+
*/
|
|
1416
|
+
export type PreprocessorDslInterface = Omit<DocumentProcessorDslInterface, "process"> & {
|
|
1417
|
+
process(fn: (this: PreprocessorDslInterface, document: Document, reader: Reader) => Reader | void): void;
|
|
1418
|
+
};
|
|
1419
|
+
/**
|
|
1420
|
+
* DSL interface for tree processors.
|
|
1421
|
+
*/
|
|
1422
|
+
export type TreeProcessorDslInterface = Omit<DocumentProcessorDslInterface, "process"> & {
|
|
1423
|
+
process(fn: (this: TreeProcessorDslInterface, document: Document) => Document | void): void;
|
|
1424
|
+
};
|
|
1425
|
+
/**
|
|
1426
|
+
* DSL interface for postprocessors.
|
|
1427
|
+
*/
|
|
1428
|
+
export type PostprocessorDslInterface = Omit<DocumentProcessorDslInterface, "process"> & {
|
|
1429
|
+
process(fn: (this: PostprocessorDslInterface, document: Document, output: string) => string): void;
|
|
1430
|
+
};
|
|
1077
1431
|
/**
|
|
1078
1432
|
* DSL interface for syntax processors (BlockProcessor, BlockMacroProcessor, InlineMacroProcessor).
|
|
1079
1433
|
*/
|
|
@@ -1092,37 +1446,59 @@ export type SyntaxProcessorDslInterface = ProcessorDslInterface & {
|
|
|
1092
1446
|
/**
|
|
1093
1447
|
* DSL interface for include processors.
|
|
1094
1448
|
*/
|
|
1095
|
-
export type IncludeProcessorDslInterface = DocumentProcessorDslInterface & {
|
|
1449
|
+
export type IncludeProcessorDslInterface = Omit<DocumentProcessorDslInterface, "process"> & {
|
|
1096
1450
|
handles(fn: (target: string) => boolean): void;
|
|
1097
1451
|
handles(fn: (doc: Document, target: string) => boolean): void;
|
|
1452
|
+
process(fn: (this: IncludeProcessorDslInterface, document: Document, reader: Reader, target: string, attributes: Record<string, string>) => void): void;
|
|
1098
1453
|
};
|
|
1099
1454
|
/**
|
|
1100
1455
|
* DSL interface for docinfo processors.
|
|
1101
1456
|
*/
|
|
1102
|
-
export type DocinfoProcessorDslInterface = DocumentProcessorDslInterface & {
|
|
1457
|
+
export type DocinfoProcessorDslInterface = Omit<DocumentProcessorDslInterface, "process"> & {
|
|
1103
1458
|
atLocation(value: string): void;
|
|
1459
|
+
process(fn: (this: DocinfoProcessorDslInterface, document: Document) => string): void;
|
|
1104
1460
|
};
|
|
1105
1461
|
/**
|
|
1106
1462
|
* DSL interface for block processors.
|
|
1463
|
+
*
|
|
1464
|
+
* The `process` callback is bound to the processor instance, so `this` inside it
|
|
1465
|
+
* (and inside the registration function) exposes the `createBlock` helpers.
|
|
1107
1466
|
*/
|
|
1108
|
-
export type BlockProcessorDslInterface = SyntaxProcessorDslInterface & {
|
|
1467
|
+
export type BlockProcessorDslInterface = Omit<SyntaxProcessorDslInterface, "process"> & {
|
|
1109
1468
|
contexts(...value: (string | string[])[]): void;
|
|
1110
1469
|
onContexts(...value: (string | string[])[]): void;
|
|
1111
1470
|
onContext(...value: (string | string[])[]): void;
|
|
1112
1471
|
bindTo(...value: (string | string[])[]): void;
|
|
1472
|
+
createBlock(parent: AbstractBlock, context: string, source?: string | string[] | null, attrs?: object, opts?: object): Block;
|
|
1473
|
+
process(fn: (this: BlockProcessorDslInterface, parent: AbstractBlock, reader: Reader, attributes: Record<string, unknown>) => AbstractBlock | void): void;
|
|
1113
1474
|
};
|
|
1114
1475
|
/**
|
|
1115
1476
|
* DSL interface for macro processors (block and inline macros).
|
|
1116
1477
|
*/
|
|
1117
1478
|
export type MacroProcessorDslInterface = SyntaxProcessorDslInterface;
|
|
1479
|
+
/**
|
|
1480
|
+
* DSL interface for block macro processors.
|
|
1481
|
+
*
|
|
1482
|
+
* The `process` callback is bound to the processor instance, so `this` inside it
|
|
1483
|
+
* (and inside the registration function) exposes the `createBlock` helpers.
|
|
1484
|
+
*/
|
|
1485
|
+
export type BlockMacroProcessorDslInterface = Omit<MacroProcessorDslInterface, "process"> & {
|
|
1486
|
+
createBlock(parent: AbstractBlock, context: string, source?: string | string[] | null, attrs?: object, opts?: object): Block;
|
|
1487
|
+
process(fn: (this: BlockMacroProcessorDslInterface, parent: AbstractBlock, target: string, attributes: Record<string, unknown>) => AbstractBlock | void): void;
|
|
1488
|
+
};
|
|
1118
1489
|
/**
|
|
1119
1490
|
* DSL interface for inline macro processors.
|
|
1491
|
+
*
|
|
1492
|
+
* The `process` callback is bound to the processor instance, so `this` inside it
|
|
1493
|
+
* (and inside the registration function) exposes the `createInline` helper.
|
|
1120
1494
|
*/
|
|
1121
|
-
export type InlineMacroProcessorDslInterface = MacroProcessorDslInterface & {
|
|
1495
|
+
export type InlineMacroProcessorDslInterface = Omit<MacroProcessorDslInterface, "process"> & {
|
|
1122
1496
|
format(value: string): void;
|
|
1123
1497
|
matchFormat(value: string): void;
|
|
1124
1498
|
usingFormat(value: string): void;
|
|
1125
1499
|
match(value: RegExp): void;
|
|
1500
|
+
createInline(parent: AbstractBlock, context: string, text: string, opts?: object): Inline;
|
|
1501
|
+
process(fn: (this: InlineMacroProcessorDslInterface, parent: AbstractBlock, target: string, attributes: Record<string, unknown>) => Inline | void): void;
|
|
1126
1502
|
};
|
|
1127
1503
|
import { Section } from './section.js';
|
|
1128
1504
|
import { Block } from './block.js';
|
package/types/index.d.cts
CHANGED
|
@@ -29,11 +29,15 @@ export function load(input: string | string[] | Buffer, options?: any): Promise<
|
|
|
29
29
|
export function loadFile(filename: string, options?: any): Promise<Document>;
|
|
30
30
|
export type { ProcessorDslInterface } from './extensions.js';
|
|
31
31
|
export type { DocumentProcessorDslInterface } from './extensions.js';
|
|
32
|
+
export type { PreprocessorDslInterface } from './extensions.js';
|
|
33
|
+
export type { TreeProcessorDslInterface } from './extensions.js';
|
|
34
|
+
export type { PostprocessorDslInterface } from './extensions.js';
|
|
32
35
|
export type { SyntaxProcessorDslInterface } from './extensions.js';
|
|
33
36
|
export type { IncludeProcessorDslInterface } from './extensions.js';
|
|
34
37
|
export type { DocinfoProcessorDslInterface } from './extensions.js';
|
|
35
38
|
export type { BlockProcessorDslInterface } from './extensions.js';
|
|
36
39
|
export type { MacroProcessorDslInterface } from './extensions.js';
|
|
40
|
+
export type { BlockMacroProcessorDslInterface } from './extensions.js';
|
|
37
41
|
export type { InlineMacroProcessorDslInterface } from './extensions.js';
|
|
38
42
|
import { Document } from './document.js';
|
|
39
43
|
import { convert } from './convert.js';
|
package/types/index.d.ts
CHANGED
|
@@ -28,11 +28,15 @@ export function load(input: string | string[] | Buffer, options?: any): Promise<
|
|
|
28
28
|
export function loadFile(filename: string, options?: any): Promise<Document>;
|
|
29
29
|
export type { ProcessorDslInterface } from './extensions.js';
|
|
30
30
|
export type { DocumentProcessorDslInterface } from './extensions.js';
|
|
31
|
+
export type { PreprocessorDslInterface } from './extensions.js';
|
|
32
|
+
export type { TreeProcessorDslInterface } from './extensions.js';
|
|
33
|
+
export type { PostprocessorDslInterface } from './extensions.js';
|
|
31
34
|
export type { SyntaxProcessorDslInterface } from './extensions.js';
|
|
32
35
|
export type { IncludeProcessorDslInterface } from './extensions.js';
|
|
33
36
|
export type { DocinfoProcessorDslInterface } from './extensions.js';
|
|
34
37
|
export type { BlockProcessorDslInterface } from './extensions.js';
|
|
35
38
|
export type { MacroProcessorDslInterface } from './extensions.js';
|
|
39
|
+
export type { BlockMacroProcessorDslInterface } from './extensions.js';
|
|
36
40
|
export type { InlineMacroProcessorDslInterface } from './extensions.js';
|
|
37
41
|
import { Document } from './document.js';
|
|
38
42
|
import { convert } from './convert.js';
|