Sphinx substitution with a container

2019-07-03 16:36发布

How can I substitute a container directive ? The following doesn't work:

.. |sub| container::

    Some text here

    .. image:: img/some_image.png

    Some other text here

The error message is

WARNING: Substitution definition "sub" empty or invalid.

1条回答
成全新的幸福
2楼-- · 2019-07-03 17:10

This is not possible. ReST substitutions apply to inline text (single paragraphs), but a container is a block element.

And if you try

.. |sub| replace:: container::

    Some text here

    .. image:: img/some_image.png

    Some other text here

you will get

ERROR: Error in "replace" directive: may contain a single paragraph only.

You could work around this by putting the container in a separate file and pull it in to the master file using .. include::.

查看更多
登录 后发表回答