Niklas R
Niklas R

Reputation: 16900

Sphinx substitution with a container

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.

Upvotes: 6

Views: 1610

Answers (1)

mzjn
mzjn

Reputation: 51052

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

Upvotes: 6

Related Questions