72
↪
When entering asectioning rootp175
element
Run these steps:
1. Ifcurrent outline targetis not null, pushcurrent outline targetonto the stack.
2. Letcurrent outline targetbe the element that is being entered.
3. Letcurrent outline target'sparent sectionbecurrent section.
4. Letcurrent sectionbe a newly createdsectionp176
for thecurrent outline targetelement.
5. Let there be a newoutlinep176
for the newcurrent outline target, initialised with just the newcurrent sectionas the
onlysectionp176
in the outline.
↪
When exiting asectioning rootp175
element, if the stack is not empty
Run these steps:
1. If thecurrent sectionhas no heading, create an implied heading and let that be the heading for thecurrent section.
2. Letcurrent sectionbecurrent outline target'sparent section.
3. Pop the top element from the stack, and let thecurrent outline targetbe that element.
↪
When exiting asectioning contentp117
element or asectioning rootp175
element (when the stack is empty)
If thecurrent sectionhas no heading, create an implied heading and let that be the heading for thecurrent section.
Skip to the next step in the overall set of steps. (The walk is over.)
↪
When entering aheading contentp117
element
If thecurrent sectionhas no heading, let the element being entered be the heading for thecurrent section.
Otherwise, if the element being entered has arankp167
equal to or higher than the heading of the last section of theoutlinep176
of thecurrent outline target, or if the heading of the last section of theoutlinep176
of thecurrent outline targetis an implied
heading, then create a newsectionp176
and append it to theoutlinep176
of thecurrent outline targetelement, so that this new
section is the new last section of that outline. Letcurrent sectionbe that new section. Let the element being entered be the
new heading for thecurrent section.
Otherwise, run these substeps:
1. Letcandidate sectionbecurrent section.
2. Heading loop: If the element being entered has arankp167
lower than therankp167
of the heading of thecandidate
section, then create a newsectionp176
, and append it tocandidate section. (This does not change which section is
the last section in the outline.) Letcurrent sectionbe this new section. Let the element being entered be the new
heading for thecurrent section. Abort these substeps.
3. Letnew candidate sectionbe thesectionp176
that containscandidate sectionin theoutlinep176
ofcurrent outline
target.
4. Letcandidate sectionbenew candidate section.
5. Return to the step labeledheading loop.
Push the element being entered onto the stack. (This causes the algorithm to skip any descendants of the element.)
↪
Otherwise
Do nothing.
In addition, whenever the walk exits a node, after doing the steps above, if the node is not associated with asectionp176
yet, associate
the node with thesectionp176
current section.
Thecurrent outline targetis the element being exited, and it is thesectioning contentp117
element or asectioning
rootp175
element at the root of the subtree for which an outline is being generated.
Note
Recall thath1p167
has thehighestrank, andh6p167
has the lowest rank.
Note
178