update: They fixed the bug in 9.0.1, so we don't need this script any more, but I'll leave it as a starting point for how to crack open the contents of a Keynote document.
I dutifully upgraded to iWork '09 which contains an upgraded version of Keynote. Much to my dismay, there's a critical bug in this first release: when the outline mode left column is resized before saving the keynote document, upon restoration the left column is not resized properly, often hiding the scroll handle and scrollbars!

But, I recalled that a keynote document is nothing more than a zip archive around a bunch of files, one of which is a giant XML file containing most of the base content. After a half hour of experimenting, I figured out that the difference between a broken save and a good save was the presence of a single XML element. So I wrote a quick script to remove the XML element, and rebuild the zip archive:

#!/usr/bin/env perl use strict; $|++; use Cwd qw(abs_path); use File::Temp qw(tempdir); @ARGV = map abs_path($_), @ARGV or die "$0: please give keynote zip names on command line"; while (@ARGV) { my $key = shift; -e $key or die "$key not found"; my $tempdir = tempdir( CLEANUP => 1 ); chdir $tempdir or die "cannot cd $tempdir: $!"; system "unzip", $key; my $flag = 0; { local @ARGV = "index.apxl"; local $^I = "~"; while (<>) { s#(<key:BGShowUIStateOutlineWidth>.*?</key:BGShowUIStateOutlineW +idth>)## and $flag = 1 and warn "removed $1"; print; } } (warn "no changes made, skipping\n"), next unless $flag; my $old_key = $key; $old_key =~ s/\.key$/ OLD.key/ or $old_key .= "-OLD"; (warn "unsafe to mv $key $old_key, skipping\n"), next if -e $old_key +; rename $key, $old_key or die "cannot mv $key $old_key: $!"; system "zip", "-r", $key, '.'; }
Now, I can get on with my Keynote development, just remembering to run this script once to start a new editing session. I just pop open a local Terminal window, type "fix-keynote-outline" followed by a space, then drag the keynote file into the Terminal window, which automatically pastes the full unix path. I press return, and within a few seconds, a new keynote file appears with the outline mode restored.

Replies are listed 'Best First'.
Re: Work around a bug in Apple Keynote '09
by graff (Chancellor) on Mar 15, 2009 at 23:25 UTC
    Whoa! merlyn is editing XML without using an XML parser module?? I'm shocked! SHOCKED! ;^)

    (I'd be tempted to put the "s" modifier at the end of the s#....## -- who knows when you might run into a line-feed inside that tag.)

    I don't use iWork, but I'm truly grateful to hear about file drag-and-drop in the Terminal window -- I wasn't aware that was possible.

Re: Work around a bug in Apple Keynote '09
by Anonymous Monk on Mar 18, 2009 at 05:46 UTC
    what does this mean? local $^I = "~";
Re: Work around a bug in Apple Keynote '09
by pmonk4ever (Friar) on May 14, 2009 at 15:56 UTC
    Randal,

    Thank you for coming by and keeping the rest of us humble...I certainly wouldn't have figured that one out.

    I would have left the package unused until Apple fixed the problem.

    "I'm not worthy!"

    ki6jux

    "No trees were harmed in the creation of this node. However, a rather large number of electrons were somewhat inconvenienced."