Preserving hyperlink formatting from the system clipboard

I simply paste a hyperlink from the system clipboard, such as the word "Link", with an underlying URL. Works beautifully.

I copy the system clipboard to a named clipboard, then paste from the named clipboard. Only the URL is pasted, the text "Link" is lost.

From what I've been reading on these forums, the dilemma above is more complicated than the uneducated (me) might expect.

I have also tried writing the system clipboard to an RTF or RTFD file and reading the file back to the system clipboard. Same result: The underlying URL is pasted but the "Link" text is lost.

I have found no (simple) way to save the hyperlink (to use later) and preserve the hyperlink formatting.

The application that is doing the copying (when you use ⌘C) will typically create distinct pasteboard items in different formats, perhaps for example, 2 or more of:

  • public.utf8-plain-text
  • public.html
  • public.rtf

The application that is doing the pasting, (or the retrieving from the clipboard) will typically be faced with a choice. It may for example, choose, by default, to make use of the public.utf8-plain-text pasteboard item rather than any public.html or public.rtf which it finds.

Hard, therefore, to be sure of what is happening without knowing how and what you are copying, and exactly what range of formats the copying application is putting in the clipboard.

To obtain a formatted link, you might, for example, be able to delete a public.utf8-plain-text item from the pasteboard, leaving only richer formats for pasting applications to choose from.


Should should be able to inspect what range of pasteboard items are in your clipboard by using a macro like:

2 Likes

PS another way of listing the "flavours" (pasteboard item types) present in the clipboard is to use the Keyboard Maestro token %SystemClipboardFlavors%

Once you know which flavour(s) you want to remove,

you can then use the Remove Clipboard Flavors action.

Perhaps, for example, to zap public.utf8-plain-text etc,
leaving one or more of public.html or public.rtf in place.

1 Like