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
You can’t assume that all applications accept HTMLand convert it automatically into a clickable string. Your ability to do this depends on how the target application handles rich text. Some may use Cocoa’s built-in rich text area classes while others may have their own completely custom text areas, each handling URLs their own way. You can look in the target application’s Dictionary to see if it allows you to create URLs in an identifiable way.