texi2html-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texi2html-bug] Some more questions about texi2html


From: Reinhold Kainhofer
Subject: Re: [Texi2html-bug] Some more questions about texi2html
Date: Wed, 19 Mar 2008 18:09:56 +0100
User-agent: KMail/1.9.9

Am Mittwoch, 19. März 2008 schrieb Reinhold Kainhofer:
> Am Mittwoch, 19. März 2008 schrieb Patrice Dumas:
> > > -) Is there any way to get a customized TOC? In particular, the TOC in
> > > the left "frame" (it's actually a <div> with absolution positioning) is
> > > way too long, while the overview with only the top-level sections is
> > > way too short. Idially, each page would get a TOC with the first two
> > > levels expanded, plus the whole path to the current page expanded.
> >
> > This is possible, but you have to do it more or less yourself.
>
> Thanks, I wasn't expecting to get this automatically this anyway. The only
> problem I see now is that print_page_foot gets only a handle to the file,
> so in that function I can't really special-case on the contents, right?

Okay, I found a workaround: I keep a global variable, like TOC_LINES, where I 
store the TOC for the current page. In print_element_header I fill this list 
(if it wasn't already filled, so this is only done for the very first element 
of the page) and then in print_page_footer I print it out to the fileand 
clear it. This makes sure that the TOC for the very first node on the page 
(typically a numbered sub-/section) will be created.

However, where I'm currently failing is in traversing the element tree. From 
book.init I see how to get the top node (and the full path of the current 
element), but how can I traverse the tree then? It seems that the Top node 
has only "forward", but not "FastForward" set, the first real chapter 
has 'next' set, the first section uses entirely different keys, and there is 
no key  of immediate children in all cases...

In particular, given an element, how can I get the list of immediate child 
nodes (or traverse all immediate children by some iterator)? I need this to 
be able to ignore all children below level 2, except those that are children 
of ancestors of the current node. It seems that the meaning/existence of the 
various keys in the $element hash is very different and heavily depends on 
the level of the $element...

E.g. Assume a section tree like (i.e. each (sub)section has exactly two 
children):
1. One
  1.1 One-one
    1.1.1 One-one-one
      1.1.1.1 One-one-one-one
      1.1.1.2 One-one-one-two
    1.1.2 One-one-two
      1.1.1.1 One-one-two-one
      1.1.1.2 One-one-two-two
  1.2 One-two
    1.2.1 One-two-one
      1.2.1.1 One-two-one-one
      1.2.1.2 One-two-one-two
    1.2.2 One-two-two
      1.2.2.1 One-two-two-one
      1.2.2.2 One-two-two-two
2. Two
  2.1 Two-one
    2.1.1 Two-one-one
      2.1.1.1 Two-one-one-one
      2.1.1.2 Two-one-one-two
    2.1.2 Two-one-two
      2.1.1.1 Two-one-two-one
      2.1.1.2 Two-one-two-two
  2.2 Two-two


On the page for section 1.2.1.2, I want the TOC to look like:

1. One
  1.2 One-two
    1.2.1 One-two-one
      1.2.1.1 One-two-one-one
      1.2.1.2 One-two-one-two
    1.2.2 One-two-two
  1.3 One-three
2. Two
  2.1 Two-one
  2.2 Two-two

In particular, 1.2.1.2, 1.2.1, 1.2 are ancestors, so all their immediate 
children should be shown (similar to the file tree in a file browser).

In texi2html.init, you go through the array of element nodes sequentially, 
manually keeping track of the depth. In my case, this would get quite 
complicated keeping book of ancestors, levels, etc.
Using a recursive function and the list of direct children, it would be so 
easy: 
Given an element, print its <li> entry and then traverse through its children 
by calling the same function again, but only if the level < 2 or the element 
is an ancestor for the current page. In all other cases, simply ignore all 
children (and thus also all their descendents).

Thanks a lot,
Reinhold
-- 
------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: address@hidden, http://reinhold.kainhofer.com/
 * Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/
 * K Desktop Environment, http://www.kde.org, KOrganizer maintainer
 * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]