      let formatted = html
        .replace(/>\s*</g, '><')  // Remove spaces between tags
        .replace(/></g, '>\n<');   // Add newlines between tags

      const lines = formatted.split('\n');
      let indentLevel = 0;
      const indentChar = '  ';
      const result = [];

      for (let i = 0; i < lines.length; i++) {
        const line = lines[i].trim();
        if (!line) continue;

        // Check if this is a closing tag
        if (line.startsWith('</')) {
          indentLevel = Math.max(0,