“Lazy” Markdown reference links

[Tweet : ADN : nvALT]

Inspired by a workflow used at TidBits, here’s a script that allows you to use [*] reference links as lazy markers. The first [*]: http://... definition found after a [link][*] will be used as the definition for it. It’s easier to show:

This is my text and [this is my link][*]. I'll define
the url for that link under the paragraph.

[*]: http://brettterpstra.com

I can use [multiple][*] lazy links in [a paragraph][*],
and then just define them in order below it.

[*]: https://gist.github.com/ttscoff/7059952
[*]: http://blog.bignerdranch.com/4044-rock-heads/

This allows you to not bother naming or numbering links while writing, and easily move links along with their paragraphs without breaking numbering sequences or naming conventions.

It requires a little scripting to work, though, as you have to process the lazy links before running it through your normal processor. This script works as a Custom Preprocessor in Marked 2, as well as a standalone script as part of a chained workflow:

If this fits with the way you typically write, it’s a neat trick. Credit goes to Glenn Fleishman at TidBits for the idea and original implementation.