1

This is from my pry console:

> input = <<-HEREDOC
* # Header 1
* ## Header 2
*
* ```
* def hello
*   puts "hello world"
* end
* ```
* HEREDOC
=> "# Header 1\n## Header 2\n\n```\ndef hello\n  puts \"hello world\"\nend\n```\n"
> Kramdown::Document.new(input, input: "GFM", syntax_highlighter: "rouge").to_html
=> "<h1 id=\"header-1\">Header 1</h1>\n<h2 id=\"header-2\">Header 2</h2>\n\n<div class=\"highlighter-rouge\">def hello\n  puts \"hello world\"\nend\n</div>\n"

As you can see, the html generated for the code block doesn't contain any <pre> code wrapper. But if I removed rouge option and use coderay, it works beautifully.

> Kramdown::Document.new(input, input: "GFM").to_html
=> "<h1 id=\"header-1\">Header 1</h1>\n<h2 id=\"header-2\">Header 2</h2>\n\n<pre><code>def hello\n  puts \"hello world\"\nend\n</code></pre>\n"

Any idea what's wrong? Thanks in advance.

RubyCat
  • 155
  • 11

1 Answers1

0

It's because of the rouge gem version. I need to change it to < v2.0.0. And now I'm using:

  • kramdown v1.13.1
  • rouge v1.11.1
RubyCat
  • 155
  • 11