gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 274 forks source link

Select whether an HTML tag is parsed as block or span level #793

Closed EtienneMiret closed 1 year ago

EtienneMiret commented 1 year ago

According to the WHATWG, the img element is both flow content and phrasing content. I might be wrong on that one, but I understand “flow content” from the WHATWG spec as meaning “block level” while “phrasing content” would be “span level”.

In any case, there is no doubt img elements are allowed as direct children of the body element. Which seems currently impossible to achieve with kramdown.

So, could that feature be added? I’m thinking about something like:

<img alt="" src="foo" level="span"/>

<img alt="" src="foo" level="block"/>

that would translates to:

<p><img alt="" src="foo"></p>

<img alt="" src="foo">

Also, I took img as an example, but I expect that new level attribute to work on any tag.

gettalong commented 1 year ago

You can already achieve this with kramdown:

{::nomarkdown}
<img alt="" src="foo" />
{:/}

will result in

<img alt="" src="foo" />
EtienneMiret commented 1 year ago

Oh, OK, cool! Not sure why I didn’t see that in the doc. Thank-you!