bhollis / maruku

A pure-Ruby Markdown-superset interpreter (Official Repo).
MIT License
502 stars 80 forks source link

Extra newlines inside fenced code blocks #111

Closed konklone closed 10 years ago

konklone commented 10 years ago

Newlines are being generated at the beginning and end of the <code> blocks generated by fenced_code_blocks (whether tildes or backticks). This does not occur with <code> blocks generated by indentations.

With fenced code blocks:

fenced = "```ruby\nputs \"Hello world\"\n```\n"
Maruku.new(fenced, fenced_code_blocks: true).to_html

yields:

"\n<pre class=\"ruby\"><code class=\"ruby\">\nputs &quot;Hello world&quot;\n</code></pre>\n"

This causes the display to look like this:


puts "Hello world"

Without fenced code blocks (whether or not the fenced_code_blocks option is passed):

normal = "    puts \"hello world\"\n"
Maruku.new(normal).to_html

yields:

"\n<pre><code>puts &quot;hello world&quot;</code></pre>\n"

Which looks fine:

puts "hello world"
konklone commented 10 years ago

And filed a PR over at #112, whose tests pass, that fixes this.