Feature Request External label resolution

Michel Fortin michel.fortin at michelf.com
Sun Apr 20 15:40:24 EDT 2008

Le 2008-04-20 à 11:47, Sherwood Botsford a écrit :

> How do you deal with large numbers of links?

If you were using PHP Markdown, You could write a little extension
like this:

class PreLinkedMarkdown_Parser extends Markdown_Parser {
var $preurls = array();
var $pretitles = array();
function PreLinkedMarkdown_Parser($preurls = array(),
$pretitles = array()) {
$this->$preurls = $preurls;
$this->pretitles = $pretitles;
$this->document_gamut["fillPreURLs"] = -999;
function fillPreURLs($text) {
$this->urls = $this->preurls;
$this->titles = $this->pretitles;
return $text;

and use your parser like this:

// read you link file once and populate arrays this way:
$preurls = array('link-ref' => 'url');
$pretitles = array('link-ref' => 'title'); // optional

$parser = new PreLinkedMarkdown_Parser($preurls, $prelinks);
$html = $parser->transform($text);

(Note that I haven't tested any of this code)

If there is enough interest, I could add this feature to the regular
PHP Markdown Parser class.

Michel Fortin
michel.fortin at michelf.com

More information about the Markdown-Discuss mailing list