Useful script to quote selected text and create markdown link

Hello all,
I’ve been getting some help from people on my hook scripts, so wanted to share one of my own that I use all the time. It’s very simple, but I find it useful.

What it does:

  1. Select some text within a webpage, document, pdf file or anything where cmd-c copies text to clipboard.
  2. Trigger the applescript (I use an alfred trigger of alt-cmd-shft-c to trigger it)
  3. Clipboard will now contains a markdown-style link with your selected text as the visible title and the hook link as the link.
    So you can paste it into docs that accept markdown-style links

===============
tell application “System Events”
keystroke “c” using command down
end tell
tell application “Hook”
set b to bookmark from active window
set the clipboard to “[” & the clipboard & “](” & address of b & “)”
end tell

5 Likes

Thanks , @carlcasca . And here is your script formatted:

tell application "System Events"
	keystroke "c" using command down
end tell
tell application "Hook"
	set b to bookmark from active window
	set the clipboard to "[" & (the clipboard) & "](" & address of b & ")"
end tell

to get formatted code, use the </> in the forum editor’s toolbar (6th button from the left).

1 Like

by the way, a tip to anyone who wants to try AppleScript they get from any website. On the web page, do Hook to New > Script Editor. copy/paste the code in.

That way the Script Editor file will be

  • created for you
  • appropriately named
  • saved
  • hooked (bidirectionally linked) back to the source.

then in future you can find the script via Hook’s search, contextually from the source, and via other tools :slight_smile: .

You can use this same principle for experimenting with any source in any language from any website.

4 Likes