Skip to content

Conversation

gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Oct 16, 2025

This addresses some comments on #2335.

Currently, our Markdown package heavily relies on md-to-react-email, this makes it much harder for us to fix issues on the Markdown component, and makes it significantly harder for the community to contribute to the component.

This pull requests moves in most of the code from md-to-react-email that we needed, while updating the dependency on marked (which actually fixes the issue), and simplifying the code a bit more. This move shouldn't bring much of a maintenance burden to us, because md-to-react-email was more of a thin-wrapper around marked which actually does much of the heavy lifting.

In the future I think we need to find some way to converting the Markdown content into actual React elements, using our components for a better compatibility, and probably easier maintenance.


Summary by cubic

Moved Markdown rendering in-house by replacing md-to-react-email with a custom marked-based renderer. This fixes the Markdown issue and makes the component easier to maintain and contribute to.

  • Refactors

    • Re-implemented Markdown with marked and a custom Renderer that applies inline styles via parseCssInJsToInlineCss.
    • Added local default styles (styles.ts) that can be overridden with markdownCustomStyles.
    • Dropped md-to-react-email and now depend on [email protected]. No API changes.
  • Bug Fixes

@gabrielmfern gabrielmfern self-assigned this Oct 16, 2025
Copy link

changeset-bot bot commented Oct 16, 2025

🦋 Changeset detected

Latest commit: 8cf06ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@react-email/markdown Patch
@react-email/components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-email Ready Ready Preview Comment Oct 17, 2025 0:49am
react-email-demo Ready Ready Preview Comment Oct 17, 2025 0:49am

Copy link

pkg-pr-new bot commented Oct 16, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/markdown@2569

commit: 8cf06ac

@gabrielmfern
Copy link
Member Author

@cubic-dev-ai review

Copy link
Contributor

cubic-dev-ai bot commented Oct 16, 2025

@cubic-dev-ai review

@gabrielmfern I've started the AI code review. It'll take a few minutes to complete.

@gabrielmfern gabrielmfern marked this pull request as ready for review October 16, 2025 15:11
@gabrielmfern gabrielmfern requested review from a team and cassiozen and removed request for a team October 16, 2025 15:11
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="packages/markdown/src/utils/parse-css-in-js-to-inline-css.ts">

<violation number="1" location="packages/markdown/src/utils/parse-css-in-js-to-inline-css.ts:41">
`lineHeight` must stay unitless. Appending `px` turns values like `1.5` into `1.5px`, collapsing line-height and breaking layout.</violation>
</file>

<file name="packages/markdown/src/markdown.tsx">

<violation number="1" location="packages/markdown/src/markdown.tsx:100">
Image attributes are interpolated without escaping, so characters like quotes in the alt or title break the attribute boundary and allow HTML/script injection. Please HTML-escape attribute values (src/title/alt) before embedding them.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="packages/markdown/src/utils/parse-css-in-js-to-inline-css.ts">

<violation number="1" location="packages/markdown/src/utils/parse-css-in-js-to-inline-css.ts:41">
Please treat numeric lineHeight as unitless; adding it to the px allowlist forces values like 1.5 to become 1.5px and collapses layout spacing.</violation>
</file>

<file name="packages/markdown/src/styles.ts">

<violation number="1" location="packages/markdown/src/styles.ts:57">
Spreading `codeInline` into `codeBlock` carries over `display: &#39;inline&#39;`, so the `&lt;pre&gt;` emitted by the renderer now renders inline instead of block, breaking code block layout.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@gabrielmfern gabrielmfern force-pushed the feat/move-out-of-md-to-react-email branch from 28e03a4 to 49023ec Compare October 17, 2025 12:44
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcommander@​13.1.010010010087100

View full report

@gabrielmfern gabrielmfern merged commit 21bae86 into canary Oct 17, 2025
15 checks passed
@gabrielmfern gabrielmfern deleted the feat/move-out-of-md-to-react-email branch October 17, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants