-
-
Save NHDaly/7669596 to your computer and use it in GitHub Desktop.
Enable textual diff of iWork '09 Pages documents.
(Forked and updated from a gist that works for older Pages documents)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.pages diff=iworkpages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# output folder for unzipping the .pages file (really long name to avoid name conflicts) | |
FOLDER_NAME=$1.unzipped.for.git.diff.text.comparison | |
# exit if a file already exists with $FOLDER_NAME so we don't delete it later.. (but this is really unlikely) | |
mkdir $FOLDER_NAME || { echo 'mkdir failed.. $FOLDER_NAME already exists' ; exit 1; } | |
# unzip the .pages file into the folder | |
unzip -qq -o $1 -d $FOLDER_NAME | |
# convert to text and print the text to stdout | |
xsltproc Pages.xsl $FOLDER_NAME/index.xml | |
# clean up our work | |
rm -rf $FOLDER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#run this command from your git working directory: | |
echo ' | |
[diff "iworkpages"] | |
textconv = $GIT_DIR/../ConvertPagesToText.sh | |
' >> .git/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sf="http://developer.apple.com/namespaces/sf"> | |
<xsl:template match="sf:p"> | |
<xsl:apply-templates/> | |
<xsl:text> | |
</xsl:text> | |
</xsl:template> | |
<xsl:template match="sf:lnbr"> | |
<xsl:text> | |
</xsl:text> | |
</xsl:template> | |
<xsl:template> | |
<xsl:value-of select="text()"/> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Including these files in your git repo will allow you to perform
git diff
on *.pages files!Apple had changed the format of the .pages files since @bycpx wrote their Gist.