DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion
MIT License
63 stars 14 forks source link

Included figures with relative paths are not found #25

Closed massoncl closed 3 years ago

massoncl commented 3 years ago

Hi,

I have the following folder structure and files:

.
├── A.rst
├── included 
│   ├── B.rst
│   ├── diagram.jpg

A.rst:

Heading
----------

$include included/B.rst

B.rst:

.. figure:: imageB.png

The figure in B.rst is included via a relative path (relative to B). When B is included into A, this path is included as-is and becomes invalid:

> pandoc  --filter=pandoc-include -f rst -t pdf A.rst
[WARNING] Could not fetch resource diagram.jpg: replacing image with description

For that use case to work, I guess the $include should rewrite the paths to the figures and prepend the path from A to B, so that the relative paths become relative to A. Another option would be to convert them to absolute paths during the include, although I'm not sure how that fits into the overall pandoc-filter philosophy.

DCsunset commented 3 years ago

Hi, thanks for your suggestions. I also think it is reasonable to rewrite the path in included files. I will work on this later.

DCsunset commented 3 years ago

I have added this feature in v1.1.0.

massoncl commented 3 years ago

Thanks !