max
max

Reputation: 2396

Using reStructuredText to include a file that also has an image directive in it

This is an extension of this question. I want to include (not literalinclude) a section from another reST file that contains an image directive. Below is an example of what I'm trying to do.

File with Include directive (summary.rst):

Weekly Summary
--------------

These are Monday's notes::

  .. include:: ./notes/weekly_notes.rst
      :start-after: begin-monday
      :end-before: end-monday

File to be included (./notes/weekly_notes.rst):

.. begin-monday

Meeting Notes from Monday
+++++++++++++++++++++++++

... some text ...

.. image:: image.png

.. end-monday

Currently, the include is working just fine except the image is NOT being displayed in the summary.rst. It is displayed correctly in the weekly_notes.rst. This is obviously because the relative location is not the same for the two files.

Is there a way around this to get the image to display in both locations??

Thanks.

Upvotes: 2

Views: 3799

Answers (1)

Roberto Alsina
Roberto Alsina

Reputation: 800

The problem is the path to the image. I am guessing image.png is in the same folder as weekly_notes.rst

Docutils (or most likely the writer you are using) is trying to find the image in the folder of summary.rst instead.

If you only use weekly_notes.rst included, then you should use ./notes/image.png as the image path.

Upvotes: 2

Related Questions