lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
911 stars 72 forks source link

fenced div/span syntax for subfigures #395

Open fcskit opened 11 months ago

fcskit commented 11 months ago

Could you support the fenced div/span syntax used for tables also for subfigures in addition to a

block?

:::{#fig:subfigure label="Figure"}
![subfigure caption 1](link_to_image1.png){#fig:subfigure_2}
![subfigure caption 2](link_to_image1.png){#fig:subfigure_1}
: Caption
:::

The background of my question is that I'm using Obsidian as my primary markdown editor, which has a live preview editing mode. Embedded markdown figure links are directly rendered in the live preview editing mode. The syntax above would show the images in live preview (which would be my preferred option) while placing the subfigures in a div block will not, since the markdown code inside the div will by interpreted as normal text and not as markdown.

It would also be a bit more consistent, because the same syntax works for tables.

lierdakil commented 11 months ago

Hi. Fenced divs should work fine for subfigures, pandoc-crossref doesn't even know whether the div is fenced or not. You do need a paragraph break before caption, however. Also, : is superfluous, the last paragraph in subfigure div is interpreted as the caption verbatim. So this should work:

:::{#fig:subfigure}
![subfigure caption 1](link_to_image1.png){#fig:subfigure_2}
![subfigure caption 2](link_to_image1.png){#fig:subfigure_1}

Caption
:::