May 10, '07 07:30:00AM • Contributed by: Anonymous
set the_url to the clipboard
set the_text to "<a href="" & the_url ¬
& ""target=_blank>here</a>"
set the clipboard to the_text
Save this as an AppleScript application, and then put it wherever it's easiest for you to run -- I put it into my AppleScript utility menu. When you paste the link HTML into a document, the link will look like this: here. If you want to control the link text to say something other than "here," then read on for an alternative script.This version will prompt you for the link text each time you use it:
set the_url to the clipboard
set temp to display dialog ¬
"Please enter the link text" default answer "here"
set link_text to text returned of temp
set the_text to "<a href="" & the_url ¬
& "" target=_blank>" & link_text & "</a>"
set the clipboard to the_text
[robg adds: These worked as described, and using something like Butler, QuicKeys, or any of a dozen other utilities, you could bind it to a hotkey for extra easy access. As an alternative, I use a simple TypeIt4Me expansion to create HTML links: %| -- the ⌘ tells TypeIt4Me to paste the clipboard contents (the URL), and then %| positions the cursor at that location. So I copy a URL, type my shortcut (I use hhref) in the destination app, and then type the text for the link. I use this literally dozens of times a day for hints postings and Macworld blogs.]
