hey-red/Markdown

Update list of block tags

follesoe opened this issue · 1 comments

I've run into an issue using markdown to generate HTML for Facebook Instant Articles. Facebook expect every image to be wrapped in a <figure> element. Using the support for inline HTML I could write it like this:

<figure>![my alt text](myimage.jpg)</figure>

But when transformed, the output is:

<p><figure><img alt="my alt text" src="myimage.jpg" /></figure></p>

As far as I can tell is is because the Markdown processor threat the <figure> as an inline element and wrapping it in a <p>. It looks like all that would be needed, is to update the list of block elements at this line: https://github.com/hey-red/Markdown/blob/master/src/Markdown/Markdown.cs#L486

If doing the change, it might be an idea to consider to include more block elements from https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements

What do you guys think?

I can extend the block list, but it will not work in your case.
See note from markdown spec

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style emphasis inside an HTML block.

You don't need markdown for this. Just create image as html tag:
<figure><img src="myimage.jpg" alt="my alt text" /></figure>