/** * Markdown output escaping utilities. * * Provides functions to safely escape content for Markdown output, * including tables, code blocks, and Mermaid diagrams. */ /** * Escape a string for use in a Markdown table cell. * Handles pipe characters and other special characters that break table structure. * * @param text - The text to escape * @returns Escaped text safe for table cells */ export declare function escapeTableCell(text: string): string; /** * Escape a string for use inside a code block. * Handles backticks that would prematurely close the code block. * * @param text - The text to escape * @returns Escaped text safe for code blocks */ export declare function escapeCodeBlock(text: string): string; /** * Escape a string for use in a Mermaid diagram. * Handles quotes, brackets, and other special characters. * * @param text - The text to escape * @returns Escaped text safe for Mermaid */ export declare function escapeMermaid(text: string): string; /** * Escape a string for use as a Mermaid node label. * Wraps in quotes and escapes special characters. * * @param text - The text to use as a label * @returns Safe Mermaid node label */ export declare function mermaidLabel(text: string): string; /** * Options for JSON code block validation. */ export interface JsonCodeBlockOptions { /** Maximum length before truncating (default: unlimited) */ maxLength?: number; /** Truncation indicator (default: '...(truncated)') */ truncationIndicator?: string; /** Whether to pretty-print the JSON (default: true) */ prettyPrint?: boolean; /** Indentation for pretty-printing (default: 2) */ indent?: number; } /** * Result of validating JSON for a code block. */ export interface JsonCodeBlockResult { /** Whether the JSON is valid */ valid: boolean; /** The formatted JSON string (or original if invalid) */ content: string; /** Whether the content was truncated */ truncated: boolean; /** Error message if JSON is invalid */ error?: string; } /** * Validate and format JSON for output in a code block. * Returns safe content even if JSON is invalid. * * @param json - The JSON string or object to validate * @param options - Formatting options * @returns Validation result with safe content */ export declare function validateJsonForCodeBlock(json: string | unknown, options?: JsonCodeBlockOptions): JsonCodeBlockResult; /** * Escape special characters in inline code. * * @param text - The text to escape * @returns Escaped text safe for inline code */ export declare function escapeInlineCode(text: string): string; /** * Escape text for use in a Markdown link title. * * @param text - The text to escape * @returns Escaped text safe for link titles */ export declare function escapeLinkTitle(text: string): string; /** * Escape text for use in a Markdown bullet list item. * * @param text - The text to escape * @returns Escaped text safe for list items */ export declare function escapeListItem(text: string): string; /** * Wrap text to ensure it fits within table cell width constraints. * * @param text - The text to wrap * @param maxWidth - Maximum width (default: 50) * @returns Wrapped text with
for line breaks */ export declare function wrapTableCell(text: string, maxWidth?: number): string; /** * Build a Markdown table from headers and rows. * Automatically escapes cell content. * * @param headers - Array of header strings * @param rows - 2D array of cell values * @param alignments - Optional array of column alignments ('left', 'center', 'right') * @returns Complete Markdown table string */ export declare function buildTable(headers: string[], rows: string[][], alignments?: Array<'left' | 'center' | 'right'>): string; //# sourceMappingURL=markdown.d.ts.map