xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.35k stars 448 forks source link

Add support for implicit figures for images #100

Open RickStrahl opened 7 years ago

RickStrahl commented 7 years ago

I'm using builder.UseFigures() in my pipeline builder code, but I don't see figure output rendered.

Example here: https://babelmark.github.io/?text=!%5BSave+Image+to+Azure+Blob+Storage+Addin%5D(https%3A%2F%2Fgithub.com%2FRickStrahl%2FSaveToAzureBlob-MarkdownMonster-Addin%2Fraw%2Fmaster%2FSaveToAzureMarkdownMonsterAddin.gif)%0A

Markdig renders the image only which seems like Figures is not doing anything. Pandoc renders with figure classes, multi-markdown uses figure proper figure/figcaption elements.

Looks like MarkDig should render figure/figurecaption, but I don't see it rendered. Double checked to make sure FigureExtension is loaded in the final PipelineBuilder used to render with:

Markdown.Convert(markdown, renderer, Pipeline);

BTW, how does the Markdig Parser run in BabelMark? With all options enabled?

xoofx commented 7 years ago

Afair, The figure extension is not doing anything with regular image links. As described on CommonMark forum, I implemented the following:

^^^
This is a text
> With a block quote and an ![image](/url "my title")
^^^ My caption

The ^^^ identifies a figure block with a block caption and renders like this:

<figure>
  <p>This is a text</p>
  <blockquote><p>With a block quote and an <img src="/url" alt="image" title="my title"><p>
  </blockquote>
  <figcaption>My caption</figcaption>
</figure>

In this discussion, they talked about implementing something automatically for img, but It was not settled and I prefer to have an explicit figure caption (and not automatically generated)

^^^
![Kookburra](/kookaburra.jpg "Kookburra")
![Pelican](/pelican.jpg "Pelican")
![Cheeky looking Rainbow Lorikeet](/lorikeet.jpg "Rainbow Lorikeet")
^^^ From left to right, Kookburra, Pelican, and Rainbow Lorikeet.

should render like this (check markdig advanced on babelmark):

<figure>
   <p>
  <img src="/kookaburra.jpg" alt="Kooaburra" title="Kookburra">
  <img src="/pelican.jpg" alt="Pelican stood on the beach" title="Pelican">
  <img src="/lorikeet.jpg" alt="Cheeky looking Rainbow Lorikeet" title="Rainbow Lorikeet">
  </p>
  <figcaption>From left to right, Kookburra, Pelican, and Rainbow Lorikeet.</figcaption>
</figure>

BTW, how does the Markdig Parser run in BabelMark? With all options enabled?

RickStrahl commented 7 years ago

Yeah I kind of agree about the explicit nature. PanDoc however does render figure captions (using styling rather than figure/figcaption tho)...

Thanks for the clarification.

xoofx commented 7 years ago

PanDoc however does render figure captions (using styling rather than figure/figcaption tho)...

Reopening and mark it as an enhancement. Implicit figure for image is something that can be done as part of the figure extension (through no spare time to work on this)