erusev / parsedown-extra

Markdown Extra Extension for Parsedown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrapping <img> in <figure>

anasram opened this issue · comments

Hi Emanuil,

I currently use FigureExtParsedownPicoPlugin to wrap <img> tag in a <figure> element with <figcaption>.

Recently, when I switched to the last version of Parsdown & ParesdownExtra (seems 1.8.0-beta-4), I noticed that ParesdownExtra doesn't work properly.

More about this issue here.

I'm wondering if you could merge the original work FigureExtParsedown.class.php with ParesdownExtra, or even merge such a function to it in your own way.

Thanks in advance.

I have added an automatic figure element feature recently in my ParsedownExtraPlugin extension. But it does not use title attribute value as the image caption. Instead, it uses indented paragraph elements that appear next to the image block. That way, you could add other inline element markup in the image caption such as bold text, credit link, etc. It also will degraded gracefully when parsed by other Markdown converters.

https://github.com/taufik-nurrohman/parsedown-extra-plugin#automatic-figure-elements

Thank you Taufik. However, I think it could be better if you make sure this syntax is supported by something like Pandoc.

I've been thinking recently about a unified syntax for figcaption for figures and caption for tables:

![Image](/path/to/image.jpg)

:  Image caption.

Likewise for table:

Head1 | Head2 | Head3
--- | --- | ---
cell11 | cell12 | cell13
cell21 | cell22 | cell23

:  Table caption.

@anasram Nice proposal BTW. But for now, I need to make sure that this kind of custom syntax will be degraded gracefully on general Markdown parser.

Your caption style might confuse average Markdown reader, they might think that it’s just a native definition list next to the image or table.

I will consider making the change if this kind of syntax started to be used everywhere.

This syntax is already supported by Pandoc for table captions, check this:

https://pandoc.org/MANUAL.html#extension-table_captions

Wow, the spec is so complicated 😵