Nik*_*s R 6 containers restructuredtext substitution python-sphinx
如何替换容器指令?以下不起作用:
.. |sub| container::
Some text here
.. image:: img/some_image.png
Some other text here
Run Code Online (Sandbox Code Playgroud)
错误信息是
WARNING: Substitution definition "sub" empty or invalid.
Run Code Online (Sandbox Code Playgroud)
这不可能。ReST 替换适用于内联文本(单个段落),但容器是块元素。
如果你尝试
.. |sub| replace:: container::
Some text here
.. image:: img/some_image.png
Some other text here
Run Code Online (Sandbox Code Playgroud)
你会得到
ERROR: Error in "replace" directive: may contain a single paragraph only.
Run Code Online (Sandbox Code Playgroud)
您可以通过将容器放入单独的文件中并使用 将其拉入主文件来解决此问题.. include::
。