yeah, AFAIK the MediaWiki people spent a lot of time to write a new parser for their visual editor that creates an AST from the syntax. That should be a much better way to create whatever format you want.
OTOH this is just hearsay and I never really looked into it. So maybe this was the last ditch and OP just did not mention the failed attempts before?