Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use inline code with a trailing whitespace?

When I use

``# ``

in my Sphinx documentation I get the following warning:

WARNING: Inline literal start-string without end-string.

Trying

:samp:`# `

leads to

WARNING: Inline interpreted text or phrase reference start-string without end-string.

The problem seems to be the trailing whitespace however I couldn't figure out a way of getting around this problem. Escaping the whitespace with a backslash (\) doesn't help either (for the first example the warning persists and for the second example the whitespace is omitted in the generated docs).

This answer doesn't work because the inline code section interprets the |space| as a literal string.


Experienced with Sphinx 1.6.2.

like image 807
a_guest Avatar asked Aug 06 '17 17:08

a_guest


2 Answers

A workaround is to use a no-break space character (U+00A0) instead of a regular space (U+0020) for the trailing whitespace.

There are several ways to insert a literal no-break space character. See https://en.wikipedia.org/wiki/Non-breaking_space#Keyboard_entry_methods.

like image 70
mzjn Avatar answered Nov 10 '22 07:11

mzjn


Use a "literal" role__ with an escaped space after the intended trailing space::

:literal:`# \ `

__https://docutils.sourceforge.io/docs/ref/rst/roles.html#literal

like image 32
G. Milde Avatar answered Nov 10 '22 07:11

G. Milde