# "textilize" playing silly buggers with me

**URL:** <https://www.ruby-forum.com/t/textilize-playing-silly-buggers-with-me/49633>\
**Category:** Rails\
**Created:** [December 7, 2005, 2:23am UTC](https://www.ruby-forum.com/t/textilize-playing-silly-buggers-with-me/49633 "2005-12-07T02:23:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [December 7, 2005, 2:23am UTC](https://www.ruby-forum.com/t/textilize-playing-silly-buggers-with-me/49633/1 "2005-12-07T02:23:13Z")

</div>

note: please CC me on replies as I’m not subscribed to the list, thanks.

hey guys,

I’m using \<%= textilize(@article.body) %\> in my view, but it’s doing  
funny  
things with a html header tag, like so:

* * *

## General Observations ``` <ul> <li>lots of points here</li> </ul></h2> ``` * * *

however, if I copy and paste the text from the database to a ruby script  
and run  
that, I get the following:

* * *

require ‘redcloth’

r = RedCloth.new "h2. General Observations

- There are almost as many theories on growing cymbidiums as there are  
growers."

## puts r.to\_html

## gives me

## General Observations

```
<ul>
<li>There are almost as many theories on growing cymbidiums as there 

```

## are growers.

you can see that there isn’t a   
 tag and the h2 tag is correct.

Any tips on where I’m going wrong? The database field is a mysql text  
field,  
utf-8, which I’ve been editing using phpMyAdmin on localhost.

thanks!  
scott

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [December 7, 2005, 5:37am UTC](https://www.ruby-forum.com/t/textilize-playing-silly-buggers-with-me/49633/2 "2005-12-07T05:37:50Z")

</div>

> you can see that there isn’t a   
> tag and the h2 tag is correct.
> 
> Any tips on where I’m going wrong? The database field is a mysql text field,  
> utf-8, which I’ve been editing using phpMyAdmin on localhost.

update - looks like there is some kind of bug in redcloth concerning  
hard  
breaks. if I change the textilize function like so:

* * *

# Returns the text with all the Textile codes turned into HTML-tags.

```
    # <i>This method is only available if RedCloth can be 

```

## required. def textilize(text) if text.blank? “” else #textilized = RedCloth.new(text, [:hard\_breaks]) #textilized.hard\_breaks = true if textilized.respond\_to?(“hard\_breaks=”) # \*\*\* SM change - hard\_breaks screws up large amounts textilized text, like a long article, and screws formatting in general textilized = RedCloth.new(text) textilized.to\_html end end

it works just fine with \<%= textilize(@article.body) %\>

it would appear that changing line breaks to   
 tags is triggering a  
bug in  
textilize, because otherwise I can get a long textile-marked-up document  
to  
render just fine.

thoughts? I guess I’ll have to dive into the RedCloth code now, to solve  
this.

-sm

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [December 7, 2005, 9:13am UTC](https://www.ruby-forum.com/t/textilize-playing-silly-buggers-with-me/49633/3 "2005-12-07T09:13:38Z")

</div>

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

> thoughts? I guess I’ll have to dive into the RedCloth code now, to solve this.

[fanatico.org&nbsp;-&nbsp;This website is for sale!&nbsp;-&nbsp;fanatico Resources and Information.](http://fanatico.org/ruby/textile/fix_hard_break.diff) - simple fix for  
RedCloth.

[fanatico.org&nbsp;-&nbsp;This website is for sale!&nbsp;-&nbsp;fanatico Resources and Information.](http://fanatico.org/ruby/textile/allow_redcloth_restrictions.diff) -  
patch for Rails. Allows users to pass options to RedCloth through the  
textilize method.

---

<div class="post-metadata">

**Author:** ![scott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://www.ruby-forum.com/u/scott)\
**Post date:** [December 7, 2005, 2:48pm UTC](https://www.ruby-forum.com/t/textilize-playing-silly-buggers-with-me/49633/4 "2005-12-07T14:48:17Z")

</div>

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

> > you can see that there isn’t a   
> > tag and the h2 tag is correct.
> > 
> > Any tips on where I’m going wrong? The database field is a mysql text field,  
> > utf-8, which I’ve been editing using phpMyAdmin on localhost.
> 
> update - looks like there is some kind of bug in redcloth concerning hard  
> breaks. if I change the textilize function like so:

There seem to be a number of little issues with RedCloth 3.0.4  
(latest?). Rolling back to 3.0.3 fixed things nicely for me.

–  
Jack Baty  
Fusionary Media - [http://www.fusionary.com](http://www.fusionary.com)
