View Single Post
Old 12-24-2009, 09:23 AM   #16
vishalg
Junior Member
vishalg began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2009
Device: Kindle
Index by sub-sections

Here is a patch to create an index by sub-sections
Code:
87,96c87,89
< 
<         for ul in idx.findAll('ul', recursive=False):
<             for li in ul.findAll('li', recursive=False):
<                 s = li.find('strong',attrs={'class':'book'})
<                 if s is not None:
<                     a1 = s.find('a', href=True)
<                     section_title = self.tag_to_string(a1)
<                     for a in li.findAll('a', attrs={'class':'book-section'}, href=True):
<                         sub_section_title = section_title.strip() + " : " + self.tag_to_string(a).strip()
<                         yield (sub_section_title, a['href'])
---
>         for s in idx.findAll('strong', attrs={'class':'book'}):
>             a = s.find('a', href=True)
>             yield (self.tag_to_string(a), a['href'])
vishalg is offline   Reply With Quote