Copy to Markdown

I love using iA Writer basically for everything. Why? Because it’s so dead simple, fast & clean — Something I was missing though was the ability to copy links and quotes from websites directly to markdown. Here’s a simple solution I’ve developed using AppleScript and Apple’s Automator that I’ve been using for a while now and I would like to share.


Lets say you visit a Website in Chrome or Safari:

You press ⇧⌘C

You press ⌘V in iA Writer

If you want to reference a quote from a Website:

You select the section and press ⇧⌘C

You press ⌘V in iA Writer

Here’s the Code

Simply create a new Utility using Automator from the code and assign any shortcut eg. ⇧⌘C like I did in the quick example.

tell application "System Events" to set the clipboard to ""
tell application "System Events"
keystroke "c" using command down
delay 0.2
set theQuote to the clipboard as Unicode text
end tell
tell application "System Events" to set FrontAppName to name of first process where frontmost is true
if FrontAppName is "Google Chrome" then
tell application "Google Chrome"
set theName to title of active tab of front window
set theURL to URL of active tab of front window
end tell
else if FrontAppName is "Safari" then
tell application "Safari"
set theURL to URL of front document
set theName to name of front document
end tell
end if
if theQuote is "" then
set the clipboard to "[" & theName & "](" & theURL & ")"
set the clipboard to ">> " & theQuote & " [" & theName & "](" & theURL & ")"
end if
display notification with title FrontAppName subtitle "Copied to clipboard"

Hope this helps!