jupyter-book
jupyter-book copied to clipboard
Cannot cross-reference a specific section in a notebook page
Describe the bug
When I try to cross-reference a specific section of a notebook page, the hyperlink just takes me to the top of that notebook page instead of the specific place in the page that I placed the reference.
This is a problem because I want to directly point people towards specific sections of my notebooks (e.g. to show blocks of analysis that are too long for the markdown pages, or to show things that only render correctly in the notebook pages like plotly plots) but I'm not able to do that if the reference just takes me to the top of the notebook page.
Reproduce the bug
For example, if I have this in a markdown cell in the middle of my notebook:
(test-section)=
#### Header for test section
And then I include this in one of the markdown pages:
Check out the test section [here](test-section)
Then when I click on the resulting hyperlink, I just get sent to the top of the notebook page that I placed the test-section reference in.
List your environment
jupyter-book --version
Jupyter Book : 0.12.3
External ToC : 0.2.4
MyST-Parser : 0.15.2
MyST-NB : 0.13.2
Sphinx Book Theme : 0.1.10
Jupyter-Cache : 0.4.3
NbClient : 0.5.13
uname -a
Linux jupyter-arao 5.10.109+ #1 SMP Sun Apr 24 09:09:13 UTC 2022 x86_64 GNU/Linux
Using python 3.9
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
I think I've found a temporary workaround for this bug - the reference tag has to be the same as the sequence of characters that’s added to the url when you manually link to a specific section of the notebook. So for example, this would work correctly:
Notebook file:
(header-for-test-section)=
#### Header for test section
Markdown file:
Check out the test section [here](header-for-test-section)
For me this silences the build error, but the link still does not render
Jupyter Book : 0.15.1
External ToC : 0.3.1
MyST-Parser : 0.18.1
MyST-NB : 0.17.2
Sphinx Book Theme : 1.0.1
Jupyter-Cache : 0.6.1
NbClient : 0.7.4
The workaround I ended up using was to embed an HTML link e.g.
<a href="./Results.html#figure-1">Figure 1</a>
for the notebook Results.ipynb.