Skip to content

Instantly share code, notes, and snippets.

@asiamoth
Created October 29, 2011 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asiamoth/1324690 to your computer and use it in GitHub Desktop.
Save asiamoth/1324690 to your computer and use it in GitHub Desktop.
YouTube の新「埋め込みコード」を XHTML と HTML5 で Valid にする!
#!/usr/bin/perl
use strict;
use warnings;
use Tkx qw( clipboard );
my $text = Tkx::clipboard('get');
# http://d.hatena.ne.jp/unau/20100121/1264073552
my $DOUBLE_QUOTED = qr{ \" ( [^ \" ]* ) \" }msx;
$text =~ s{ <iframe \s+
width = $DOUBLE_QUOTED \s+
height= $DOUBLE_QUOTED \s+
src = $DOUBLE_QUOTED \s+ [^>]+ >
</iframe>
}
{<object width="$1" height="$2" data="$3?wmode=transparent" type="text/html">
\n</object>\n}msxgo;
Tkx::clipboard( 'append', $text );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment