Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto links to subheader when TOC is present #20279

Merged
merged 1 commit into from
Aug 27, 2022

Conversation

a-mr
Copy link
Contributor

@a-mr a-mr commented Aug 27, 2022

It was observed (in #20112)
that links to 2nd- (and subsequent) -level headings
fail if TOC is present, e.g.:

.. contents::

Type relations
==============

Convertible relation
--------------------

Ref. `Convertible relation`_

The problem here is that links are resolved in rst.nim but later
rstgen.nim fixes ("fixes") anchors to make them unique so that
TOC 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).

It was observed (in nim-lang#20112)
that links to 2nd- (and subsequent) -level headings
fail if TOC is present, e.g.:
```nim
.. contents::

Type relations
==============

Convertible relation
--------------------

Ref. `Convertible relation`_
```

The problem here is that links are resolved in `rst.nim` but later
`rstgen.nim` fixes ("fixes") anchors to make them unique so that
TOC 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 final anchors.

The bug seems to be added in nim-lang#2332
in 2015, that is it is present in Nim 1.0.
@Varriount Varriount merged commit de9cbf6 into nim-lang:devel Aug 27, 2022
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from de9cbf6

Hint: mm: orc; threads: on; opt: speed; options: -d:release
163884 lines; 14.327s; 840.684MiB peakmem

a-mr added a commit to a-mr/Nim that referenced this pull request Sep 7, 2022
Also the warning is improved a bit.

Local links (targeting inside its document) which had had a full anchor
were turned into concise form.
The very fact that they existed may be due to the bug in
reference to subsections fixed nim-lang#20279,
now they are working well (both in RST syntax and
new Pandoc Markdown syntax implemented in
nim-lang#20304)
Varriount pushed a commit that referenced this pull request Sep 9, 2022
Markdown link migration part 1

Also the warning is improved a bit.

Local links (targeting inside its document) which had had a full anchor
were turned into concise form.
The very fact that they existed may be due to the bug in
reference to subsections fixed #20279,
now they are working well (both in RST syntax and
new Pandoc Markdown syntax implemented in
#20304)
capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
Fix links to subheader when TOC is present

It was observed (in nim-lang#20112)
that links to 2nd- (and subsequent) -level headings
fail if TOC is present, e.g.:
```nim
.. contents::

Type relations
==============

Convertible relation
--------------------

Ref. `Convertible relation`_
```

The problem here is that links are resolved in `rst.nim` but later
`rstgen.nim` fixes ("fixes") anchors to make them unique so that
TOC 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 final anchors.

The bug seems to be added in nim-lang#2332
in 2015, that is it is present in Nim 1.0.
capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
Markdown link migration part 1

Also the warning is improved a bit.

Local links (targeting inside its document) which had had a full anchor
were turned into concise form.
The very fact that they existed may be due to the bug in
reference to subsections fixed nim-lang#20279,
now they are working well (both in RST syntax and
new Pandoc Markdown syntax implemented in
nim-lang#20304)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants