Question

I have rst files containing lines like

.. figure:: examples/foo.png 
    :scale: 80%

    Fig. 1 : Illustration of the awesomeness of stackoverflow

now I want this file to be converted into markdown. I tried using pandoc,

pandoc -s -w rst --toc foo.rst -o foo.md

but the output file foo.md seems ignore the figure inclusion lines. So, how can I convert into markdown files without losing the awesomeness of figures? Thanks

Was it helpful?

Solution

This online demonstration of Pandoc converts the following markdown:

![Map to buried treasure](/path/to/img.jpg "Optional title")

into the following reStructuredText:

.. figure:: /path/to/img.jpg
   :align: center
   :alt: Optional title

   Map to buried treasure

So this should be how you can define a figure that can be converted to markdown. However, using this reStructuredText in the online converter causes an error with a very unhelpful error message. Do you get any error messages when you run Pandoc?

Perhaps your reStructuredText syntax is incorrect: options to the figure (and any other) directive should be indented with respect to the directive name. Try using

.. figure:: examples/foo.png 
   :scale: 80%

   Fig. 1 : Illustration of the awesomeness of stackoverflow

and see if that makes a difference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top