miyakogi / m2r

Markdown to reStructuredText converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

literalinclude no content permitted

fjp opened this issue · comments

commented

First of all thank you for this amazing converter, I really like it so far. However, when I try to include an external cpp file in one of my markdown with the following literalinclude directive:

.. literalinclude:: ../ch2-hello_world/exercises/exercise-01/main.cpp
   :language: cpp
   :caption: helloworldextended.cpp

The code is not rendered and I get the following warning in the raw build output:

../ch2-hello_world/exercises/exercise-01/README.md:12: WARNING: Error in "literalinclude" directive:
no content permitted.

.. literalinclude:: ../ch2-hello_world/exercises/exercise-01/main.cpp

:language: cpp
:caption: helloworldextended.cpp

However, if I add text or just a single character after the above literalinclude everything works as expected. The code from the cpp file renders fine.

.. literalinclude:: ../ch2-hello_world/exercises/exercise-01/main.cpp
   :language: cpp
   :caption: helloworldextended.cpp


here is some text

Am I missing an option at the end of the literalinclude or why is text after it required to render the code properly?

Here is the result on read the docs running Sphinx v1.8.5, python 3.7 and m2r v0.2.1

Noticed the same problem.

Found work around for now

.. literalinclude:: ../ch2-hello_world/exercises/exercise-01/main.cpp
   :language: cpp
   :caption: helloworldextended.cpp

.. here is some text

I think the problem is that m2r adds new line after initial directive. But that only happens if there is nothing else following after this directive