PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Redcloth ignore YouTube embeds?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Redcloth ignore YouTube embeds?

Réponse
 
LinkBack Outils de la discussion
Vieux 03/12/2007, 19h06   #1
Douglas Shearer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Redcloth ignore YouTube embeds?

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&rel=1"></param><param
name="wmode" value="transparent"></param><embed
src="http://www.youtube.com/v/xyujSekNfsg&rel=1"
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-forum.com/.

  Réponse avec citation
Vieux 03/12/2007, 20h38   #2
Douglas Shearer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Redcloth ignore YouTube embeds?

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-forum.com/.

  Réponse avec citation
Vieux 04/12/2007, 03h01   #3
Matt Todd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Redcloth ignore YouTube embeds?

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.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h52.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12347 seconds with 11 queries