Yes and if the author specifies a link definition where the link label matches the text of a heading (and potentially shortcut reference links) and the link target starts with a hash sign #
, the shortcut anchor link gets an explicit ID.
## To Be Explicit Or Not To Be Explicit
pros: some pros
cons: some cons
〰〰〰〰〰
See [To Be Explicit Or Not To Be Explicit] above. [Same target](#2BX).
〰〰〰〰〰
[To Be Explicit Or Not To Be Explicit]: #2BX
## Foo ##
[Foo]
[Foo][]
[Foo][Foo]
[Foo](#bar)
[Foo]: #bar
.
<h2 id="bar">Foo</h2>
<p><a href="#bar">Foo</a>
<a href="#bar">Foo</a>
<a href="#bar">Foo</a>
<a href="#bar">Foo</a></p>
If the parser understands some attribute syntax extension, there would be an alternative, inline way to achieve an explicit ID for the heading, but shortcut anchor links would probably fail then, unless the system supported multiple IDs per element.
## Foo ## {#bar}
[Foo]
[Foo][]
[Foo][Foo]
[Foo](#bar)
.
<h2 id="bar">Foo</h2>
<p>[Foo]
[Foo][]
[Foo][Foo]
<a href="#bar">Foo</a></p>
Also, if an author puts the heading text inside square brackets, this should be an easy way to provide a link to itself.
[Foo]
=====
## [Bar] ##
[Foo] [Bar]
.
<h1 id="Foo"><a href="#Foo">Foo</a></h1>
<h2 id="Bar"><a href="#Bar">Bar</a></h2>
<p><a href="#Foo">Foo</a> <a href="#Bar">Bar</a></p>
If, however, a proper reference link definition with that link label exists, its link destination would get preferred (for backwards compatibility), although the implicit ID is still generated.
## [Foo] ##
[Foo]
[Foo]: /bar
.
<h2 id="Foo"><a href="/bar">Foo</a></h2>
<p><a href="/bar">Foo</a></p>