kramdown
kramdown copied to clipboard
incorrect text inserted after nested spans
Run the following:
s = <<END
<div class="navbar">
<span style="white-space:nowrap" markdown="1">
<span class="parent"><a href="tech">Technical Details</a></span>
</span>
</div>
END
h = Kramdown::Document.new(
s, :auto_ids => false, :entity_output => :numeric
).to_html
puts h
The output is:
<div class="navbar">
<span style="white-space:nowrap">
<span class="parent"><a href="tech">Technical Details</a></span></span>
</span>
</div>
The bug is the extra </span>
inserted into the text.
I can see a way of working around this, and I probably will do so; but this is new behavior that is affecting a longstanding web site of mine (though I can't specify the kramdown update in which the problem started, sorry) so perhaps it counts as a genuine bug.
This behaviour has changed in version 1.11.0 - have you been running a version older than this before? Have to dig a bit to find out why this behaviour changed because it probably shouldn't have.
Why are you using markdown="1"
in the first <span>
element? This seems to be causing the issue.
Yes, clearly I was using an older version of kramdown the last time I built my site. The change seems surprising; what I'm doing was never obviously forbidden by the kramdown syntax rules — nested <span>
is legal, and kramdown probably shouldn't care at what level the markdown="1"
occurs — and injecting </span>
into my text seems just wrong. The workaround from my end is to move that markdown="1"
into the inner <span>
element, or remove the nesting entirely (i.e. have just one level of <span>
). There is more going on here at kramdown's end; for example, if you remove the outer <div>
the issue doesn't arise.