Markdown: HTML inside code blocks and inline code isn't escaped
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- markdown, react, typescript
- Domain
- frontend
Research direction
Start in markdown.tsx and find the code and codespan renderers; the issue reports that both insert text without escaping. Read the existing Markdown component tests and add a case for HTML in fenced code and inline code. Done means both render as escaped text, matching the expected output in the issue.
Written by the indexing model from the issue text.
Description
What versions are you using? (if relevant)
[email protected] (also on canary), [email protected], [email protected]
Describe the Bug
<Markdown> doesn't escape what's inside code blocks and inline code. If a fenced block or a code span contains HTML, the tags go into the email as real HTML, so a code sample showing <b>bold</b> comes out as bold text instead of the snippet.
The code and codespan renderers in markdown.tsx insert text as is, while marked's own renderers escape it.
What is affected (leave empty if unsure)
Markdown Component
Link to the code that reproduces this issue
The repro is short, so it's inline under To Reproduce. It only needs [email protected], [email protected] and [email protected].
To Reproduce
Save this as check.mjs and run it with node:
import { createElement as h } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { Markdown } from 'react-email';
const md = '```html\n<b>bold</b> & <i>x</i>\n```\n\nInline: `<br>`';
console.log(renderToStaticMarkup(h(Markdown, null, md)).replace(/ style="[^"]*"/g, ''));
With the inline styles stripped, the output contains <pre><code><b>bold</b> & <i>x</i> and <p>Inline: <code><br></code></p>.
Expected Behavior
The code gets escaped, the way marked's default renderer does it: <b>bold</b> & <i>x</i> and <code><br></code>.
I'd like to send a PR for this with a test, if that's okay.
What's your node version? (if relevant)
26.7.0
- Dominant language
- TypeScript
- Stars
- 19.9k
- Forks
- 1.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 49
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from resend/react-email
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
resend/react-email#3876 ·
Maintainers usually reply within 1 day
-
render: unstableTextConversion outputs HTML comments and repeats link URLs in plain textPossibly taken @lakshya-dhariwal claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
resend/react-email#3864 ·
Maintainers usually reply within 1 day
-
<CodeInline> causes duplicated text in body previews in Gmail and other providers due to hacky Orange.fr workaroundPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
resend/react-email#3853 ·
Maintainers usually reply within 1 day
-
Tailwind stacked media variants leave nested CSS in rendered emailsPossibly taken @lakshya-dhariwal claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
resend/react-email#3874 ·
Maintainers usually reply within 1 day
-
Inspector Text panel omits Uppercase mark toggle (MARK_NAMES missing "uppercase")Possibly taken @svargas-dev claimed this 6 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 22/100
resend/react-email#3849 ·
Maintainers usually reply within 1 day
All issues in resend/react-email
Similar issues
-
documentation good first issue roadmap
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
siyuan-note/siyuan#21324 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dmno-dev/varlock#1279 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
himynameisdave/bsky-profanity-counter#59 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100