Outline algorithm

The section that starts

Otherwise, if the element being entered has a rank equal to or greater 
than the heading of the current section, then create a new section and 
append it to the outline of the current outlinee element

Doesn't seem to work well for documents like <h1><h2><h3><h2>; the last 
<h2> becomes a sibling of the <h1> (which is the last section of the 
current outline element). Either I have misunderstood what is supposed 
to happen here or we want to do something like the steps below:

1. Let candidate section be the current section

2. Let new section be a new section with the element being entered as 
its heading

3. Let current section be new section

4. If the rank of element being entered is less than the rank of 
candidate section's heading then append current section to candidate 
section and abort these steps

5. If candidate section is a direct child section in the outline of 
current outlinee, append current section to the outline of curent outlinee

6. Otherwise let candidate section be the parent section of candidate 
section

7. Return to step 4.


I'm also slightly confused about the next section down, which starts 
"Otherwise, run these substeps". This seems to be invoked only if the 
rank of the element is less than the rank of current section's heading, 
so the step that starts "If the element being entered has a rank lower 
than the rank of the heading of the candidate section" will always be 
true on the first iteration.

Received on Thursday, 6 March 2008 00:22:24 UTC