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 275 forks source link

Unexpected discrepancy between renders of code-blocks and code-span #752

Closed ashmaroli closed 2 years ago

ashmaroli commented 2 years ago

Hi, the following discrepancy was detected while investigating https://github.com/jekyll/jekyll/issues/8990

For context, Jekyll sets config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext" prior to passing config onto kramdown. With this set up, when Jekyll renders the following snippet:

This is a Ruby code fragment `x = Class.new`{:.language-ruby}

```
def what?
  42
end
```
{: .language-ruby}

into:

<p>This is a Ruby code fragment <code class="language-plaintext highlighter-rouge"><span class="n">x</span> <span class="o">=</span> <span class="no">Class</span><span class="p">.</span><span class="nf">new</span></code></p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">what?</span>
  <span class="mi">42</span>
<span class="k">end</span>
</code></pre></div></div>

Note how code-span gets language-plaintext assigned while the code-block gets language-ruby.

I'm not saying this is a bug with kramdown. But would like to get your opinion on the situation.

gettalong commented 2 years ago

Hi @ashmaroli!

I can confirm that this is a bug in the kramdown HTML converter.

ashmaroli commented 2 years ago

Thank you for looking into this, @gettalong :)

gettalong commented 2 years ago

@ashmaroli Fix will be released in a bit.

ashmaroli commented 2 years ago

Thanks for the quick fix, @gettalong i confirm that this issue has been resolved with kramdown-2.4.0

But I don't see the change on the master branch nor a REL_2_4_0 tag pushed to this repo..

gettalong commented 2 years ago

@ashmaroli Thanks, fixed!