Enhanced Markdown

After the migration to mgeisler.net I’ve been busy updating links on my site, and also a bit outsite whenever I found them. While doing so I thought a bit about how the current link structure of the Web works, or rather how it doesn’t always work.

For example: After I started redirecting people using standard HTTP “301 Moved Permanently” headers, smart search engines such as Google automatically updated their links to point to mgeisler.net. I wish that kind of auto-updating links were implemented more often!

The basic problem is that content sometimes more around in Cyberspace, so links need to be updatable. Of course one can just go through all links by hand and update them — and I’ve also partly done so, with the help of some SQL of course.

But the real solution is some kind of indirection. To make it easier for myself to do exactly that I’ve decided to seed the list of links in [PHP Markdown][] with a bunch of often used links. This means two things

  1. I can easily change all links to, say, [PHP][] if the needed be. I might decide one day that I would like to have a page here at mgeisler.net describing PHP, with links to my tutorial and other PHP related projects I’m involved in.

    (Hint: I’ve had exactly such a page back in an old version of gimpster.com, and I’ve now been updating lots of stale links pointing to /php/index.php. So the example is very real…)

  2. I can make lots of links very conveniently, knowing that they are predefined with a correct URL and title. I can, for example, write something about [Emacs][] and make a link by writing ...something about [Emacs][] and making…. Simple isn’t it?

The seeding is very simple: I’ve just changed the initialization of $md_urls and $md_titles from empty arrays to arrays with the content I want. So for example with

$md_urls = array('gnu' => 'http://www.gnu.org/');
$md_titles = array('gnu' => 'GNU's Not Unix!');

I can afterwards link to the [GNU homepage][GNU] using reference links with gnu as the link label. Just remember that the labels are converted into lower-case before being used — this means that writing [GNU][] works as expected because the label GNU is converted into gnu and then used to lookup the URL and title.

The changes must be made in the beginning of the Markdown function, about 13% into markdown.php.


  1. Denis de Bernardy:

    Try the smart link plugin. :)

  2. Martin Geisler:

    Thanks for the tip! From reading your description, it looks to me that your plugin would be able to make links just as easily, after I’ve created links to PHP, GNU, etc… I’ll have to try it out!

  3. Martin Geisler:

    The plugin has now been [enabled->now using smart links!] here on the

Leave a comment