DCsunset / pandoc-include

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

reST directives are not executed in the included files #22

Closed massoncl closed 3 years ago

massoncl commented 3 years ago

Hi,

I have two reST files, let's call them A and B:

A.rst :

Heading
---------- 

.. figure:: imageA.png

$include B.rst

B.rst :

.. figure:: image.png

The ..figure line is inserted vertbatim in the output document, instead of being replaced by an image.

I'm new to pandoc, and I assume this issue arises because the filters run after the reST directives have been processed. Is there any workaround for this ?

Thanks !

DCsunset commented 3 years ago

Hello, can you show your command to compile this file? It could help me to reproduce this problem.

massoncl commented 3 years ago

With the two files above, this command shows the problem (I added a figure directive to A.rst to show the difference): pandoc A.rst -f rst -t latex --filter=pandoc-include

The resulting output I get is this:

\hypertarget{heading}{%
\section{Heading}\label{heading}}

\begin{figure}
\centering
\includegraphics{imageA.rst}
\caption{}
\end{figure}

.. figure:: imageB.png

The file B.rst has been included, but the figure directive remains, instead of being converted to a LaTeX figure as the first image.

DCsunset commented 3 years ago

This happens because this filter didn't properly handle other formats. The latest update adds automatic format deduction from the file's name. It also supports setting the format manually.

The next version of this package may not be published immediately since there are still some pending issues. If you need this feature now, you may try installing the development version.

Feel free to comment here if there's any problem. :)

massoncl commented 3 years ago

I just tried the development version and I can confirm that it works on my test case. Thanks for the quick update !