AppleScript to Export Notes in OPML
Re: AppleScript to Export Notes in OPML
Jon,
Thanks.
Aside from that digital ball and chain called e-mail, my main tools are Bookends, Scrivener and a genealogy program called Evidentia. All are written by individual entrepreneurs with constant connections with their users. A strong powerful testament to the value of listening to customers, engaging and helping solve issues, and commitment to their product. Again, thank you!
Thanks.
Aside from that digital ball and chain called e-mail, my main tools are Bookends, Scrivener and a genealogy program called Evidentia. All are written by individual entrepreneurs with constant connections with their users. A strong powerful testament to the value of listening to customers, engaging and helping solve issues, and commitment to their product. Again, thank you!
Cheers,
Dave
Dave
Re: AppleScript to Export Notes in OPML
dave83 wrote:No, I use the Bookends keywords. They are embedded in within the notes and preceded with the percent sign (%).
Hm, my BE keywords are not included in the OPML output, and I can't see how they are processed? Do you manually add them to your notes or how does the OPML script do this?
No, the URL is not linked. I also tried using html <a/> just on the off-chance but no luck either, and using CDATA to encode the html links, also no luck. We will need Keith to modify the OPML import.dave83 wrote:Thanks for the improvements. When you added the URI, does Scrivener recognize it; thus allowing you to link to the reference?
Anyway, you can easily convert them to hyperlinks in Scrivener, just type a space after the URL. Here are my changes to your code:
https://gist.github.com/iandol/4266b62e ... ed4cbd7211
See line 214+. I've added DOI, PMID, URL and BibTeX key, and do add the bookends:// link too.
-
- Posts: 64
- Joined: Thu Jul 05, 2007 1:07 pm
Re: AppleScript to Export Notes in OPML
I prefer to use PMID for citations to allow for collaboration with colleagues that use other Bookends libraries.
I can't figure out where, in the script, to replace BE's unique ID with user18; would appreciate guidance. Thanks!
I can't figure out where, in the script, to replace BE's unique ID with user18; would appreciate guidance. Thanks!
-
- Posts: 64
- Joined: Thu Jul 05, 2007 1:07 pm
Re: AppleScript to Export Notes in OPML
iandol: Thanks for posting this. The OPML file I generate with your code cannot be read by Scrivener, Tinderbox, or OmniOutliner. I tried debugging but failed. Thanks.
Re: AppleScript to Export Notes in OPML
Dear Asaf,
Yes, it is possible that the DOI or URL contains unescaped characters that are invalid for OPML files. I've not had any problems so far. In other languages it is easy to fix, but applescript is generally terrible and has few native functions to help in these sorts of tasks. I tried using CDATA (which should stop any XML parsing) but Scrivener's parser can't handle it.
Can you please send me an example OPML file that fails? I can work out if the problem really is the unescaped characters.
Where exactly do you want the PMID? We can add it to the title or within the main text, or only in the note like the temporary citation? I've put the BibTeX user key in the main text as that is most useful to my workflow.
Yes, it is possible that the DOI or URL contains unescaped characters that are invalid for OPML files. I've not had any problems so far. In other languages it is easy to fix, but applescript is generally terrible and has few native functions to help in these sorts of tasks. I tried using CDATA (which should stop any XML parsing) but Scrivener's parser can't handle it.
Can you please send me an example OPML file that fails? I can work out if the problem really is the unescaped characters.
Where exactly do you want the PMID? We can add it to the title or within the main text, or only in the note like the temporary citation? I've put the BibTeX user key in the main text as that is most useful to my workflow.
-
- Posts: 64
- Joined: Thu Jul 05, 2007 1:07 pm
Re: AppleScript to Export Notes in OPML
Thanks for helping with this. I'm attaching a sample output file.
I would like the PMID to appear in the citation key (instead of the unique id), if possible.
Thanks again!
I would like the PMID to appear in the citation key (instead of the unique id), if possible.
Thanks again!
- Attachments
-
- BE-to-OPML.opml.zip
- (1.8 KiB) Downloaded 4928 times
Re: AppleScript to Export Notes in OPML
Yes, as I suspected it was the URLs (although it does load in my Scrivener). Anyway I've added proper URL encoding and I've used xmllint tool to verify the XML is now compliant.
I've also added some user options at the top:
This will show temporary citations in the main text, and use the PMID instead of uniqueID. Set to false,false,false should be Dave's preference, true,true,false to yours, and true,false,true is my preference
See the Code / Download
I've also put the "metadata" below the abstract:
I've also added some user options at the top:
Code: Select all
--User Options---------------------------------------------------------------------
set showCitation to true -- show temp citation in main text (it will always be shown in the child notes)?
set citationPMID to true -- replace the uniqueID with PMID in the temp citation if present
set useBibTeXKey to false -- use BiBteX formatting for temp citation
![Cool 8)](./images/smilies/icon_cool.gif)
See the Code / Download
I've also put the "metadata" below the abstract:
-
- Posts: 64
- Joined: Thu Jul 05, 2007 1:07 pm
Re: AppleScript to Export Notes in OPML
This is incredibly useful; thank you so much!
Re: AppleScript to Export Notes in OPML
Agreed, many thanks to Dave who took the bull by the horns to tackle this. Trying to build scripts with Applescript always gives me headaches, so I can't imagine how much effort Dave put into this!!!
There is a thread on the forums showing how to use Javascript instead of Applescript, but I haven't tried it yet: viewtopic.php?f=2&t=4017&p=18356 — seems like this would make these kinds of scripts much easier — most importantly that you can DEBUG using Safari's tool!
There is a thread on the forums showing how to use Javascript instead of Applescript, but I haven't tried it yet: viewtopic.php?f=2&t=4017&p=18356 — seems like this would make these kinds of scripts much easier — most importantly that you can DEBUG using Safari's tool!
Re: AppleScript to Export Notes in OPML
Thanks for the updates. This is finally a great tool. I appreciate the comments, but more imporatantly the open collaboration.
Cheers,
Dave
Dave
Re: AppleScript to Export Notes in OPML
One thing I didn't understand but left as is, is <iimg> a typo or deliberate:
I don't have any images in my notes so don't know what it is supposed to be...
EDIT, I also updated script to V1.14 to fix some formatting errors for the note stream contents (page numbers cannot use @ in BibTeX citations etc., if you click on revisions on the gist page you can see the differences), and not escape all the forward slashes in URLs, looks a bit nicer in Scrivener...
Code: Select all
--set image content tags
set open_image_tag to "<iimg>"
set end_image_tag to "</iimg>"
EDIT, I also updated script to V1.14 to fix some formatting errors for the note stream contents (page numbers cannot use @ in BibTeX citations etc., if you click on revisions on the gist page you can see the differences), and not escape all the forward slashes in URLs, looks a bit nicer in Scrivener...
Re: AppleScript to Export Notes in OPML
I'll get on gisthub tomorrow to get the revised code. I can't thank you enough for making this a better tool.
As for the images, the tags <iimg> and </iimg> encapsulate the image. I discovered this using the iHex application on the resulting .opml file after I tested the script with an image I captured using Bookends. The OPML structure does not resolve images, so I just strip them out and insert a note that the image was stripped. It's a trade-off to use OPML, so I just know that if I really need the image, then I will have to manually cut/paste it over to Scrivener.
As for the images, the tags <iimg> and </iimg> encapsulate the image. I discovered this using the iHex application on the resulting .opml file after I tested the script with an image I captured using Bookends. The OPML structure does not resolve images, so I just strip them out and insert a note that the image was stripped. It's a trade-off to use OPML, so I just know that if I really need the image, then I will have to manually cut/paste it over to Scrivener.
Cheers,
Dave
Dave
Re: AppleScript to Export Notes in OPML
I can't get images in the note stream at all, and I thought the note stream was text only? Also, HTML markup should be <img>, not <iimg> which was why I am a bit confused about this.
Re: AppleScript to Export Notes in OPML
Right, no images in Notes. Is suspect this is a leftover from the corresponding script that was used with Sente, which can contain images in Notes.
Jon
Sonny Software
Jon
Sonny Software
Re: AppleScript to Export Notes in OPML
I had images from when I imported from Sente. I added this feature to account for others who might also transition from Sente.
Cheers,
Dave
Dave