From 571ded6706cbe4efeb6796aa92c96856e7d8d8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Efe=20Karakanl=C4=B1?= <102619516+actuallyzefe@users.noreply.github.com> Date: Sat, 1 Nov 2025 19:53:05 +0300 Subject: [PATCH 1/3] fix(markdown): support nested lists in markdown component Fixes #2599 Previously, nested lists would crash with 'Token with "list" type was not found' error because the listitem renderer used parseInline() which only handles inline tokens. Changes: - Updated listitem renderer to detect nested lists - Use parse() for list items with nested content - Use parseInline() for simple list items (backward compatible) - Added test case for nested lists The fix maintains backward compatibility by only using parse() when needed, preventing unnecessary

tag wrapping in simple lists. --- .../src/__snapshots__/markdown.spec.tsx.snap | 18 ++++++++++++++++++ packages/markdown/src/markdown.spec.tsx | 16 ++++++++++++++++ packages/markdown/src/markdown.tsx | 7 ++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/markdown/src/__snapshots__/markdown.spec.tsx.snap b/packages/markdown/src/__snapshots__/markdown.spec.tsx.snap index 564c58405a..71d6cecf95 100644 --- a/packages/markdown/src/__snapshots__/markdown.spec.tsx.snap +++ b/packages/markdown/src/__snapshots__/markdown.spec.tsx.snap @@ -14,6 +14,24 @@ exports[` component renders correctly > renders lists in the correct f " `; +exports[` component renders correctly > renders nested lists in the correct format for browsers 1`] = ` +"

+
" +`; + exports[` component renders correctly > renders text in the correct format for browsers 1`] = ` "

This is sample bold text in markdown and this is italic text

" diff --git a/packages/markdown/src/markdown.spec.tsx b/packages/markdown/src/markdown.spec.tsx index 3743fa0383..c070ffbdf7 100644 --- a/packages/markdown/src/markdown.spec.tsx +++ b/packages/markdown/src/markdown.spec.tsx @@ -111,4 +111,20 @@ console.log(\`Hello, $\{name}!\`); ); expect(actualOutput).toMatchSnapshot(); }); + + it('renders nested lists in the correct format for browsers', async () => { + const actualOutput = await render( + + {` +- parent list item + - nested list item 1 + - nested list item 2 +- another parent item + 1. nested ordered item 1 + 2. nested ordered item 2 + `} + , + ); + expect(actualOutput).toMatchSnapshot(); + }); }); diff --git a/packages/markdown/src/markdown.tsx b/packages/markdown/src/markdown.tsx index f3cae751d2..d8b8172a7a 100644 --- a/packages/markdown/src/markdown.tsx +++ b/packages/markdown/src/markdown.tsx @@ -119,7 +119,12 @@ export const Markdown = React.forwardRef( }; renderer.listitem = ({ tokens }) => { - const text = renderer.parser.parseInline(tokens); + // Check if tokens contain nested lists + // Use parse() for nested lists, parseInline() for simple content + const hasNestedList = tokens.some((token) => token.type === 'list'); + const text = hasNestedList + ? renderer.parser.parse(tokens) + : renderer.parser.parseInline(tokens); return ` Date: Mon, 3 Nov 2025 09:00:29 -0300 Subject: [PATCH 2/3] remove comment --- packages/markdown/src/markdown.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/markdown/src/markdown.tsx b/packages/markdown/src/markdown.tsx index d8b8172a7a..282e5556a1 100644 --- a/packages/markdown/src/markdown.tsx +++ b/packages/markdown/src/markdown.tsx @@ -119,8 +119,6 @@ export const Markdown = React.forwardRef( }; renderer.listitem = ({ tokens }) => { - // Check if tokens contain nested lists - // Use parse() for nested lists, parseInline() for simple content const hasNestedList = tokens.some((token) => token.type === 'list'); const text = hasNestedList ? renderer.parser.parse(tokens) From 85e1954fbe77afc10bbf6a8e18e5814b9c2e8bde Mon Sep 17 00:00:00 2001 From: gabriel miranda Date: Mon, 3 Nov 2025 09:01:19 -0300 Subject: [PATCH 3/3] add changeset --- .changeset/angry-lights-turn.md | 5 +++++ .changeset/silent-maps-fail.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/angry-lights-turn.md create mode 100644 .changeset/silent-maps-fail.md diff --git a/.changeset/angry-lights-turn.md b/.changeset/angry-lights-turn.md new file mode 100644 index 0000000000..34dd96fbe7 --- /dev/null +++ b/.changeset/angry-lights-turn.md @@ -0,0 +1,5 @@ +--- +"@react-email/markdown": patch +--- + +fix nested lists not working diff --git a/.changeset/silent-maps-fail.md b/.changeset/silent-maps-fail.md new file mode 100644 index 0000000000..f2b61731c0 --- /dev/null +++ b/.changeset/silent-maps-fail.md @@ -0,0 +1,5 @@ +--- +"@react-email/components": patch +--- + +markdown: fix nested lists not working