2011/1/1 lampak llampak@gmail.com:
It could be fixed by forbidding leaving unclosed tags in templates.
[...]
I've tried to think how a perfect parser should work. Most of this has been already mentioned. I think it should work in two steps: first tokenise the code and transform it into an intermediate tree structure like
[...]
and so on. Then this structure could be transformed into a) HTML for display, b) JSON for the WYSIWYG editor. Thanks for this you wouldn't need to write a whole new JS parser. The editor would get a half-ready product. The JS code would need to be able to: a) transform this structure into HTML, b) modify the structure, c) transform this structure back into wikitext.
Trevor Parscal already has a proof-of-concept parser that follows this philosophy pretty much to the letter. I don't think it's in our SVN repository yet (he said he would commit it some time ago) and I haven't succeeded in convincing him to reply on this list (holidays, I guess), but he's been playing around for it for about nine months now, on and off, and from what I've heard and seen it's promising and entirely in the spirit of your post.
Roan Kattouw (Catrope)