Skip to content

Commit db1eaef

Browse files
committed
Rewrite white space chapter using a unified concept of 'segment break'.
1 parent 6d7c8f3 commit db1eaef

2 files changed

Lines changed: 110 additions & 112 deletions

File tree

css3-text/Overview.html

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232

3333
<h1>CSS Text Level 3</h1>
3434

35-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 13 January
35+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 14 January
3636
2012</h2>
3737

3838
<dl>
3939
<dt>This version:
4040

41-
<dd><a href="http://dev.w3.org/csswg/css3-text/">$Date: 2012/01/12
42-
23:36:47 $ (CVS $Revision$)</a> <!--
43-
<dd><a href="http://www.w3.org/TR/2012/WD-css3-text-20120113/">http://www.w3.org/TR/2012/WD-css3-text-20120113/</a></dd>
41+
<dd><a href="http://dev.w3.org/csswg/css3-text/">$Date: 2012/01/13
42+
02:00:08 $ (CVS $Revision$)</a> <!--
43+
<dd><a href="http://www.w3.org/TR/2012/WD-css3-text-20120114/">http://www.w3.org/TR/2012/WD-css3-text-20120114/</a></dd>
4444
-->
4545

4646

@@ -226,10 +226,7 @@ <h2 class="no-num no-toc" id=contents> Table of Contents</h2>
226226
Example of bidirectionality with white space collapsing</a>
227227

228228
<li><a href="#line-break-transform"><span class=secno>3.3.2. </span>
229-
Line Feed Transformation Rules</a>
230-
231-
<li><a href="#white-space-summary"><span class=secno>3.3.3. </span>
232-
Informative Summary of White Space Collapsing Effects</a>
229+
Line Break Transformation Rules</a>
233230
</ul>
234231

235232
<li><a href="#white-space"><span class=secno>3.4. </span> White Space
@@ -670,21 +667,18 @@ <h2 id=white-space-processing><span class=secno>3. </span> White Space
670667
segments (lines) for ease of editing or adding white space characters such
671668
as tabs and spaces to indent the source code. CSS white space processing
672669
allows the author to control interpretation of such formatting: to
673-
preserve or collapse it away when rendering the document.
674-
675-
<p id=segment-normalization> In the document source, segments can be
676-
delimited by carriage returns (U+000D), linefeeds (U+000A) or a
677-
combination (U+000D U+000A), or by some other mechanism, such as the SGML
678-
RECORD-START and RECORD-END tokens. If no segmentation rules are specified
679-
for the document language, each line feed (U+000A), carriage return
680-
(U+000D) and CRLF sequence (U+000D U+000A) in the text is considered a
681-
segment break. (This default rule also applies to generated content.) In
682-
CSS, each such segment break is treated as a single line feed character
683-
(U+000A).
684-
685-
<p>White space processing in CSS interprets white space characters only for
670+
preserve or collapse it away when rendering the document. Note that white
671+
space processing in CSS interprets white space characters only for
686672
rendering: it has no effect on the underlying document data.
687673

674+
<p id=segment-normalization> CSS does not define document segmentation
675+
rules. Segments could be separated by a particular newline seqence (such
676+
as a line feed or CRLF pair), or delimited by some other mechanism, such
677+
as the SGML RECORD-START and RECORD-END tokens. For CSS processing, each
678+
document-defined segment break, CRLF sequence (U+000D U+000A), carriage
679+
return (U+000D), and line feed (U+000A) in the text is treated as a
680+
segment break, which is then interpreted for rendering as defined below.
681+
688682
<p class=note>Note that the document parser may have not only normalized
689683
segment breaks, but also collapsed other space characters or otherwise
690684
processed white space according to markup rules. Because CSS processing
@@ -762,17 +756,32 @@ <h3 id=white-space-collapsing><span class=secno>3.1. </span> White Space
762756
class=css>preserve</code>&rsquo;</dfn>
763757

764758
<dd>This value prevents user agents from collapsing sequences of white
765-
space. Line feeds are preserved as forced line breaks.
759+
space. Segment breaks such as line feeds and carriage returns are
760+
preserved as forced line breaks.
766761

767762
<dt><dfn id=preserve-breaks
768763
title="white-space:preserve-breaks">&lsquo;<code
769764
class=css>preserve-breaks</code>&rsquo;</dfn>
770765

771-
<dd>This value collapses white space as for &lsquo;<code
772-
class=css>collapse</code>&rsquo;, but preserves line feeds as forced line
773-
breaks.
766+
<dd>This value collapses consecutive spaces, but renders segment breaks as
767+
forced line breaks.
774768
</dl>
775769

770+
<p>See <a href="#white-space-processing">White Space Processing Rules</a>
771+
for details on how white space collapses. An informative summary of
772+
&lsquo;<code class=css>collapse</code>&rsquo; is presented below:
773+
774+
<ul>
775+
<li>A sequence of segment breaks and other white space between two
776+
Chinese, Japanese, or Yi characters collapses into nothing.
777+
778+
<li>A zero width space before or after a white space sequence containing a
779+
segment break causes the entire sequence of white space to collapse into
780+
a zero width space.
781+
782+
<li>Otherwise, consecutive white space collapses into a single space.
783+
</ul>
784+
776785
<h3 id=tab-size><span class=secno>3.2. </span> Tab Character Size: the
777786
&lsquo;<a href="#tab-size0"><code
778787
class=property>tab-size</code></a>&rsquo; property</h3>
@@ -828,8 +837,7 @@ <h3 id=white-space-rules><span class=secno>3.3. </span> The White Space
828837
Processing Rules</h3>
829838

830839
<p>White space processing affects only spaces (U+0020), tabs (U+0009), and
831-
(<a href="#segment-normalization">post-normalization</a>) line feeds
832-
(U+00A0).
840+
<a href="#segment-normalization">segment breaks</a>.
833841

834842
<p>For each inline (including anonymous inlines) within an inline
835843
formatting context, white space characters are handled as follows,
@@ -845,21 +853,20 @@ <h3 id=white-space-rules><span class=secno>3.3. </span> The White Space
845853
performing the following steps:</p>
846854

847855
<ol>
848-
<li>All spaces and tabs immediately preceding or following a line feed
849-
character are removed.
856+
<li>All spaces and tabs immediately preceding or following a segment
857+
break are removed.
850858

851-
<li>If &lsquo;<a href="#text-space-collapse"><code
852-
class=property>text-space-collapse</code></a>&rsquo; is not
853-
&lsquo;<code class=css>preserve-breaks</code>&rsquo;, line feed
854-
characters are transformed for rendering according to the <a
855-
href="#line-break-transform">line feed transformation rules</a>.
859+
<li>Segment breaks are transformed for rendering according to the <a
860+
href="#line-break-transform">line break transformation rules</a>.
856861

857862
<li>Every tab is converted to a space (U+0020).
858863

859864
<li>Any space immediately following another collapsible space
860-
&mdash;even one outside the boundary of the inline&mdash;is removed.
861-
However, if removing this space would eliminate a line breaking
862-
opportunity in the text, that opportunity is still considered to exist.
865+
&mdash;even one outside the boundary of the inline containing the
866+
space, provided they are within the same inline formatting
867+
context&mdash;is removed. However, if removing this space would
868+
eliminate a line breaking opportunity in the text, that opportunity is
869+
still considered to exist.
863870
</ol>
864871

865872
<li>
@@ -946,48 +953,40 @@ <h4 id=egbidiwscollapse><span class=secno>3.3.1. </span> Example of
946953
on implicit bidirectionality instead of explicit embedding levels.</p>
947954
</div>
948955

949-
<h4 id=line-break-transform><span class=secno>3.3.2. </span> Line Feed
956+
<h4 id=line-break-transform><span class=secno>3.3.2. </span> Line Break
950957
Transformation Rules</h4>
951958

952-
<p>When line feeds are <a href="#collapse">collapsible</a>, they are either
953-
transformed into a space (U+0020) or removed depending on the context
954-
before and after the line break.
959+
<p>When &lsquo;<a href="#text-space-collapse"><code
960+
class=property>text-space-collapse</code></a>&rsquo; is &lsquo;<code
961+
class=css>preserve-breaks</code>&rsquo;, segment breaks are not <a
962+
href="#collapsible"><i>collapsible</i></a> and are transformed into a
963+
preserved line feed (U+000A).
964+
965+
<p>When segment breaks are <a href="#collapsible"><i>collapsible</i></a>,
966+
they are either transformed into a space (U+0020) or removed depending on
967+
the context before and after the break.
955968

956969
<p class=note>Note that the white space processing rules have already
957-
removed any tabs and spaces after the line feed before these checks take
958-
place.
970+
removed any tabs and spaces after the segment break before these checks
971+
take place.
959972

960973
<ul>
961-
<li>If the character immediately before or immediately after the line feed
962-
is the zero width space character (U+200B), then the line feed is
963-
removed.
974+
<li>If the character immediately before or immediately after the segment
975+
break is the zero-width space character (U+200B), then the break is
976+
removed, leaving behind the zero-width space.
964977

965978
<li>Otherwise, if the East Asian Width property <a href="#UAX11"
966979
rel=biblioentry>[UAX11]<!--{{!UAX11}}--></a> of both the character before
967980
and after the line feed is F, W, or H (not A), and neither side is
968-
Hangul, then the line feed is removed.
981+
Hangul, then the segment break is removed.
969982

970-
<li>Otherwise, the line feed is converted to a space (U+0020).
983+
<li>Otherwise, the segment break is converted to a space (U+0020).
971984
</ul>
972985

973986
<p class=issue>Comments on how well this would work in practice would be
974987
very much appreciated, particularly from people who work with Thai and
975988
similar scripts.
976989

977-
<h4 id=white-space-summary><span class=secno>3.3.3. </span> Informative
978-
Summary of White Space Collapsing Effects</h4>
979-
980-
<ul>
981-
<li>Consecutive white space collapses into a single space.
982-
983-
<li>A sequence of newlines and other white space between two Chinese,
984-
Japanese, or Yi characters collapses into nothing.
985-
986-
<li>A zero width space before or after a white space sequence containing a
987-
newline causes the entire sequence of white space to collapse into a zero
988-
width space.
989-
</ul>
990-
991990
<h3 id=white-space><span class=secno>3.4. </span> White Space and Text
992991
Wrapping Shorthand: the &lsquo;<a href="#white-space0"><code
993992
class=property>white-space</code></a>&rsquo; property</h3>

css3-text/Overview.src.html

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -353,24 +353,19 @@ <h2 id="white-space-processing">
353353
white space characters such as tabs and spaces to indent the
354354
source code. CSS white space processing allows the author to
355355
control interpretation of such formatting: to preserve or
356-
collapse it away when rendering the document.
356+
collapse it away when rendering the document. Note that white
357+
space processing in CSS interprets white space characters only
358+
for rendering: it has no effect on the underlying document data.
357359

358360
<p id="segment-normalization">
359-
In the document source, segments can be delimited by carriage
360-
returns (U+000D), linefeeds (U+000A) or a combination (U+000D U+000A),
361-
or by some other mechanism, such as the SGML RECORD-START
362-
and RECORD-END tokens.
363-
364-
If no segmentation rules are specified for the document language,
365-
each line feed (U+000A), carriage return (U+000D) and CRLF sequence
366-
(U+000D U+000A) in the text is considered a segment break. (This
367-
default rule also applies to generated content.)
368-
369-
In CSS, each such segment break is treated as a single line feed
370-
character (U+000A).
371-
372-
<p>White space processing in CSS interprets white space characters
373-
only for rendering: it has no effect on the underlying document data.
361+
CSS does not define document segmentation rules. Segments could be
362+
separated by a particular newline seqence (such as a line feed or
363+
CRLF pair), or delimited by some other mechanism, such as the SGML
364+
RECORD-START and RECORD-END tokens.
365+
For CSS processing, each document-defined segment break, CRLF sequence
366+
(U+000D U+000A), carriage return (U+000D), and line feed (U+000A)
367+
in the text is treated as a segment break, which is then interpreted
368+
for rendering as defined below.
374369

375370
<p class="note">Note that the document parser may have not only normalized
376371
segment breaks, but also collapsed other space characters or
@@ -437,12 +432,26 @@ <h3 id="white-space-collapsing">
437432
cases</a>, no character).</dd>
438433
<dt><dfn title="white-space:preserve">''preserve''</dfn></dt>
439434
<dd>This value prevents user agents from collapsing sequences
440-
of white space. Line feeds are preserved as forced line breaks.</dd>
435+
of white space. Segment breaks such as line feeds and carriage returns
436+
are preserved as forced line breaks.</dd>
441437
<dt><dfn title="white-space:preserve-breaks">''preserve-breaks''</dfn></dt>
442-
<dd>This value collapses white space as for ''collapse'', but preserves
443-
line feeds as forced line breaks.</dd>
438+
<dd>This value collapses consecutive spaces, but renders segment
439+
breaks as forced line breaks.</dd>
444440
</dl>
445441

442+
<p>See <a href="#white-space-processing">White Space Processing Rules</a>
443+
for details on how white space collapses. An informative summary of
444+
''collapse'' is presented below:
445+
<ul>
446+
<li>A sequence of segment breaks and other white space between two
447+
Chinese, Japanese, or Yi characters collapses into nothing.
448+
<li>A zero width space before or after a white space sequence
449+
containing a segment break causes the entire sequence of white space
450+
to collapse into a zero width space.
451+
<li>Otherwise, consecutive white space collapses into a single space.
452+
</ul>
453+
454+
446455
<h3 id="tab-size">
447456
Tab Character Size: the 'tab-size' property</h3>
448457

@@ -491,8 +500,7 @@ <h3 id="white-space-rules">
491500
The White Space Processing Rules</h3>
492501

493502
<p>White space processing affects only spaces (U+0020), tabs (U+0009),
494-
and (<a href="#segment-normalization">post-normalization</a>)
495-
line feeds (U+00A0).
503+
and <a href="#segment-normalization">segment breaks</a>.
496504

497505
<p>For each inline (including anonymous inlines) within an inline
498506
formatting context, white space characters are handled as follows,
@@ -504,17 +512,17 @@ <h3 id="white-space-rules">
504512
are considered <dfn>collapsible</dfn> and are processed by
505513
performing the following steps:</p>
506514
<ol>
507-
<li>All spaces and tabs immediately preceding or following a line
508-
feed character are removed.</li>
509-
<li>If 'text-space-collapse' is not
510-
''preserve-breaks'', line feed characters are transformed for
515+
<li>All spaces and tabs immediately preceding or following a segment
516+
break are removed.</li>
517+
<li>Segment breaks are transformed for
511518
rendering according to the <a href="#line-break-transform">line
512-
feed transformation rules</a>.
519+
break transformation rules</a>.
513520
</li>
514521
<li>Every tab is converted to a space (U+0020).</li>
515522
<li>Any space immediately following another collapsible space
516-
&mdash;even one outside the boundary of the inline&mdash;is
517-
removed.
523+
&mdash;even one outside the boundary of the inline containing
524+
the space, provided they are within the same inline formatting
525+
context&mdash;is removed.
518526
However, if removing this space would eliminate a line breaking
519527
opportunity in the text, that opportunity is still considered
520528
to exist.</li>
@@ -587,43 +595,34 @@ <h4 id="egbidiwscollapse">
587595
</div>
588596

589597
<h4 id="line-break-transform">
590-
Line Feed Transformation Rules</h4>
598+
Line Break Transformation Rules</h4>
599+
600+
<p>When 'text-space-collapse' is ''preserve-breaks'', segment breaks are
601+
not <i>collapsible</i> and are transformed into a preserved line feed
602+
(U+000A).
591603

592-
<p>When line feeds are <a href="#collapse">collapsible</a>, they are
604+
<p>When segment breaks are <i>collapsible</i>, they are
593605
either transformed into a space (U+0020) or removed depending on the
594-
context before and after the line break.</p>
606+
context before and after the break.</p>
595607

596608
<p class="note">Note that the white space processing rules have already
597-
removed any tabs and spaces after the line feed before these checks
609+
removed any tabs and spaces after the segment break before these checks
598610
take place.</p>
599611

600612
<ul>
601-
<li>If the character immediately before or immediately after the line
602-
feed is the zero width space character (U+200B), then the line feed
603-
is removed.
613+
<li>If the character immediately before or immediately after the segment
614+
break is the zero-width space character (U+200B), then the break
615+
is removed, leaving behind the zero-width space.
604616
<li>Otherwise, if the East Asian Width property [[!UAX11]] of both
605617
the character before and after the line feed is F, W, or H (not A),
606-
and neither side is Hangul,
607-
then the line feed is removed.
608-
<li>Otherwise, the line feed is converted to a space (U+0020).
618+
and neither side is Hangul, then the segment break is removed.
619+
<li>Otherwise, the segment break is converted to a space (U+0020).
609620
</ul>
610621

611622
<p class="issue">Comments on how well this would work in practice would
612623
be very much appreciated, particularly from people who work with
613624
Thai and similar scripts.</p>
614625

615-
<h4 id="white-space-summary">
616-
Informative Summary of White Space Collapsing Effects</h4>
617-
618-
<ul>
619-
<li>Consecutive white space collapses into a single space.
620-
<li>A sequence of newlines and other white space between two
621-
Chinese, Japanese, or Yi characters collapses into nothing.
622-
<li>A zero width space before or after a white space sequence
623-
containing a newline causes the entire sequence of white space
624-
to collapse into a zero width space.
625-
</ul>
626-
627626
<h3 id="white-space">
628627
White Space and Text Wrapping Shorthand: the 'white-space' property</h3>
629628

0 commit comments

Comments
 (0)