sphinx-doc / sphinx-doc/sphinx
HTML5 permalinks are not permanent if section header starts with number
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
In pip Changelog slugs in html anchors are not permanently pointed to corresponding version. Instead, they are incremental position numbers, which start with #id1, so when new version of pip is released all anchors shift and start to point to a different version.
To Reproduce
#!/bin/bash
DOCDIR=testnumslug
rm -rf $DOCDIR
mkdir $DOCDIR
cat <<EOF > $DOCDIR/index.rst
Hi
==
1.2.0
-----
1.1.0
-----
1.0.0
-----
EOF
# Application error:
# config directory doesn't contain a conf.py file (testnumslug)
touch $DOCDIR/conf.py
sphinx-build $DOCDIR $DOCDIR/_html
echo -e "\n-----\n"
grep -R 'Permalink' $DOCDIR/_html/index.html
This gives the output.
<h1>Hi<a class="headerlink" href="#hi" title="Permalink to this headline">¶</a></h1>
<h2>1.2.0<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<h2>1.1.0<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<h2>1.0.0<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
Expected behavior
<h1>Hi<a class="headerlink" href="#hi" title="Permalink to this headline">¶</a></h1>
<h2>1.2.0<a class="headerlink" href="#1.2.0" title="Permalink to this headline">¶</a></h2>
<h2>1.1.0<a class="headerlink" href="#1.1.0" title="Permalink to this headline">¶</a></h2>
<h2>1.0.0<a class="headerlink" href="#1.0.0" title="Permalink to this headline">¶</a></h2>
Environment info
- Python version: 3.9.1
- Sphinx version: 3.2.1
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided shell reproduction with Sphinx 3.2.1 and inspect the generated testnumslug/_html/index.html. Locate the HTML5 permalink generation path and add a regression test for section headings beginning with numbers; done means numeric headings receive stable anchors based on their text rather than shifting id1/id2 values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100