Skip to content

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

@Jadenzzz
Copy link
Contributor

@Jadenzzz Jadenzzz commented Feb 25, 2026

PR App Fix RM-XYZ

đź§° Changes

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

Issue

Built-in <Anchor> 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 <Anchor href="/docs" target="_blank">here</Anchor> to learn more.

It fragments it into multiple sibling nodes inside the paragraph:

paragraph
├── text: "Click "
├── html: "<Anchor href="/docs" target="_blank">"
├── text: "here"
├── html: "</Anchor>"
└── 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 Jadenzzz marked this pull request as ready for review March 2, 2026 04:30
Copy link
Contributor

@maximilianfalco 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 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 Jadenzzz requested a review from maximilianfalco March 6, 2026 02:38
@eaglethrost
Copy link
Contributor

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 Jadenzzz requested a review from eaglethrost March 6, 2026 06:38
Co-authored-by: Dimas Putra Anugerah <63914983+eaglethrost@users.noreply.github.com>
Copy link
Contributor

@kevinports 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

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

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

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 Jadenzzz requested a review from kevinports March 10, 2026 10:42
@kevinports
Copy link
Contributor

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

@Jadenzzz Jadenzzz merged commit 30e037d into next Mar 13, 2026
11 checks passed
@Jadenzzz 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants