Bookmarklet to Save a Link and Title in Markdown Format and Copy to Clipboard

Inspired by Federico Viticci over at MacStories, I have created a bookmarklet that allows you to grab the title and URL of a web page in your mobile browser, have it formatted in Markdown as a link, and then copied to the clipboard so that you can paste it into the iOS text editor of your choice:

 
This bookmarklet relies on the Drafts URL scheme (which means you have to have it installed on your device). The page title is surrounded by URL-encoded brackets, and the link is surrounded by parentheses, as follows:

[MacStories](http://www.macstories.net]

 
This text string is then copied to the clipboard using the action parameter. (Visit Drafts for Developers to learn more.) “Copy to Clipboard” is a built-in action, so you don’t have to fiddle with Drafts to make this bookmarklet work.

Bonus!

If you would like to immediately jump to your iOS text editor of choice (provided it has an URL scheme of its own), you can add something like the following immediately before the final single quote in the bookmarklet:

&x-success=byword:

 
By adding the above to the bookmarklet, Drafts will automatically open Byword after it has copied the link to the clipboard. If you use a different app than Byword, just insert its link after the = sign.

How to Create a Bookmarklet

If you have never created a bookmarklet before, do the following:

  1. Copy the above script to your iOS clipboard.
  2. In mobile Safari, bookmark any page, and call it something like “Markdown Link.”
  3. Then go to bookmarks, tap on Edit, then tap on the bookmark.
  4. Tap on the URL of the page you actually bookmarked, then tap on the X to delete it.
  5. Paste the script into that field and hit Done.