Textile trouble


#1

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 link. it should be removed by “redcloth”:http://http://rubyforge.org/projects/redcloth/”
=> “a <a href=“http://www.bad.com/”>bad 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 link. it should be
removed by
“redcloth”:http://http://rubyforge.org/projects/redcloth/”

textilized.to_html(:inline_textile_span, :glyphs_textile, :inline_textile_link)
=> “

a <a href=“http://www.bad.com/”>bad link. it should be
removed by <a
href=“http://http://rubyforge.org/projects/redcloth/”>redcloth

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