# Redcloth ignore YouTube embeds?

**URL:** <https://www.ruby-forum.com/t/redcloth-ignore-youtube-embeds/122003>\
**Category:** Ruby\
**Created:** [December 3, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/redcloth-ignore-youtube-embeds/122003 "2007-12-03T20:06:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [December 3, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/redcloth-ignore-youtube-embeds/122003/1 "2007-12-03T20:06:24Z")

</div>

Hi folks.

I’m trying to process blog posts using RedCloth, stripping any html  
entered by the user, but leaving , and tags  
untouched.

So far I’ve tried…

# ========================

require ‘rubygems’  
require ‘redcloth’

t = 'I am a _badger_ ’

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

r = RedCloth.new(t, [:filter\_html])  
p r.to\_html

# ========================

=\> "

I am a **badger**

"

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.

---

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [December 3, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/redcloth-ignore-youtube-embeds/122003/2 "2007-12-03T21:38:47Z")

</div>

Just noticed the Gsub is wrong, it should be:

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

Still not problem solved though.

---

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [December 4, 2007, 4:01am UTC](https://www.ruby-forum.com/t/redcloth-ignore-youtube-embeds/122003/3 "2007-12-04T04:01:50Z")

</div>

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.
