Matthew Palmer Top Articles Vanilla Rocket Kubernetes Book Standing Invitation

How to Extract Markdown Reference Links from Text

Like a lot of people, I write in Markdown. Markdown has support for reference links, which look like the following:

This is a [link to something][lts] that I am sharing.
More writing...

`[lts]: http://wwww.link.com`

(The backticks are there so that the Markdown parser doesn’t think I’m trying to link to something.)

I love using links in this style, but I often forget what I’ve referenced after I’ve linked it. I’ve written a short command line to grab out the link identifiers from a Markdown post.

With the contents of your writing on the clipboard, run the following in Terminal.

pbpaste | egrep -o '\]\[[a-zA-Z0-9\-]+\]' | sed -E 's/]//' | pbcopy

Now all of the references to links will be on the clipboard, ready for you to hit Command+V to paste at the end of your blog post.

`[editor]: ...`
`[fs]: ...`
`[mp]: ...`

If you have any questions, let me know on Twitter.

My products
💅 Vanilla – hide icons from your Mac menu bar for free
🚀 Rocket – super-fast emoji shortcuts everywhere on Mac… :clap: → 👏
Horo – the best free timer app for Mac
📂 FastFolderFinder – a lightning-fast launchbar app for folders and apps
📖 Kubernetes – my book on Kubernetes for web app developers
😄 Emoji Bullet List – easily emojify your bullet point lists (like this one!)

Jump on my email list to get sent the stuff that’s too raunchy for the blog.
(Seriously though, it’s an occasional update on apps I’ve built and posts I’ve written recently.)