One of the main benefits of Markdown is that it should be human-readable in it’s native format, but how often have you ended up with a page looking something like this:
* [Robert Herjavec: Top 10 tips for budding entrepreneurs](http://www.cbc.ca/news/business/story/2009/10/05/f-small-business-robert-herjavec-dragons-den.html)
* [Why you shouldn’t launch your startup in the press](http://gigaom.com/2011/12/19/lean-startup-launch-strategy/)
* [Slideshow on Customer Development Methodology](http://www.slideshare.net/venturehacks/customer-development-methodology-presentation)
* [You are in the emotion business](http://blog.kaisdavis.com/post/7877623196/you-are-in-the-emotion-business)
Human-readable? Not really…
The links above use the standard Markdown syntax of [title](URL)
, for example [Google](http://google.com)
, but as you can see, when the URLs are long, a list of links can become quite unwieldily.
Reference-style links to the rescue!
We’ve all read a Wikipedia page with the little reference links strewn throughout the document, and a list of links at the bottom of the page. Markdown actually provides native support for cleaning up pages using something similar. Instead of the standard Markdown link syntax of [Google](http://google.com)
, reference style syntax allows you to enter the link as [Google][1]
, and then place the link at the bottom of the page:
Go to [Google][1] to search for stuff.
Words, words, words...
[1]: http://google.com
You don’t have to use numeric references, the reference can also be a human-readable string.
If you already have a page containing hundreds of links using the standard syntax, there is a handy tool that can automatically convert them all to reference-style links for you. Brett Terpstra’s Markdown service tools for Mac include a “Inline Links to References” service which makes maintaining reference-style links a breeze!
After intalling the service tools, just select your Markdown in your favourite Mac editor of choice and select Services > md - Inline Links to References
. Applying this to the nightmarish list of links above results in the following:
* [Robert Herjavec: Top 10 tips for budding entrepreneurs][cbc]
* [Why you shouldn’t launch your startup in the press][gigaom]
* [Slideshow on Customer Development Methodology][slideshare]
* [You are in the emotion business][kaisdavis]
[cbc]: http://www.cbc.ca/news/business/story/2009/10/05/f-small-business-robert-herjavec-dragons-den.html
[gigaom]: http://gigaom.com/2011/12/19/lean-startup-launch-strategy/
[kaisdavis]: http://blog.kaisdavis.com/post/7877623196/you-are-in-the-emotion-business
[slideshare]: http://www.slideshare.net/venturehacks/customer-development-methodology-presentation
Ah… much better! You can now maintain your list of links by entering them using standard Markdown syntax ([Title](URL)
), select the entire document and then run the “Inline links to References” service on it to re-generate all the references.
Since installing this service tool, I’ve been using it to clean up my WikiPack pages. Hope it helps you in your Markdown workflow too.