-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(mdx): push last highlighted line when making highlight blocks #13156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the issue where the last highlighted line in MDX code blocks wasn’t being pushed into the rendered output.
- Added an index parameter to the reduce function
- Modified the conditional logic to flush highlighted groups when the last item is reached
Comments suppressed due to low confidence (1)
src/components/codeHighlights/codeHighlights.tsx:47
- Consider adding tests that specifically cover the case where the last line is highlighted to ensure that the flush logic handles this scenario as expected.
if (!isHighlightedLine || index === items.length - 1) {
Bundle ReportChanges will increase total bundle size by 280 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: sentry-docs-server-cjsAssets Changed:
Files in
App Routes Affected:
view changes for bundle: sentry-docs-client-array-pushAssets Changed:
Files in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @nikolovlazar - great catch! (for context, I caused this in #12983)
I hope you don't mind but I'll merge this to get it out :)
DESCRIBE YOUR PR
I noticed that in code blocks where the last line is highlighted it doesn't get shown. There's a good example in the TanStack Start React guide:

The code block ends abruptly and it doesn't show how to wrap the
defaultStreamHandler
with Sentry'swrapStreamHandlerWithSentry
. I checked the mdx page and noticed that there's only one missing line from the code block and it's also the highlighted one.The changes I made ensure that we "flush" any started highlight groups at the end before returning the markup. The previous implementation relied on having a non-highlighted line that follows a highlighted one in order to "flush" the group.
This PR would fix any code blocks that highlight the last line(s). I'm not sure if there are other instances other than the TanStack Start one.
After the fix:
Additionally, this PR removes the bottom padding of codeblocks whose last child is a highlight:
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes: