reStructuredText - Include External Documents

05/13/2021, Thu
Categories: #markup
Tags: #reStructuredText

Inline Variables Within a Paragraph

For general reuse, one can reference another file in reStructuredText using the include directive.

.. main.rst - this document will the insert the external content from the path below

.. include:: the/path/to/my-included-file.rst

This is good when the content which you want to embed directly into your document can stand by itself as a separate paragraph, however, if you wish to embed content inline within an existing paragraph, it would be necessary to place the included content as variables in another document with the following example.

.. main.rst

.. Reference the external file to load the variables

.. include:: my-included-file.rst

.. Using the variables

My |custom-content|.
.. my-included-file.rst

.. The external file with the variables

.. |custom-content| replace:: words beyond description.