# Redcloth poblems

**URL:** <https://www.ruby-forum.com/t/redcloth-poblems/58759>\
**Category:** Rails\
**Created:** [April 25, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/redcloth-poblems/58759 "2006-04-25T18:39:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 25, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/redcloth-poblems/58759/1 "2006-04-25T18:39:09Z")

</div>

Hi, I’m having some problems with redcloth(3.0.4 gem) and textilize.

I have a string:  
"h2. hello

_what’s up?_"

which is being textilized as:

## hello _what’s up?_

so no paragraph and h2 wrapped all the way.

the input is coming from firefox 1.5.2 on a mac

Anybody got any idea what the problem might be?

–  
I do things for love or money

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 25, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/redcloth-poblems/58759/2 "2006-04-25T19:14:14Z")

</div>

dorian mcfarland wrote:

> Hi, I’m having some problems with redcloth(3.0.4 gem) and textilize.
> 
> I have a string:  
> "h2. hello
> 
> _what’s up?_"
> 
> which is being textilized as:
> 
> ## hello _what’s up?_
> 
> so no paragraph and h2 wrapped all the way.
> 
> the input is coming from firefox 1.5.2 on a mac
> 
> Anybody got any idea what the problem might be?
> 
> –  
> I do things for love or money

I have had similar issues. It seems to come down to the :hard\_breaks  
option, which is enabled by default. I had to add a hlper method called  
textilize to application\_helper.rb that overrides the default behavior.

def textilize(text, options = nil)  
if text.blank?  
“”  
else  
textilized = (options ? RedCloth.new(text, options) :  
RedCloth.new(text))  
textilized.to\_html  
end  
end

That should make textilize work as expected, and allows you to pass in  
your option to the RedCloth object.

However single line breaks will not produce a   
. If anyone knows  
how to make textile work so “\n” is a   
 and “\n\n” does paragraphs  
I would be quite interested to know.

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 25, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/redcloth-poblems/58759/3 "2006-04-25T19:47:49Z")

</div>

yeah, that worked.  
I knew there were problems with hard\_breaks and rails in 3.0.3. but that  
all of this might have been resolved in 3.0.4  
I thought that both should be possible. Maybe it’s an either/or thing.  
It does seem to be a redcloth issue though because textile _should_  
handle both at the same time. Try doing it here:

> **[Textism: Tools: Textile](https://www.booked.net/textism.html)**
>
> Textism.com: Tools: Textile

Oh well, it’s working ok for now but not ideal.

thanks

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [May 19, 2006, 9:17pm UTC](https://www.ruby-forum.com/t/redcloth-poblems/58759/4 "2006-05-19T21:17:58Z")

</div>

> However single line breaks will not produce a   
> . If anyone knows  
> how to make textile work so “\n” is a   
> and “\n\n” does paragraphs  
> I would be quite interested to know.

I, too, would love to know how to do this with textile/redcloth.

Any suggestions with regards to this would be much appreciated!!

-raymond

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [May 19, 2006, 10:16pm UTC](https://www.ruby-forum.com/t/redcloth-poblems/58759/5 "2006-05-19T22:16:13Z")

</div>

It seems like this was answered, but in case it wasn’t here’s a console  
dump:

> > s=“this is\na two line string”  
> > =\> “this is\na two line string”  
> > RedCloth.new(s).to\_html  
> > =\> “
> > 
> > this is\na two line string
> > 
> > ”  
> > class RedCloth  
> > def hard\_breaks; true; end  
> > end  
> > =\> nil  
> > RedCloth.new(s).to\_html  
> > =\> “
> > 
> > this is  
> > a two line string
> > 
> > ”

It does come down to hard line breaks. For further reference, see:

[http://redhanded.hobix.com/inspect/usingRedcloth3.html](http://redhanded.hobix.com/inspect/usingRedcloth3.html)

–  
View this message in context:  
[http://www.nabble.com/redcloth+poblems-t1506534.html#a4476275](http://www.nabble.com/redcloth+poblems-t1506534.html#a4476275)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).
