On Thu, Mar 22, 2012 at 10:28 AM, Adam Wight <spam@ludd.net> wrote:
So, in the course of trying to implement user signature processing in
the PEGjs grammar (https://bugzilla.wikimedia.org/show_bug.cgi?id=35392),
it occurred to me that this is in a whole new class of transformation
function.  "~~~~" is actually replaced in the wikitext during the
round-trip of saving on the server.  Ha ha, not the quaint little
evening project I thought I was taking on!

Looking at includes/parser/Parser.php::pstPass2, in addition to user
signatures, pre-save transformations can also insert the current
timestamp, do a literal transclusion using the {{subst:  tag, or
complete the "context" of a wikilink.

Implementing this class of transformation in the VisualEditor gets
tricky because the client wikitext must be kept in sync.  Is there
already a provision made for mutating wikitext after a round-trip?

These sorts of things really should be happening *in* the editor, rather than in the parser. We only have to put ~~~~ in because the original editor was too primitive to have a nice "insert signature" live function. So I think it's worth really rethinking how these things get done for the new paradigm. :)

-- brion