/** * Render a single PlantUML block to sanitised SVG with a content-addressed cache. * @module markdown/render */ import { createCache } from "./cache.mjs"; /** Package version; part of every cache key so upgrades never serve stale output. */ export declare const PACKAGE_VERSION: string; /** Cache shared by every caller that does not pass its own `cache`. */ export declare const defaultCache: import("./cache.mjs").Cache; export type BlockOptions = { /** * Theme name or object. */ theme?: string | import("../draw/theme.mjs").Theme; /** * Individual colour overrides by theme path. */ themeColors?: Record; /** * Clean strokes instead of the hand-drawn look. */ clean?: boolean; /** * Same as `clean`, inverted; wins over `clean`. */ sketch?: boolean; /** * Seed for stroke wobble. */ seed?: string | number; /** * Rescale the SVG to this pixel width (16–16000). */ width?: number; /** * Page of a `newpage` diagram. */ page?: number; /** * Fail on unrecognised lines. */ strict?: boolean; /** * Per-diagram limits. */ limits?: Partial; /** * `!include` resolver. */ include?: import("../core/preprocess/preprocessor.mjs").IncludeResolver; /** * Entry path in the include resolver's namespace. */ sourcePath?: string; /** * Fail when an include cannot be resolved. */ strictIncludes?: boolean; /** * Identifies the include resolver's content. Without it, results * rendered with `include` are not stored in the shared cache. */ includeKey?: string; /** * Predefined preprocessor variables. */ defines?: Record; /** * Date returned by `%date()`. */ date?: Date | null; /** * Value of `%filename()`. */ filename?: string; /** * Force a diagram kind. */ kind?: string; /** * Inline Excalifont as a data URL (default true). */ embedFont?: boolean; /** * Background colour. */ background?: string; /** * CSS scope prefix for the SVG's text rule (inline use). */ scope?: string; /** * Cache to use; * `false` disables caching. */ cache?: import("./cache.mjs").Cache | false | null; }; export type BlockResult = { /** * Sanitised standalone SVG (absent on error). */ svg?: string; /** * Content hash of source + options + package version (16 hex chars). */ hash: string; diagnostics: import("../core/diagnostics.mjs").Diagnostic[]; /** * Readable message when the block could not be rendered. */ error?: string; /** * Line within the block's source the error refers to. */ line?: number | null; /** * Diagram kind. */ kind?: string; /** * Plain-text diagram title, if any. */ title?: string | null; /** * Whether the result came from the cache. */ cached?: boolean; }; /** * @param {string} text * @returns {string} 16 hex characters. */ export declare function hash16(text: string): string; /** * Cache key (content hash) of a block without rendering it. * @param {string} source * @param {BlockOptions} [options] * @returns {string} * @public */ export declare function blockHash(source: string, options?: BlockOptions): string; /** * Look a block up in the cache without rendering it. * @param {string} source * @param {BlockOptions} [options] * @returns {{ hash: string, result: BlockResult | undefined }} * @public */ export declare function peekBlock(source: string, options?: BlockOptions): { hash: string; result: BlockResult | undefined; }; /** * Strip simple markup (``, ``, …) and collapse whitespace. * @param {string} text */ export declare function plainText(text: string): string; /** * Render one PlantUML block to a sanitised standalone SVG. Never throws: * failures come back as `{ error }`. Results are cached by content hash. * @param {string} source PlantUML text (with or without `@startuml`). * @param {BlockOptions} [options] * @returns {Promise} * @public */ export declare function renderBlock(source: string, options?: BlockOptions): Promise; /** * Merge fence attributes (`{theme=dark clean}`) over base options. * @param {BlockOptions} base * @param {import("./scan.mjs").FenceAttrs} attrs * @returns {BlockOptions} */ export declare function mergeAttrs(base: BlockOptions, attrs: import("./scan.mjs").FenceAttrs): BlockOptions; /** * Accessible label for a rendered block. * @param {BlockResult} result * @param {import("./scan.mjs").FenceAttrs} [attrs] */ export declare function altText(result: BlockResult, attrs?: import("./scan.mjs").FenceAttrs): string; /** * Inline HTML for a rendered block. * @param {BlockResult} result Must carry `svg`. * @param {string} alt */ export declare function inlineHtml(result: BlockResult, alt: string): string; /** * Visible error box (escaped message). * @param {string} message */ export declare function errorHtml(message: string): string; /** * Normalise a relative asset directory (`assets`, `docs/img`, `../img`). * @param {unknown} dir * @returns {string} Forward-slash path without trailing slash; `""` for the document directory. */ export declare function normalizeAssetsDir(dir: unknown): string; /** * Validate a URL prefix for emitted image links (`/img/diagrams`, `assets`, `https://cdn/x`). * @param {unknown} prefix * @returns {string} */ export declare function normalizeAssetsUrl(prefix: unknown): string; /** * Path of an asset file relative to the document, and the URL used to link it. * @param {string} hash * @param {string} dir Output of {@link normalizeAssetsDir}. * @param {string} [urlPrefix] Output of {@link normalizeAssetsUrl}; defaults to `dir`. * @returns {{ name: string, url: string }} */ export declare function assetRef(hash: string, dir: string, urlPrefix?: string): { name: string; url: string; }; /** * Escape text for use inside Markdown image alt text. * @param {string} text */ export declare function escapeMarkdownAlt(text: string): string; /** Re-export so callers need one import for cache creation. */ export { createCache };