/** * Formats raw HTML string with proper indentation and line breaks for better readability. * * This utility takes minified or unformatted HTML and returns a human-readable version with: * - Line breaks between tags * - Proper indentation (2 spaces per nesting level) * - Preserved text content and attributes * - Correct handling of HTML comments () * - Correct handling of CDATA sections () * - Correct handling of DOCTYPE declarations () * - Safe handling of comparison operators (e.g., "5 < 10") in text content * * The formatter uses improved regex patterns that only match actual HTML tags * (starting with < followed by a letter or /), preventing false matches on * text content containing < characters. Special HTML constructs (comments, * CDATA, DOCTYPE) are temporarily replaced with placeholders during formatting * and restored afterward to preserve their exact content. * * @param html - Raw HTML string to format (can be minified or already formatted) * @returns Formatted HTML string with proper indentation and line breaks * * @example * ```typescript * const raw = '

Hello

World

'; * const formatted = formatHtml(raw); * // Returns: * //
* //

Hello

* //

World

* //
* * // Handles text with < characters correctly * const withComparison = '
5 < 10 is true
'; * const formatted2 = formatHtml(withComparison); * // Returns: * //
* // 5 < 10 is true * //
* * // Preserves HTML comments * const withComment = '

Text

'; * const formatted3 = formatHtml(withComment); * // Returns: * //
* // * //

Text

* //
* ``` */ export default function formatHtml(html: string): string;