From 51f3fe81b6a517a92ff95242c55ac13786e010f3 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Sat, 8 Aug 2026 18:59:57 -0700 Subject: [PATCH] fix(site-builder): make formatHtml quote- and raw-text-aware Code review found two Important bugs from only
 being exempted from
the naive  tag-boundary scan: a > inside a quoted attribute value split
tags and broke idempotency, and 
'; + expect(formatHtml(src)).toBe( + '
\n \n
\n
\n \n
', + ); + }); + + test('a CSS child combinator inside '; + expect(formatHtml(src)).toBe( + '
\n \n
', + ); + }); + + test('is idempotent across a quoted ">" attribute and
'; + const scripted = formatHtml(scriptSrc); + expect(formatHtml(scripted)).toBe(scripted); + }); + + test('an unclosed
 is swallowed verbatim to the end of the document', () => {
+    expect(formatHtml('
no closing tag here')).toBe(
+      '
\n
no closing tag here',
+    );
+  });
+});
diff --git a/craft/src/utils/format-html.ts b/craft/src/utils/format-html.ts
index 07214dd..f16e311 100644
--- a/craft/src/utils/format-html.ts
+++ b/craft/src/utils/format-html.ts
@@ -7,7 +7,13 @@
  * user markup is a formatter people stop trusting.
  *
  * Inline tags (, , , ...) are left exactly where they sit,
- * and 
 contents are copied through verbatim.
+ * and 
/