Le 2007-04-19 à 4:24, [EMAIL PROTECTED] a écrit :

I have tried to implement PHP Markdown Extra in a forum (PunBB) and found that however well each message is translated, there are collisions when different messages in the same page have the same inside link names (footnotes, title links).

I guess similar issues are met on wiki implementations, so solutions adopted for wikis might be what I am looking for.

Has this question already been met?

Yes and no. There is a provision in PHP Markdown Extra to help solve this problem, althoug it requires additional input. It is also buggy right now.

The way this should be done is by setting the `fn_id_prefix` property on the parser instance you're using. (If you're currently using the Markdown function, you'll have to create your own parser instance.) Like this:

    $parser = new MarkdownExtra_Parser;
$parser->fn_id_prefix = "$post->id."; // anything unique to your post.
    $html = $parser->transform($post->text);

You can also reuse the same parser object and change the `fn_id_prefix` property before each call to `transform`.

But there is a bug right now (version 1.1.2) which prevent footnotes from working altogether when the prefix is not empty. The fix is to change the first line of the `_stripFootnotes_callback` function of the `MarkdownExtra_Parser` which looks like this:

    $note_id = $matches[1];

to this:

    $note_id = $this->fn_id_prefix . $matches[1];

After this change, you can use `fn_id_prefix` as explained above. I should release a an update soon to fix this.

I hope this helps.

 - - -

As of title ids, it is expected they should be different enought to not clash between eachother. How would you link to them without knowing the prefix anyway?

 - - -

May I suggest the addition of an _option_ to add a key to each link or link pair (`[^1]` and `[^1]: ...` for instance), that could help insulate each message from its neighbors?

I could be done by defining a random 6-8-char key for each instance of PHP Markdown, and appending or prepending it to the name of each element in the html output.

A random string would make links to footnotes change every time the page is reprocessed. This is something I want to avoid as it would break bookmarked links.

So PHP Markdown Extra isn't going to add random strings to footnote ids by itself. Of course, if you want, you could fill the `fn_id_prefix` property with a random prefix every time, which would yeild the same result.


Michel Fortin
[EMAIL PROTECTED]
http://www.michelf.com/


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

Reply via email to