UNPKG

remark-retext

Version:
133 lines 5.01 kB
/** * 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 `remarkRetext` * should be retext plugins * * @overload * @param {Processor<NlcstRoot>} processor * @param {Options | null | undefined} [options] * @returns {TransformBridge} * * @overload * @param {Parser} parser * @param {Options | null | undefined} [options] * @returns {TransformMutate} * * @overload * @param {Parser | Processor<NlcstRoot>} destination * @param {Options | null | undefined} [options] * @returns {TransformBridge | TransformMutate} * * @param {Parser | Processor<NlcstRoot>} destination * Parser or processor (required). * @param {Options | null | undefined} [options] * Configuration (optional). * @returns {TransformBridge | TransformMutate} * Transform. */ export default function remarkRetext(processor: Processor<NlcstRoot>, options?: Options | null | undefined): 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 `remarkRetext` * should be retext plugins * * @overload * @param {Processor<NlcstRoot>} processor * @param {Options | null | undefined} [options] * @returns {TransformBridge} * * @overload * @param {Parser} parser * @param {Options | null | undefined} [options] * @returns {TransformMutate} * * @overload * @param {Parser | Processor<NlcstRoot>} destination * @param {Options | null | undefined} [options] * @returns {TransformBridge | TransformMutate} * * @param {Parser | Processor<NlcstRoot>} destination * Parser or processor (required). * @param {Options | null | undefined} [options] * Configuration (optional). * @returns {TransformBridge | TransformMutate} * Transform. */ export default function remarkRetext(parser: Parser, options?: Options | null | undefined): 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 `remarkRetext` * should be retext plugins * * @overload * @param {Processor<NlcstRoot>} processor * @param {Options | null | undefined} [options] * @returns {TransformBridge} * * @overload * @param {Parser} parser * @param {Options | null | undefined} [options] * @returns {TransformMutate} * * @overload * @param {Parser | Processor<NlcstRoot>} destination * @param {Options | null | undefined} [options] * @returns {TransformBridge | TransformMutate} * * @param {Parser | Processor<NlcstRoot>} destination * Parser or processor (required). * @param {Options | null | undefined} [options] * Configuration (optional). * @returns {TransformBridge | TransformMutate} * Transform. */ export default function remarkRetext(destination: Parser | Processor<NlcstRoot>, options?: Options | null | undefined): TransformBridge | TransformMutate; export type Parser = ParserConstructor | ParserInstance; /** * Bridge-mode. * * Runs the destination with the new nlcst tree. * Discards result. */ export type TransformBridge = (tree: MdastRoot, file: VFile) => Promise<undefined>; /** * Mutate-mode. * * Further transformers run on the nlcst tree. */ export type TransformMutate = (tree: MdastRoot, file: VFile) => NlcstRoot; import type { Root as NlcstRoot } from 'nlcst'; import type { Processor } from 'unified'; import type { Options } from 'mdast-util-to-nlcst'; import type { ParserConstructor } from 'mdast-util-to-nlcst'; import type { ParserInstance } from 'mdast-util-to-nlcst'; import type { Root as MdastRoot } from 'mdast'; import type { VFile } from 'vfile'; //# sourceMappingURL=index.d.ts.map