W3C home > Mailing lists > Public > www-style@w3.org > December 2011

Re: [CSS21][css3-content] quotes nesting level

From: L. David Baron <dbaron@dbaron.org>
Date: Tue, 6 Dec 2011 09:01:36 -0800
To: Simon Sapin <simon.sapin@kozea.fr>
Cc: "www-style@w3.org" <www-style@w3.org>
Message-ID: <20111206170136.GA6212@pickering.dbaron.org>
On Monday 2011-12-05 17:51 +0100, Simon Sapin wrote:
> Both section 12.3.2 of CSS 2.1 and section 4.1 of Generated Content
> 3 use the same text to describe the quotes nesting level for the
> `quotes` property and the `open-quote` and `close-quote` values of
> the `content` property:
> 
> """
> ‘Open-quote’ refers to the first of a pair of quotes, ‘close-quote’
> refers to the second. Which pair of quotes is used depends on the
> nesting level of quotes: the number of occurrences of ‘open-quote’
> in all generated text before the current occurrence, minus the
> number of occurrences of ‘close-quote’. If the depth is 0, the first
> pair is used, if the depth is 1, the second pair is used, etc. If
> the depth is greater than the number of pairs, the last pair is
> repeated.
> """
> 
> For the quotes to be balanced and match the examples, the nesting
> level should be more accurately described as:
> 
> the number of occurrences of ‘open-quote’ in all generated text
> before the current occurrence *excluding the current occurrence*,
> minus the number of occurrences of ‘close-quote’ before the current
> occurrence *including the current occurrence*.
> 
> Of course this sentence is much too heavy but I couldn’t find a
> better way to explain it in prose.

I think either way is only an approximation of the rules, since
neither one accounts for the rule (at the end of the same paragraph,
in CSS 2.1) that describes what happens when the quotes nesting
level is attempted to be reduced below 0.  I think it might make
more sense to reword things so that part of the paragraph is an
approximate summary of the behavior, followed by an exact set of
rules.  For example:

  'Open-quote' refers to the first of a pair of quotes,
  'close-quote' refers to the second. Which pair of quotes is used
  depends on the nesting level of quotes.  The nesting level begins
  at 0 at the start of the document, and then, by a depth-first
  traversal of the document, it is incremented at every occurrence
  of 'open-quote' or 'no-open-quote', and decremented at every
  occurrence of 'close-quote' or 'no-close-quote' other than those
  that would make it negative.  The quotation mark rendered for an
  open-quote is the first quotation mark in the pair of quotes at
  the nesting level after that open-quote, unless that nesting level
  is greater than the number of pairs, in which case the first
  quotation mark in the last pair is repeated.  Likewise, for
  close-quote, the quotation mark rendered is the second quotation
  mark in the pair of quotes at the nesting level before that
  close-quote, unless that nesting level is greater than the number
  of pairs, in which case the second quotation mark in the last pair
  is repeated, or unless that depth is 0, in which case no quotation
  mark is rendered.


> For example, if a sequence of quotes is:
> 
>     open   open close   open  open close  close   close
>    (spacing added for clarity)
> 
> Then we want the nesting levels to be, respectively:
> 
>     0      1    1      1     2    2     1      0
>     =0-0   =1-0 =2-1   =2-1  =3-1 =4-2  =4-3   =4-4
> 
> The algorithm to implement this cloud be:
> 
>     nesting_level = 0
>     for each occurrence of *-quote in content:
>         if it is close-quote or no-close-quote:
>             decrement nesting_level (with a minimum at 0)
>         if it is open-close or close-quote:
>             insert the quote at nesting_level
>         if it is open-quote or no-open-quote:
>             increment nesting_level
> 
> The order in which each of the three operations must be done is
> important but not intuitive. The current prose did not help at all
> to get at it.

That's not quite right, since it would insert a quote for a
close-quote that did not decrement the nesting level because it was
already 0.

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                           http://www.mozilla.org/   𝄂
Received on Tuesday, 6 December 2011 17:03:01 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:47 GMT