Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to generate a report by using a Ruby script to parse an XML document. I'm pulling link text and the actual URL and I'd like to be able to format those in a way that I could simply copy/paste the results into Pages/Numbers and have the hyperlink with correct link text immediately set. Is there a way to do this?

share|improve this question

echo -En '<a href="http://t.co">tco</a><br><a href="http://g.co">gco</a>' | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf

The output will always include styles. For some reason pbcopy -Prefer rtf doesn't include a plain text version on the clipboard so you won't be able to paste anything in plain text views.

share|improve this answer

If you want to copy / paste a link with a descriptive text different from the URL into Pages, the OS X pasteboard needs to contain an URL object (not plain text or HTML). In Ruby, you can create such a URL pasteboard object using the pasteboard gem (gem install pasteboard) and the following code:

require 'pasteboard'
pasteboard = Pasteboard.new
pasteboard.put_url '<link URL>', '<link text>'

See the gem documentation, where I lifted this example wholesale.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .