UNPKG

remark-flexible-markers

Version:

Remark plugin to add custom mark element with customizable properties in markdown

68 lines (67 loc) 2.11 kB
import type { Plugin } from "unified"; import type { Data, Parent, PhrasingContent, Root } from "mdast"; interface MarkData extends Data { } interface Mark extends Parent { /** * Node type of mdast Mark. */ type: "mark"; /** * Children of paragraph. */ children: PhrasingContent[]; /** * Data associated with the mdast paragraph. */ data?: MarkData | undefined; } declare module "mdast" { interface PhrasingContentMap { mark: Mark; } interface RootContentMap { mark: Mark; } } type Key = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"; type Dictionary = Partial<Record<Key, string>>; type RestrictedRecord = Record<string, unknown> & { className?: never; }; type TagNameFunction = (color?: string) => string; type ClassNameFunction = (color?: string) => string[]; type PropertyFunction = (color?: string) => RestrictedRecord; export type FlexibleMarkerOptions = { dictionary?: Dictionary; markerTagName?: string | TagNameFunction; markerClassName?: string | ClassNameFunction; markerProperties?: PropertyFunction; equalityOperator?: string; actionForEmptyContent?: "keep" | "remove" | "mark"; }; export declare const REGEX: RegExp; export declare const REGEX_GLOBAL: RegExp; export declare const REGEX_STARTING: RegExp; export declare const REGEX_STARTING_GLOBAL: RegExp; export declare const REGEX_ENDING: RegExp; export declare const REGEX_ENDING_GLOBAL: RegExp; export declare const REGEX_EMPTY: RegExp; export declare const REGEX_EMPTY_GLOBAL: RegExp; /** * * a utility like "clsx" package */ export declare function clsx<T>(arr: (T | false | null | undefined | 0)[]): T[]; /** * * This plugin turns ==content== into a <mark> element with customizable classification * * for example: * * Here is ==marked text with default color== * Here is =r=marked text with red classification== * */ declare const plugin: Plugin<[FlexibleMarkerOptions?], Root>; export default plugin;