You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a same-page-link that starts with #, the link is formatted as "external", even though it points to the same page, which I would consider "internal", right?
How to Reproduce
index.rst:
Title
=====
`link to subsection <#a-subsection>`_
A Subsection
------------
`link to top <#>`_
conf.py:
# empty
Run:
python -m sphinx . _build
After that, _build/index.html contains this:
<p><aclass="reference external" href="#a-subsection">link to subsection</a></p>
...
<p><aclass="reference external" href="#">link to top</a></p>
An "internal" reference would point to an explicit (hard-coded) label (see https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#hyperlink-targets). Since there is no explicit label being created, it does not work. Now, by looking at the Sphinx implementation, I think we should mark internal=True when a reference has an explicit target starting with #.
An "internal reference" uses a refname instead of a refuri. The "reference name" may be established by an explicit target or an implicit target (like a section title).
Since there is no explicit label being created, it does not work.
Actually,
`link to subsection <a subsection_>`__
A Subsection
------------
works fine and creates an internal reference.
Now, by looking at the Sphinx implementation, I think we should mark internal=True when a reference has an explicit target starting with #.
This may be an enhancement for the Docutils HTML5 writer. It is a backwards incompatible change, though.
Describe the bug
This might be a
docutils
problem ...When creating a same-page-link that starts with
#
, the link is formatted as "external", even though it points to the same page, which I would consider "internal", right?How to Reproduce
index.rst
:conf.py
:# empty
Run:
python -m sphinx . _build
After that,
_build/index.html
contains this:Environment Information
Sphinx extensions
No response
Additional context
spatialaudio/nbsphinx#530
The text was updated successfully, but these errors were encountered: