/markdown-figures

Extension for Python-Markdown to parse figure elements, optionally with a caption.

Primary LanguagePythonGNU General Public License v2.0GPL-2.0

Python module mdx_figures

This is the extension mdx_figures for Python-Markdown to make captioned figures out of images that are followed by a description.

In contrast to other extensions with that purpose, this one

  • does not introduce new syntax tokens,
  • does not change the block/inline category of the ![] element
  • does not repurpose existing image attributes like alt or title,
  • allows use of Markdown in the caption,
  • is most natural to write, thus fitting the Markdown spirit very well.

Forked from lehni who forked from helderco. Added a cherry-pick from the fork by gijsdeheij.

A simple example

![](http://lorempixel.com/350/150/)
:   Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    Praesent at consequat magna, faucibus ornare eros. Nam et
    mattis urna. Cras sodales, massa id gravida

Output:

<figure>
    <img alt="" src="http://lorempixel.com/350/150/" />
    <figcaption>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Praesent at consequat magna, faucibus ornare eros. Nam et
        mattis urna. Cras sodales, massa id gravida</p>
    </figcaption>
</figure>

How to Install

Clone and run

sudo python setup.py install

For mkdocs add this to your mkdocs.yml file:

markdown_extensions:
    - mdx_figures