AppleScript to Export Notes in OPML

Users asking other users for AppleScripts that work with Bookends.
aroddick
Posts: 50
Joined: Tue Aug 29, 2017 1:27 pm

Re: AppleScript to Export Notes in OPML

Post by aroddick »

(Hello fellow archaeologist!)
mjvalente
Posts: 35
Joined: Tue Dec 15, 2015 8:13 am

Re: AppleScript to Export Notes in OPML

Post by mjvalente »

(Hello there as well!)
"If we knew what it was we were doing, it would not be called research, would it?"
tappazee
Posts: 14
Joined: Mon Mar 22, 2021 8:00 am

Re: AppleScript to Export Notes in OPML

Post by tappazee »

iandol wrote: Mon May 13, 2019 6:33 pm Updated the gist, although I am likely to keep the bookends-tool source always up-to-date and it is the same script:

https://raw.githubusercontent.com/iando ... pplescript
This script is excellent! Is there a way to preserve any formatting (bold/italics/underline) given to notes from bookends? I use bold/italics to distinguish quotations from my commentary on them. Thanks
iandol
Posts: 465
Joined: Fri Jan 25, 2008 2:31 pm

Re: AppleScript to Export Notes in OPML

Post by iandol »

The applescript interface returns text without any formatting (this script uses the older event system, but the newer dictionary also returns text). I suppose there may be a possibility to create a custom format including the note field, and return it as formatted text like HTML, I tested it and bold text in a note does make it to the output...

Code: Select all

tell application "Bookends"
	set myRefs to selected publication items of front library window
	set rtfRefs to format myRefs using "Printout.fmt" as HTML
end tell
but the next question would be the best way to encode it in the OPML, and whether whatever reads the OPML would understand it. I personally don't have time to edit this script.

One other solution would be if Bookends could convert its formatting (which I assume is RTF encoded?), to markdown when accessing individual itemsso at least the formatting would be plain text yet readable to other applications.
tappazee
Posts: 14
Joined: Mon Mar 22, 2021 8:00 am

Re: AppleScript to Export Notes in OPML

Post by tappazee »

Thanks iandol, much appreciated. I have no scripting expertise so I think I'll have to admit defeat there. I'm no going to try to figure out whether there's a way to get paragraph breaks within single bookends notecards as an alternative way to distinguish between quotes and commentary.
tappazee
Posts: 14
Joined: Mon Mar 22, 2021 8:00 am

Re: AppleScript to Export Notes in OPML

Post by tappazee »

iandol wrote: Mon Mar 22, 2021 9:18 pm The applescript interface returns text without any formatting (this script uses the older event system, but the newer dictionary also returns text). I suppose there may be a possibility to create a custom format including the note field, and return it as formatted text like HTML, I tested it and bold text in a note does make it to the output...
I've now found out, courtesy of Jon, how to make multi-paragraph notecards (double returns initiate a new notecard, so separate any returns with a space to keep them within a single notecard). So this provides me with a way to differentiate quotes and my commentary instead of bold/italics.

This leads me to ask if it's possible for your script to enable these within-single-notecard paragraph separations to be reflected in the notes as they appear in scrivener? I just tried it out and they are not currently. Thanks in advance and sorry to pester.
iandol
Posts: 465
Joined: Fri Jan 25, 2008 2:31 pm

Re: AppleScript to Export Notes in OPML

Post by iandol »

As far as I can tell, Notes are already split into separate cards (look at the raw OPML to see), and Scrivener imports them as children of the OPML document:
Screen Shot 2021-03-25 at 14.21.35_SMALL.png
Screen Shot 2021-03-25 at 14.21.35_SMALL.png (38.28 KiB) Viewed 27375 times
At the moment the title is not parsed, this could be added by using markdown headers?
iandol
Posts: 465
Joined: Fri Jan 25, 2008 2:31 pm

Re: AppleScript to Export Notes in OPML

Post by iandol »

Actually, headers are parsed if formatted correctly:

Bookends:
Screen Shot 2021-03-25 at 14.32.11_SMALL.png
Screen Shot 2021-03-25 at 14.32.11_SMALL.png (29.94 KiB) Viewed 27373 times
Scrivener:
Screen Shot 2021-03-25 at 14.32.39_SMALL.png
Screen Shot 2021-03-25 at 14.32.39_SMALL.png (9.91 KiB) Viewed 27373 times
Post Reply