Modify

Opened 18 years ago

Closed 18 years ago

#642 closed defect (fixed)

titleindex, inline combination produces strange lists

Reported by: Ryan Witt Owned by: Christian Boos
Priority: normal Component: TocMacro
Severity: normal Keywords:
Cc: Ryan Witt Trac Release: 0.11

Description

When you use the "titlelist" option along with "inline", each title appears in it's own ordered list.

This is probably not what users want, since it results in something like:


  1. FooPage : A very nice page
  1. BarPage : Another nice page
  1. BazPage : Yet a third nice page

See all the 1's? Anyways, the blatantly obvious fix is to place the <ol> tag outside the whole thing. Here's a patch for the simple case:

  • macro.py

     
    159159            out.write("<div class='wiki-toc'>\n")
    160160        if heading:
    161161            out.write("<h4>%s</h4>\n" % heading)
     162        if params['title_index']:
     163            out.write('<ol>')
    162164        for pagename in pagenames:
    163165            if params['title_index']:
    164166                li_class = pagename.startswith(current_page) and ' class="active"' or ''
     
    167169                all_pages = list(WikiSystem(self.env).get_pages(prefix))
    168170                if all_pages:
    169171                    all_pages.sort()
    170                     out.write('<ol>')
     172                    if not params['title_index']:
     173                        out.write('<ol>')
    171174                    for page in all_pages:
    172175                        page_text, _ = get_page_text(page)
    173176
     
    178181                            title = re.sub('<[^>]*>','', title) # Strip all tags
    179182                            header = ': ' + wiki_to_oneliner(title, self.env)
    180183                        out.write('<li%s> <a href="%s">%s</a> %s</li>\n' % (li_class, self.env.href.wiki(page), page, header))
    181                     out.write('</ol>')
     184                    if not params['title_index']:
     185                        out.write('</ol>')
    182186                else :
    183187                    out.write('<div class="system-message"><strong>Error: No page matching %s found</strong></div>' % prefix)
    184188            else:
     
    188192                    formatter.format(current_page, page, page_text, out, params['min_depth'], params['max_depth'])
    189193                else:
    190194                    out.write('<div class="system-message"><strong>Error: Page %s does not exist</strong></div>' % pagename)
     195        if params['title_index']:
     196            out.write('</ol>')
    191197        if not inline:
    192198            out.write("</div>\n")
    193199        return out.getvalue()

This is the fix I'm running on my own trac installation.

Attachments (0)

Change History (2)

comment:1 Changed 18 years ago by Christian Boos

Owner: changed from Alec Thomas to Christian Boos
Status: newassigned
Trac Release: 0.90.11

Ok. See also #2.

comment:2 Changed 18 years ago by Christian Boos

Resolution: fixed
Status: assignedclosed

(In [1904]) Improve a bit the display of the TOC in inline mode (although it's still quite bad until #2 gets solved...). Fixes #642.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.