Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggest]TOC can click+TOC anchor unique #41

Open
GoogleCodeExporter opened this issue Apr 18, 2015 · 0 comments
Open

[suggest]TOC can click+TOC anchor unique #41

GoogleCodeExporter opened this issue Apr 18, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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]


Original issue reported on code.google.com by Zoom.Quiet on 3 Aug 2010 at 3:17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant