Forked from waltonjones/Skim_notes_to_clipboard.scpt
Last active
February 23, 2022 04:32
-
-
Save jsmm/7113972 to your computer and use it in GitHub Desktop.
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
--Based in http://www.organognosi.com/export-skim-notes-according-to-their-highlight-colors/ | |
--Modified with http://drosophiliac.com/2012/09/an-academic-notetaking-workflow.html | |
--Colors and codes changed. | |
tell application "Skim" | |
set the clipboard to "" | |
set numberOfPages to count pages of document 1 | |
activate | |
set myColorCodes to my chooseColor() | |
display dialog "Do you want to export all the notes or some of them?" buttons {"All", "Some"} default button 1 | |
set answer to button returned of the result | |
if answer is "All" then | |
set firstPage to "1" as number | |
set lastPage to numberOfPages | |
set the clipboard to "# Skim notes #" & return | |
else | |
display dialog "Give the number of the first page." default answer "" | |
set firstPage to text returned of the result as number | |
display dialog "Give the number of the last page" default answer "" | |
set lastPage to text returned of the result as number | |
end if | |
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 ({"Destacado", "Resumen", "Citable/Definición", "Pregunta/Referencia", "Técnica/Método", "Resultado/Interpretación"}) | |
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 (choose from list {"Destacado", "Resumen", "Citable/Definición", "Pregunta/Referencia", "Técnica/Método", "Resultado/Interpretación"} with prompt ("Choose the color of notes for exporting (you can select multiple colors):") default items {"Destacado"} with multiple selections allowed) | |
set colorCodes to {} | |
set noteColor to "" | |
repeat with noteCol in selectedColors | |
set noteColor to noteCol as text | |
if noteColor is "Destacado" then | |
set end of colorCodes to {65535, 65531, 2689, 65535} | |
else if noteColor is "Resumen" then | |
set end of colorCodes to {52428, 65535, 26214, 65535} | |
else if noteColor is "Citable/Definición" then | |
set end of colorCodes to {26214, 65535, 65483, 65535} | |
else if noteColor is "Pregunta/Referencia" then | |
set end of colorCodes to {52428, 52428, 52428, 65535} | |
else if noteColor is "Técnica/Método" then | |
set end of colorCodes to {65260, 52435, 26213, 65535} | |
else if noteColor is "Resultado/Interpretación" then | |
set end of colorCodes to {26214, 65535, 26214, 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