It will copy the selected reference in Bookends, switch to Scrivener and paste the unformatted reference to the cursor position. In doing this it will link the Bookends-ID to Bookends and the group "Author Year" to DTPO (I store the DTPO-reference-URL in Bookends in userfield 20).
The unformatted link looks a little bit different than the normal output from Bookends, but Bookends does not seem to have a problem to still identify the correct reference when formatting the bibliography. However, before the final Scan-command can be invoked the document has to be stripped from all hyperlinks. The easiest way to do this seems to be in Microsoft Word (select all and then cmd-6) but I would be eager to hear about other solutions.
My only aesthethic problem with the script is that diacritic letters look awful. Somewhere along the script letters like "ä", "ö", "ø" etc. are changed in something like "ö", despite the fact that the shell script retains the RTF-format. Perhaps anyone knows of an easy way to remedy this?
Cheers,
Nils
Code: Select all
tell application "Bookends"
set theIDString to «event DNtpRUID» "selection"
set theauthor to «event ToySRFLD» theIDString given string:"authors"
set theyear to «event ToySRFLD» theIDString given string:"thedate"
set devonthinkReference to «event ToySRFLD» theIDString given string:"user20"
set authorYear to theauthor & ", " & theyear as string
if devonthinkReference is "" then
set theReference to "{" & authorYear & ", #" & ("<font face=\"times new roman\"><a href=\"" & "bookends://sonnysoftware.com/" & theIDString & "\">" & theIDString & "</a></font>") & "}"
else
set theReference to "{" & ("<font face=\"times new roman\"><a href=\"" & devonthinkReference & "\">" & authorYear & "</a></font>") & ", #" & ("<font face=\"times new roman\"><a href=\"" & "bookends://sonnysoftware.com/" & theIDString & "\">" & theIDString & "</a></font>") & "}"
end if
set RTFtheReference to (do shell script "echo " & quoted form of theReference & " | textutil -stdin -stdout -format html -convert rtf | pbcopy -Prefer rtf")
end tell
tell application "Scrivener"
activate
end tell
tell application "System Events"
key code 9 using {command down} -- v key
end tell