[WISH] Improved OPML Import

A really nice recent script takes Bookends references and makes an OPML file that can be imported into Scrivener. OPML is a pretty open format, with few hard and fast rules, and at the moment Scrivener supports only text and _note attributes. But it would be great if we could get slightly better custom support for URL links. This could be composed of two levels:

  1. Support import of an optional url attribute () if present in the OPML — this gets converted into an RTF link at the top of the content. For example, Bookends supports a bookends:// backlink so you can go straight back to the references in the Bookends database.
  2. Auto-linkify URLs on Import. Currently the URLs are plain text on import. You can manually auto-linkify them be pressing a space after each URI, and if this could be automated on import it would be great!

This would improve the interoperability of working with OPML data from other apps like Bookends.

Another lovely additional idea would be to support a keywords attribute, that way we could get our Bookends/other-research-app keywords into Scrivener keywords on import — would keyword the document with 3 keywords on import.


[1] As my hammer is markdown, one possible solution would be markdown -> RTF conversion of the _note content, this would auto-convert markdown links and other formatting from the plain text to rich text. But this could conflict with others who just want plain text.

I’m going to bump this now that we are well and truly “post-Scrivener 3”! 8)

AmberV: I was wondering whether we could encode the links as fragments of RTF, which may be a workaround; although I still think small tweaks to the OPML importer would be beneficial to Scrivener…

Keywords would I think require official support, but would be really really nice!

OPML is a very basic format that different software adds different extensions to. Scrivener already supports the basics (the “official” spec) and there are no plans to add support beyond that at the moment, sorry!

All the best,
Keith

Keith, do you know if there is any trick to try to import plain text as RTF links:

{\field{\*\fldinst{HYPERLINK "https://github.com/"}}{\fldrslt a link}}\

I can encode " as " for the XML, but Scrivener escapes \ { } so the RTF code ends up as plain text. I was hoping AmberV’s suggested trick for importing footnotes (viewtopic.php?f=2&t=51808) may apply to hyperlinks…


a baby kitten is crying because she cannot import keywords via OPML, she thinks it would make a wonderful addition to Scrivener interoperability, but ultimately she respects you must have your reasons… :laughing:

Ioa’s trick for importing footnotes only works because it’s not using RTF codes but some custom tags Scrivener uses in the rich text itself, which gets converted internally after the RTF has loaded. You cannot type RTF tags into Scrivener’s editor and have them turned into RTF.

However, after reconsidering, for 3.0.3 I have added automatic link detection to OPML import provided the “Automatically detect web addresses” option is turned on in the Preferences, which helps you there. So it’s just the backlink URL (suggestion (1)) that isn’t being implemented.

All the best,
Keith

OK, that is great :smiley: :smiley: :smiley: , I can simply place the backlink at the top of the content myself, as long as the URL gets linkified all is good. Will the URL scanner only encode http[s]:// or should it work with custom urls like bookends://sonnysoftware.com/myID ? Would enclosing links in help?

EDIT: I’ve attached a sample OPML file if it would help. URL / DOI / Backlink in the _note text.

BE-Selection.opml.zip (1.73 KB)

Bookends links as well. The code simply uses Apple’s NSDataDetector, so link detection is handled by Apple code.

All the best,
Keith