Skip to content

[DX-998] fix: remove spurious # from anchor IDs and harden headers hook#3305

Merged
jamiehenson merged 1 commit intomainfrom
fix/anchor-double-hash
Mar 31, 2026
Merged

[DX-998] fix: remove spurious # from anchor IDs and harden headers hook#3305
jamiehenson merged 1 commit intomainfrom
fix/anchor-double-hash

Conversation

@jamiehenson
Copy link
Copy Markdown
Member

@jamiehenson jamiehenson commented Mar 31, 2026

Human preamble

@SimonWoolf raised some broken internal anchor links in docs content here. This is actually fairly widespread, and is largely an MDX content issue - HTML id attributes should not include '#' characters.

This PR fixes incorrect id syntax in the MDX assets themselves (additional '#' characters), and allows the UI components to catch future issues.

Summary

  • 73 MDX headings across 5 pages (api/realtime-sdk/authentication, api/realtime-sdk/types, api/rest-sdk/types, getting-started/flutter, getting-started/react-native) had <a id="#foo"/> instead of <a id="foo"/>. The literal # ended up as part of the HTML id attribute value, so fragment links like [text](#foo) found no matching element.
  • The useCopyableHeaders hook in src/components/Layout/mdx/headers.ts compounded the issue by prepending another # when building the copyable-link href, producing ##foo.
  • Fixed by stripping the spurious # from all 73 affected anchor tags, and adding a defensive strip in the hook so the same breakage cannot recur if the pattern reappears in content.

Test plan

  • Visit https://ably.com/docs/api/realtime-sdk/authentication and verify in-page anchor links (e.g. links to #tokens, #auth-object, #authorize) navigate correctly
  • Confirm the copy-link icon on affected headings produces single-hash URLs (e.g. …/authentication#tokens not …/authentication##tokens)
  • Spot-check api/realtime-sdk/types and api/rest-sdk/types for the same

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 43e9d0bf-fb00-4f38-8ba5-f359728b27dc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/anchor-double-hash

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

@jamiehenson jamiehenson added the review-app Create a Heroku review app label Mar 31, 2026
@ably-ci ably-ci temporarily deployed to ably-docs-fix-anchor-do-8bhcjp March 31, 2026 11:08 Inactive
73 MDX headings across 5 API/getting-started pages had `<a id="#foo"/>`
instead of `<a id="foo"/>`, causing the literal `#` to appear in the HTML
id attribute. This broke in-page fragment links and caused the copyable
header hook to produce double-hash hrefs (`##foo`).

- Strip leading `#` from all affected `<a id="...">` tags in content
- Defensively strip any leading `#` from id values in useCopyableHeaders
  to prevent recurrence if the pattern reappears in content

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jamiehenson jamiehenson force-pushed the fix/anchor-double-hash branch from b0ad82a to fc30aff Compare March 31, 2026 11:08
@jamiehenson jamiehenson temporarily deployed to ably-docs-fix-anchor-do-8bhcjp March 31, 2026 11:09 Inactive
@jamiehenson jamiehenson temporarily deployed to ably-docs-fix-anchor-do-8bhcjp March 31, 2026 12:27 Inactive
@jamiehenson jamiehenson force-pushed the fix/anchor-double-hash branch from 647b7c8 to fc30aff Compare March 31, 2026 12:31
@jamiehenson jamiehenson requested review from a team and kennethkalmer and removed request for a team March 31, 2026 12:31
@jamiehenson jamiehenson marked this pull request as ready for review March 31, 2026 12:31
@jamiehenson jamiehenson changed the title fix: remove spurious # from anchor IDs and harden headers hook [DX-998] fix: remove spurious # from anchor IDs and harden headers hook Mar 31, 2026
@jamiehenson jamiehenson enabled auto-merge March 31, 2026 13:12
Copy link
Copy Markdown
Member

@kennethkalmer kennethkalmer left a comment

Choose a reason for hiding this comment

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

#goodcatch @jamiehenson!

@jamiehenson jamiehenson merged commit 64f0618 into main Mar 31, 2026
7 checks passed
@jamiehenson jamiehenson deleted the fix/anchor-double-hash branch March 31, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

3 participants