On Mon, 2007-12-02 at 11:17 -0500, Simetrical wrote:
No, just very difficult, with lots of corner cases. Which makes it effectively impossible to guarantee that any tool other than MediaWiki itself (which is correct by definition) can parse the wikitext correctly in all cases. And perhaps more importantly, parse time for MediaWiki itself is, as I recall, somewhere on the order of 800ms. That's totally unacceptable for real-time use like WYSIWYG.
So, it's probably worth noting that the Wikiwyg library (http://www.wikiwyg.net/ ) doesn't actually parse Wikitext.
What happens is that at the user's request (clicking "edit this page", for example), the HTML of the page (output by MW itself) is put into "editable mode" on the client side. This uses some fancy features built into the two main browsers to provide WYSIWYG editing of HTML content.
If the user chooses to switch over to "wikitext mode", or when they choose to save, then a process walks the DOM tree of the HTML content and outputs wikitext. This is either shown in the "wikitext mode" window or submit back to the server. (NB: this is a very tricky process that works fine for simple markup, sections, tables, etc. and is extremely difficult for things like magic words, transclusion, category listings, etc. It can be done, but we'll probably need to make some changes to our parser output to e.g. "tag" a <span> of text as coming from a particular magic word.)
If the user switches from wikitext mode to WYSIWYG edit mode (or preview mode, or even "raw HTML editing" mode), the library uses Ajax to submit the wikitext it has back to a special page on the server to be rendered, and then shows the results of that rendering.
If you think about it, it's really a clever system. MediaWiki is excellent at converting wikitext to HTML, and you really shouldn't have any other software do that job. And the client nowadays is really good at parsing HTML into a DOM tree, so it should take on the job of the HTML -> Wikitext conversion. The actual conversions only happen at times that the user has asked for a change of mode or submit for a save, so the delay isn't unexpected or frustrating for the user.
~Evan
________________________________________________________________________ Evan Prodromou evan@prodromou.name http://evan.prodromou.name/