Adam Wight | 22 Mar 2012 18:28
Favicon

Pre-save transformations in VisualEditor

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?

Thanks,
Adam Wight
Brion Vibber | 22 Mar 2012 19:28
Picon

Re: Pre-save transformations in VisualEditor

On Thu, Mar 22, 2012 at 10:28 AM, Adam Wight <spam <at> 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
_______________________________________________
Wikitext-l mailing list
Wikitext-l <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitext-l
Adam Wight | 22 Mar 2012 20:28
Favicon

Re: Pre-save transformations in VisualEditor

bvibber <at> wikimedia.org:
> On Thu, Mar 22, 2012 at 10:28 AM, Adam Wight <spam <at> 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

+1.0

The {{subst: incantation would be easy to handle with the editor as well, if we
care.  Just make an api call to fetch template wikitext.

-adam
Trevor Parscal | 26 Mar 2012 17:20
Picon
Gravatar

Re: Pre-save transformations in VisualEditor

I agree that this is an excellent example of PST being used to supplement the primitive nature of the plain text editor.

What's going to be interesting is that in the editor when you add your signature, it will be treated as a discreet object, but once you save it will just be linked text like anything else. This is just how it works though, no getting around that.


- Trevor

On Thu, Mar 22, 2012 at 12:28 PM, Adam Wight <spam <at> ludd.net> wrote:
bvibber <at> wikimedia.org:
> On Thu, Mar 22, 2012 at 10:28 AM, Adam Wight <spam <at> 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

+1.0

The {{subst: incantation would be easy to handle with the editor as well, if we
care.  Just make an api call to fetch template wikitext.

-adam

_______________________________________________
Wikitext-l mailing list
Wikitext-l <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitext-l

_______________________________________________
Wikitext-l mailing list
Wikitext-l <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitext-l

Gmane