Forked from RichardDooling/2014_11_02_Send_Keynote_Text_To_Markdown_File.applescript
Last active
January 4, 2023 23:00
-
-
Save neilernst/829039bc1263e85d71ab2c744df72ee9 to your computer and use it in GitHub Desktop.
Extract Keynote text and reformat as Markdown Marp file
This file contains hidden or 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
--============================== | |
-- Send Keynote Text to Desktop Markdown File | |
-- Formats the markdown as Marp syntax (a MarkDown presentation format) https://marp.app | |
-- Based on | |
-- Writted By: Richard Dooling https://github.com/RichardDooling/ | |
-- Based on | |
-- Send Keynote Presenter Notes to Evernote | |
-- Version 1.0.1 | |
-- Written By: Ben Waldie <[email protected]> | |
-- 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" | |
set extractNotes to button returned of (display alert "Would you like to extract presenter notes 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 | |
if extractNotes = true then | |
-- Retrieve the presenter notes for all slides. | |
set theNotes to presenter notes of every slide | |
end if | |
end tell | |
end tell | |
-- Prepare the notes as Marp Markdown. See https://marpit.marp.app/markdown | |
set theFormattedNotes to "---" & return & "title: " & thePresentationName & return & "marp: true" & return & "---" & return | |
repeat with a from 1 to length of theTitles | |
-- set theFormattedNotes to theFormattedNotes & "## Slide " & a & return & return | |
set theFormattedNotes to theFormattedNotes & return & "----" & return & "# " & item a of theTitles & return & return | |
--if extractBody = true then | |
set theFormattedNotes to theFormattedNotes & 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment