From c88f887b743ad45f0d45489c298f996d8887adac Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Fri, 31 Jul 2026 21:18:49 +0530 Subject: [PATCH 1/5] fix: escape hint output instead of parsing it --- src/lib/__tests__/formatHintOutput.test.ts | 34 ++++++++++++++++++ src/lib/formatHintOutput.ts | 40 ++++++++++++++-------- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/src/lib/__tests__/formatHintOutput.test.ts b/src/lib/__tests__/formatHintOutput.test.ts index 6f72347..a636a39 100644 --- a/src/lib/__tests__/formatHintOutput.test.ts +++ b/src/lib/__tests__/formatHintOutput.test.ts @@ -59,4 +59,38 @@ describe('formatHintOutput', () => { it('returns an empty string for empty input', () => { expect(formatHintOutput(' ')).toBe(''); }); + + it('keeps attributes readable as text on escaped elements', () => { + expect(formatHintOutput('Your is missing alt text.')).toBe( + 'Your <img src="cat.jpg"> is missing alt text.', + ); + }); + + it('keeps attributes readable as text inside code elements', () => { + expect(formatHintOutput('Use .')).toBe( + 'Use <meta charset="utf-8">.', + ); + }); + + it('does not let raw-text elements swallow the closing code tag', () => { + expect(formatHintOutput('Wrap it in