Skip to content

Instantly share code, notes, and snippets.

@waltonjones
Last active December 20, 2015 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save waltonjones/6068013 to your computer and use it in GitHub Desktop.
Save waltonjones/6068013 to your computer and use it in GitHub Desktop.
Send color-coded Skim.app PDF notes to the clipboard with custom page urls. (See http://drosophiliac.com/2012/09/an-academic-notetaking-workflow.html)
tell application "Skim"
set the clipboard to ""
set numberOfPages to count pages of document 1
activate
set myColorCodes to my chooseColor()
set firstPage to "1" as number
set lastPage to numberOfPages
set the clipboard to "# Notes" & return & return
repeat with currentPage from firstPage to lastPage
set pageNotes to notes of page currentPage of document 1
exportPageNotes(pageNotes, currentPage, myColorCodes) of me
end repeat
end tell
on exportPageNotes(listOfNotes, pageForProcessing, myColorCodes)
tell application "Skim"
set currentPDFpage to pageForProcessing
repeat with coloredNote in listOfNotes
repeat with i from 1 to the count of myColorCodes
if color of coloredNote is item i of myColorCodes then
set categoryColors to ({"Summary", "Technique", "Result", "Reference", "Hypothesis", "Question or connection"})
set noteColor to color of coloredNote as string
if noteColor is item i of myColorCodes as string then
set noteColor to item i of categoryColors
end if
set noteText to get text for coloredNote
set the clipboard to (the clipboard) & "**[" & noteColor & "]" & "(skimmer://" & name of document 1 & "#page=" & pageForProcessing & ")**" & ": " & return & noteText & return & return
end if
end repeat
end repeat
end tell
end exportPageNotes
on chooseColor()
set selectedColors to ({"Summary", "Technique", "Result", "Reference", "Hypothesis", "Question or connection"})
set colorCodes to {}
set noteColor to ""
repeat with noteCol in selectedColors
set noteColor to noteCol as text
if noteColor is "Summary" then
set end of colorCodes to {64634, 900, 1905, 65535}
else if noteColor is "Technique" then
set end of colorCodes to {64907, 32785, 2154, 65535}
else if noteColor is "Result" then
set end of colorCodes to {65535, 65531, 2689, 65535}
else if noteColor is "Reference" then
set end of colorCodes to {8608, 65514, 1753, 65535}
else if noteColor is "Hypothesis" then
set end of colorCodes to {8372, 65519, 65472, 65535}
else if noteColor is "Question or connection" then
set end of colorCodes to {64587, 1044, 65481, 65535}
end if
end repeat
return colorCodes
end chooseColor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment