fix: assign display names to same-language code tabs#730
fix: assign display names to same-language code tabs#730shivxmsharma wants to merge 1 commit intonodejs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #730 +/- ##
==========================================
+ Coverage 76.15% 76.63% +0.47%
==========================================
Files 151 157 +6
Lines 13641 13951 +310
Branches 1066 1125 +59
==========================================
+ Hits 10388 10691 +303
- Misses 3248 3255 +7
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Indeed it is: https://openjs-foundation.slack.com/archives/C09EXEEHFKP/p1774740421197399 Please double-check this sort of thing. |
I am unable to login to this. |
To access our Slack, see https://slack-invite.openjsf.org/ To "double-check this sort of thing", you can test local deployments before spending time on a change. It'll save lots of time :) |
Thank you for your feedback, it'll really help. I'll take more care next time before raising a PR:) |
Description
When two or more consecutive code blocks share the same language (e.g. two
jsblocks back to back),@node-core/rehype-shikigroups them into aCodeTabscomponent. The problem is both tabs end up labelled identically — "JS | JS" — which doesn't help the reader distinguish between them.This PR adds a small rehype plugin (
src/utils/code-tabs.mjs) that runs before@node-core/rehype-shikiin thegetRemarkRecmapipeline. It scans consecutive code blocks either language appears more than once in a group, it injectsdisplayNamemetadata onto each duplicate so the tabs render as "(1)", "(2)" instead. Blocks with different languages are left untouched.Validation
npm test).npm run lint,npm run format:check).jsblocks — confirmeddisplayName="(1)"anddisplayName="(2)"are injected intodata.meta.Related Issues
Addresses #596
Check List
node --run testand all tests passed.node --run format&node --run lint.