fix: modify migrate link reference to not accidentally replace [] values#1220
Merged
kellyjosephprice merged 4 commits intoreadmeio:nextfrom Oct 31, 2025
Merged
Conversation
kellyjosephprice
suggested changes
Oct 30, 2025
Contributor
kellyjosephprice
left a comment
There was a problem hiding this comment.
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()
eaglethrost
commented
Oct 31, 2025
|
|
||
| return ( | ||
| mdx(ast, { remarkTransformers: [migrateCallouts, migrateLinkReferences, migrateHtmlTags], file: doc }) | ||
| mdx(ast, { remarkTransformers: [migrateCallouts, [migrateLinkReferences, { rdmd }], migrateHtmlTags], file: doc }) |
Contributor
Author
There was a problem hiding this comment.
Passing in the rdmd instance since I believe we can't import it
kellyjosephprice
approved these changes
Oct 31, 2025
rafegoldberg
pushed a commit
that referenced
this pull request
Oct 31, 2025
Contributor
This PR was released!🚀 Changes included in v11.5.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🧰 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