markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD051: Add support for Gitiles section anchors and named anchors

Open dholm opened this issue 3 years ago • 6 comments

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)

dholm avatar Aug 30 '22 08:08 dholm

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.

DavidAnson avatar Nov 04 '22 03:11 DavidAnson

+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.

fekete-robert avatar Jan 25 '23 12:01 fekete-robert

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?

scottamain avatar May 23 '23 17:05 scottamain

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

DavidAnson avatar May 23 '23 17:05 DavidAnson

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

scottamain avatar May 24 '23 16:05 scottamain

+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.

Svintooo avatar Jun 09 '23 12:06 Svintooo