UNPKG

@vahor/rehype-d2

Version:

A Rehype plugin to convert D2 diagrams to SVG or PNG.

51 lines (45 loc) 1.09 kB
import "./d2.d.ts"; import { Root } from 'hast'; import { Plugin } from 'unified'; declare const strategies: readonly [ "inline-svg", "inline-png" ]; export type Strategy = (typeof strategies)[number]; export type Themes = readonly [ string, ...string[] ]; export type RehypeD2Options<T extends Themes = Themes> = { strategy?: Strategy; cwd?: string; target?: { tagName: string; className: string; }; defaultThemes?: T; defaultMetadata?: Record<T[number], { [k in keyof NodeMetadata]?: NodeMetadata[k] | ((value: string) => NodeMetadata[k]); }>; globalImports?: Record<T[number], Array<`${string}.d2` | { filename: `${string}.d2`; mode: "prepend" | "import"; }>>; }; export interface NodeMetadata extends Omit<CompileOptions, `font${string}` | "target" | "darkThemeId"> { title?: string; alt?: string; width?: string; height?: string; optimize?: boolean; } export declare class RehypeD2RendererError extends Error { constructor(message: string); } declare const rehypeD2: Plugin<[ RehypeD2Options ], Root>; export { rehypeD2 as default, }; export {};