-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix badge links in README section headings to point to anchors instead of images #923
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: kingyue737 <[email protected]>
Co-authored-by: kingyue737 <[email protected]>
@copilot Don't forget the trailing hyphen in the |
Co-authored-by: kingyue737 <[email protected]>
Fixed the anchor hrefs to include trailing hyphens ( |
@copilot you still create the |
Hmm I didn't notice that the badges are creating a trailing hyphen to the link. What do you think if we move the badge to the next line? |
When GitHub renders README.md files, it automatically wraps images in anchor tags that link to the image URL. This causes an issue with badges used in section headings - when users click on these badges, they open the shield image in a new page instead of navigating to the section.
This PR fixes the issue by explicitly wrapping the badge images with anchor tags that link to their respective section anchors:
Before:
#### On-demand importing <sup><img src="https://img.shields.io/badge/recommended-10B981" alt="recommended" align="middle" height="16"></sup>
Clicking the badge opens
https://img.shields.io/badge/recommended-10B981
in a new tab.After:
#### On-demand importing <sup><a href="#on-demand-importing-"><img src="https://img.shields.io/badge/recommended-10B981" alt="recommended" align="middle" height="16"></a></sup>
Clicking the badge now navigates to the "On-demand importing" section on the same page.
Sections fixed:
The anchor IDs follow GitHub's actual generation rules, including trailing hyphens when there's a space between the heading text and the badge (lowercase, spaces replaced with hyphens, Chinese characters preserved, trailing hyphen for spaced elements). This change improves navigation UX without affecting the visual appearance or breaking any existing functionality.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.