You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support GitHub style markdown heading anchor and link reference (#1540)
I started the work to address #1537, but I think we should just go with
the GH markdown style anchor/link generation in the future.
Anchors Generated:
| Context | Before | After |
|---------|--------|-------|
| Heading `== Hello` (standalone) | `id="label-Hello"` | `id="hello"` |
| Heading `== Hello` (in class Foo) | `id="class-Foo-label-Hello"` |
`id="class-foo-hello"` |
| Heading `== Hello` (in method #bar) | `id="method-i-bar-label-Hello"`
| `id="method-i-bar-hello"` |
| Class/Module anchor | `id="class-Foo::Bar"` | `id="class-foo-bar"` |
**Legacy anchors preserved as hidden `<span class="legacy-anchor">`
elements. So links targeting old anchors should still work.**
Links Generated:
| Syntax | Before | After |
|--------|--------|-------|
| `rdoc-ref:@foo` | `href="#label-foo"` | `href="#foo"` |
| `rdoc-ref:Class@foo` | `href="#class-Class-label-foo"` |
`href="#class-class-foo"` |
| `rdoc-ref:Class#method@foo` | `href="#method-i-method-label-foo"` |
`href="#method-i-method-foo"` |
| `rdoc-ref:Class@Section Title` | `href="#Section Title"` |
`href="#section-title"` |
These changes now enable Markdown links to work with GitHub-style
anchors.
Markdown `[link](#foo)` passes through unchanged as `href="#foo"`.
- Before: Anchor was `id="label-Foo"` -> link broken
- After: Anchor is `id="foo"` -> link works
Supportive Changes:
- ToC sidebar links updated to use new anchor format
Closes#1537
0 commit comments