Skip to content

Comments

Fix case-insensitive anchor ID collision in markdown help output#10095

Open
aidanfnv wants to merge 4 commits intoshader-slang:masterfrom
aidanfnv:fix/github-markdown-anchors
Open

Fix case-insensitive anchor ID collision in markdown help output#10095
aidanfnv wants to merge 4 commits intoshader-slang:masterfrom
aidanfnv:fix/github-markdown-anchors

Conversation

@aidanfnv
Copy link
Contributor

Fixes #10083

The markdown help output (slangc -help-style markdown -h) generates explicit <a id> anchor IDs for headings using case-sensitive deduplication, but GitHub's markdown renderer generates heading IDs case-insensitively. This causes the ## Target category heading and ## target value section heading to produce non-colliding explicit anchors (Target and target), while GitHub assigns them colliding auto-IDs (target and target-1). The auto-ID target-1 for ## target then coincides with the explicit anchor for the ### -target option, so clicking "target" in GitHub's right-side navigation scrolls to the -target option instead of the target value list.

This fix lowercases anchor ID prefixes in _getLinkName so that deduplication matches GitHub's case-insensitive behavior. The explicit anchors now align with GitHub's auto-generated heading IDs, and the right-side navigation links to the correct sections.

@aidanfnv aidanfnv requested a review from a team as a code owner February 19, 2026 23:49
@aidanfnv aidanfnv requested review from bmillsNV and Copilot and removed request for a team February 19, 2026 23:49
@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Standardizes anchor IDs in the command-line reference to lowercase and updates the Markdown link-name generator to lowercase prefixes so generated anchors align with revised doc IDs, resolving incorrect navigation to duplicated anchors.

Changes

Cohort / File(s) Summary
Documentation Anchor Standardization
docs/command-line-slangc-reference.md
Rewrote many HTML anchors and corresponding hrefs from PascalCase/mixed-case to lowercase (e.g., Generalgeneral, Targettarget) and adjusted numeric/suffix variants to avoid collisions between similarly named anchors.
Link Name Generation
source/core/slang-command-options-writer.cpp
Modified _getLinkName() to lowercase the prefix characters before building the slug, so generated Markdown anchor names match the new lowercase documentation IDs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibbled at anchors, made them small and neat,

lowered each label so links properly meet.
Target now hops to target, no detour in sight,
nav finds its home by day and by night.
A tiny rabbit cheer for links done right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix case-insensitive anchor ID collision in markdown help output' accurately describes the main change: resolving case-sensitivity issues in anchor ID generation.
Description check ✅ Passed The description clearly explains the problem, root cause, and solution related to anchor ID case-sensitivity and GitHub's markdown rendering behavior.
Linked Issues check ✅ Passed The PR addresses issue #10083 by lowercasing anchor prefixes in _getLinkName to match GitHub's case-insensitive heading ID generation, ensuring navigation links route correctly.
Out of Scope Changes check ✅ Passed All changes directly address the anchor ID collision issue: documentation updates reflect lowercase anchors and the code change implements case-insensitive prefix handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@aidanfnv aidanfnv added the pr: non-breaking PRs without breaking changes label Feb 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes anchor collisions in the generated Markdown help output by aligning explicit <a id> generation with GitHub’s case-insensitive heading ID behavior, preventing navigation from jumping to the wrong section.

Changes:

  • Lowercase anchor ID prefixes in _getLinkName to match GitHub’s case-insensitive deduplication.
  • Update generated command-line-slangc-reference.md anchors and links to the new IDs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
source/core/slang-command-options-writer.cpp Lowercases anchor ID prefixes during link-name generation to avoid case-only collisions.
docs/command-line-slangc-reference.md Refreshes explicit anchors and in-doc links to match the updated ID generation behavior.
Comments suppressed due to low confidence (1)

docs/command-line-slangc-reference.md:1

  • “inbetween” should be “in between”.
# Slang Command Line Options

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@jkwak-work jkwak-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

* [Internal](#Internal)
* [Deprecated](#Deprecated)
* [General](#general)
* [Target](#target)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it strange that there are two "target" links.
One as line 16 and another at line 36.

Copy link
Contributor Author

@aidanfnv aidanfnv Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Target" (uppercase, line 16) refers to the category for the Target-related options, "-target" (with hyphen, not in the quick links) refers to the command-line option for specifying a target (and is listed in the "Target" category too), and "target" (lowercase, line 36) refers to the list of targets accepted as <target> for -target <target>.
It is quite confusing, and since I will need to regenerate this file anyways after other changes are merged, I will consider updating "Target" (the category) to "Target-related", as I think "Target-related Options" is a bit more descriptive than "Target Options".

@aidanfnv aidanfnv added this pull request to the merge queue Feb 20, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 20, 2026
)

Fixes #10083

The markdown help output (`slangc -help-style markdown -h`) generates
explicit `<a id>` anchor IDs for headings using case-sensitive
deduplication, but GitHub's markdown renderer generates heading IDs
case-insensitively. This causes the `## Target` category heading and `##
target` value section heading to produce non-colliding explicit anchors
(`Target` and `target`), while GitHub assigns them colliding auto-IDs
(`target` and `target-1`). The auto-ID `target-1` for `## target` then
coincides with the explicit anchor for the `### -target` option, so
clicking "target" in GitHub's right-side navigation scrolls to the
`-target` option instead of the target value list.

This fix lowercases anchor ID prefixes in `_getLinkName` so that
deduplication matches GitHub's case-insensitive behavior. The explicit
anchors now align with GitHub's auto-generated heading IDs, and the
right-side navigation links to the correct sections.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 20, 2026
@aidanfnv aidanfnv added this pull request to the merge queue Feb 20, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link to "Target" section in a doc, command-line-slangc-reference is incorrect

2 participants