From 5a7fc420524d5bcf64a2af45824645336b587af5 Mon Sep 17 00:00:00 2001 From: Annes Negmel-Din Date: Fri, 12 Sep 2025 11:04:25 +0200 Subject: [PATCH 1/2] fix(marked-react): add support for unescaping ` ` and ` ` entities --- src/helpers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers.ts b/src/helpers.ts index a41bd4b..2d2f587 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -4,10 +4,12 @@ const htmlUnescapes: Record = { '>': '>', '"': '"', ''': "'", + ' ': ' ', + ' ': ' ', }; /** Used to match HTML entities and HTML characters. */ -const reEscapedHtml = /&(?:amp|lt|gt|quot|#(?:0+)?39);/g; +const reEscapedHtml = /&(?:amp|lt|gt|quot|nbsp|#(?:0+)?(?:39|160));/g; const reHasEscapedHtml = RegExp(reEscapedHtml.source); export const unescape = (str = '') => { From 4388d9e5bd166f5da20067817321cfc6a7cc67a9 Mon Sep 17 00:00:00 2001 From: Annes Negmel-Din Date: Mon, 15 Sep 2025 09:20:58 +0200 Subject: [PATCH 2/2] test(helpers): add tests for unescaping ` ` and ` ` entities --- tests/helpers.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/helpers.spec.ts b/tests/helpers.spec.ts index e3d5f3b..518ac95 100644 --- a/tests/helpers.spec.ts +++ b/tests/helpers.spec.ts @@ -15,6 +15,8 @@ describe('Helpers', () => { expect(unescape('>')).toBe('>'); expect(unescape('"')).toBe('"'); expect(unescape(''')).toBe("'"); + expect(unescape(' ')).toBe(' '); + expect(unescape(' ')).toBe(' '); expect(unescape('')).toBe(''); expect(unescape()).toBe(''); });