However, when a heading command at a specified level is trapped, a new weaver is created and pushed onto the stack. When a heading at that same level is trapped again, the weaver on the top of the stack is popped, and a new weaver pushed in its place.
In this way, all headings at a certain level in a document will create a new html document.'remote_directory'.
A stacking weaver requires a list of montonic increasing integers to determine when to spawn a child page. When a child is spawned by a level n heading, that heading becomes the title of the spawned page, and a heading of level n+m is sent to the child as a level m heading.
On the other hand, it has to create separate sinks for each new weaver, except the top level (main page). This is currently done by supplying a prefix for the child page filenames, the stacking weaver appends a number representing the child number, in order the children were spawned.
Implementation notes. We maintain a document stack. Each document is triggered by the corresponding heading level from the supplied trigger list (which had better be strictly montonic increasing).
When we get a heading level n, we pop off weavers until n is greater than the trigger level of that weaver. (The test is performed first).
Then, we push documents onto the stack, until n is greater than or equal to the document trigger level. (The test is performed first).
Then, if n is the trigger level of the document, we use it as a title and hyperlink the document into it's parent, otherwise we just typeset the heading.
Note that the first loop will destroy a document whose trigger
level is equal to the heading level, and the second loop
will create a new document at this level.
6.14.6.1. Bugs
6.14.6.2. Code
6.14.6.3. Test Code