Forum: Ruby on Rails Textile trouble

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
mark (Guest)
on 2005-11-24 21:04
(Received via mailing list)
Hi there

This isn't strictly a rails question - more of a Textile/RedCloth query
but the rubyforge site for RedCloth seems to have been abandoned (at
least, the bugtracker has).

I want to use Textile/RedCloth to strip out user-supplied HTML and CSS
but permit textile mark for bold, italic, etc as well as links in the
"text":url fashion. The rails textilize() is out because it has
:hard_breaks set, which I don't want.

According to the RedCloth docs, this is what I want:

textilized =, [ :filter_html, :filter_styles ])
textilized.to_html(:inline_textile_span, :glyphs_textile,

but it's not working:

>> text = "a <a href=\"\">bad</a> link. it should be *removed* by 
=> "a <a href=\"\">bad</a> link. it should be
*removed* by

>> textilized =, [ :filter_html, :filter_styles ])
=> "a <a href=\"\">bad</a> link. it should be
*removed* by

>> textilized.to_html(:inline_textile_span, :glyphs_textile, :inline_textile_link)
=> "<p>a <a href=\"\">bad</a> link. it should be
<strong>removed</strong> by <a

As you can see, it's added emphasis for *asterisks* and converted the
"text":url okay, but it hasn't stripped out the HTML I supplied in the
original text.

Any ideas, anyone? I don't really want to have to write my own.



Mark Drayton
This topic is locked and can not be replied to.