Master

A dark mode as a rule set in one pass

A dark mode is not a style. It is a set of rules about colour, and a set of rules is what makes a page that was never designed still readable.

What you will see

two unanswered named. A count is what makes the gap a finding.

About 1 min of reading

Try It

Write rules as pairs

1

Write the pairs

printf 'white black\nblack white\n' > /tmp/p.txt; wc -l < /tmp/p.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
2. Two pairs is the rule set, which is a file.
2

Walk once

printf 'a b c\n' | wc -w

Before you run it, say out loud what it will print. Then open the answer.

What it prints
3. One walk answers three nodes, and the order does not matter.
3

Count the answered

printf 'nodes 30 answered 28\n' | awk '{print $4}' | awk '{print ($1<30) ? "two unanswered named" : "all answered"}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
two unanswered named. A count is what makes the gap a finding.

Data Flow

A rule set to one pass
1 The rules are written as pairs in a file
↓
2 The page is walked once
↓
3 Each node is answered by the pair that fits
↓
4 The pass counts the nodes it answered
Why this works
Why the rules are a file and not a name

A name is a decision nobody reads. A file of pairs is a decision that a reviewer counts line by line.

The one thing the pass never does

Read the page twice. Twice is two answers, and two answers is a page that changes itself.

Examples

The rules are written as pairs

A colour to a colour. A pair is a line, and a line is what a reader changes without touching a script.

The pass is one walk

One walk for every rule. One walk is what makes the order of the rules not matter.

An image is a rule too

An image has a colour in it. A rule about an image is a rule that a reader of the page can see.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Shipping with a review that names the reach
Previous Lesson
Shipping with a review that names the reach
Next Lesson
Running across many tabs as a queue
Running across many tabs as a queue →