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

Converting notebooks with spaces in their names to RST gives broken images #5350

Open
DavidPowell opened this issue Mar 13, 2014 · 8 comments · Fixed by #5395
Open

Converting notebooks with spaces in their names to RST gives broken images #5350

DavidPowell opened this issue Mar 13, 2014 · 8 comments · Fixed by #5395
Milestone

Comments

@DavidPowell
Copy link

I am using ipython nbconvert --to rst example1.ipynb to convert my example notebooks into reStructuredText, for incorporation into my package's Sphinx documentation. This works quite well, unless the filename has a space in it. In this case, any image files from my notebooks are lost when I run Sphinx's make html.

My guess is that the problem seems is in the generated rst file, where the .. image command may need to be escaped or quoted somehow to work with spaces in the filename.

I note that a similar issue was reported and resolved for latex output in issue #3774, however the solution was specific to latex.

ivanov added a commit to ivanov/ipython that referenced this issue Mar 20, 2014
@ivanov
Copy link
Member

ivanov commented Mar 20, 2014

@DavidPowell thanks for reporting this bug. Can you try out #5395 to verify that it fixes this issue?

@ellisonbg
Copy link
Member

I have verified this fixes the issue by running rst2html.py against a notebook created with ipython nbconvert --to rst that has a figure and a space in its name. Merging. Thanks @ivanov

@minrk minrk added this to the 2.0 milestone Mar 20, 2014
@DavidPowell
Copy link
Author

I can confirm that running rst2html on the generated rst file correctly shows the images. Unfortunately incorporating the rst file into a Sphinx document still does not correctly show the images. Given that rst2html produces correct output, I assume that this would be a separate issue with Sphinx.

@ellisonbg
Copy link
Member

Hmm, what is the error that sphinx gives?

@minrk
Copy link
Member

minrk commented Mar 20, 2014

sphinx doesn't copy image files from the sources tree by default, does it? I suspect the image files might just be missing from sphinx build dir.

@DavidPowell
Copy link
Author

@ellisonbg Sphinx doesn't give any error, it just displays the image file name instead of the image file.
@minrk I think you're right, I checked doc/_build/html/_images and the image files are missing if my notebook had spaces in its name

@ellisonbg
Copy link
Member

Here is Sphinx's take on the issue:

https://bitbucket.org/birkenfeld/sphinx/issue/453/spaces-get-stripped-from-image-file-names

By using the urlencoded fiename we are tricking docutils to work, but
because that is not the actual filename, sphinx can't use it to move the
file into place. I think the right fix is to get docutils working with
spaces in filenames, rather that urlencoding the name. What if we double
quote the filename with spaces, does that work?

On Thu, Mar 20, 2014 at 4:28 PM, DavidPowell notifications@github.comwrote:

@ellisonbg https://github.com/ellisonbg Sphinx doesn't give any error,
it just displays the image file name instead of the image file.
@minrk https://github.com/minrk I think you're right, I checked
doc/_build/html/_images and the image files are missing if my notebook
had spaces in its name

Reply to this email directly or view it on GitHubhttps://github.com//issues/5350#issuecomment-38233379
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@DavidPowell
Copy link
Author

I just upgraded from IPython 1.2.1 to 2.0.0. Now images are broken for all filenames, not just those with spaces. The offending character is %5c (backslash), which is appearing under windows. I guess I hadn't checked this carefully previously. It does confirm @ellisonbg's suggestion that names should not be urlencoded, as this breaks sphinx's ability to move the files. Now I cannot even work around the problem by avoiding file names with spaces, so I may have to revert to 1.2.1 to build my documentation.

By the way, can someone please unclose this issue, as it really isn't fixed.

@ivanov ivanov reopened this Apr 4, 2014
Zaharid pushed a commit to Zaharid/ipython that referenced this issue Apr 22, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@minrk minrk modified the milestones: wishlist, 2.0 Nov 13, 2014
jenshnielsen added a commit to jenshnielsen/Qcodes that referenced this issue Nov 24, 2017
WilliamHPNielsen pushed a commit to microsoft/Qcodes that referenced this issue Dec 6, 2017
* set matplotlib backend in a way that works

* parameter correct rst syntax

* also ignore M4i file since the import breaks in docs build

* Change filenames to fix missing images

due to ipython/ipython#5350

* Strip invalid output

* Add missing phony

* Build docs with sphinx warnings as errors

* dont treat warnings as errors

* exclude the wrong keysight dir

* try to fix issue in tutorial

* Revert "dont treat warnings as errors"

This reverts commit e8367b9.

* add title

* Better name

* make sure that autogen api is removed too
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 a pull request may close this issue.

4 participants