Just new ideas, I think MoinDev/WikiDom is over-engineered (or under-engineered?) with two stages and all that.

terms

placeholder node
a node that can be replaced by a subtree at that spot, contains a function to call
activation
the process of expanding a placeholder node
transformer
anything that takes a DOM tree and transforms it to a new tree (example: html transformer, activation transformer)
transformation
the process of running a transformer on a tree

Process

Initially a document starts out with a parsed representation. This representation can be cached.

This will finish with all placeholders that had no dependencies replaced or at least invoked to make sure they could not be replaced at this stage.

dependency information

Each placeholder node may have a dependency on another placeholder node. After a placeholder node is activated, the dependent nodes will be activated as well. Initially, all placeholder nodes that are created by a parser have the no dependency information meaning they can be activated at any time; but they might possibly replace themselves with other placeholder nodes having dependencies.

An activation of a node can thus also activate other dependent nodes.

Examples

Table of contents

The table of contents macro is initially a simple macro placeholder node inserted into the tree by the parser. Thus, the first activation run will call it with the subdocument node it is contained in. It then scans the subdocument and emits new nodes depending on the subdocument:

Proof of concept code

git clone http://git.sipsolutions.net/dom.git
-or-
hg clone static-http://johannes.sipsolutions.net/dom.hg/

Or see gitweb: http://git.sipsolutions.net/dom.git

retrofitting it into MoinMoin

While I'm no longer convinced it is possible to retrofit DOM-based formatting into the existing code base, I have previously written a pickle-based formatter and some more code that allows creating a DOM-tree from formatter calls. This is available in these two files:

MoinMoin: JohannesBerg/DOM (last edited 2007-10-29 19:09:29 by localhost)