I'm on a Mac, python 3.7.2. I want to write text, linked to a url, to the clipboard. This is so that I can paste it straight into a Wordpress site, an email, a Google doc, etc.
I copied a hyperlinked piece of text from a document and confirmed it works by pasting it into a different application. The text retains its link to the specific url.
When I try and read that from the clipboard using pbpaste
(in order to understand what bytes are needed to craft new hypertext linked strings I can put back onto the clip board) the text comes back as bytes but with no url present in it. For example copying the following line:
But on running the following code I don't see any URL information:
import subprocess
p = subprocess.Popen(['pbpaste', 'r'], stdout=subprocess.PIPE, close_fds=True)
stdout, stderr = p.communicate()
stdout
b'This: 00:06 is a link to a video.'
It appears that's because pbpaste
is loosing the extra information. Is there any way to use this command line tool or any other python tool to get this rich text information from the clipboard? Using p = subprocess.Popen(['pbpaste', '-Prefer', 'rtf', 'r'], stdout=subprocess.PIPE, close_fds=True)
does not work.