UNPKG

remark-flexible-code-titles

Version:

Remark plugin to add title or/and container for code blocks with customizable properties in markdown

57 lines 1.55 kB
import type { Plugin } from "unified"; import type { Root, Data, BlockContent, Parent } 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; } } interface Properties { [PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>; } type PropertyFunction = (language?: string, title?: string) => Omit<Properties, "className"> & { className?: never; }; export type CodeTitleOptions = { title?: boolean; titleTagName?: string; titleClassName?: string; titleProperties?: PropertyFunction; container?: boolean; containerTagName?: string; containerClassName?: string; containerProperties?: PropertyFunction; handleMissingLanguageAs?: string; tokenForSpaceInTitle?: string; }; /** * * This plugin adds a title element before the code element, if the title exists in the markdown code block; * and wraps them in a container. * * for example: * ```javascript:title.js * // some js code * ``` */ export declare const plugin: Plugin<[CodeTitleOptions?], Root>; export default plugin; //# sourceMappingURL=index.d.ts.map