Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(mdxish-editor): built in anchor component not deserializing to to a link in mdxish editor#1361

Merged
Jadenzzz merged 20 commits intonextfrom
jayden/rm-15357-built-in-anchor-component-not-deserializing-to-to-a-link-in
Mar 13, 2026
Merged

fix(mdxish-editor): built in anchor component not deserializing to to a link in mdxish editor#1361
Jadenzzz merged 20 commits intonextfrom
jayden/rm-15357-built-in-anchor-component-not-deserializing-to-to-a-link-in

Conversation

Copy link
Contributor

Jadenzzz commented Feb 25, 2026 *
edited
Loading

Fix RM-XYZ

Changes

Notes
These changes related to https://github.com/readmeio/readme/pull/17426

Issue

Built-in components were not properly deserializing to links in the MDXish editor. When an Anchor component with a target attribute was saved and reloaded, it wasn't being recognized as a proper inline component node

When the markdown parser encounters an inline component like:
Click here to learn more.

It fragments it into multiple sibling nodes inside the paragraph:

paragraph
+-- text: "Click "
+-- html: ""
+-- text: "here"
+-- html: "
"
+-- text: " to learn more."

Unlike block components (Recipe, Callout) which are parsed as single elements, inline components need to be reassembled from these fragments.

Solution

Created mdxish-inline-components.ts transformer - A new MDAST transformer that:

  • Detects PascalCase inline component opening tags (e.g., )
  • Finds the matching closing tag
  • Preserves all attributes (href, target, title, etc.)

QA & Testing

Jadenzzz requested review from eaglethrost and maximilianfalco March 2, 2026 02:14
Jadenzzz added 2 commits March 2, 2026 10:14
Jadenzzz marked this pull request as ready for review March 2, 2026 04:30
maximilianfalco requested changes Mar 3, 2026
Copy link
Contributor

maximilianfalco left a comment

Choose a reason for hiding this comment

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

looks good but probs need to remove the duplicate JSX expression parsing

Jadenzzz changed the title fix(mdxish-editor): built in anchor component not deserializing to to a link in fix(mdxish-editor): built in anchor component not deserializing to to a link in mdxish editor Mar 4, 2026
Jadenzzz added 2 commits March 5, 2026 16:52
Jadenzzz requested a review from maximilianfalco March 6, 2026 02:38
Copy link
Contributor

eaglethrost commented Mar 6, 2026

Logic to transform the anchor tag looks good, tests are pretty extensive, though it covers many edge cases I was concerned about. Since the new transformer only applies to tags & is behind the editor flag, this shouldn't cause rendering regressions.

Just 1 concern about the evaluateExpressions code!

Jadenzzz requested a review from eaglethrost March 6, 2026 06:38
Co-authored-by: Dimas Putra Anugerah <63914983+eaglethrost@users.noreply.github.com>
kevinports approved these changes Mar 9, 2026
Copy link
Contributor

kevinports left a comment

Choose a reason for hiding this comment

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

Looks good. Had a few minor comments.

});

it('should handle Anchor with JavaScript URL (should preserve as-is)', () => {
// Security note: Anchor component should handle sanitization at render time
Copy link
Contributor

kevinports Mar 9, 2026

Choose a reason for hiding this comment

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

Does the Anchor component actually sanitize this?

Copy link
Contributor

kevinports Mar 10, 2026

Choose a reason for hiding this comment

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

@Jadenzzz you marked this conversation as resolved, but this was an actual question for you. Does the Anchor component actually sanitize this already? Or is this work we need to follow up with?

Copy link
Contributor Author

Jadenzzz Mar 13, 2026

Choose a reason for hiding this comment

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

sorry this comment is kinda misleading. The goal of this test is to make sure JavaScript URLs are preserved as-is

Jadenzzz added 2 commits March 10, 2026 15:26
Jadenzzz requested a review from kevinports March 10, 2026 10:42
kevinports approved these changes Mar 10, 2026
Copy link
Contributor

kevinports commented Mar 12, 2026

@Jadenzzz is this good to merge? Then you can get on with https://github.com/readmeio/readme/pull/17426

maximilianfalco approved these changes Mar 13, 2026
Jadenzzz merged commit 30e037d into next Mar 13, 2026
11 checks passed
Jadenzzz deleted the jayden/rm-15357-built-in-anchor-component-not-deserializing- to-to-a-link-in branch March 13, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

kevinports kevinports approved these changes

maximilianfalco maximilianfalco approved these changes

eaglethrost Awaiting requested review from eaglethrost

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants