Re: [Wikitech-l] [RFC] Balanced templates (was: [RFC] Hygienic templates)

2015-11-12 Thread C. Scott Ananian
In this repost I forgot to mention that the phab task for `{{#balance}}` is
https://phabricator.wikimedia.org/T114445.

I copied the excellent points made by Gergo into a comment there.
 --scott
​
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] [RFC] Balanced templates (was: [RFC] Hygienic templates)

2015-11-12 Thread C. Scott Ananian
On Wed, Nov 11, 2015 at 8:15 PM, Gergo Tisza  wrote:

> On Tue, Nov 10, 2015 at 1:40 PM, C. Scott Ananian 
> wrote:
>
> >2. `{{#balance:inline}}` would only allow inline (i.e. phrasing)
> content
> >and generate an error if a
> ``/``/``/``/``/``/`
> >`/`` tag is seen in the content.
>
>
> Why is  in that list? It's not flow/block content model and filtering it
> out would severely restrict the usefulness of inline templates.
>

That's a good point.  The problem is nested  tags.  So we can either ban
open  tags from the context, or ban  tags from the content.  Or split
things and have {{#balance:link}} vs {{#balance:inline}} or something like
that.  Feedback welcome!  The details of HTML parsing are hairy, and I
wouldn't be surprised if we need slight tweaks to things when we actually
get to the point of implementation.

To be extra specific:  if the context is:

hello, there friend 

and the template is "foo bar", then HTML5 parsing will produce:

hello, there friend foo bar

where the added closing  tag inside the template body prevents "simple
substitution" of the template contents.

   - We just need to emit synthetic `` tokens, the tree
> >builder will take care of closing a tag if necessary or else
> discarding
> > the
> >token.
> >
>
> What if there are multiple levels of unclosed tags?
>

We basically emit enough unclosed tags to close anything which might be
open, and let the tidy phase discard any which are not applicable.

Off-hand, I think the only tag where nesting would be an issue would be
.  So I guess we'll need the Sanitizer to count the open 
tags so we can be sure to emit enough close tags.  Tricky!
 --scott

-- 
(http://cscott.net)
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] [RFC] Balanced templates (was: [RFC] Hygienic templates)

2015-11-11 Thread Gergo Tisza
On Tue, Nov 10, 2015 at 1:40 PM, C. Scott Ananian 
wrote:

>2. `{{#balance:inline}}` would only allow inline (i.e. phrasing) content
>and generate an error if a ``/``/``/``/``/``/`
>`/`` tag is seen in the content.


Why is  in that list? It's not flow/block content model and filtering it
out would severely restrict the usefulness of inline templates.

   - In the Sanitizer leave that marker alone, and then just before
>handling the output to tidy/depurate
> we'll replace the marker
> with
>`...etc...`.  That pass will close the tags (and discard any
>irrelevant `` tags).  Some care needed to ensure we discard
>unnecessary close tags, and not html-entity-escape them.

 (...)

   - We just need to emit synthetic `` tokens, the tree
>builder will take care of closing a tag if necessary or else discarding
> the
>token.
>

What if there are multiple levels of unclosed tags?
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l