Closed rbuchberger closed 5 years ago
The reason for this is that the <div>
tag is not an inline/span level tag but a block level tag. Therefore it can't be nested inside span level elements like anchors.
Also, kramdown has to decide what to do with HTML elements. If it encounters a span level HTML tag like <a>
, it assumes that the tag starts a paragraph. Therefore the <a>...</a>
line gets wrapped in a <p>
tag.
So if you want to use HTML elements in a way that contradicts the conceptual model of kramdown, you have to tell kramdown to ignore those lines using the {::nomarkdown}
extension:
{::nomarkdown}
<a href="example.com" markdown="0"><div markdown="0"></div></a>
{:/}
This is the solution I was looking for, thanks a ton. Sorry I couldn't find it in the docs.
Problem: Wrapping a block level element in an anchor tag results in mangled HTML.
This came to light in this issue with jekyll-picture-tag.
I've created a small test project to replicate it:
When test.md looks like this:
The output looks like this:
Adding or removing
markdown="0"
doesn't seem to have any effect. This problem shows up in a number of cases:If you wrap the whole thing in a div, you don't get the same issue: