middleman / middleman-syntax

Code syntax highlighting plugin via Rouge for Middleman
https://middlemanapp.com
MIT License
179 stars 57 forks source link

Indentation problem with fenced code blocks in Markdown #16

Closed SachaG closed 11 years ago

SachaG commented 11 years ago

I'm using middleman-syntax with Redcarpet to get GitHub-style code blocks and everything's working fine, except that the indentation is off, as you can see here:

http://tmb-middleman.herokuapp.com/2013/02/20/a-look-at-a-meteor-template/

The same problem was also reported on Stack Overflow but in that case the code block was inside HAML whereas here it's inside Markdown.

Here is my config.rb file:

activate :syntax

set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true, :smartypants => true
bhollis commented 11 years ago

What does your layout file look like? Is that really your whole config.rb?

SachaG commented 11 years ago

Here's a link to the repo: https://github.com/SachaG/TMB-Middleman

Relevant files:

bhollis commented 11 years ago

It looks like I solved this on my own blog by putting this in the article layout:

.post-content= find_and_preserve do
  = yield

It just works around Haml's overwhelming desire to indent everything.

SachaG commented 11 years ago

Awesome, it works! So it's the same HAML problem after all, I just didn't think it would affect the markdown code inside another file too!

Thanks again :)

dansowter commented 11 years ago

Thanks very much for this tip. This was driving me crazy.

thattommyhall commented 9 years ago

I found I could not get

    .container.menu--push= find_and_preserve do
      = yield

to work, but

    .container.menu--push
      ~ yield

(~ in place of =) did.

How bloody annoying!

doolin commented 9 years ago

@thattommyhall ~ yield worked for me as well. Thanks!

xavdid commented 8 years ago

For those just finding this, worth noting that haml's ~ is just an = with #find_and_preserve run: http://haml.info/docs/yardoc/file.REFERENCE.html#whitespace_preservation

xavibenjamin commented 8 years ago

Thank you!! Was just having problems with this.