Package: keynote-parser
keynote-parserkeynote-parseris a Python module for unpacking and re-packingApple Keynote.keyfiles. It supports Keynote
files generated by Keynote version 12.2.1 (current as of December 2022).Keynote uses a proprietary, compressed binary format to store its presentations.
This format is comprised of a zip file containing images and videos, as well asSnappy-compressedProtobuf.iwafiles containing
metadata, text, and all other definitions used in the presentation.keynote-parserunpacks these component files into.yamlfiles in a directory,
making them editable by text editors and/or scripts, then allows re-packing of these
files into a working Keynote archive.What could you use this for? Well, I use it to allow versioning of Keynote files in Git,
which makes diffs more understandable (rather than binary), as well as modifying text
in Keynote files in response to external scripts.
(e.g.: figures that update from databases before giving a presentation)Installationpip3installkeynote-parserUsage# Unpack MyPresentation.key into ./MyPresentation/keynote-parserunpackMyPresentation.key# Re-pack ./MyPresentation/ into MyPresentation.out.keykeynote-parserpack./MyPresentation/# List the files within a Keynote archivekeynote-parserlsMyPresentation.key# Dump a particular .iwa file into its yaml representation on stdoutkeynote-parsercatMyPresentation.key/Index/Slide-00001.iwa# Replace text within a Keynote file in-placekeynote-parserreplaceMyPresentation.key--find"hello world"--replace"hello dolly"Formatskeynote-parsersupports reading a list of replacements from a JSON file passed in
as--replacements. This file must have the form:{"replacements":[{"find":"regexp to search for","replace":"string to replace with"},...]}This argument can be passed tokeynote-parser replaceto replace text in a Keynote
file in-place. It can also be passed tokeynote-parser packto pack a directory
into a Keynote file, replacing text along the way.Replacing ImagesThereplacementsjson format can also be used to replace images in a Keynote file.
To do so:Use thekeynote-parser lscommand to determine the name of the image to replace.Set thefindpattern to the image's name, with the-\d\d\dsuffix removed.Set thereplacefield to the local path to the replacement image.keynote-parserwill automatically rescale the replacement image to fit all of the
sizes of the target image.CompatibilityNote that between Keynote 10.2 and Keynote 11.2, a number of Protobuf definitions
used by Keynote have changed names.keynote-parserdoes not yet support
backwards compatibility: it can only read.keyfiles as the
currently-supported Keynote version would, and will write.yamloutput with
keys that match the current names of the keys. This means that.yamlfiles
generated with older versions ofkeynote-parsermay not be readable by with
v1.11.2.1 or higher ofkeynote-parser.Until this issue is fixed (ifit's ever fixed) - to properly read.yamlfiles
created by older versions ofkeynote-parser:use an older version ofkeynote-parserto read the filewrite a.key(or.iwa) file with that older versionupgradekeynote-parserread that resulting.iwafile in the newer version ofkeynote-parserUpdatesAskeynote-parserincludes Protobuf definitions extracted from a copy of Keynote,
new versions of Keynote will inevitably create.keyfiles that cannot be read bykeynote-parser.
As new versions of Keynote are released, updates tokeynote-parsercan be made automatically
by running the following on a macOS machine with Keynote installed:# protobuf>=3.20.0rc1 must be installed, with the C++ runtime# on Intel, this can be done with "pip install 'protobuf>=3.20.0rc1'"# on Apple Silicon, this may require a manual build from sourcecddumper
makeclean
makeTroubleshootingUnable to complete installation due to snappy-c.h not found.snappy/snappymodule.cc:31:10:fatalerror:'snappy-c.h'filenotfoundThis means you're missing the Snappy libraries. Install Snappy via whatever method your OS supports. e.g.brew install snappy,sudo apt-get install libsnappy-dev, etc.Creditskeynote-parserwas built byPeter Sobotbut heavily based onprior
workbySean Patrick O'Brien.
A copy of O'Brien's format documentation is included in thedocsfolder for posterity.LicenseAll code in this repository is licensed under the MIT License.Copyright 2019-2022 Peter Sobot

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.