UNPKG

remark-flexible-containers

Version:

Remark plugin to add custom containers with customizable properties in markdown

60 lines (59 loc) 1.81 kB
import type { Plugin } from "unified"; import type { BlockContent, Data, Parent, Root } from "mdast"; interface ContainerData extends Data { } interface Container extends Parent { /** * Node type of mdast Mark. */ type: "container"; /** * Children of paragraph. */ children: BlockContent[]; /** * Data associated with the mdast paragraph. */ data?: ContainerData | undefined; } declare module "mdast" { interface BlockContentMap { container: Container; } interface RootContentMap { container: Container; } } type TitleFunction = (type?: string, title?: string) => string | null | undefined; type TagNameFunction = (type?: string, title?: string) => string; type ClassNameFunction = (type?: string, title?: string) => string[]; type PropertyFunction = (type?: string, title?: string) => RestrictedRecord; type RestrictedRecord = Record<string, unknown> & { className?: never; }; export type FlexibleContainerOptions = { title?: TitleFunction; containerTagName?: string | TagNameFunction; containerClassName?: string | ClassNameFunction; containerProperties?: PropertyFunction; titleTagName?: string | TagNameFunction; titleClassName?: string | ClassNameFunction; titleProperties?: PropertyFunction; }; export declare const REGEX_START: RegExp; export declare const REGEX_END: RegExp; export declare const REGEX_BAD_SYNTAX: RegExp; export declare const REGEX_CUSTOM: RegExp; /** * * This plugin adds container node with customizable properties in order to produce container element like callouts and admonitions * * for example: * * ::: warning My Title * Content with **bold text** * ::: * */ export declare const plugin: Plugin<[FlexibleContainerOptions?], Root>; export default plugin;