1

After watching this RailsCast, I thought I'd give RedCloth a try. Unfortunately, it looks like I'm having an issue that involves the resultant HTML being encodeded instead of rendered as straight HTML.

  1. First I added the following to my Gemfile:

    gem 'RedCloth', '4.2.7'
    
  2. I added a basic RedCloth implementation to my view:

    <%= RedCloth.new("* one\n* two\n * three").to_html %>
    
  3. When I "view source" for the page that is rendered, this is what appears:

    &lt;ul&gt;
        &lt;li&gt;one&lt;/li&gt;
        &lt;li&gt;two&lt;/li&gt;
        &lt;li&gt;three&lt;/li&gt;
    &lt;/ul&gt;
    

    The output I expected was the following:

    <ul>
        <li>one</li>
        <li>two</li>
        <li>three</li>
    </ul>
    

    Am I doing something wrong? Do I need to pass a parameter to to_html or the RedCloth constructor?

Matt Huggins
  • 81,398
  • 36
  • 149
  • 218

1 Answers1

4

Try this:

<%= raw RedCloth.new("* one\n* two\n * three").to_html %>

Also check out this blog post on the subject.

tjwallace
  • 5,528
  • 1
  • 26
  • 15
  • Excellent, that did the trick! Thanks for the informative link as well...I just started toying with Rails 3 (vs. 2.3.x), and I haven't yet read up on all the changes introduced. – Matt Huggins Apr 16 '11 at 19:06