Skip to content

Commit f34e4d7

Browse files
committed
[css-color] Everything's syntax-highlighted now.
1 parent 1f4ad2c commit f34e4d7

2 files changed

Lines changed: 84 additions & 59 deletions

File tree

css-color/Overview.bs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Foreground Color: the 'color' property</h2>
7474
There are different ways to specify lime green:
7575

7676
<div class="example">
77-
<pre>
77+
<pre class="lang-css">
7878
em { color: lime; } /* color keyword */
7979
em { color: rgb(0,255,0); } /* RGB range 0-255 */
8080
</pre>
@@ -623,7 +623,7 @@ The ''currentcolor'' keyword</h3>
623623
<div class='example'>
624624
Here's a simple example showing how to use the ''currentcolor'' keyword:
625625

626-
<pre>
626+
<pre class="lang-css">
627627
.foo {
628628
color: red;
629629
background-color: currentcolor;
@@ -632,7 +632,7 @@ The ''currentcolor'' keyword</h3>
632632

633633
This is equivalent to writing:
634634

635-
<pre>
635+
<pre class="lang-css">
636636
.foo {
637637
color: red;
638638
background-color: red;
@@ -890,7 +890,7 @@ HSL Colors: ''hsl()'' and ''hsla()'' functions</h2>
890890
For example, the following colors can all be generated off of the basic "green" hue,
891891
just by varying the other two arguments:
892892

893-
<pre class='literal'>
893+
<pre>
894894
hsl(120, 100%, 50%) <span style="color:black; background:hsl(120,100%,50%);">lime green</span>
895895
hsl(120, 100%, 25%) <span style="color:white; background:hsl(120,100%,25%);">dark green</span>
896896
hsl(120, 100%, 75%) <span style="color:black; background:hsl(120,100%,75%);">light green</span>
@@ -1618,7 +1618,7 @@ Specifying Grays: the ''gray()'' functional notation</h2>
16181618
''gray(A)'' represents the same color as ''rgb(A,A,A)''.
16191619
''gray(A,B)'' represents the same color as ''rgb(A,A,A,B)''.
16201620

1621-
<div class='issue'>
1621+
<div class='issue lang-javascript'>
16221622
<a>gray()</a> should have a keyword arg that opts it into smarter modes.
16231623
"luminance", for example, instead of being a simple expansion to ''rgb()'',
16241624
could actually compute the gray with the specified luminance.
@@ -1725,7 +1725,7 @@ Converting Between CMYK and RGB-Based Colors</h3>
17251725
(converting it to RGB as well, if necessary).
17261726
Otherwise:
17271727

1728-
<ul>
1728+
<ul class="lang-javascript">
17291729
<li><code>red = 1 - min(1, cyan * (1 - black) + black)</code>
17301730
<li><code>green = 1 - min(1, magenta * (1 - black) + black)</code>
17311731
<li><code>blue = 1 - min(1, yellow * (1 - black) + black)</code>
@@ -1734,11 +1734,11 @@ Converting Between CMYK and RGB-Based Colors</h3>
17341734

17351735
To <dfn title="naively convert from RGBA to CMYK | naively converted to CMYK">naively convert from RGBA to CMYK</dfn>:
17361736

1737-
<ul>
1738-
<li>black = 1 - max(red, green, blue)
1739-
<li>cyan = (1 - red - black) / (1 - black), or 0 if black is 1
1740-
<li>magenta = (1 - green - black) / (1 - black), or 0 if black is 1
1741-
<li>yellow = (1 - blue - black) / (1 - black), or 0 if black is 1
1737+
<ul class="lang-javascript">
1738+
<li><code>black = 1 - max(red, green, blue)</code>
1739+
<li><code>cyan = (1 - red - black) / (1 - black), or 0 if black is 1</code>
1740+
<li><code>magenta = (1 - green - black) / (1 - black), or 0 if black is 1</code>
1741+
<li><code>yellow = (1 - blue - black) / (1 - black), or 0 if black is 1</code>
17421742
<li>alpha is the same as the input color
17431743
<li>fallback color must be set to the input color
17441744
</ul>
@@ -1847,7 +1847,7 @@ Modifying Colors: the ''color()'' function</h2>
18471847
<div class='example'>
18481848
For example, here's a possible ''color()'' function that lightens and brightens the <var>base color</var>:
18491849

1850-
<pre>color(X w(+ 20%) s(+ 20%))</pre>
1850+
<pre class="lang-css">color(X w(+ 20%) s(+ 20%))</pre>
18511851

18521852
If X is a color like ''blue'',
18531853
this works in the expected way -
@@ -2087,7 +2087,7 @@ Color Blending: the ''blend'' and ''blenda'' adjusters</h3>
20872087
To achieve counter-clockwise behavior,
20882088
adjust either color's hue angle by a small amount toward the desired direction.
20892089

2090-
<div class='example'>
2090+
<div class='example lang-javascript'>
20912091
For example, blending ''yellow'' (hue angle ''60deg'') with 50% ''purple'' (hue angle ''300deg'')
20922092
results in ''red'' (hue angle ''0deg''),
20932093
not ''cyan'' (hue angle ''180deg''),
@@ -2098,7 +2098,7 @@ Color Blending: the ''blend'' and ''blenda'' adjusters</h3>
20982098

20992099

21002100
<dt>''blenda( <<color>> <<percentage>> [rgb | hsl | hwb]? )''
2101-
<dd>
2101+
<dd class="lang-javascript">
21022102
Identical to the previous clause,
21032103
except it pays attention to the alpha channel of the two colors
21042104
(''blend()'' just preserves the alpha channel of the <var>base color</var>).
@@ -2195,7 +2195,7 @@ Guaranteeing Adequate Contrast: the ''contrast'' adjuster</h3>
21952195
<p>
21962196
To compute the <dfn>luminance</dfn> of a color:
21972197

2198-
<ol>
2198+
<ol class="lang-javascript">
21992199
<li>
22002200
Scale the red, green, and blue channels of the color to the range [0,1].
22012201

@@ -2224,7 +2224,7 @@ Guaranteeing Adequate Contrast: the ''contrast'' adjuster</h3>
22242224
<p>
22252225
To compute the <dfn>contrast ratio</dfn> of two colors:
22262226

2227-
<ol>
2227+
<ol class="lang-javascript">
22282228
<li>
22292229
Compute the <a>luminance</a> of both colors.
22302230

@@ -3317,7 +3317,7 @@ Adding New Color-Manipulating Methods</h4>
33173317
To add a method of this type,
33183318
follow these steps:
33193319

3320-
<ol>
3320+
<ol class="lang-javascript">
33213321
<li>
33223322
Define the method for {{RGBColor}}s,
33233323
by adding it to <code>{{RGBColor}}.prototype</code>.
@@ -3344,12 +3344,12 @@ Adding New Color-Manipulating Methods</h4>
33443344
directly on the prototype of the color classes you're interested in.
33453345
</ol>
33463346

3347-
<div class='example'>
3347+
<div class='example lang-javascript'>
33483348
For example,
3349-
here's how you would add a "lightness" method to all color classes,
3349+
here's how you would add a <code>lightness()</code> method to all color classes,
33503350
which computes the approximate perceptual lightness of a color:
33513351

3352-
<pre class="lang-javascript">
3352+
<pre>
33533353
RGBColor.prototype.lightness = function() {
33543354
return .2126 * Math.pow(this.r, 2.2) +
33553355
.7152 * Math.pow(this.g, 2.2) +
@@ -3383,7 +3383,7 @@ Adding New Color Classes</h4>
33833383
To work correctly with the rest of the color classes,
33843384
a new color class <em>must</em>:
33853385

3386-
<ol>
3386+
<ol class="lang-javascript">
33873387
<li>
33883388
Subclass {{CSSColor}},
33893389
such as via:
@@ -3482,7 +3482,7 @@ Adding New Color Classes</h4>
34823482
however,
34833483
to get maximum value and consistency with the CSS-defined color classes:
34843484

3485-
<ul>
3485+
<ul class="lang-javascript">
34863486
<li>
34873487
A constructor that builds the color with multiple arguments
34883488
(typically the color's properties, in some order, with alpha optional and last).
@@ -3510,7 +3510,7 @@ Adding New Color Classes</h4>
35103510
If your class is very similar to an existing class,
35113511
such that you can do a better/faster conversion between the existing class and yours directly
35123512
rather than doing through {{RGBColor}} first,
3513-
an <code>toMyColor()</code> method on <code>TheOtherColor.prototype</code>,
3513+
a <code>toMyColor()</code> method on <code>TheOtherColor.prototype</code>,
35143514
and a <code>toTheOtherColor()</code> method on <code>MyNewColor.prototype</code>.
35153515
Add cases to your constructor to handle these classes as well.
35163516

@@ -3685,24 +3685,24 @@ The CSSColor Object</h3>
36853685
which is a helper function for adding new methods to all color classes
36863686
(see [[#api-adding-methods]] for more detail on using this function).
36873687

3688-
<div class='example'>
3688+
<div class='example lang-javascript'>
36893689
The most common use of this interface is to parse color strings into an appropriate color object.
36903690

36913691
The following code sets <code>color</code> to a {{HexColor}} object:
36923692

3693-
<pre class="lang-javascript">var color = CSSColor.parse("#96c");</pre>
3693+
<pre>var color = CSSColor.parse("#96c");</pre>
36943694

36953695
While this code sets <code>color</code> to an {{HSLColor}} object:
36963696

3697-
<pre class="lang-javascript">var color = CSSColor.parse("hsl(120deg, 100%, 50%)");</pre>
3697+
<pre>var color = CSSColor.parse("hsl(120deg, 100%, 50%)");</pre>
36983698

36993699
Note that this returns a color class matching the type of input provided to it.
37003700
If a particular color class is desired,
37013701
the class's constructor can be passed a string instead.
37023702
For example, the following will set <code>color</code> to an {{RGBColor}} object,
37033703
even though it uses the ''hsl()'' function:
37043704

3705-
<pre class="lang-javascript">var color = new RGBColor("hsl(120deg, 100%, 50%)")</pre>
3705+
<pre>var color = new RGBColor("hsl(120deg, 100%, 50%)")</pre>
37063706
</div>
37073707

37083708
<pre class='idl'>
@@ -3743,6 +3743,7 @@ The CSSColor Object</h3>
37433743
DOMString <dfn argument for="CSSColor/parse()">css</dfn>,
37443744
Element <dfn argument for="CSSColor/parse()">el</dfn>)
37453745
<dd>
3746+
37463747
Issue: Should parse the string,
37473748
returning the appropriate CSSColor subclass
37483749
depending on how the color was written.

0 commit comments

Comments
 (0)