如何将内联代码与尾随空格一起使用?

a_g*_*est 5 whitespace restructuredtext python-sphinx

当我使用

``# ``
Run Code Online (Sandbox Code Playgroud)

在我的Sphinx文档中,我收到以下警告:

WARNING: Inline literal start-string without end-string.
Run Code Online (Sandbox Code Playgroud)

:samp:`# `
Run Code Online (Sandbox Code Playgroud)

导致

WARNING: Inline interpreted text or phrase reference start-string without end-string.
Run Code Online (Sandbox Code Playgroud)

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.

mzj*_*zjn 2

解决方法是对尾随空白使用不间断空格字符 (U+00A0),而不是常规空格 (U+0020)。

有多种方法可以插入原义不间断空格字符。请参阅https://en.wikipedia.org/wiki/Non-breaking_space#Keyboard_entry_methods