Fix It In Post
Idea: an HTML post-processor.
This is really an extension of what NW currently does. The loading process recursively parses each node in the tree in order to discover element definitions. Extending this metaphor (replacing some declaration with another representation of it's symbolic reference), it would be entirely possible to devise an HTML post-processor engine. Using some combination of recursive tree walking and regular expression matching, it should be fairly straight forward to create a language for creating entity definitions and then replace them in the document once it's loaded. For example, equations or code snippets. More work could even yield a client-side conditional include type of functionality.
So here's how it might work in practice: I've got a really long name that I use all over a given document, which could be something like "Robert Alexander Russell" (me). Writing that over and over again would really suck. Instead, if you could just put an abbreviation for it in (say, [[rar]]) and then correlate this with the full string, it wouldn't be hard to do replacement once the page loads. Heck, it'd be cake.
Now suppose I've got a variable that I want to represent in the document, say a variable T. In order to get T to look right in HTML, it might have some extra formatting associated with it's use as a variable, like so:
<span class="variable">T</span>
While regular expressions in editors can ease changes should the class name change, or we want to use a div and not a span, the fact remains that the margin for error is pretty high. If we can just write something like [[T]] and have the previous string inserted for it, then we gain something quite useful for long technical documents.
Better yet, removing portions of a document based on certain criteria become possible with this approach. All we would need would be something like a directive, perhaps:
[[#ifdef myvar]]
where myvar
could be either a javascript variable or some other identifier which could be discerned from the document, as with a [[#define myvar]]
type of a symbol.
Honestly, I'm not sure that this approach buys us much more than a codified way of doing the trivial. While setting up something like this isn't hard for custom stuff, why bother? Might be more powerful and useful to write it once and leverage it moving forward...