# Textilize - redcloth

**URL:** <https://www.ruby-forum.com/t/textilize-redcloth/50819>\
**Category:** Rails\
**Created:** [December 21, 2005, 1:51pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819 "2005-12-21T13:51:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 1:51pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/1 "2005-12-21T13:51:31Z")

</div>

Hi,

I’m using textilize with redcloth 3.0.4. Everything works best except  
that paragraphs are not translated as an HTML paragraph

When I write something like:

_first paragraph_

second paragraph

the output is without paragraph:

_first paragraph_  
second paragraph

Any help??? Thanks

Jörg

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 3:28pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/2 "2005-12-21T15:28:18Z")

</div>

=?ISO-8859-15?Q?J=F6rg?= wrote:

> Hi,
> 
> I’m using textilize with redcloth 3.0.4. Everything works best except  
> that paragraphs are not translated as an HTML paragraph

Are you including newlines? i.e. “\n”

Jake

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 4:10pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/3 "2005-12-21T16:10:18Z")

</div>

Hi, JÃ¶rg,

thats got to do with the hardcoded :hard\_breaks in rails textilize  
helper:

# File vendor/rails/actionpack/lib/action\_view/helpers/text\_helper.rb,

line 84  
84: def textilize(text)  
85: if text.blank?  
86: “”  
87: else  
88: textilized = RedCloth.new(text, [:hard\_breaks])  
89: textilized.hard\_breaks = true if  
textilized.respond\_to?(“hard\_breaks=”)  
90: textilized.to\_html  
91: end  
92: end

put your own helper in application\_helper.rb, use that one and you  
should be fine:

def tlize(text)  
text = RedCloth.new(text)  
return text.to\_html  
end

Regards  
Jan

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 4:31pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/4 "2005-12-21T16:31:47Z")

</div>

> 

Hi Jan,

thanks for the answer, now paragraphs work but new lines do not?! : )  
do you have another glue?

Thanks

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 4:13pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/5 "2005-12-21T16:13:19Z")

</div>

Jake J. schrieb:

> Are you including newlines? i.e. “\n”
> 
> Jake

No, new lines do work. It’s only when seperating text by a blank line  
the text should be a paragraph, that does not work.

JÃ¶rg

i.e.:

This is what I write into my textarea:

_test_

test

this is what comes out:

\*test  
\*test

and this it what should come out ([Textile Reference](http://hobix.com/textile/)):

_test_

test

thanks for any help!!!

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 5:29pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/6 "2005-12-21T17:29:10Z")

</div>

Ahh, thats interesting, seems as if its kind of an ‘alternative’ thing.  
maybe you’ll find something on redcloth forums or mailing-lists (there  
surely are some?) or might try something like:

```
def tlize(text)
  text.gsub!( /(.*)(\n)/, '\1<br />' )
  text = RedCloth.new(text)
  return text.to_html
end

```

the regex might be quite naive (n00b), if you’ve got something better  
tell us!

Regards  
Jan

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 7:51pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/7 "2005-12-21T19:51:03Z")

</div>

Ezra Z. schrieb:

> > _first paragraph_  
> > Jörg
> 
> [http://yakimaherald.com](http://yakimaherald.com)

yea, thanks too, 3.0.3 works best!

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 5:56pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/8 "2005-12-21T17:56:20Z")

</div>

On Dec 21, 2005, at 4:49 AM, Jörg wrote:

> the output is without paragraph:
> 
> _first paragraph_  
> second paragraph
> 
> Any help??? Thanks
> 
> Jörg

Redcloth 3.0.4 is b0rked. Everything will work as expected if you  
downgrade to Redcloth 3.0.3

Cheers-  
-Ezra Z.  
Yakima Herald-Republic  
WebMaster  
[http://yakimaherald.com](http://yakimaherald.com)  
509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![SSSISO-8859-15SQSJS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@SSSISO-8859-15SQSJS](https://www.ruby-forum.com/u/SSSISO-8859-15SQSJS)\
**Post date:** [December 21, 2005, 7:20pm UTC](https://www.ruby-forum.com/t/textilize-redcloth/50819/9 "2005-12-21T19:20:44Z")

</div>

thanks a lot, this just cropped up on me too.

On 12/21/05, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > _first paragraph_  
> > Jörg
> 
> [http://yakimaherald.com](http://yakimaherald.com)  
> 509-577-7732  
> removed\_email\_address@domain.invalid
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
=\> the blog from beyond \<=  
=\> [www.eyeheartzombies.com](http://www.eyeheartzombies.com) \<=
