Ah ha, marvelous thank you so much.

On Mar 24, 11:05 pm, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
> Ah, I see what you mean. There's a quick and easy solution to this: wrap
> the call to markdown in the find_and_preserve Haml helper. That'll
> replace all newlines within <pre> tags in the markdown output with the
> HTML entity for newlines, which will cause the Haml indenter to ignore
> them. That'll make it render properly in a browser. So, what you want to
> do is:
>
> .message
>   .body= find_and_preserve(markdown(message.body))
>   .by= message.author
>
> Hope that's helpful!
>
> - Nathan
>
> Spongy wrote:
> > Hi the template is this, its actually a partial but should be complete
> > enough
>
> > file messages/_message.haml
> > .message
> >   .body= markdown(message.body)
> >   .by= message.author
>
> > An example of the content of message.body is
>
> > ## start example
> > This is my chicken example ruby file
>
> >     class Chicken
> >       def noise
> >         "squawk"
> >       end
> >     end
>
> > this is after my chicken code block
>
> > ## end example
>
> > Markdown will automatically wrap the code block in the above example
> > in <pre><code> and </code></pre> tags. When the partial is rendered
> > and the current indentation level is already more than one level deep
> > then additional indentation will be added to the contents of the <pre>
> > contents.
>
> >           <div class="message">
> >             <pre><code>class Chicken
> >               def noise
> >                 "squawk"
> >               end
> >             end
> >             </code></pre>
> >             <div class="by">Rooster</div>
> >           </div>
>
> > Now this is fine within the HTML but when rendered all of the
> > preceding indentation on each line after the first will be more
> > greatly indented than the first. In order for it to render properly
> > the HTML would need to probably look like this
>
> >           <div class="message">
> >             <pre><code>class Chicken
> >   def noise
> >     "squawk"
> >   end
> > end
> >             </code></pre>
> >             <div class="by">Rooster</div>
> >           </div>
>
> > Which admittedly is absolutely horrible when viewing HTML but does
> > render properly.
>
> > Does that make more sense?
>
> > On Mar 24, 8:22 pm, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
>
> >> I'm a little confused. What "<pre><code>" tags? What's chicken.rb have
> >> to do with this?
>
> >> Could you give an example of the template you're evaluating, the value
> >> you're passing to markdown, the output given by Haml, and the output you
> >> expect? Thanks.
>
> >> - Nathan
>
> >> Spongy wrote:
>
> >>> Hi,
> >>> I have a view template like
>
> >>>     .message
> >>>       .body= markdown(message.body)
> >>>       .by= message.author
>
> >>> and the message.body has a number of markdown code blocks within it.
> >>> Now what keeps happening is when viewed in a browser the first line of
> >>> the code block is fine. Its on the same line as the <pre><code> tags
> >>> but each other line is over indented. As below
>
> >>>     ## chicken.rb
> >>>                 class Chicken
> >>>                   def bawk
> >>>                     puts "baw-kawk"
> >>>                   end
> >>>                 end
>
> >>> I am guessing that this is caused in part by markdown and partly by
> >>> Haml, but I've no idea how to resolve it. I tried using the markdown
> >>> Haml filter but you can't pass a variable or anything like that to the
> >>> filter.
>
> >>> Are there any ideas about how I can fix this?
>
> >>> Thank you,
> >>> Spongy


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to