UNPKG

strip-markdown

Version:

remark plugin to remove markdown formatting

46 lines (45 loc) 1.52 kB
/** * Remove markdown formatting. * * * remove `code`, `html`, `horizontalRule`, `table`, `toml`, `yaml`, and * their content * * render everything else as simple paragraphs without formatting * * uses `alt` text for images * * @param {Readonly<Options> | null | undefined} [options] * Configuration (optional). * @returns * Transform. */ export default function stripMarkdown(options?: Readonly<Options> | null | undefined): (tree: Root) => Root; export type Heading = import('mdast').Heading; export type Image = import('mdast').Image; export type ImageReference = import('mdast').ImageReference; export type InlineCode = import('mdast').InlineCode; export type Nodes = import('mdast').Nodes; export type Paragraph = import('mdast').Paragraph; export type Parents = import('mdast').Parents; export type Root = import('mdast').Root; export type RootContent = import('mdast').RootContent; export type Text = import('mdast').Text; /** * Transform a node. */ export type Handler = (node: any) => Array<Nodes> | Nodes | null | undefined; /** * Handlers. */ export type Handlers = Partial<Record<Nodes['type'], Handler>>; /** * Configuration. */ export type Options = { /** * List of node types to leave unchanged (optional). */ keep?: ReadonlyArray<Nodes['type']> | null | undefined; /** * List of node types to remove (or replace, with handlers) (optional). */ remove?: ReadonlyArray<readonly [Nodes['type'], Handler] | Nodes['type']> | null | undefined; };