From: Waylan L. <wa...@gm...> - 2008-10-17 13:26:00
|
Hi Jack, Interesting. I was just thinking about how to do that the other day. It looks like your approach is very similar to how mine would have been. There is a few things though: * Why are you creating anchors in each header? Why not just assign each header an "id" attribute? That is generally considered the correct way to do things and works just the same. * It would be nice if it worked with the HeaderID extension. That is, if a header already has an id attribute, that is used rather than recreating one which may be different. On Fri, Oct 17, 2008 at 2:18 AM, Jack Miller <ja...@co...> wrote: > Hi all. > > I just wanted to point out that I wrote a TOC extension that's nicer than the > one linked to the wiki and (more importantly) is 2.0+ compatible. Some > differences from the aforementioned extension: > > 1. The anchor names aren't mangled... they are anchors generated by > slugifying the header contents (ala Django), which leads to much more > readable/memorizable links. > > 2. Header text is replaced by a self link of type toclink. > > 3. All instances of the marked (by default [TOC]) are replaced by the TOC > div, not just the first one. It also replaces the entire containing tag too. > It's designed for having > > Textextextextextextextextextext > > [TOC] > > Moretextextextextextextex > > So, to avoid messing up validation, it replaces the <p> tags created by > having the breaks. > > Anyway, the code is available: http://codezen.org/static/toc.py > And it's in use on my project pages, if you want to see an example: > http://codezen.org/canto/config/ > > I'd like to get this included with the main source, if possible. Otherwise, > I'll just add a link to the wiki when 2.0 is officially released. > > --Jack > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss > -- ---- Waylan Limberg wa...@gm... |