8000 move some common serializing algorithms up · w3c/csswg-drafts@548a343 · GitHub
Skip to content

Commit 548a343

Browse files
committed
move some common serializing algorithms up
1 parent fdf7719 commit 548a343

2 files changed

Lines changed: 128 additions & 128 deletions

File tree

cssom/Overview.html

Lines changed: 75 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ <h2 class="no-num no-toc" id=toc>Table of Contents</h2>
9191

9292
<li><a href="#conformance"><span class=secno>2.2. </span>Conformance
9393
Requirements</a>
94+
95+
<li><a href="#common-serializing-idioms"><span class=secno>2.3.
96+
</span>Common Serializing Idioms</a>
9497
</ul>
9598

9699
<li><a href="#media-queries"><span class=secno>3. </span>Media Queries</a>
@@ -331,6 +334,78 @@ <h3 id=conformance><span class=secno>2.2. </span>Conformance Requirements</h3>
331334
</dl>
332335
-->
333336

337+
<h3 id=common-serializing-idioms><span class=secno>2.3. </span>Common
338+
Serializing Idioms</h3>
339+
340+
<p>To <dfn id=escape-a-character>escape a character</dfn> means to create a
341+
string of "<code>\</code>" (U+005C), followed by the character.
342+
343+
<p>To <dfn id=escape-a-character-as-code-point>escape a character as code
344+
point</dfn> means to create a string of "<code>\</code>" (U+005C),
345+
followed by the Unicode code point as the smallest possible number of
346+
hexadecimal digits in the range 0-9 a-f (U+0030 to U+0039 and U+0061 to
347+
U+0066) to represent the code point in base 16, followed by a space
348+
(U+0020).
349+
350+
<p>To <dfn id=escape-an-identifier>escape an identifier</dfn> means to
351+
create a string represented by the concatenation of, for each character of
352+
the identifier:
353+
354+
<ul>
355+
<li>If the character is in the range U+0000 to U+001F, the character <a
356+
href="#escape-a-character-as-code-point" title="escape a character as
357+
code point">escaped as code point</a>.
358+
359+
<li>If the character is the first character and is in the range 0-9
360+
(U+0030 to U+0039), the character <a
361+
href="#escape-a-character-as-code-point" title="escape a character as
362+
code point">escaped as code point</a>.
363+
364+
<li>If the character is the second character and is in the range 0-9
365+
(U+0030 to U+0039) and the first character is a "<code>-</code>"
366+
(U+002D), the character <a href="#escape-a-character-as-code-point"
367+
title="escape a character as code point">escaped as code point</a>.
368+
369+
<li>If the character is the second character and is "<code>-</code>"
370+
(U+002D) and the first character is "<code>-</code>" too, the <a
371+
href="#escape-a-character" title="escape a character">escaped</a>
372+
character.
373+
374+
<li>If the character is not handled by one of the above rules and is
375+
greater than or equal to U+0080, is "<code>-</code>" (U+002D) or
376+
"<code>_</code>" (U+005F), or is in one of the ranges 0-9 (U+0030 to
377+
U+0039), A-Z (U+0041 to U+005A), or a-z (U+0061 to U+007A), the character
378+
itself.
379+
380+
<li>Otherwise, the <a href="#escape-a-character" title="escape a
381+
character">escaped</a> character.
382+
</ul>
383+
384+
<p>To <dfn id=escape-a-string>escape a string</dfn> means to create a
385+
string represented by '<code>"</code>' (U+0022), followed by the result of
386+
applying the rules below to each character of the given string, followed
387+
by '<code>"</code>' (U+0022):
388+
389+
<ul>
390+
<li>If the character is in the range U+0000 to U+001F, the character <a
391+
href="#escape-a-character-as-code-point" title="escape a character as
392+
code point">escaped as code point</a>.
393+
394+
<li>If the character is '<code>"</code>' (U+0022) or '<code>\</code>'
395+
(U+005C), the <a href="#escape-a-character" title="escape a
396+
character">escaped</a> character.
397+
398+
<li>Otherwise, the character itself.
399+
</ul>
400+
401+
<p class=note>"<code>'</code>" (U+0027) is not escaped because strings are
402+
always serialized with '<code>"</code>' (U+0022).
403+
404+
<p>To <dfn id=escape-a-url>escape a URL</dfn> means to create a string
405+
represented by "<code title="">url(</code>", followed by the <a
406+
href="#escape-a-string" title="escape a string">string escaped</a> value
407+
of the given string, followed by "<code>)</code>".
408+
334409
<h2 id=media-queries><span class=secno>3. </span>Media Queries</h2>
335410

336411
<p><dfn id="media queries">Media queries</dfn> are defined by the Media
@@ -3638,77 +3713,6 @@ <h4 id=serializing-css-values><span class=secno>5.6.2. </span>Serializing
36383713
CSS3/CSS4 timeline by moving the above definitions to the drafts that
36393714
define the CSS components.
36403715

3641-
<hr>
3642-
3643-
<p>To <dfn id=escape-a-character>escape a character</dfn> means to create a
3644-
string of "<code>\</code>" (U+005C), followed by the character.
3645-
3646-
<p>To <dfn id=escape-a-character-as-code-point>escape a character as code
3647-
point</dfn> means to create a string of "<code>\</code>" (U+005C),
3648-
followed by the Unicode code point as the smallest possible number of
3649-
hexadecimal digits in the range 0-9 a-f (U+0030 to U+0039 and U+0061 to
3650-
U+0066) to represent the code point in base 16, followed by a space
3651-
(U+0020).
3652-
3653-
<p>To <dfn id=escape-an-identifier>escape an identifier</dfn> means to
3654-
create a string represented by the concatenation of, for each character of
3655-
the identifier:
3656-
3657-
<ul>
3658-
<li>If the character is in the range U+0000 to U+001F, the character <a
3659-
href="#escape-a-character-as-code-point" title="escape a character as
3660-
code point">escaped as code point</a>.
3661-
3662-
<li>If the character is the first character and is in the range 0-9
3663-
(U+0030 to U+0039), the character <a
3664-
href="#escape-a-character-as-code-point" title="escape a character as
3665-
code point">escaped as code point</a>.
3666-
3667-
<li>If the character is the second character and is in the range 0-9
3668-
(U+0030 to U+0039) and the first character is a "<code>-</code>"
3669-
(U+002D), the character <a href="#escape-a-character-as-code-point"
3670-
title="escape a character as code point">escaped as code point</a>.
3671-
3672-
<li>If the character is the second character and is "<code>-</code>"
3673-
(U+002D) and the first character is "<code>-</code>" too, the <a
3674-
href="#escape-a-character" title="escape a character">escaped</a>
3675-
character.
3676-
3677-
<li>If the character is not handled by one of the above rules and is
3678-
greater than or equal to U+0080, is "<code>-</code>" (U+002D) or
3679-
"<code>_</code>" (U+005F), or is in one of the ranges 0-9 (U+0030 to
3680-
U+0039), A-Z (U+0041 to U+005A), or a-z (U+0061 to U+007A), the character
3681-
itself.
3682-
3683-
<li>Otherwise, the <a href="#escape-a-character" title="escape a
3684-
character">escaped</a> character.
3685-
</ul>
3686-
3687-
<p>To <dfn id=escape-a-string>escape a string</dfn> means to create a
3688-
string represented by '<code>"</code>' (U+0022), followed by the result of
3689-
applying the rules below to each character of the given string, followed
3690-
by '<code>"</code>' (U+0022):
3691-
3692-
<ul>
3693-
<li>If the character is in the range U+0000 to U+001F, the character <a
3694-
href="#escape-a-character-as-code-point" title="escape a character as
3695-
code point">escaped as code point</a>.
3696-
3697-
<li>If the character is '<code>"</code>' (U+0022) or '<code>\</code>'
3698-
(U+005C), the <a href="#escape-a-character" title="escape a
3699-
character">escaped</a> character.
3700-
3701-
<li>Otherwise, the character itself.
3702-
</ul>
3703-
3704-
<p class=note>"<code>'</code>" (U+0027) is not escaped because strings are
3705-
always serialized with '<code>"</code>' (U+0022).
3706-
3707-
<p>To <dfn id=escape-a-url>escape a URL</dfn> means to create a string
3708-
represented by "<code title="">url(</code>", followed by the <a
3709-
href="#escape-a-string" title="escape a string">string escaped</a> value
3710-
of the given string, followed by "<code>)</code>".
3711-
37123716
<h5 id=examples0><span class=secno>5.6.2.1. </span>Examples</h5>
37133717

37143718
<p>Here are some examples of before and after results on specified values.

cssom/Overview.src.html

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,62 @@ <h3 id="conformance">Conformance Requirements</h3>
157157
</dl>
158158
-->
159159

160+
<h3>Common Serializing Idioms</h3>
160161

162+
<p>To <dfn>escape a character</dfn> means to create a string of
163+
"<code>\</code>" (U+005C), followed by the character.</p>
164+
165+
<p>To <dfn>escape a character as code point</dfn> means to create a string
166+
of "<code>\</code>" (U+005C), followed by the Unicode code point as the
167+
smallest possible number of hexadecimal digits in the range 0-9 a-f
168+
(U+0030 to U+0039 and U+0061 to U+0066) to represent the code point in
169+
base 16, followed by a space (U+0020).</p>
170+
171+
<p>To <dfn>escape an identifier</dfn> means to create a string represented
172+
by the concatenation of, for each character of the identifier:</p>
173+
174+
<ul>
175+
<li>If the character is in the range U+0000 to U+001F, the character
176+
<span title="escape a character as code point">escaped as code point</span>.</li>
177+
<li>If the character is the first character and is in the range 0-9
178+
(U+0030 to U+0039), the character
179+
<span title="escape a character as code point">escaped as code point</span>.</li>
180+
<li>If the character is the second character and is in the range 0-9
181+
(U+0030 to U+0039) and the first character is a "<code>-</code>"
182+
(U+002D), the character
183+
<span title="escape a character as code point">escaped as code point</span>.</li>
184+
<li>If the character is the second character and is "<code>-</code>"
185+
(U+002D) and the first character is "<code>-</code>" too, the
186+
<span title="escape a character">escaped</span> character.</li>
187+
<li>If the character is not handled by one of the above rules and is
188+
greater than or equal to U+0080, is "<code>-</code>" (U+002D) or
189+
"<code>_</code>" (U+005F), or is in one of the ranges 0-9 (U+0030 to
190+
U+0039), A-Z (U+0041 to U+005A), or a-z (U+0061 to U+007A), the character
191+
itself.</li>
192+
<li>Otherwise, the <span title="escape a character">escaped</span>
193+
character.</li>
194+
</ul>
161195

196+
<p>To <dfn>escape a string</dfn> means to create a string represented by
197+
'<code>"</code>' (U+0022), followed by the result of applying the rules
198+
below to each character of the given string, followed by
199+
'<code>"</code>' (U+0022):</p>
162200

201+
<ul>
202+
<li>If the character is in the range U+0000 to U+001F, the character
203+
<span title="escape a character as code point">escaped as code point</span>.</li>
204+
<li>If the character is '<code>"</code>' (U+0022) or '<code>\</code>'
205+
(U+005C), the <span title="escape a character">escaped</span> character.</li>
206+
<li>Otherwise, the character itself.</li>
207+
</ul>
208+
209+
<p class="note">"<code>'</code>" (U+0027) is not escaped because strings
210+
are always serialized with '<code>"</code>' (U+0022).</p>
211+
212+
<p>To <dfn>escape a URL</dfn> means to create a string represented by
213+
"<code title="">url(</code>", followed by the
214+
<span title="escape a string">string escaped</span> value of the given
215+
string, followed by "<code>)</code>".</p>
163216

164217

165218

@@ -2307,63 +2360,6 @@ <h4>Serializing CSS Values</h4>
23072360
the CSS3/CSS4 timeline by moving the above definitions to the drafts that
23082361
define the CSS components.</p>
23092362

2310-
<hr>
2311-
2312-
<p>To <dfn>escape a character</dfn> means to create a string of
2313-
"<code>\</code>" (U+005C), followed by the character.</p>
2314-
2315-
<p>To <dfn>escape a character as code point</dfn> means to create a string
2316-
of "<code>\</code>" (U+005C), followed by the Unicode code point as the
2317-
smallest possible number of hexadecimal digits in the range 0-9 a-f
2318-
(U+0030 to U+0039 and U+0061 to U+0066) to represent the code point in
2319-
base 16, followed by a space (U+0020).</p>
2320-
2321-
<p>To <dfn>escape an identifier</dfn> means to create a string represented
2322-
by the concatenation of, for each character of the identifier:</p>
2323-
2324-
<ul>
2325-
<li>If the character is in the range U+0000 to U+001F, the character
2326-
<span title="escape a character as code point">escaped as code point</span>.</li>
2327-
<li>If the character is the first character and is in the range 0-9
2328-
(U+0030 to U+0039), the character
2329-
<span title="escape a character as code point">escaped as code point</span>.</li>
2330-
<li>If the character is the second character and is in the range 0-9
2331-
(U+0030 to U+0039) and the first character is a "<code>-</code>"
2332-
(U+002D), the character
2333-
<span title="escape a character as code point">escaped as code point</span>.</li>
2334-
<li>If the character is the second character and is "<code>-</code>"
2335-
(U+002D) and the first character is "<code>-</code>" too, the
2336-
<span title="escape a character">escaped</span> character.</li>
2337-
<li>If the character is not handled by one of the above rules and is
2338-
greater than or equal to U+0080, is "<code>-</code>" (U+002D) or
2339-
"<code>_</code>" (U+005F), or is in one of the ranges 0-9 (U+0030 to
2340-
U+0039), A-Z (U+0041 to U+005A), or a-z (U+0061 to U+007A), the character
2341-
itself.</li>
2342-
<li>Otherwise, the <span title="escape a character">escaped</span>
2343-
character.</li>
2344-
</ul>
2345-
2346-
<p>To <dfn>escape a string</dfn> means to create a string represented by
2347-
'<code>"</code>' (U+0022), followed by the result of applying the rules
2348-
below to each character of the given string, followed by
2349-
'<code>"</code>' (U+0022):</p>
2350-
2351-
<ul>
2352-
<li>If the character is in the range U+0000 to U+001F, the character
2353-
<span title="escape a character as code point">escaped as code point</span>.</li>
2354-
<li>If the character is '<code>"</code>' (U+0022) or '<code>\</code>'
2355-
(U+005C), the <span title="escape a character">escaped</span> character.</li>
2356-
<li>Otherwise, the character itself.</li>
2357-
</ul>
2358-
2359-
<p class="note">"<code>'</code>" (U+0027) is not escaped because strings
2360-
are always serialized with '<code>"</code>' (U+0022).</p>
2361-
2362-
<p>To <dfn>escape a URL</dfn> means to create a string represented by
2363-
"<code title="">url(</code>", followed by the
2364-
<span title="escape a string">string escaped</span> value of the given
2365-
string, followed by "<code>)</code>".</p>
2366-
23672363

23682364
<h5>Examples</h5>
23692365

0 commit comments

Comments
 (0)