HAML and pre/code blocks extra indentation (find_and_preserve() not helping?)

174 views
Skip to first unread message

jbrennan

unread,
Jun 13, 2011, 2:22:09 PM6/13/11
to ha...@googlegroups.com
Writing a little Sinatra app and using haml for my layout. I've got some markdown text I'm parsing elsewhere, and then trying to render with HAML, but for my blocks of code, I'm getting too much indentation after the first line of code.

This seems to be a semi-common issue and so I'd read the solution is to wrap the yield in a call to find_and_preserve(). This gives slightly different output (the second line is now only indented by 2, instead of 4, spaces), but obviously not what I'm trying to accomplish. Any ideas?


layout.haml
!!! 5
    %body
        = find_and_preserve(yield)


index.haml
=@the_html_from_md



app.rb
get '/' do
    @the_html_from_md = …
    haml :index
end



Markdown:

This is a line

    first line of code
    second line of code


Output:

<!DOCTYPE html>
<html lang='en'>
  <body

      <pre><code>First line of code  second line of code  </code></pre>
  </body>
</html>
Reply all
Reply to author
Forward
0 new messages