spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
457 stars 130 forks source link

Replacing space with hyphens in markdown links #518

Closed FarBo closed 3 years ago

FarBo commented 4 years ago

Hello the github maintainers,

I wanted to reference an ipython notebook in another notebook as you instructed here: https://nbsphinx.readthedocs.io/en/0.4.1/markdown-cells.html

I replaced all spaces with hyphens in my linked notebook, but it didn't work. Then, I replace the spaces with %20 to be able to link it successfully. Is there something that I am missing or if this is a known issue and needs to be corrected or what? my nbsphinx version is 0.8.0

Thanks

mgeier commented 4 years ago

Can you please provide a reproducible example?

Without that, I can just speculate: You have to replace spaces in the titles, i.e. the part after the #. This does not apply to the part before # (filename and/or directory name), where you should be able to simply keep the spaces or replace them by %20 if you prefer.

The documentation is probably not clear enough about this distinction.

FarBo commented 4 years ago

Thanks @mgeier for the fast reply. Sorry for not providing enough explanation. By the way, I am using MS Edge as the browser.

Reproducing:

Create a notebook called "linked notebook.ipynb"

Create another notebook called "main notebook.ipynb" in the same directory as the above one create a markdown cell in the main and put below in that cell: Link this notebook

Execute the cell: It creates a link called Link this notebook, which if you click on the link the result will be opening a webpage with 404 : Not Found

The working solution: Link this notebook

I hope this is useful.

mgeier commented 3 years ago

This is still not a reproducible example, but it confirms my speculation.

However, I forgot that it's not possible to have spaces in plain Markdown links, so it is no wonder if the links with the spaces don't work.

As you say, replacing spaces with %20 should work, but alternatively you could also try to surround your links by < and > like this:

[Link this notebook][mylink]
[mylink]: <linked notebook.ipynb>

Does that work?

BTW, you don't need to start local links with ./.

And the best thing would be to not use files/directories with spaces at all!

FarBo commented 3 years ago

I can't reproduce it on my home computer either. Maybe I have something in my work computer conda environment that can use the mentioned syntax.

For using ./, that's right. I just use it as a personal preference. For not using spaces in files/ folders, I think I can't go and change a whole repository's files that has spaces all over the place. So, sometimes you have to overcome issues in a current situation rather than changing that situation :)

Thank you for your responses. I could solve my problem and If you like, you can close the issue.