That script can’t work in Nicola’s case because with the exceptions of two
notes, none of the highlight notes in his document have any selection and thus
they don’t know what they have selected. They are only characterised by their
bounds, which can not be used to grab the text. If they had a selection, the
conversion would already yield the expected result.
On 4 Jun, 2014, at 23:12, Glenn Hoetker <[email protected]> wrote:
> In response to Nicola's query about exporting highlights, here are some
> pieces of a script I have used that might provide some useful leads. The
> most useful part is probably in the middle. I would help to know that my
> notes can come in one of two forms:
>
>
> -----------
> SOME CATCHY TITLE
>
> The highlighted text as inserted by Skim.
>
> # Tag 1, Tag 2
>
> -----------
>
> -----------
> SOME CATCHY TITLE
>
>
> # Tag 1, Tag 2
>
> -----------
>
>
> I hope this is somewhat useful as a starting point.
>
> G.
>
>
> set updatePdfTagsScript to POSIX file
> ("/Users/me/Library/Scripts/Applications/Skim/Update PDF tags.scpt") as alias
>
> use Skim : application "Skim"
> use scripting additions
> use zp : script "Zero Pad" -- Saved in my scripting Libraries folder. Just
> turns "9" into "09", which allows more consistent sorting.
>
> set thisDoc to Skim's front document
> set fileName to name of thisDoc
> using terms from scripting additions
> set noteName to (change ".pdf" into "" in fileName)
> end using terms from
>
>
> tell application "Skim"
> set allHighlightNotes to every note of thisDoc where its type is highlight
> note
> end tell
>
> repeat with theNote in allHighlightNotes
> set theNoteText to (get text of theNote)
>
> set thePage to zp's zeroPad(index of page of theNote, 2)
>
> set thisNotesName to noteName & "-" & thePage & " "
>
>
> --Catch case were there is no headline (relies on their being a blank line
> after the headline)
> (*******The next two lines are probably the most useful. Skim highlights
> "know" what they've selected*******)
> (*******and the slightly convoluted "get text for" can grab the corresponding
> text. *******)
> set noteSelection to selection of theNote
> set selectionText to (get text for noteSelection) as text
> if the second paragraph of theNoteText is not "" then
> set theHeadline to ""
> set quoteStart to 1
> else
> set theHeadline to first paragraph of theNoteText
> set quoteStart to 2
> end if
>
> if last paragraph of theNoteText contains "#" then
> set quoteEnd to -2
> set theTags to change "# " into "" in the last paragraph of theNoteText
> else
> set quoteEnd to -1
> set theTags to ""
> end if
>
>
> set theQuote to (paragraphs quoteStart through quoteEnd of theNoteText)
> set theQuote to (change "- " into "" in theQuote)
> set theQuote to (change "-\n" into "" in theQuote)
> set theQuote to (change "\n" into " " in theQuote)
>
>
> set theContents to "**" & theHeadline & "**" & return & return & theQuote &
> return & return & "Tags: " & theTags & return & return & "**[" & fileName &
> ", page " & thePage & "]" & "(skimmer://" & fileName & "#page=" & thePage &
> ")**"
> log theContents
> set theFile to (path to home folder as text) & "Dropbox:PDF_storage:" &
> thisNotesName & space & theHeadline & ".md"
> set theOutput to open for access theFile with write permission
> write theContents to theOutput as utf8
> close access theOutput
> do shell script "/usr/local/bin/tag --add='" & theTags & "' " & quoted form
> of the POSIX path of theFile
> end repeat
>
> tell me to run script updatePdfTagsScript
> display notification ("Skim export done")
>
>
>
>
>
> Glenn Hoetker
> Arizona State University | W. P. Carey School of Business
> Professor & Dean's Council Distinguished Scholar
> Affiliate Professor Sandra Day O'Conner College of Law
> Senior Sustainability Scholar Julie Ann Wrigley Global Institute of
> Sustainability
> Faculty Fellow Center for Science, Law & Innovation
> [email protected] | http://hoetker.faculty.asu.edu | 480-965-4566
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech_______________________________________________
> Skim-app-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/skim-app-users
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Skim-app-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-users