Today I've been tying up some hacking to revise Wikizzle's XML wikitext representation. This wikitext: [[talk:woot]] now parses to this:
<article>
<paragraph lineno="0" charno="0">
<link avaliable="unknown">
<parse:token direction="open" type="link">[[</parse:token>
<linktarget>
<namespace type="normal">
<key>talk</key>
<parse:token direction="open+close" type="namespace">:</parse:token>
<article-name>woot</article-name>
</namespace>
</linktarget>
<parse:token direction="close" type="link">]]</parse:token>
<linkoptions/>
</link>
</paragraph>
</article>
New things:
- The parse namepace hints at where the syntax tree came from. When I convert the wikixml to xhtml parse elements get ignored but lots of interesting applications open up when you know where your tokens are, the first being a syntax highlighting editor. Later, I want to offer a 'pseudo-preview' which overlays some of the wikitext tokens as a learning aid.
- If you traverse and output all the text nodes in order (in xpath, as easy as '//text()') you get (pretty much) the original wikitext. I can't say why this is cool or useful but I'm pretty sure it is. Remember, Beauty is our Business.
Just imagine if you could cleanly go from wikitext to XML and back again - you could programatically alter the parse tree for the user (eg, adding rows to tables) and the wikitext would be rewritten to represent this - fancy editor functions without all that ugly regexp half-parser substitutions.

0 comments:
Post a Comment