Update MD051/link-fragments to allow HTML's implicit "#top" fragment (fixes #1488).

This commit is contained in:
David Anson 2025-03-15 16:30:32 -07:00
parent 5749c8dcf7
commit 50300fa7af
7 changed files with 58 additions and 1 deletions

View file

@ -52,6 +52,13 @@ attribute can be used to define a fragment:
An `a` tag can be useful in scenarios where a heading is not appropriate or for
control over the text of the fragment identifier.
[HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
rule allows that syntax (using lower-case for consistency):
```markdown
[Link](#top)
```
This rule also recognizes the custom fragment syntax used by GitHub to highlight
[specific content in a document][github-linking-to-content].
@ -81,3 +88,4 @@ append an incrementing integer as needed for uniqueness.
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
[html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment