middleman / middleman-syntax

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

block doesn't play well with haml #34

Closed lbain closed 10 years ago

lbain commented 10 years ago

I'm working on a site using middleman (very excited about it btw, only found it yesterday!), and I'd like to add syntax highlighting. I'm working in haml, and found the

<% code("ruby") do %>
def my_cool_method(message)
  puts message
end
<% end %>

when translated directly to haml

- code("ruby") do
  def my_cool_method(message)
    puts message
  end

causes problems because of the whitespace. I played around with it a bit and found that prefixing the code with :plain makes everything play nicely (much thanks to this Google group)

- code("ruby") do
  :plain
    def my_cool_method(message)
      puts message
    end

Would it be possible to check if the user is working with haml and then add the :plain prefix automatically? Perhaps something like what's happening for kramdown? I'm not sure I'm reading that code correctly though...

bhollis commented 10 years ago

From the README:

Indentation Problems

Some templating languages, like Haml, will indent your HTML for you, which will mess up code formatted in <pre> tags. When using Haml, either use the find_and_preserve helper, the :preserve filter, or add set :haml, { ugly: true } in your config.rb to turn off Haml's automatic indentation.

bhollis commented 10 years ago

I have introduced a new :code helper for Haml that will automatically handle whitespace correctly. See the README for this repo for how to use it. This is available in master now and will be released with the 2.0 version of the gem.

lbain commented 10 years ago

Awesome, thanks so much!