Spaces get stripped from image file names

Anonymous avatarAnonymous created an issue

I've been using Sphinx for Python module documentation, and so far it's been great.

Now I'd like to add some images, and/or matplotlib plots. But I'm finding that on Windows at least, it's giving me problems with filenames with spaces.

My repo is under:

c:\Documents and Settings\cmcqueen\...

When I try to add an image using .. image::, Sphinx seems to be calculating the full pathname, and then stripping any spaces from the name. So of course it can't find the file.

This also seems to affect matplotlib plots, which I try to add using .. plot::, using the matplotlib extensions.

Comments (5)

  1. Matt Williams

    Sure. To reproduce this I created a new folder under my documentation source root called "test dir" (i.e. I did "mkdir test\ dir" in Linux). I then moved an image file to it so that the full path of the image is now "/home/matt/PolyVox/doc/test dir/image.png".

    Then in the reST file, I do ".. image:: test dir/image.png" and the error I receive is:

    /home/matt/PolyVox/doc/index.rst:17: WARNING: image file not readable: testdir/image.png
    

    See how the space in the filename (between 'test' and 'dir') has been removed. With no amount of quoting around the directive argument can I make it keep the space intact.

    I do note that in my example I'm having to pass a filename with spaces to the image directive but in the original reporter's case, the spaces in the filename were well above the documentation source root.

  2. Georg Brandl

    Ah, I see now. I had not tried actual spaces in the URI, but in the repo path.

    This issue is caused by docutils; they process the image directive argument and strip spaces out of it, so please report an issue on their mailing list or tracker.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.