Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force non-breaking space in reStructuredText, in code environment?

I have this snippet in my reStructuredText document:

  1. Find the file at ``~/Google Drive/code/mac/install.sh``.

Notice the code/quote environment. Notice the space between Google and Drive in the path.

When rendered with Sphinx in HTML, there is a line-wrap between Google and Drive, and the space is gone. (Since this is documentation, I need everything in the code environment to appear to the user exactly as it is entered, which includes the space between 'Google' and 'Drive'. Not only should a space be present, but it should be shaded grey just like all the other code in the code environment)

How do I tell reStructuredText to use a non-breaking space in that location?

like image 614
mareoraft Avatar asked May 19 '16 14:05

mareoraft


Video Answer


1 Answers

It works for me if the regular space character is replaced with a non-breaking space (U+00A0) in the reST file. That will produce a single <span> element containing Google&nbsp;Drive in the output:

<span class="pre">~/Google&nbsp;Drive/code/mac/install.sh</span>

Inserting a literal non-breaking space can be done in several ways. See https://en.wikipedia.org/wiki/Non-breaking_space#Keyboard_entry_methods.

like image 160
mzjn Avatar answered Sep 17 '22 09:09

mzjn