[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Redcloth ignore YouTube embeds?

dougal.s

12/3/2007 7:06:00 PM

Hi folks.

I'm trying to process blog posts using RedCloth, stripping any html
entered by the user, but leaving <object>, <embed> and <param> tags
untouched.

So far I've tried...

# ========================
require 'rubygems'
require 'redcloth'

t = 'I am a *badger* <object width="425" height="355"><param
name="movie"
value="http://www.youtube.com/v/xyujSekNfsg&r...></param>...
name="wmode" value="transparent"></param><embed
src="http://www.youtube.com/v/xyujSekNfsg&r...
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="355"></embed></object>'

t = t.gsub( /(<object(.|\n)+?<\/object>)/ ,
"<notextile>#{$1}</notextile>")

r = RedCloth.new(t, [:filter_html])
p r.to_html
# ========================

=> "<p>I am a <strong>badger</strong> </p>"

But the object tags are still stripped, as the filter_html ignores the
notextlie tags.

Has anyone done similar to this before, or know how I can add tags to
the ignore list?

Thanks in advance.
--
Posted via http://www.ruby-....

2 Answers

dougal.s

12/3/2007 8:39:00 PM

0

Just noticed the Gsub is wrong, it should be:

t = t.gsub( /(<object(.|\n)+?<\/object>)/ ,
"<notextile>\\1</notextile>")


Still not problem solved though.
--
Posted via http://www.ruby-....

Matt Todd

12/4/2007 3:01:00 AM

0

You could use that regexp to pull out the object/embed tags into a
temporary variable, put in a temporary key word, then replace the key
word with the object/embed data after generating the RedCloth HTML.

May not be exactly what you want, but it'll work.