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()) {
            parent::Markdown_Parser();
            $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
[EMAIL PROTECTED]
http://michelf.com/


_______________________________________________
Markdown-Discuss mailing list
[email protected]
http://six.pairlist.net/mailman/listinfo/markdown-discuss

Reply via email to