Redcloth ignore YouTube embeds?

  • Thread starter Douglas Shearer
  • Start date
D

Douglas Shearer

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="
"></param><param
name="wmode" value="transparent"></param><embed
src="
"
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.
 
D

Douglas Shearer

Just noticed the Gsub is wrong, it should be:

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


Still not problem solved though.
 
M

Matt Todd

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top