In reStructuredText, how does one do an 'inline' include of an external document fragment?

86 views Asked by At

I have a bullet lists of hyperlinks to articles, where each article has a one-line summary. And, I would like my one-line summary to appear in the bullet list:

Because (1) my summaries quite involved, (2) I have many articles, and (3) even more bullets, I'd like to put the summaries into their own document fragments and 'include' them in both the bullet list and the article. But, this does not fly in reStructuredText:

* `Thing1`_: .. include:: summary-of-thing1.txt
* `Thing1`_: .. include:: summary-of-thing2.txt

The text .. include:: summary-of-thing1.txt ends up in my generated HTML document, and this appears to be because directives (like .. include::) must be in their own 'paragraph' like this:

* `Thing1`_:

  .. include: summary-of-thing1.txt

But, doing that puts my document fragment into its own paragraph, which makes it look like this:

When, what I really want is for my summaries to appear on the very same line as my hyperlinks.

1

There are 1 answers

0
davidrmcharles On

OK, I see this is what .. replace:: is for. One can say this:

* `Thing1`_: |summary-of-thing1|
* `Thing2`_: |summary-of-thing2|

.. include:: summaries.txt

And put the summaries into summaries.txt like this:

.. |summary-of-thing1| replace:: This is a thing.
.. |summary-of-thing2| replace:: This is also a thing.