I know how to copy plain text to the clipboard:
oascript -e 'set the clipboard to "plain text"'
But the question is how can I copy html contents to the clipboard? For example, how can I copy the following html content to the clipboard:
<b>bold text</b>
so that I get bold text when I paste it in TextEdit?
Thanks for the help in advance!
I found an intermediate solution for this:
echo "<b>bold text</b>" | textutil -stdin -stdout -format html -convert rtf | pbcopy
This works, so far so good, but unfortunately I found that it doesn't work for an image tag:
echo "<img src=\"https://www.google.com/images/srpr/logo3w.png\">" | textutil -stdin -stdout -format html -convert rtf | pbcopy
This does not do the job I want, so anybody knows the reason?
Thanks!
I've found a working solution and posted it below :)
img
tag doesn't work is because RTF documents can probably only use embedded images, and therefore can't display images hosted on HTTP servers. – Arteimg
tag to RTF format, which leaves you with a broken image. – Arte