Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect text inserted after nested spans #636

Open
mattneub opened this issue Jan 3, 2020 · 2 comments
Open

incorrect text inserted after nested spans #636

mattneub opened this issue Jan 3, 2020 · 2 comments
Assignees

Comments

@mattneub
Copy link

mattneub commented Jan 3, 2020

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>
&nbsp;&nbsp;&nbsp;
</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>
&lt;/span&gt;
&nbsp;&nbsp;&nbsp;
</div>

The bug is the extra &lt;/span&gt; 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.

@gettalong gettalong self-assigned this Jan 3, 2020
@gettalong
Copy link
Owner

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.

@mattneub
Copy link
Author

mattneub commented Jan 4, 2020

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 &lt;/span&gt; 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.

mattneub added a commit to mattneub/RubyFrontier that referenced this issue Jan 13, 2020
remove Haml `ugly` (no longer supported)
work around kramdown nested-span bug (gettalong/kramdown#636)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants