/** * Replace PlantUML code fences in a Markdown document by rendered diagrams. * @module markdown/document */ export type MarkdownBudget = { /** * Largest accepted Markdown document (default 8 MiB). */ maxDocumentBytes: number; /** * Diagram blocks rendered per document (default 50). */ maxBlocks: number; /** * Sum of all diagram sources (default 1 MiB). */ maxTotalSourceBytes: number; /** * Sum of all rendered SVG (default 32 MiB). */ maxTotalOutputBytes: number; }; /** * Per-document budget. Block rendering itself is bounded by `DEFAULT_LIMITS` * (`limits` option); this caps the sum over a whole document. * @typedef {object} MarkdownBudget * @property {number} maxDocumentBytes Largest accepted Markdown document (default 8 MiB). * @property {number} maxBlocks Diagram blocks rendered per document (default 50). * @property {number} maxTotalSourceBytes Sum of all diagram sources (default 1 MiB). * @property {number} maxTotalOutputBytes Sum of all rendered SVG (default 32 MiB). */ /** @type {Readonly} */ export declare const MARKDOWN_LIMITS: Readonly; /** * @param {Partial | undefined} overrides * @returns {MarkdownBudget} */ export declare function resolveBudget(overrides: Partial | undefined): MarkdownBudget; export type MarkdownOptions = import("./render.mjs").BlockOptions & { mode?: "inline" | "file"; keepSource?: boolean | "comment" | "details"; assetsDir?: string; assetsUrl?: string; writeFile?: (name: string, data: string) => void | Promise; shareFont?: boolean; budget?: Partial; }; export type MarkdownBlock = { /** * Position among all diagram blocks of the document. */ index: number; /** * `region` = rendered earlier with `keepSource`. */ kind: "fence" | "region"; /** * 1-based line in the input. */ line: number; /** * Offset in the input. */ start: number; /** * Offset in the input. */ end: number; lang: string; /** * Content hash of the rendered block. */ hash?: string; /** * Whether the output differs from the input for this block. */ replaced: boolean; /** * Readable message; the block is left unchanged. */ error?: string; /** * 1-based line inside the diagram source. */ errorLine?: number | null; diagnostics: import("../core/diagnostics.mjs").Diagnostic[]; /** * Asset path (relative to the document) in `file` mode. */ asset?: string; }; export type MarkdownResult = { /** * The rewritten document. */ markdown: string; blocks: MarkdownBlock[]; /** * Files that `file` mode needs next to the document. */ assets: { name: string; data: string; }[]; /** * Whether `markdown` differs from the input. */ changed: boolean; }; /** * Render every PlantUML fence of a Markdown document. * * - `mode: "inline"` (default) writes `
…svg…
`. * - `mode: "file"` links `assets/.svg`; the files are returned in * `assets` and handed to `writeFile(name, data)` when given. `name` is * relative to the document and uses forward slashes. * - `keepSource` wraps the result in `` markers that * carry the source (safe against `-->`), so the block can be re-rendered * later. Existing regions are always re-rendered and keep their source. * - An empty fence with `src="path.puml"` loads the diagram through `include` * and retains the reference by default. * * Blocks that fail to render, or exceed the budget, stay exactly as written * and are reported in `blocks[].error`. Running the function on its own output * returns the same text. * @param {string} markdown * @param {MarkdownOptions} [options] * @returns {Promise} * @public */ export declare function renderMarkdown(markdown: string, options?: MarkdownOptions): Promise;