Create a gist now

Instantly share code, notes, and snippets.

--==============================
-- Send Keynote Text to Desktop Markdown File
-- Writted By: Richard Dooling https://github.com/RichardDooling/
-- Based on
-- Send Keynote Presenter Notes to Evernote
-- Version 1.0.1
-- Written By: Ben Waldie <ben@automatedworkflows.com>
-- http://www.automatedworkflows.com
-- Version 1.0.0 - Initial release
-- Version 1.0.1 - Updated for Keynote 6.2 compatibility
--==============================
-- Make sure a presentation is opened in Keynote. If not, notify the user and stop.
tell application "Keynote"
if (front document exists) = false then
display alert "Unable to proceed." message "Please open a presentation in Keynote."
return
end if
set extractBody to button returned of (display alert "Would you like to extract slide content too?" buttons {"Yes", "No"}) = "Yes"
-- Target the front presentation.
tell front document
-- Get the name of the presentation.
set thePresentationName to name
-- Retrieve the titles of all slides.
set theTitles to object text of default title item of every slide
-- If specified, retrieve the body text of all slides
if extractBody = true then
set theBodyText to object text of default body item of every slide
end if
-- Retrieve the presenter notes for all slides.
set theNotes to presenter notes of every slide
end tell
end tell
-- Prepare the notes as Markdown.
set theFormattedNotes to "# " & "Keynote Presentation: " & thePresentationName & return & return
repeat with a from 1 to length of theTitles
set theFormattedNotes to theFormattedNotes & "## Slide " & a & return & return
set theFormattedNotes to theFormattedNotes & "### Title: " & item a of theTitles & return & return
if extractBody = true then
set theFormattedNotes to theFormattedNotes & "#### Body " & return & return & item a of theBodyText & return & return
end if
set theFormattedNotes to theFormattedNotes & "#### Presenter Notes: " & return & return & item a of theNotes & return & return
end repeat
set theFormattedNotes to theFormattedNotes & return
-- Replace any returns with line breaks.
set AppleScript's text item delimiters to {return, ASCII character 10}
set theFormattedNotes to text items of theFormattedNotes
set AppleScript's text item delimiters to {return, ASCII character 10}
set theFormattedNotes to theFormattedNotes as string
set AppleScript's text item delimiters to ""
tell application "TextEdit"
activate
-- Create Desktop Markdown .md file named after Presentation
set theDesktopPath to the path to the desktop folder as text
make new document with properties {text:theFormattedNotes}
save document 1 in file (theDesktopPath & thePresentationName & ".md")
close document 1
end tell
@RichardDooling
Owner

This script takes a Keynote 6.2 Presentation that is open in Keynote, grabs the text from the Title, Body, and Presenter Notes and sends the text in outline format to a Desktop Markdown file named after the Keynote file. Keynote.key will be saved as Keynote.key.md

@rsgranne

I love this. Love it! This is exactly what I need, with one small exception. Could you please change it so that if a slide does not have any Presenter Notes, it isn’t added to the Markdown file? Thank you again!

@berndjj
berndjj commented Jan 13, 2016

Thanks for your work! Is there a chance we will see an update for this to work with Keynote 6.6.1?

cheers, Bernd

@kevyn7
kevyn7 commented Apr 7, 2016

I'm a major rookie...I tried to run this however, I am getting a permissions error. I'm assuming that this is referring to the file I'm trying to convert, not something within the script file. Is that correct?

@Wolfr
Wolfr commented May 19, 2016

I am on the lookout to find a way to extract the images together with the text from my Keynote presentations in some kind of format that I can then turn into HTML. In the end I want to arrive at the kind of layout achieved here:

screen shot 2016-05-19 at 15 16 38

You can tweak the PDF output from Keynote to look like this:

screen shot 2016-05-19 at 15 06 25

This gives me a PDF and it's the easiest way to share the content. But I would like to easily make websites from my presentations without endlessly going back and forth copy-pasting.

Anybody with any ideas?

@spkane
spkane commented May 22, 2016

Brilliant. Saved me a lot of cut and pasting. Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment