Status: New
Owner: Zoom.Quiet
Labels: Type-Enhancement Priority-High OpSys-All Component-Scripts Usability

New issue 41 by Zoom.Quiet: [suggest]TOC can click+TOC anchor unique
http://code.google.com/p/txt2tags/issues/detail?id=41

for blogging,i hacked txt2tags.py v2.4, so share at first, i will try
to merge into v2.5:
    + for make TOC can click,and make TOC anchor unique:
        - e.g http://blog.zoomquiet.org/pyblosxom/utility/Subversion/
        - in this page include several t2t export xhtml body
        - include several TOC guider list
        - with my hacked,every TOC list can click jump to that chapter
        - and every chapter can click back the right entry top
        hacking: appended one global ver as
        XHTML_TOPTOP = ""
        ...
        # hacked for generate unique top anchor seed
        def doHeader(headers, config):
            #100419:zoomq for toc fixed in multipages
            global XHTML_TOPTOP
            ...
            ret =  string.split(template, '\n')
            #   zoomq:100419 for toc in multi pages
            for i in range(len(ret)):
                if "<h1>" in ret[i]:
                    #print ret[i][4:-5]
                    XHTML_TOPTOP =
base64.b64encode(base64.b32encode(ret[i][4:-6]))[:9]
                    ret[i] = "<a name='toptop%s'
id='toptop%s'></a>%s"%(XHTML_TOPTOP
                        ,XHTML_TOPTOP
                        ,ret[i]
                        )
                    break
            #return string.split(template, '\n')
            return ret

        ...
        class TitleMaster:
            import base64
            ...

            # hacked for generate unique anchor seed for every TOC title
            def _get_tagged_anchor(self):
            ...
                if CONF['toc'] and self.level <= CONF['toc-level']:
                self.anchor_count = self.anchor_count + 1
                # zoomq:100414 fixed link as unique str
                unique =
base64.b64encode(base64.b32encode(self._get_full_title_text()))
                label = label or '%s%s%s'%(
                        self.anchor_prefix
                        , self.anchor_count
                        , unique[:9]
                        )
            ...
            # hacked for plugin jump back the top link usage
XHTML_TOPTOP as unique anchor seed
            def get(self):
                ...
                global XHTML_TOPTOP
                full_title = "<A href='#toptop%s'> %s </A>"
%(XHTML_TOPTOP, self._get_full_title_text())
            ...
            # hacked for generate every TOC title jump into unique anchor
            def dump_marked_toc(self, max_level=99):
                ...
                    for level, count_id, txt, label in self.toc:
                        # zoomq:100414 fixed link as unique str
                        tocStr = "%s %s%s"%(count_id,txt, label)
                        uniqueStr =  
base64.b64encode(base64.b32encode(tocStr))
                        if level > max_level: continue   # ignore
                        indent = '  '*level
                        id_txt = string.lstrip('%s %s'%(count_id, txt))
                        label = label or self.anchor_prefix+`toc_count`
                        label += uniqueStr[:9]




------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list

Reply via email to