tanoku/redcarpet — Issue #68: fenced code block is rendering code w/ 8 spaces in front of each line
Author: briandmcnabb
Created: 2011-10-25 20:22:47+00:00
State: open

For some reason, any code I place inside a fenced code block does not seem to be bypassing the markdown renderer because it is being rendered with 8 spaces in front of each line.

My implementation:

```ruby
def render_markdown(text)
extensions = { no_intra_emphasis: true, fenced_code_blocks: true, autolink: true, strikethrough: true, space_after_headers: true, superscript: true }
render_options = { hard_wrap: true }
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(render_options), extensions)
Redcarpet::Render::SmartyPants.render(markdown.render(text)).html_safe
end
```

The 8 spaces seem to be triggered by line breaks. If my markdown looks like this (using apostrophes to represent back-ticks):

```
'''ruby
foo = "foo"
def say_foo
puts foo
end
'''
```

Then it will look like this rendered:

```ruby
foo = "foo"
def say_foo
puts foo
end
```

But if I add a line break after the start of the fenced code block all of the code contained therein is indented 8 spances, ie:

```
'''ruby

foo = "foo"
def say_foo
puts foo
end
'''
```

Then it will look like this rendered:

```ruby
foo = "foo"
def say_foo
puts foo
end
```