docs: fix broken Table of Contents anchors for duplicate headings#6
Open
youngfish42 wants to merge 1 commit into
Open
docs: fix broken Table of Contents anchors for duplicate headings#6youngfish42 wants to merge 1 commit into
youngfish42 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes broken in-document navigation in MATLAB-Coding-Guidelines.md by updating Table of Contents links for duplicated headings so each TOC entry points to the correct GitHub-generated anchor (e.g., #general-1, #general-2, …).
Changes:
- Update the “General” TOC entries to use the correct disambiguated anchors (
#general-1through#general-5). - Update the second “Variables” TOC entry to use the correct disambiguated anchor (
#variables-1).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the broken in-document navigation links in the Table of
Contents of
MATLAB-Coding-Guidelines.md, addressing #5.Problem
GitHub-Flavored Markdown auto-generates heading anchors by slugifying
the heading text (lowercasing, replacing spaces with
-, strippingpunctuation). When the same heading text appears multiple times in a
document, GitHub disambiguates the later occurrences by appending
-1,-2,-3, ... to their slugs, in order of appearance.The current TOC uses the bare slug (e.g.
#general,#variables)for every duplicate, so all six "General" links jump to the same
first section (under "Naming Guidelines"), and both "Variables"
links jump to the first "Variables" section. Users cannot navigate
to the intended subsections via the TOC.
The document contains the following duplicated headings:
## Generalappears 6 times (Naming, Statements & Expressions,Code Comments, Function Authoring, Class Authoring, Error Handling)
## Variablesappears 2 times (Naming, Statements & Expressions)Fix
Append the correct GitHub-generated suffix (
-1..-5) to theanchor of every duplicate TOC entry. The visible link text is left
unchanged; only the anchor target is corrected.
#general#general-1#variables#variables-1#general#general-2#general#general-3#general#general-4#general#general-5All other TOC entries already point to unique headings and are left
untouched.
Scope
MATLAB-Coding-Guidelines.md(TOC block only,lines 18, 19, 30, 33, 37, 41)
Verification
Rendered the file on GitHub after the change and confirmed that each
TOC link now jumps to its intended section.
Closes #5