Skip to content

fix: modify migrate link reference to not accidentally replace [] values#1220

Merged
kellyjosephprice merged 4 commits intoreadmeio:nextfrom
eaglethrost:dimas/RM-14308-table-content-malform
Oct 31, 2025
Merged

fix: modify migrate link reference to not accidentally replace [] values#1220
kellyjosephprice merged 4 commits intoreadmeio:nextfrom
eaglethrost:dimas/RM-14308-table-content-malform

Conversation

@eaglethrost
Copy link
Copy Markdown
Contributor

@eaglethrost eaglethrost commented Oct 30, 2025

PR App Fix RM-14308

🧰 Changes

We've had a migrated project have its document content malformed because a [] is recognized as a link & accidentally replaced with another content.

Update the migrate-link-reference logic to not use positions.

🧬 QA & Testing

Added some tests to check if we accidentally modify [] blocks. Let me know if it’s possible for link blocks to not be [].

This solves the issue for the markdown in https://linear.app/readme-io/issue/RM-14308/page-content-not-converting-correctly

Copy link
Copy Markdown
Contributor

@kellyjosephprice kellyjosephprice left a comment

Choose a reason for hiding this comment

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

The only really complete data I could find for the various link reference formats are in the test fixtures for remark:

https://github.com/remarkjs/remark/blob/9.0.0/test/fixtures/input/reference-link-not-closed.text


One way that could cover all formats would be to pass in the @readme/markdown@6 into this transformer and use it to compile the node back to a string.

Something like:

parent.children.splice(...,
  value: rdmd.md(node).trim()


return (
mdx(ast, { remarkTransformers: [migrateCallouts, migrateLinkReferences, migrateHtmlTags], file: doc })
mdx(ast, { remarkTransformers: [migrateCallouts, [migrateLinkReferences, { rdmd }], migrateHtmlTags], file: doc })
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Passing in the rdmd instance since I believe we can't import it

@kellyjosephprice kellyjosephprice merged commit d180161 into readmeio:next Oct 31, 2025
rafegoldberg pushed a commit that referenced this pull request Oct 31, 2025
## Version 11.5.1
### 🛠 Fixes & Updates

* modify migrate link reference to not accidentally replace [] values ([#1220](#1220)) ([d180161](d180161))

<!--SKIP CI-->
@rafegoldberg
Copy link
Copy Markdown
Contributor

This PR was released!

🚀 Changes included in v11.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants