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 - but not HAML #40

Closed chrissearle closed 10 years ago

chrissearle commented 10 years ago

I've just found https://github.com/middleman/middleman-syntax/issues/16 - which shows the symptom I have exactly. However it (as well as a fair few other hits on the net) all end up being about how HAML is doing the indenting - and the fix seems to be haml config.

However - I'm not using haml.

My content files are title.html.md.erb

Config for markdown er

set :markdown, :fenced_code_blocks => true, :smartypants => true

Markdown engine is kramdown (1.3.3). Have also tested with redcarpet 3.1.1.

What I see is that if there are two or more lines in a fenced code section (see e.g. this source document - for both ruby and sql blocks) then in the built HTML I see nicely indented HTML generated from the markdown - which of course breaks the code layout by adding those spaces when inside a pre block. The example article renders like this

I'd appreciate any ideas on how to fix this :)

bhollis commented 10 years ago

What does your layout look like?

chrissearle commented 10 years ago

Now that was a good hint. I'd totally forgotten that I was using haml there (and yes - now I feel stupid).

Arcovion commented 10 years ago

If you didn't know already, ~ in Haml is the same as running find_and_preserve, so just switch your = to ~