[GH-ISSUE #570] MD051: Add support for Gitiles section anchors and named anchors #2302

Open
opened 2026-03-07 20:06:30 +03:00 by kerem · 6 comments
Owner

Originally created by @dholm on GitHub (Aug 30, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/570

Would it be possible to add a configuration option for MD051 to support section anchors as defined by Gitiles markdown? I believe they pretty much follow the same convention as GitHub but they keep the case of each character rather than forcing them to lowercase.

It would also be nice if their named anchors could be supported, e.g.:

## Some Section {#name}

...

## Other Section

See [some section](#name)
Originally created by @dholm on GitHub (Aug 30, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/570 Would it be possible to add a configuration option for MD051 to support section anchors as [defined by Gitiles markdown](https://gerrit.googlesource.com/gitiles/+/HEAD/Documentation/markdown.md#named-anchors)? I believe they pretty much follow the same convention as GitHub but they keep the case of each character rather than forcing them to lowercase. It would also be nice if their named anchors could be supported, e.g.: ``` text ## Some Section {#name} ... ## Other Section See [some section](#name) ```
Author
Owner

@DavidAnson commented on GitHub (Nov 4, 2022):

As I understand the specification you link to, there are a few differences:

  • Translation of header text is different, notably for accented characters.
  • Nested headings generate unique identifiers based on structure
  • Curly bracket syntax can appear anywhere in the file

None of this is unreasonable, but overall it represents more than a trivial tweak to the logic of the existing rule.

<!-- gh-comment-id:1302928101 --> @DavidAnson commented on GitHub (Nov 4, 2022): As I understand the specification you link to, there are a few differences: - Translation of header text is different, notably for accented characters. - Nested headings generate unique identifiers based on structure - Curly bracket syntax can appear anywhere in the file None of this is unreasonable, but overall it represents more than a trivial tweak to the logic of the existing rule.
Author
Owner

@fekete-robert commented on GitHub (Jan 25, 2023):

+1 for adding support to custom header ids. They are supported in a number of static site generators (for example, Hugo and docusaurus), and in these contexts this markdownlint rule throws a false positive.

<!-- gh-comment-id:1403510310 --> @fekete-robert commented on GitHub (Jan 25, 2023): +1 for adding support to custom header ids. They are supported in a number of static site generators (for example, Hugo and [docusaurus](https://docusaurus.io/docs/markdown-features/toc#heading-ids)), and in these contexts this markdownlint rule throws a false positive.
Author
Owner

@scottamain commented on GitHub (May 23, 2023):

I'm very interested in just the second part of this request, so that MD051 will not flag this as an invalid link:

## Some Section {#name}

See [some section](#name)

Currently, I need to disable MD051 (and use a separate linkchecker) because this use-case is important to me.

Should this be filed as a separate enhancement request?

<!-- gh-comment-id:1559828725 --> @scottamain commented on GitHub (May 23, 2023): I'm very interested in just the second part of this request, so that MD051 will not flag this as an invalid link: ``` ## Some Section {#name} See [some section](#name) ``` Currently, I need to disable MD051 (and use a separate linkchecker) because this use-case is important to me. Should this be filed as a separate enhancement request?
Author
Owner

@DavidAnson commented on GitHub (May 23, 2023):

@scottamain Please do. I think supporting named anchors is more straightforward and has value in isolation.

<!-- gh-comment-id:1559847810 --> @DavidAnson commented on GitHub (May 23, 2023): @scottamain Please do. I think supporting named anchors is more straightforward and has value in isolation.
Author
Owner

@scottamain commented on GitHub (May 24, 2023):

Done: https://github.com/DavidAnson/markdownlint/issues/830

<!-- gh-comment-id:1561530598 --> @scottamain commented on GitHub (May 24, 2023): Done: https://github.com/DavidAnson/markdownlint/issues/830
Author
Owner

@Svintooo commented on GitHub (Jun 9, 2023):

+1 for adding support for gitiles flavored anchors.
My company uses gerrit with gitiles for all development, and uses markdownlint in all CI pipelines. And broken links slips through from time to time because MD051 needs to be disabled.

<!-- gh-comment-id:1584470669 --> @Svintooo commented on GitHub (Jun 9, 2023): +1 for adding support for gitiles flavored anchors. My company uses gerrit with gitiles for all development, and uses markdownlint in all CI pipelines. And broken links slips through from time to time because MD051 needs to be disabled.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2302
No description provided.