rehype-retext
Version:
rehype plugin to transform to retext
117 lines • 4.13 kB
TypeScript
/**
* Bridge or mutate to retext.
*
* ###### Notes
*
* * if a [processor][] is given, uses its parser to create a new nlcst tree,
* then runs the plugins attached to with that ([*bridge mode*][bridge]);
* you can add a parser to processor for example with `retext-english`; other
* plugins used on the processor should be retext plugins
* * if a [parser][] is given, uses it to create a new nlcst tree, and returns
* it (*mutate mode*); you can get a parser by importing `Parser` from
* `retext-english` for example; other plugins used after `rehypeRetext`
* should be retext plugins
*
* @overload
* @param {Processor<NlcstRoot>} processor
* @returns {TransformBridge}
*
* @overload
* @param {Parser} parser
* @returns {TransformMutate}
*
* @overload
* @param {Parser | Processor<NlcstRoot>} options
* @returns {TransformBridge | TransformMutate}
*
* @param {Parser | Processor<NlcstRoot>} options
* Configuration (required).
* @returns {TransformBridge | TransformMutate}
* Transform.
*/
export default function rehypeRetext(processor: Processor<NlcstRoot>): TransformBridge;
/**
* Bridge or mutate to retext.
*
* ###### Notes
*
* * if a [processor][] is given, uses its parser to create a new nlcst tree,
* then runs the plugins attached to with that ([*bridge mode*][bridge]);
* you can add a parser to processor for example with `retext-english`; other
* plugins used on the processor should be retext plugins
* * if a [parser][] is given, uses it to create a new nlcst tree, and returns
* it (*mutate mode*); you can get a parser by importing `Parser` from
* `retext-english` for example; other plugins used after `rehypeRetext`
* should be retext plugins
*
* @overload
* @param {Processor<NlcstRoot>} processor
* @returns {TransformBridge}
*
* @overload
* @param {Parser} parser
* @returns {TransformMutate}
*
* @overload
* @param {Parser | Processor<NlcstRoot>} options
* @returns {TransformBridge | TransformMutate}
*
* @param {Parser | Processor<NlcstRoot>} options
* Configuration (required).
* @returns {TransformBridge | TransformMutate}
* Transform.
*/
export default function rehypeRetext(parser: Parser): TransformMutate;
/**
* Bridge or mutate to retext.
*
* ###### Notes
*
* * if a [processor][] is given, uses its parser to create a new nlcst tree,
* then runs the plugins attached to with that ([*bridge mode*][bridge]);
* you can add a parser to processor for example with `retext-english`; other
* plugins used on the processor should be retext plugins
* * if a [parser][] is given, uses it to create a new nlcst tree, and returns
* it (*mutate mode*); you can get a parser by importing `Parser` from
* `retext-english` for example; other plugins used after `rehypeRetext`
* should be retext plugins
*
* @overload
* @param {Processor<NlcstRoot>} processor
* @returns {TransformBridge}
*
* @overload
* @param {Parser} parser
* @returns {TransformMutate}
*
* @overload
* @param {Parser | Processor<NlcstRoot>} options
* @returns {TransformBridge | TransformMutate}
*
* @param {Parser | Processor<NlcstRoot>} options
* Configuration (required).
* @returns {TransformBridge | TransformMutate}
* Transform.
*/
export default function rehypeRetext(options: Parser | Processor<NlcstRoot>): TransformBridge | TransformMutate;
export type Parser = ParserConstructor | ParserInstance;
/**
* Bridge-mode.
*
* Runs the destination with the new nlcst tree.
* Discards result.
*/
export type TransformBridge = (tree: HastRoot, file: VFile) => Promise<undefined>;
/**
* Mutate-mode.
*
* Further transformers run on the nlcst tree.
*/
export type TransformMutate = (tree: HastRoot, file: VFile) => NlcstRoot;
import type { Root as NlcstRoot } from 'nlcst';
import type { Processor } from 'unified';
import type { ParserConstructor } from 'hast-util-to-nlcst';
import type { ParserInstance } from 'hast-util-to-nlcst';
import type { Root as HastRoot } from 'hast';
import type { VFile } from 'vfile';
//# sourceMappingURL=index.d.ts.map