/** * Result of fixing a diagram or markdown content */ interface BoxfixResult { /** The fixed content with corrected alignment */ fixed: string; /** Statistics about the fix operation */ stats: BoxfixStats; } /** * Statistics about the fix operation */ interface BoxfixStats { /** Number of lines that were fixed */ linesFixed: number; /** Number of code blocks processed */ blocksProcessed: number; /** Number of diagrams detected and processed */ diagramsFound: number; } /** * A code block extracted from markdown */ interface CodeBlock { /** The full code block including fences */ raw: string; /** The content inside the fences */ content: string; /** The language identifier (if any) */ language: string | null; /** Start position in original string */ start: number; /** End position in original string */ end: number; } /** * Fix a single ASCII diagram by correcting right border alignment * * Algorithm: * 1. Find and recursively fix any inner boxes first * 2. Process the diagram top to bottom, tracking current box context * 3. When we see a boundary line, update the target width for subsequent lines * 4. For content lines shorter than target (by small margin), pad them * 5. This handles nested/stacked boxes correctly by using local context */ declare function boxfixDiagram(content: string): { result: string; linesFixed: number; }; /** * Fix ASCII diagrams in a string (without markdown parsing) * This is the core function that processes raw diagram content */ declare function boxfix(content: string): BoxfixResult; /** * Process a markdown string, finding and fixing diagram code blocks */ declare function boxfixMarkdown(markdown: string): BoxfixResult; /** * Check if content appears to be an ASCII diagram (as opposed to regular code) */ declare function isDiagram(content: string): boolean; /** * Check if a line is a tree structure line (should not be normalized) * Tree lines use ├── patterns and do NOT start and end with │ (box content) */ declare function isTreeLine(line: string): boolean; /** * Check if a line is a boundary line (top/bottom of a box) * Boundary lines START and END with corner characters and contain horizontal lines * This distinguishes them from content lines that may contain inner box boundaries */ declare function isBoundaryLine(line: string): boolean; /** * Check if a line is a connector line between multiple boxes * Connector lines have more than 2 vertical bars with only whitespace between them * Example: "│ │ │" (connector) vs "│ foo │ bar │" (table row with content) */ declare function isConnectorLine(line: string): boolean; /** * Check if a line is a content line that should be normalized * Content lines both START and END with a vertical border character * and have content between them (minimum 3 chars: border + content + border) * This distinguishes them from standalone connector lines (e.g., just "│" for arrows) */ declare function isContentLine(line: string): boolean; /** * Get the display width of a string, accounting for: * - CJK characters (2 columns each) * - Emoji (variable width) * - ANSI escape codes (0 width) * - Combining characters (0 width) */ declare function getDisplayWidth(str: string): number; /** * Expand tabs to spaces (default 8-space tab stops) */ declare function expandTabs(str: string, tabSize?: number): string; export { type BoxfixResult, type BoxfixStats, type CodeBlock, boxfix, boxfixDiagram, boxfixMarkdown, expandTabs, getDisplayWidth, isBoundaryLine, isConnectorLine, isContentLine, isDiagram, isTreeLine };