Forum: Ruby on Rails Textile trouble

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ff4602ff49ddafe339c70b582f5e325d?d=identicon&s=25 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 = RedCloth.new(text, [ :filter_html, :filter_styles ])
textilized.to_html(:inline_textile_span, :glyphs_textile,
:inline_textile_link)

but it's not working:

>> text = "a <a href=\"http://www.bad.com/\">bad</a> link. it should be *removed* by 
\"redcloth\":http://http://rubyforge.org/projects/redcloth/"
=> "a <a href=\"http://www.bad.com/\">bad</a> link. it should be
*removed* by
\"redcloth\":http://http://rubyforge.org/projects/redcloth/"

>> textilized = RedCloth.new(text, [ :filter_html, :filter_styles ])
=> "a <a href=\"http://www.bad.com/\">bad</a> link. it should be
*removed* by
\"redcloth\":http://http://rubyforge.org/projects/redcloth/"

>> textilized.to_html(:inline_textile_span, :glyphs_textile, :inline_textile_link)
=> "<p>a <a href=\"http://www.bad.com/\">bad</a> link. it should be
<strong>removed</strong> by <a
href=\"http://http://rubyforge.org/projects/redcloth/\">r...

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.

Cheers,

--

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