如何获取以 docutils/sphinx 空格结尾的内联代码?

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

以下 rST 指令不支持尾随空格:

:code:`foo    `

示例:

>>> 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.

有没有办法消除这个警告?

没有。根据 docutils documentation of Inline markup recognition rules:

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