Extract Anchor and URL from pasted HTML

The aim is definitely misunderstood.:grinning: This isn’t about “defining” a link in rtfd or asking Tinderbox to “pick up the pieces.” It’s a demonstration that making the rftd accessible to external scripts can be useful (at least as read-only, if setting the value of the rtfd turns out to be too problematic).

The aim is to get styled text in and out of Tinderbox via AppleScript without going through the clipboard, either manually (as in the first examples above) or through easily broken “gui” scripting.

This script demonstrates one way to get styled text out (including any “smart” links that happen to be in the rtfd). It’s not too hard. But it would be much easier if the rtfd could be read directly (like reading the value of an attribute) rather than having to resort to XQuery.

Going the other way, getting styled text into Tinderbox, as @Pete has requested above, may be more difficult. My thought was that perhaps a scripter could base64 encode and set the rtfd to that, but @eastgate would have to comment on that.

BTW, I do not believe it is entirely correct to say that native Tinderbox links are “defined in the plain text_layer.” In the xml of my current version (8.9.2) I see them defined in <links>, with the position of the anchors specified in terms of offsets (sstart and slen) in the plain text. That may seem like quibbling. But the distinction is hugely significant from a scripting point of view. Unlike smart links embedded in the rtfd, it’s not that easy via a script to get text links out of Tinderbox anchored in their proper place in the text, though that has been demonstrated in the forum using R reading the xml.

Anyway, would not making the rftd more easily accessible to external scripts be a good idea, at least read-only?