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: Patrice Dumas
Subject: Re: [Texi2html-bug] Some more questions about texi2html
Date: Wed, 19 Mar 2008 18:24:37 +0100
User-agent: Mutt/1.5.17 (2007-11-01)

On Wed, Mar 19, 2008 at 06:09:56PM +0100, Reinhold Kainhofer wrote:
> 
> 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.

Looks good.

> 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...

Uhm, this should be much simpler... If you only follow sections (and not
nodes). There is no iterator, but there is 'sectionup', 'sectionnext',
and @'section_childs'.

> 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...

Not so much. They are definitely different between nodes and 'book
sectionning' elements, but you shouldn't care about nodes and only look
at 'book sectionning' elements.

> 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).

Should be 'sectionnext'

> 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).

Can't you do that with 'sectionnext' 'sectionup' and @'section_childs'?

--
Pat




reply via email to

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