Is there a way to take a text label and an URL and use Applescript add them to the Mac clipboard such that rich-text apps see the data as a URL and make linked anchor text when pasting in the data.
I have untitled reference URLs (generated via code) that need to have a ‘screen’ title (anchor text). I can create the URL and anchor text. But, how do I combine them so that the Mac clipboard treats the data as a URL? I tried:
set the clipboard to "<a href=\"" & theURI & "\" target=\"_blank\">" & theAnchor & "</a>"
…but when using this data from other apps I get the HTML string and not a link with the anchor text as the visible screen text.
StandardAdditions has ‘URL’ and ‘web page’ classes but I can’t see how to apply them. This compiles but fails when run:
set myURL to theURI as URL
set myLinkAnchor to theAnchor as text
set linkURL to {URL: myURL, name: myLinkAnchor} as web page
Background: Barebones’ Yojimbo allows local links direct to item in the users Yojimbo library, e.g.
x-yojimbo-item://33B1CDF7-56F5-47FE-A1A3-1ED72953B4FC, but such URIs are only available via a menu item and also lack any indications to the target items’s name/label. So, I can use AppleScript to get and Items ID and turn that into the URL and separately get the target item’s name but I can seemingly make whatever record format is needed to make the date, when posted to the clipboard, get used as a link with anchor text when pasting to other apps.
Am I overlooking something obvious or is this just not possible? Ideally, if I can make the clipboard data correctly, i’ll add an Automator service to Yojimbo can paste a link into another app (in my case, Tinderbox).