thoughts on predefining links

Jason Clark jason at jclark.org
Wed Mar 10 17:10:07 EST 2004


One of the things I'd like to do with Markdown on my Blosxom blog is to 
maintain a list of common link references as a standalone file, and 
have that file always be referenced.  For example, I'd like to have a 
"links.txt" file that looks like:

[markdown]: http://daringfireball.net/projects/markdown "The Markdown 
Project Home Page"
[blosxom]: http://blosxom.com
[del]: http://del.ico.us/jason
...

These would be links I tend to refer to very often.  I am nothing if 
not lazy.

There are two ways I can go here - Blosxom-specific or 
Markdown-specific.  On the blosxom side, I can use the include plugin 
(or similar mechanism) to read the file and include it in every story, 
prior to Markdown running as a blosxom plugin.  The downside here is 
that the list of links get processed for every story.  In my default 
view, there are 10 stories on a page.

This got me thinking of attacking the problem from within Markdown.  I 
could just read the file and pass it to _StripLinkDefinitions to prime 
%g_urls.  I can even do this from start(), confining this behavior to 
the Blosxom interface.  This raises another issue... %g_urls is not 
flushed between stories.   This isn't really a problem without the 
links-file enhancement; links in each story will overwrite links in 
earlier stories.  If i prime the hash during startup(), any story that 
re-purposes a link reference tag will affect later stories.  I'll 
probably circumvent this by making my own copy of %g_urls during 
startup and refreshing the real %g_urls during each story() call before 
calling Markdown.

Before I proceed, just thought I'd see if there's any interest in 
making this more general pupose.  I intend to offer a patch with my 
changes for those who wish to use them, but If there's already a plan 
for similar functionality (or an interest) I'd rather write it to fit 
the plan the first time.



More information about the Markdown-discuss mailing list