Skip to content

Conversation

@eaglethrost
Copy link
Contributor

PR App Fix RM-XYZ

🧰 Changes

Add another regex in the migrator to replace unclosed
tags to closed
tags

🧬 QA & Testing

Copy link
Collaborator

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

I think this is good, but I also think we could improve it slightly.

Also, would you add a test here: https://github.com/readmeio/markdown/tree/next/__tests__/migration

lib/migrate.ts Outdated
// parsing weird cases.
.replaceAll(/a/g, 'a')
// A common issue is that <br> tags are not properly closed
.replaceAll(/<br(?!\s*\/)\s*>/g, '<br />')
Copy link
Collaborator

Choose a reason for hiding this comment

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

The most 'correct' way to do this would be to traverse the tree:

Suggested change
.replaceAll(/<br(?!\s*\/)\s*>/g, '<br />')
import { visit } from 'unist-util-visit';
visit(ast, 'text', textNode => {
textNode.value = textNode.value.replaceAll(/<br(?!\s*\/)\s*>/g, '<br />')
})

This would prevent replacing <br> strings when they're inside inline code or code blocks, eq:

Not a `<br>` tag

```
Also not a <br> tag
```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, implemented it! Though I've had to use 'html' to visit instead of text for it to work, let me know if that's not right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've also created a generic function for migration html tags in general in case we want to regex more tags

Copy link
Collaborator

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

LGTM!

@eaglethrost eaglethrost changed the title feat: add regex to fix <tags> feat: add regex to fix <br> Oct 17, 2025
@kellyjosephprice kellyjosephprice merged commit ff4aa28 into readmeio:next Oct 17, 2025
2 checks passed
rafegoldberg pushed a commit that referenced this pull request Oct 17, 2025
## Version 11.4.0
### ✨ New & Improved

* add regex to fix <br> ([#1210](#1210)) ([ff4aa28](ff4aa28))

### 🛠 Fixes & Updates

* **deps:** bump actions/checkout from 4 to 5 ([#1171](#1171)) ([6610a81](6610a81)), closes [actions/checkout#2226](actions/checkout#2226) [actions/checkout#2238](actions/checkout#2238) [actions/checkout#1971](actions/checkout#1971) [actions/checkout#1977](actions/checkout#1977) [actions/checkout#2043](actions/checkout#2043) [actions/checkout#2044](actions/checkout#2044) [actions/checkout#2194](actions/checkout#2194) [actions/checkout#2224](actions/checkout#2224) [actions/checkout#2236](actions/checkout#2236) [actions/checkout#2237](actions/checkout#2237) [actions/checkout#1971](actions/checkout#1971) [actions/checkout#1977](actions/checkout#1977) [actions/checkout#2043](actions/checkout#2043) [actions/checkout#2194](actions/checkout#2194) [actions/checkout#2236](actions/checkout#2236) [actions/checkout#1941](actions/checkout#1941) [actions/checkout#1946](actions/checkout#1946) [actions/checkout#1924](actions/checkout#1924) [actions/checkout#1919](actions/checkout#1919) [actions/checkout#2226](actions/checkout#2226) [actions/checkout#1971](actions/checkout#1971) [actions/checkout#1977](actions/checkout#1977) [actions/checkout#2043](actions/checkout#2043) [actions/checkout#2044](actions/checkout#2044) [actions/checkout#2194](actions/checkout#2194) [actions/checkout#2224](actions/checkout#2224) [actions/checkout#2236](actions/checkout#2236) [actions/checkout#1941](actions/checkout#1941) [actions/checkout#1946](actions/checkout#1946) [actions/checkout#1924](actions/checkout#1924) [actions/checkout#1180](actions/checkout#1180) [actions/checkout#1777](actions/checkout#1777) [actions/checkout#1872](actions/checkout#1872) [actions/checkout#1739](actions/checkout#1739) [actions/checkout#1697](actions/checkout#1697) [actions/checkout#1774](actions/checkout#1774) [actions/checkout#1776](actions/checkout#1776) [actions/checkout#1732](actions/checkout#1732) [actions/checkout#1703](actions/checkout#1703) [actions/checkout#1694](actions/checkout#1694) [actions/checkout#1696](actions/checkout#1696) [actions/checkout#1695](actions/checkout#1695) [actions/checkout#1707](actions/checkout#1707) [actions/checkout#1692](actions/checkout#1692) [actions/checkout#1688](actions/checkout#1688) [actions/checkout#1693](actions/checkout#1693) [actions/checkout#1643](actions/checkout#1643) [#2238](https://github.com/readmeio/markdown/issues/2238) [#2226](https://github.com/readmeio/markdown/issues/2226)
* **deps:** bump github/codeql-action from 3 to 4 ([#1208](#1208)) ([9db6259](9db6259)), closes [#3168](https://github.com/readmeio/markdown/issues/3168) [#3160](https://github.com/readmeio/markdown/issues/3160) [#2935](https://github.com/readmeio/markdown/issues/2935) [#2938](https://github.com/readmeio/markdown/issues/2938) [#2950](https://github.com/readmeio/markdown/issues/2950) [#2925](https://github.com/readmeio/markdown/issues/2925) [#2912](https://github.com/readmeio/markdown/issues/2912) [#2959](https://github.com/readmeio/markdown/issues/2959) [#2910](https://github.com/readmeio/markdown/issues/2910) [#2893](https://github.com/readmeio/markdown/issues/2893) [#2894](https://github.com/readmeio/markdown/issues/2894) [#2891](https://github.com/readmeio/markdown/issues/2891) [#2872](https://github.com/readmeio/markdown/issues/2872) [#3189](https://github.com/readmeio/markdown/issues/3189) [#3188](https://github.com/readmeio/markdown/issues/3188)
* creating a CODEOWNERS file ([8a24361](8a24361))

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

This PR was released!

🚀 Changes included in v11.4.0

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