Feature Request External label resolution

Tomas Doran bobtfish at bobtfish.net
Sun Apr 20 04:54:01 EDT 2008



On 20 Apr 2008, at 07:11, Sherwood Botsford wrote:


> Hmm. Ok, I think I could to it this way in Template Toolkit:


<snip>


> Downside is then that Markdown has to process every reference

> which if you have a few thousand will be time consuming.

> (I have an INSERT text at one point that jsut in template toolkit

> takes 10-12 seconds to do. It's only a thousand lines, but there

> is zero processing to do, it just stuffs it into the file.


If you're prepared to have a fiddle with perl, have a look at
Text::Markdown (on CPAN)..

You can do this reasonably trivially - here is a ghetto version of
Markdown.pl which will suck all your link references out of
~/.markdownrc:

use strict;
use warnings;
use Text::Markdown;
use File::Slurp;
use File::HomeDir;
use Path::Class;

my $m = Text::Markdown->new;
my $urls;
{
my $markdownrc = read_file(file(File::HomeDir->my_home,
'.markdownrc'));
$m->markdown($markdownrc);
$urls = $m->{_urls};
}

print $m->markdown(<>, {urls => $urls});

That should do what you originally asked for - adjust to taste..

If you wanted to add an accessor for the URLs hashref on the module,
and an option to the Markdown.pl script that I bundle in the
distribution to give it this functionality, I'd be very happy to take
a patch. :_)

Cheers
Tom



More information about the Markdown-Discuss mailing list