hey-red / Markdown

Open source C# implementation of Markdown processor, as featured on Stack Overflow.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update list of block tags

follesoe opened this issue · 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?

commented

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>