This Space for Rent

xhtml wagon repair

Problem: Youtube video embed code uses <embed>, which has been declared obsolete in xhtml (along with <font> and <center>, which have been depreciated in favo(u)r of css.) This means that my attempt to xhtmlify tsfr founders on the rocks of the imported-directly-from-google embed code.

There are plenty of web pages suggesting ways to xhtmlify youtube embeds, but, alas, none of them provide handy scripts. Sure, some of them provide web tools to do the xhtmlification (and then there’s the alistapart method, which is just weird – I’m sure it’s lovely to force the browser to update the flash plugin to the latestandgreatest, but I don’t care about that) but none of them provide a script that I can use from a command line.


#! /bin/sh

# slurp up the original script, break it up into lines

tr '<>' '@\n' | (
    while read tag rest; do
        case "$tag" in
        @param) eval "$rest"
                [ "$name" = "movie" ] && MOVIE="$value"
        @object)eval "$rest"

    if [ "$MOVIE" -a "$height" -a "$width" ]; then
        cat << FOO
<div style="border:1px solid black; background:888;
            width:${width}px; height:${height}px;
            text-align:center; margin:0 auto;">
    <object type="application/x-shockwave-flash"
        <param name="movie" value="$MOVIE" />

I’m not exactly sure whether this will work with IE at all (I don’t run windows, and the only time I have a windows machine available is when I’m working, and those machines are universally locked up inside netnanny firewalls that prohibit access to youtube) but it does seem to work well with the mouse-by-committee that is Mozilla Firefox.

At least so far. And the script gives me a good starting point for the conversion process.


Hello David. I read that you lost all copies of Mastodon in a disk crash. Well, years ago I downloaded the INST0066 or 67, I can’t remember. I have it somewhere in my backups. If I find it, I can burn it or upload somewhere for you.



Jose Molina Fri Sep 3 19:23:59 2010

While arguably much less fun, I’d be looking into using tidy; it outputs XHTML and somebody else has got to deal with the various browser issues.

Graydon Sat Sep 4 08:36:52 2010

Tidy doesn’t do the rewriting, though; for me it simply strips off the </param>’s and the </embed>, as well as helpfully informing me that <embed> is not approved by the w3c.

David Parsons Sat Sep 4 19:25:42 2010

Well, bother, that’s unhelpful.

There might be something in tidy’s host of parameters that does the rewrite, though if one has XHTML one has now got actual XML and can do the rewriting with XSLT, a course of action to which I am naturally inclined.

Your inclination to learn a strict functional tree-transformation language may be rather slight, though.

Graydon Sun Sep 5 06:35:28 2010

In the general case, I’d just write an xml walker that picks the whole <object> apart, then go in and pull out the parameters that I need (I have part of an xml walker written so I can have the next version of magicfilter read the foomatic database instead of my little handmade database. It doesn’t actually work yet, but that’s because I’ve only spent about 15 minutes working on it) but the youtube embed code is only a single case which, I suspect, isn’t likely to change because all the cool kids will probably want to do html5 (in time for the proposed 2022 rollout of the actual standard – html5 is definitely a mouse by committee) and the <embed> inside <object> is valid in that namespace.

Easier to pick apart one known format with a shell script, like g-d (and bourne) themselves intended.

David Parsons Sun Sep 5 08:25:19 2010

Comments are closed