refactor: convert emoji shortcodes without regex-only parsing#2823
refactor: convert emoji shortcodes without regex-only parsing#2823janewas wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughReimplements convertToEmoji to parse HTML with matchAll, track skipDepth for ChangesEmoji conversion with code block preservation
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hello! Thank you for opening your first PR to npmx, @janewas! 🚀 Here’s what will happen next:
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| let position = 0 | ||
| let skipDepth = 0 | ||
|
|
||
| for (const match of html.matchAll(/<\/?([a-z][\w:-]*)(?:\s[^>]*)?>|:[\w+-]+:/gi)) { |
|
I'm fairly certain you're an automated AI agent, and therefore will close this - if I'm wrong please let me know 🙏 |
Summary
Addresses #2822 by changing
convertToEmojiso it no longer relies on one regex that both finds skipped code/pre blocks and converts emoji shortcodes.The new implementation scans HTML tokens and emoji shortcodes in order, tracks whether the current position is inside a skipped tag (
code/pre), and only converts shortcodes outside those skipped ranges. This keeps code/pre contents untouched while avoiding a single regex that has to match whole code blocks.Tests
<pre><code>...</code></pre>Closes #2822