diff --git a/craft/src/utils/format-html.test.ts b/craft/src/utils/format-html.test.ts index a7bb1a1..fc9cb3a 100644 --- a/craft/src/utils/format-html.test.ts +++ b/craft/src/utils/format-html.test.ts @@ -39,3 +39,45 @@ describe('formatHtml', () => { expect(formatHtml('

x

')).toBe('\n

x

'); }); }); + +// Regression coverage from code review: only
 was originally exempted
+// from the naive '<'/'>' tag-boundary scan, which let a '>' inside a quoted
+// attribute value corrupt output, and let '<'/'>' inside 
'; + 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 
/