Fix auto links to subheader when TOC is present #20279
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It was observed (in #20112)
that links to 2nd- (and subsequent) -level headings
fail if TOC is present, e.g.:
The problem here is that links are resolved in
rst.nim
but laterrstgen.nim
fixes ("fixes") anchors to make them unique so thatTOC always works (if e.g. there was another sub-section like
"Convertible relation").
The solution implemented in this PR is to move that fix-up of anchors
into
rst.nim
, so that link resolution could know the final anchors.The bug is present in Nim 1.0, it seems to be added in #2332 in 2015.
This PR currently affects only RST syntax because there is no Markdown syntax for that (but it will be added eventually, see #20127).