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('\nx
'); }); }); + +// Regression coverage from code review: onlywas 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 unclosedis swallowed verbatim to the end of the document', () => { + expect(formatHtml('no closing tag here')).toBe( + '\nno 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, - * andcontents are copied through verbatim. + * and/