Search code examples
python-sphinxrestructuredtextdocutils

How to get inline code ending with spaces with docutils/sphinx?


The following rST directive doesn't support trailing spaces:

:code:`foo    `

Example:

>>> from docutils import core
>>> whole = core.publish_parts(""":code:`x    `""")['whole']
<string>:1: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.

Is there a way to get rid of this warning?


Solution

  • No. According to the docutils documentation of Inline markup recognition rules:

    1. Inline markup end-strings must be immediately preceded by non-whitespace.