/** * A markdown image link occurrence with its exact span in the source content. * * The span covers the whole `![alt](href)` expression so callers can rewrite the occurrence * surgically without re-serialising the surrounding document. * * @category Core */ export interface ImageLinkOccurrence { /** Alt text between the brackets, or undefined when the brackets are empty */ alt: string | undefined; /** The href exactly as written in the source */ href: string; /** Link title exactly as written, or undefined when absent */ title: string | undefined; /** Start offset of the leading `!` in the surrounding content */ start: number; /** End offset (exclusive) just past the closing parenthesis */ end: number; } /** * Find image links in markdown content whose href points at a local file. * * Uses the markdown AST, so images that merely look like syntax (inside fenced code blocks, for * example) are not reported. A href counts as local when it carries no URI scheme, is not a data * URI, and is not a same-file anchor. * * @category Core * * @param content - Markdown content to scan * * @returns Occurrences of local image links in source order */ export declare function findLocalImages(content: string): ImageLinkOccurrence[]; /** * Find image links in markdown content whose href is an inline data URI. * * @category Core * * @param content - Markdown content to scan * * @returns Occurrences of data URI image links in source order */ export declare function findInlineImages(content: string): ImageLinkOccurrence[]; /** The payload of a parsed inline data URI: its exact media type and base64 payload. */ export interface ParsedImageDataUri { /** Media type exactly as written in the URI, always an image type */ mimeType: string; /** The base64 payload between the comma and the end of the URI */ data: string; } /** * Parse an inline base64 image data URI. * * @category Core * * @param href - The data URI to parse, typically an image link href * * @returns The media type and base64 payload * * @throws Error when the URI is malformed, not base64 encoded, or not an image type */ export declare function parseImageDataUri(href: string): ParsedImageDataUri; /** * Resolve the mime type for an image file extension. * * @category Core * * @param extension - File extension with or without a leading dot; case-insensitive * * @returns The image mime type for the extension * * @throws Error when the extension has no known image mime type */ export declare function imageMimeTypeForExtension(extension: string): string; /** * Resolve the preferred file extension for an image mime type. * * @category Core * * @param mimeType - Image mime type, for example the one parsed from a data URI * * @returns The file extension without a leading dot * * @throws Error when the mime type has no known image file extension */ export declare function imageExtensionForMimeType(mimeType: string): string; /** * Render an image link in standard markdown syntax. * * Bracket characters in the alt text are backslash-escaped so the rendered link stays a single * image node when re-parsed. A href containing whitespace is angle-wrapped, the form markdown * requires for such hrefs; data URIs never contain whitespace and pass through unwrapped. * * @category Core * * @param alt - Alt text, or undefined for empty brackets * @param href - The href, typically a data URI or a filesystem path * @param title - Optional link title rendered after the href * * @returns The rendered `![alt](href "title")` expression */ export declare function renderImageMarkdown(alt: string | undefined, href: string, title?: string): string; /** A source span to replace with new text. */ export interface SpanReplacement { /** Start offset of the span, inclusive */ start: number; /** End offset of the span, exclusive */ end: number; /** The text the span is replaced with */ replacement: string; } /** * Replace spans of content with new text, leaving everything outside the spans byte-identical. * * @category Core * * @param content - The original content * @param replacements - Spans to replace, in any order; they must not overlap * * @returns The content with every span replaced * * @throws Error when spans overlap or lie outside the content bounds */ export declare function replaceSpans(content: string, replacements: SpanReplacement[]): string; //# sourceMappingURL=image-inline.d.ts.map