polytypo 1.20.1 → 1.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/lib/polytypo/data/VERSION +1 -1
  3. data/lib/polytypo/data/fixtures/bg.json +23 -4
  4. data/lib/polytypo/data/fixtures/cs.json +20 -1
  5. data/lib/polytypo/data/fixtures/de-CH.json +23 -4
  6. data/lib/polytypo/data/fixtures/de-DE.json +124 -13
  7. data/lib/polytypo/data/fixtures/el.json +39 -4
  8. data/lib/polytypo/data/fixtures/en-GB.json +34 -7
  9. data/lib/polytypo/data/fixtures/en-US.json +988 -162
  10. data/lib/polytypo/data/fixtures/es.json +12 -1
  11. data/lib/polytypo/data/fixtures/fi.json +21 -2
  12. data/lib/polytypo/data/fixtures/fr-CA.json +20 -1
  13. data/lib/polytypo/data/fixtures/fr.json +57 -13
  14. data/lib/polytypo/data/fixtures/hr.json +20 -1
  15. data/lib/polytypo/data/fixtures/hu.json +39 -4
  16. data/lib/polytypo/data/fixtures/it.json +12 -1
  17. data/lib/polytypo/data/fixtures/locale-resolution.json +1 -1
  18. data/lib/polytypo/data/fixtures/lt.json +20 -1
  19. data/lib/polytypo/data/fixtures/nl.json +28 -1
  20. data/lib/polytypo/data/fixtures/pl.json +28 -1
  21. data/lib/polytypo/data/fixtures/pt-BR.json +20 -1
  22. data/lib/polytypo/data/fixtures/pt-PT.json +20 -1
  23. data/lib/polytypo/data/fixtures/ro.json +13 -2
  24. data/lib/polytypo/data/fixtures/ru.json +49 -6
  25. data/lib/polytypo/data/fixtures/sk.json +20 -1
  26. data/lib/polytypo/data/fixtures/sl.json +20 -1
  27. data/lib/polytypo/data/fixtures/sr.json +23 -4
  28. data/lib/polytypo/data/fixtures/sv.json +23 -4
  29. data/lib/polytypo/data/fixtures/tr.json +20 -1
  30. data/lib/polytypo/data/fixtures/uk.json +12 -1
  31. data/lib/polytypo/data/locales/bg.json +10 -1
  32. data/lib/polytypo/data/locales/cs.json +3 -0
  33. data/lib/polytypo/data/locales/de-CH.json +15 -1
  34. data/lib/polytypo/data/locales/de-DE.json +16 -1
  35. data/lib/polytypo/data/locales/el.json +10 -1
  36. data/lib/polytypo/data/locales/en-GB.json +16 -4
  37. data/lib/polytypo/data/locales/en-US.json +18 -11
  38. data/lib/polytypo/data/locales/es.json +3 -0
  39. data/lib/polytypo/data/locales/fi.json +9 -3
  40. data/lib/polytypo/data/locales/fr-CA.json +10 -1
  41. data/lib/polytypo/data/locales/fr.json +4 -1
  42. data/lib/polytypo/data/locales/hr.json +4 -1
  43. data/lib/polytypo/data/locales/hu.json +10 -1
  44. data/lib/polytypo/data/locales/it.json +3 -0
  45. data/lib/polytypo/data/locales/lt.json +13 -5
  46. data/lib/polytypo/data/locales/nl.json +11 -2
  47. data/lib/polytypo/data/locales/pl.json +11 -2
  48. data/lib/polytypo/data/locales/pt-BR.json +5 -2
  49. data/lib/polytypo/data/locales/pt-PT.json +6 -3
  50. data/lib/polytypo/data/locales/registry.json +1 -1
  51. data/lib/polytypo/data/locales/ro.json +3 -0
  52. data/lib/polytypo/data/locales/ru.json +10 -17
  53. data/lib/polytypo/data/locales/sk.json +8 -5
  54. data/lib/polytypo/data/locales/sl.json +4 -1
  55. data/lib/polytypo/data/locales/sr.json +10 -2
  56. data/lib/polytypo/data/locales/sv.json +9 -6
  57. data/lib/polytypo/data/locales/tr.json +5 -2
  58. data/lib/polytypo/data/locales/uk.json +3 -0
  59. data/lib/polytypo/data/rules/modes.md +2 -2
  60. data/lib/polytypo/data/rules/nbsp.md +271 -74
  61. data/lib/polytypo/data/rules/order.json +9 -1
  62. data/lib/polytypo/data/rules/pipeline-idempotency.md +76 -9
  63. data/lib/polytypo/data/rules/quote-punctuation.md +337 -0
  64. data/lib/polytypo/data/rules/quotes.md +23 -5
  65. data/lib/polytypo/data/rules/ranges.md +7 -1
  66. data/lib/polytypo/data/rules/spaces.md +4 -2
  67. data/lib/polytypo/data/rules/symbols.md +2 -1
  68. data/lib/polytypo/data/schema/fixtures.schema.json +1 -0
  69. data/lib/polytypo/data/schema/locale.schema.json +27 -2
  70. data/lib/polytypo/engine/locale.rb +22 -1
  71. data/lib/polytypo/engine/pipeline.rb +1 -1
  72. data/lib/polytypo/engine/rules/nbsp.rb +161 -11
  73. data/lib/polytypo/engine/rules/quote_punctuation.rb +79 -0
  74. data/lib/polytypo/engine/rules.rb +1 -0
  75. data/lib/polytypo/version.rb +1 -1
  76. metadata +3 -1
@@ -36,6 +36,7 @@ Write the pipeline as `T = R₈ ∘ R₇ ∘ … ∘ R₂ₐ ∘ R₂ ∘ R₁`,
36
36
  | R₃ | `dashes` | 30 |
37
37
  | R₄ | `hyphen` | 35 |
38
38
  | R₅ | `quotes` | 40 |
39
+ | R₅ₐ | `quote-punctuation` | 45 |
39
40
  | R₆ | `apostrophe` | 50 |
40
41
  | R₇ | `symbols` | 60 |
41
42
  | R₈ | `nbsp` | 70 |
@@ -47,9 +48,16 @@ below holds for any subset, in the same relative order.)
47
48
  subscripts in this document had been cited by name from eight other rule documents. Renumbering
48
49
  `R₃ … R₈` to make the sequence contiguous would rewrite every one of those references for no
49
50
  gain in meaning, so the rule takes the letter and the composition `T = R₈ ∘ R₇ ∘ … ∘ R₂ₐ ∘ … ∘ R₁`
50
- reads with it in place at order 25. `ranges` is also the one rule that is **off by default**, so
51
- for most callers the sequence is literally the eight numbered ones; every proof below is stated
52
- over "the rules that run", which is the subset the caller's `rules` option selected.
51
+ reads with it in place at order 25. `ranges` is also one of the two rules that are **off by
52
+ default** (the other is `quote-punctuation`, below), so for most callers the sequence is literally
53
+ the eight numbered ones; every proof below is stated over "the rules that run", which is the
54
+ subset the caller's `rules` option selected.
55
+
56
+ **Why `quote-punctuation` is `R₅ₐ`.** Same reason as `ranges`: it arrived in spec 1.21.0 between
57
+ two rules whose subscripts are cited by name from other documents. It is the second rule that is
58
+ **off by default**, so with both off the sequence is the eight numbered rules; every proof below
59
+ is stated over the rules that run. When it does run, `I₅` must also survive it (§3, `I₅ₐ`), and `quote-punctuation.md`
60
+ §5 carries its obligation against `I₁ … I₅`.
53
61
 
54
62
  For each rule define the predicate
55
63
 
@@ -126,7 +134,11 @@ U+0020 in the wider set emits none in the narrower one.
126
134
 
127
135
  **Who can violate it.** Only a rule that emits U+0020. In the current pipeline that is
128
136
  `dashes` alone (`-spaced` forms). `nbsp` emits U+00A0 and U+202F, which are `CONTENT` to
129
- `spaces` and are never touched. `quotes` (0.3.0) deletes a code point inside a quote pair when
137
+ `spaces` and are never touched. `nbsp` also deletes: since spec 1.22.0 N5 removes the single
138
+ separator between a `DIGIT` and a `closedUnits` entry. That separator has a `DIGIT` on its left
139
+ and, by `nbsp.md` §3.7 U2, a code point outside `SPACELIKE` on its right, so it is a run of
140
+ length one with no space beside it, and removing it lengthens, shortens, merges or re-neighbours
141
+ no other U+0020 run (`nbsp.md` §5, composition obligation against `I₁`). `quotes` (0.3.0) deletes a code point inside a quote pair when
130
142
  `innerSpace = "none"`, but never a U+0020 that survives the deletion — the maximal-run deletion
131
143
  and the landing guard together ensure the two surviving neighbours are always `CONTENT`
132
144
  (`quotes.md` 3.7, 5). Every other rule replaces code points one-for-one or shortens a run, and
@@ -181,7 +193,23 @@ whose two sides are a quote glyph and a `DELETE-LANDING` member — neither is a
181
193
  `CLOSED-SYMBOL`, so no range member's `before`/`after` moves. `symbols` (R₇) emits only U+00A9,
182
194
  U+00AE and U+2122 and deletes only a `(`…`)` span. `nbsp` (R₈) converts a space it found and
183
195
  never inserts one where a guard reads (`nbsp.md` §3.3), and U+00A0/U+202F satisfy none of G1, G2
184
- or G3.
196
+ or G3. N5's insertion and deletion (`nbsp.md` §3.7, 1.22.0) are the one place R₈ adds or removes
197
+ an `INLINE-SPACE` beside a `DIGIT` and a unit that may be a `CLOSED-SYMBOL`; guard G-R of that
198
+ section declines both whenever the first neighbour beyond the spaces, on either side, is a `DASH`
199
+ or `INERT-DASH`, which are the only positions where G1–G3 read that gap.
200
+
201
+ That discharge covers a unit whose first code point is in `CLOSED-SYMBOL` (`%`, `‰`, `°C`, the
202
+ currency signs), and only that: it is the only kind of unit that `ranges` §3.2a and T1's p1/p2
203
+ step over. A unit such as `km` or `kg` is **not read** by `ranges` or `dashes`. Neither walks over
204
+ a letter, so such a unit is never a range member and never a flank, and the only reads that reach
205
+ the gap before it are the effective neighbours of a digit run: `after` in G2 and G3 (a `DASH`,
206
+ an `INERT-DASH` or U+002F) and T1's first and second neighbour (a `DASH` or an `INERT-DASH`).
207
+ What those reads find at the two positions differs between the runs (the unit's first code
208
+ point, against a no-break space and then that code point; or a separator and then that code
209
+ point, against that code point alone), and the only code points involved are a space and the
210
+ unit's first code point, neither of which is in those sets: `nbsp.md` §3.7 U2 states that no unit
211
+ begins with one. For a unit whose first code point is outside `CLOSED-SYMBOL`, then, G-R is not
212
+ needed and is not applied, and the argument is this one.
185
213
 
186
214
  ### I₃ — `dashes`
187
215
 
@@ -208,19 +236,39 @@ replaces code points one-for-one with quote glyphs (also outside every `dashes`
208
236
  `innerSpace = "none"`, deletes a maximal `INLINE-SPACE` run whose two sides are a quote glyph and
209
237
  a `DELETE-LANDING` member — neither in `DASH ∪ INERT-DASH`, so no dash run is ever adjacent to a
210
238
  deleted run and no token's `lsp`/`rsp` changes (`quotes.md` 3.7, 5, composition obligation
211
- against `I₃`).
239
+ against `I₃`). `nbsp`'s N5 deletes a separator with a `DIGIT` on its left and a code point outside
240
+ `DASH` ∪ `INERT-DASH` on its right (`nbsp.md` §3.7 U2), so no dash run is adjacent to it; the
241
+ longer reads of T1 and of `ranges`' `after` are the ones discharged under `I₂ₐ`.
212
242
 
213
243
  ### I₄ — `hyphen`
214
244
 
215
245
  `I₄(y)` requires no occurrence of a listed `hyphen` form whose hyphen is still U+002D. A later
216
246
  rule violates it only by changing a form's word boundaries, i.e. by inserting or removing a
217
- code point immediately beside a listed form. `nbsp` inserts only next to listed punctuation
218
- or beside a quote glyph, so the inserted space never lands between two letters; `symbols`
247
+ code point immediately beside a listed form. `nbsp` inserts next to listed punctuation or beside
248
+ a quote glyph, so the inserted space there never lands between two letters; its one other
249
+ insertion, N5's between a `DIGIT` and a `spacedUnits` entry, can land between a digit and a
250
+ letter, and is shown not to change a form's boundary in `nbsp.md` §5, composition obligation
251
+ against `I₄` (the unit ends in a letter or at the form's hyphen, which N5's right-context guard
252
+ declines); N5's deletion exposes a code point that is neither a letter nor a hyphen (U2, U3), and every form
253
+ begins with one or the other; `symbols`
219
254
  deletes only `(`…`)` spans; `quotes` (0.3.0) deletes only a run whose landing is in
220
255
  `ALNUM ∪ QUOTEMARK`, but the deletion always removes an `INLINE-SPACE` run that is *not itself*
221
256
  inside a word — `hyphen`'s `WORDISH = ALNUM ∪ HYPHENISH` excludes both a U+0020 and a quote
222
257
  glyph, so the deletion never lands inside a listed form (`quotes.md` 5). `I₄` is preserved.
223
258
 
259
+ ### I₅ₐ — `quote-punctuation`
260
+
261
+ `I₅ₐ(y)` requires that no pair `cp[i], cp[i+1]` in `y` satisfies `quote-punctuation.md` §3.2's
262
+ C1-C4: a primary close preceded by a letter, followed by a comma or full stop, followed by a
263
+ space-like code point or the end. It is vacuous for a locale whose
264
+ `quotes.punctuationPlacement` is `"none"`, and for every call that does not enable the rule.
265
+
266
+ **Who can violate it.** `apostrophe`, `symbols` and `nbsp`, by changing the class of `cp[i-1]` or
267
+ `cp[i+2]` or by putting a punctuation mark next to a primary close. The argument is in
268
+ `quote-punctuation.md` §5: none of them emits the primary close (QP-1), a letter or a
269
+ comma or full stop next to it, or anything that is not `SPACELIKE` where a space stood. `nbsp`'s N5
270
+ deletes a separator only after a `DIGIT`, never after a comma or full stop.
271
+
224
272
  ### I₅ … I₈
225
273
 
226
274
  `quotes`, `apostrophe`, `symbols` and `nbsp` are the last four rules; only `nbsp` has anything
@@ -237,7 +285,10 @@ available. `quotes.md` §5's replacement is two lemmas plus a certification gate
237
285
  own output rather than relying on an argument about it: **Lemma A** (glyph-blindness — no
238
286
  candidate's verdict depends on *which* quote glyph a neighbour is) makes `apostrophe`'s emission
239
287
  structurally inert as a neighbour (Corollary A1); **Lemma B** (space-inertness at every position
240
- `nbsp` can reach) makes `nbsp`'s three insertion sites structurally inert. Both are CO-S
288
+ `nbsp` can reach) makes `nbsp`'s three insertion sites around quote marks structurally inert; N5's insertion and
289
+ deletion (`nbsp.md` §3.7) lie between a `DIGIT` and a unit that begins with no quotation glyph
290
+ and no U+0022 or U+0027 (`nbsp.md` §3.7 U1, U2), so they are not adjacent to any quote mark
291
+ (`quotes.md` §5, Lemma B item 4). Both are CO-S
241
292
  discharges in the sense of §5.1a below, over a *reachable-position* alphabet rather than a
242
293
  whole-emission alphabet for Lemma B specifically — see `quotes.md` §5 for why the alphabet alone
243
294
  is not sufficient there.
@@ -430,6 +481,7 @@ The idempotency property test must include, in every runtime:
430
481
  | **wide** | the consumed **and** emitted sets below | 0–5 |
431
482
  | **deep** | a core of at least `1`, `-`, U+0020, `.`, U+2060 | 0–8 |
432
483
  | **quotes** (spec 0.3.0) | `{ U+0022, U+0027, U+002D, U+0020, a }` ∪ every distinct quote glyph in `spec/locales/registry.json`'s locales | 0–6, per locale |
484
+ | **units** (spec 1.22.0, **mandatory**) | `{ 1, U+0020, U+00A0, x, х (U+0445), U+002D, U+2013, U+2014, U+2060, % }` ∪ one `nbsp.spacedUnits` entry ∪ one `nbsp.closedUnits` entry of that locale, each entry **one symbol** | 0–6, per locale |
433
485
 
434
486
  **Why the quotes tier exists, separately from wide/deep.** `quotes` (0.3.0)'s worst witness —
435
487
  `‘""-"-"` in `en-GB` — is seven code points over `{ ‘ " - }`, and the committed deep tier's
@@ -439,6 +491,21 @@ The idempotency property test must include, in every runtime:
439
491
  to that single, self-consistent alphabet is the natural unit rather than folding it into wide
440
492
  or deep, which are keyed to different rules' emission alphabets.
441
493
 
494
+ **Why the units tier exists, and what it must contain.** N5 inserts and deletes (`nbsp.md`
495
+ §3.7, spec 1.22.0), and the neighbourhood where it does so is the one place `nbsp` is read by
496
+ `ranges`, `dashes` and `symbols` at once: a digit run, a separator, a unit, a dash and a
497
+ multiplication letter. None of the other tiers contains a unit, so none can reach a defect in
498
+ that composition, and the two rules whose verdicts N5 can move (`ranges`/`dashes` through the
499
+ dash and `CLOSED-SYMBOL` reads, `symbols` through guard M3) are exactly the two guarded by G-R
500
+ and 5.5. The alphabet has the digit, both spaces N5 distinguishes (U+0020 and U+00A0), both
501
+ Latin and Cyrillic `MUL-LETTER` (M3), the hyphen, en and em dash and the joiner (G-R and T1),
502
+ and `%`, a `CLOSED-SYMBOL`; the two entries stand for the other unit kinds, and a locale
503
+ whose list is empty contributes none. A locale whose `spacedUnits` or `closedUnits` is
504
+ empty runs the tier without that entry (a `%` that is in no list is inert, but the dash and
505
+ chain reads are still exercised). Length 6 is the least that holds the guard-5.5 witness
506
+ `2␣x␣3km` (digit, space, letter, space, digit, unit), and the sweep must be run for both the
507
+ per-rule and the composition assertions (2) and (3) below, not only for the full pipeline. With twelve symbols the tier is about three million strings per locale.
508
+
442
509
  **Why two tiers, and why the bound moved.** A single length-4 bound was normative until
443
510
  `dashes` defect (e) — witness `1-1 - 1`, **seven characters** — shipped underneath it. Nothing
444
511
  was excluded and no precondition hid it; the bound simply could not reach it, and the suite
@@ -0,0 +1,337 @@
1
+ # Rule: `quote-punctuation`
2
+
3
+ **Order:** 45. **Default:** off. **Modes:** text, html, markdown, yaml.
4
+ **Spec version:** 1.21.0 (new rule).
5
+
6
+ ---
7
+
8
+ ## 1. Purpose
9
+
10
+ `quote-punctuation` moves a comma or a full stop from after a closing primary quotation mark to
11
+ before it, for a locale whose cited convention puts them inside the mark. It exists because
12
+ `quotes` converts glyphs and nothing else: `"hello",` becomes `“hello”,` in `en-US` and
13
+ `‘hello’,` in `en-GB`, and in both the comma stays where the author put it (canonical
14
+ polytypo#74). For American English that is the wrong place — Chicago sets commas and periods
15
+ before the closing mark (the citation is in `spec/locales/en-US.json`) — so text typeset by
16
+ `en-US` still carries British placement whenever its author typed it.
17
+
18
+ Every other rule in this project changes characters while keeping each one next to the neighbours
19
+ the author gave it. This rule changes where a character _sits_. That is why it is **off by
20
+ default** and why it is built to decline rather than to decide.
21
+
22
+ **What it deliberately does not do.** Where punctuation goes relative to a closing mark is, in
23
+ most locales, a question of meaning: a mark that belongs to the quoted material goes inside, one
24
+ that belongs to the surrounding sentence goes outside. `"Stop."` and `"most popular",` look alike
25
+ on the surface, and a scan of code points cannot tell them apart. So the rule is defined only
26
+ where the convention is positional — **a comma or a full stop goes inside, whatever the sense** —
27
+ and everywhere else (`en-GB`, German, and every locale whose placement was not verified) the
28
+ locale says `"none"` and the rule does nothing. The accepted cost of the one positional locale is
29
+ in §6.
30
+
31
+ ---
32
+
33
+ ## 2. Locale data consumed
34
+
35
+ - `quotes.punctuationPlacement` — one of `"inside"`, `"none"`. Required in every locale file.
36
+ `"none"` means the rule does nothing: either the locale places these marks by meaning, or no
37
+ convention has been verified (a missing citation is never a licence to guess). `"inside"` means
38
+ the locale's cited convention puts a comma or full stop before the closing primary mark.
39
+ - `quotes.primary.close` — the glyph the scan keys on. `quotes.secondary` is **not** read: a
40
+ secondary close is a `NARROW` glyph, and in `en-US` it is U+2019, which is also the apostrophe
41
+ (`the dogs’, bowls`).
42
+ - Nothing else. The rule has no tables of its own.
43
+
44
+ `"inside"` is a claim the algorithm's composition argument (§5) depends on, so
45
+ `scripts/validate-spec.mjs` refuses a locale file that makes it where that argument does not hold:
46
+
47
+ - **QP-1.** `quotes.primary.close` is a `WIDE` glyph (`quotes.md` §3.1) and differs from
48
+ `quotes.primary.open`. A symmetric pair cannot tell a closing mark from an opening one, and a
49
+ `NARROW` close is either the apostrophe glyph or a mark a word can end in.
50
+ - **QP-2.** `dash.parenthetical` is not `"em-paired"`. `dashes.md` §3.4a ends a segment at a
51
+ full stop that is followed by a space; moving the stop across the quotation mark removes that
52
+ boundary (`”.␣` becomes `.”␣`), so a pair of strokes the first pass kept apart could meet on the
53
+ second.
54
+ - **QP-3.** Neither `quotes.primary.innerSpace` nor `quotes.secondary.innerSpace` is a space. A
55
+ spaced primary pair puts a space on the mark's left, so the scan could never fire, and any
56
+ spaced pair keeps `quotes.md`'s `gapInsertable` non-vacuous, which §5's argument against `I₅`
57
+ relies on being vacuous.
58
+
59
+ `en-US` is the only locale that declares `"inside"` as of spec 1.21.0. The value is a statement
60
+ about a source, not about a language: `en-GB` and `de-DE` are `"none"` for the reason §1 gives,
61
+ and carry the citation that shows it; `de-CH` and every other `"none"` locale are `"none"` because
62
+ no convention has been verified for them.
63
+
64
+ ---
65
+
66
+ ## 3. Algorithm
67
+
68
+ Input is a code-point array `cp[0 … n-1]` in which modes may have placed boundary markers
69
+ (`modes.md` §3.2). The rule performs one left-to-right scan and produces edits; the pipeline
70
+ applies them. The rule is a no-op unless `quotes.punctuationPlacement` is `"inside"`.
71
+
72
+ ### 3.1 Character classes
73
+
74
+ The classes are those of `quotes.md` §3.1, unchanged: `LETTER`, `SPACELIKE` (which contains
75
+ `BREAK`, so a −2 line marker is `SPACELIKE`), and `NONE` for an index outside the array. The −1
76
+ inline marker is in none of them (`modes.md` §3.3). Let `Q` be `quotes.primary.close`.
77
+
78
+ ### 3.2 The scan
79
+
80
+ For each index `i` from `0` while `i + 1 < n`, in ascending order, the pair `cp[i], cp[i+1]` is
81
+ an **edit** if and only if all of the following hold:
82
+
83
+ | # | Condition |
84
+ | --- | -------------------------------------------------------------------------------- |
85
+ | C1 | `cp[i] = Q` |
86
+ | C2 | `cp[i+1]` is U+002C or U+002E |
87
+ | C3 | `i ≥ 1` and `cp[i-1]` is in `LETTER` |
88
+ | C4 | `cp[i+2]` is `NONE` or in `SPACELIKE` |
89
+
90
+ The edit replaces the two code points with `cp[i+1], cp[i]` — the same two code points in the
91
+ opposite order. After an edit continue from `i + 2`; otherwise from `i + 1`.
92
+
93
+ **What each condition buys.**
94
+
95
+ - **C3** requires a letter, not merely a non-space. It declines after a digit (`5”,` is the shape
96
+ of an inch mark and of a quoted number), after another terminal (`”!.`, `…”.`), after a
97
+ full stop (`e.g.”,` — whether the stop belongs to the abbreviation is not decidable here), after
98
+ any quotation mark (a nested quotation, `“He said ‘hi’”.`), after a bracket, and across any
99
+ boundary marker or protected run (the marker is not `LETTER`).
100
+ - **C4** requires the punctuation to end its clause. It declines when a letter, a digit, a
101
+ bracket, another dot, a quotation mark or a boundary marker comes next: `“file”.txt`,
102
+ `(“hi”.)`, `“wait”…`, and `“file”.${ext}` with a protected `${ext}`.
103
+ - **C2** moves only the comma and the full stop. `;` `:` `?` `!` and the dashes are positional in
104
+ no locale this specification has verified — Chicago puts them outside unless they belong to the
105
+ quotation — so they are left where the author wrote them, and so is a full stop that duplicates
106
+ a terminal already inside the mark (`“Stop!”.`, which stays).
107
+
108
+ The edit has length two for length two, so it never changes the length of the text, never
109
+ inserts a U+0020, and never needs the edge-growth check of `modes.md` §3.4: the replacement's
110
+ first and last code points are not U+0020.
111
+
112
+ ### 3.3 Modes, `protect`, `analyze`
113
+
114
+ **Document modes.** A span boundary between the mark and the punctuation, or on either side of
115
+ the pair, puts a marker at `cp[i-1]`, `cp[i+1]` or `cp[i+2]`. A marker at `cp[i-1]` fails C3, at
116
+ `cp[i+1]` fails C2, and at `cp[i+2]` fails C4. The rule therefore needs no special handling of
117
+ `html`, `markdown` or `yaml`: it acts only when the whole of `Q`, the punctuation, and the text on
118
+ either side are in one span, and the redistribution of edits to spans is trivial because the edit
119
+ never contains a marker. The end of a text unit is `NONE`, not a marker, so `<p>Call it
120
+ "ready".</p>` moves the stop while `<p>Call it "ready".</p><p>Next</p>` does not (§6).
121
+
122
+ **`text` mode `protect`.** A protected run is a boundary marker, including at the very start or
123
+ end of the input (`modes.md` §3.9.3), so it blocks the scan the same way. The edit never changes
124
+ the length of the text and never touches a protected code point, so a case's `protectOut` equals
125
+ its `protect`.
126
+
127
+ **`analyze`.** Reports one change per edit, with `ruleId` `quote-punctuation`, and only when the
128
+ rule is enabled for the call (`analyze.md` A4).
129
+
130
+ ---
131
+
132
+ ## 4. Must not touch
133
+
134
+ **Scope.** Per [pipeline-idempotency.md](pipeline-idempotency.md) §5.2 each bullet is **[P]** — a
135
+ guarantee of `transform` as a whole — or **[R]** — true of this rule in isolation but capable of
136
+ being falsified by another rule, which is then named.
137
+
138
+ - **[P] Anything, unless the caller asked.** The rule is off by default; `transform` without
139
+ `{ rules: { "quote-punctuation": true } }` leaves every comma and stop where it was typed.
140
+ - **[P] Every locale whose `punctuationPlacement` is `"none"`.** Enabling the rule is a no-op
141
+ there.
142
+ - **[P] `;` `:` `?` `!`** and a full stop that follows one: `“Stop!”.` is unchanged.
143
+ - **[P] A punctuation mark after a digit or a non-letter.** `“Route 66”.`, `6’ 2”,`.
144
+ - **[P] A nested quotation's closing mark.** `“He said ‘hi’”.` — the glyph left of the primary
145
+ close is `’`, not a letter.
146
+ - **[P] A secondary close, and the apostrophe.** `the dogs’, bowls`. The scan keys on the primary
147
+ close only (QP-1).
148
+ - **[P] A stop or comma followed by anything but a space, a line break or the end of the text.**
149
+ `“file”.txt`, `(“hi”.)`, `“wait”…`, `“a”,”b”`.
150
+ - **[P] Across a span boundary or a protected run, on any of the three sides.**
151
+ - **[P] A straight quotation mark.** The rule reads the glyph `quotes` produced; an unconverted
152
+ U+0022 is not `Q`.
153
+ - **[R] Which marks are quotation marks.** Decided by `quotes`; this rule moves a punctuation mark
154
+ next to one that `quotes` already settled, or that the author already typed in curly form.
155
+
156
+ ---
157
+
158
+ ## 5. Idempotency argument
159
+
160
+ **The rule alone.** An edit swaps `Q` and a punctuation mark. Afterwards `Q` stands at `i+1`
161
+ with `cp[i+2]` unchanged, and `cp[i+2]` is `NONE` or `SPACELIKE`, which is not U+002C or U+002E, so
162
+ C2 fails there. The punctuation mark now at `i` is not `Q`, so C1 fails there. A candidate pair
163
+ elsewhere reads `cp[j-1]`, `cp[j]`, `cp[j+1]` and `cp[j+2]`; an edit at `i` changes only `cp[i]`
164
+ and `cp[i+1]`. For `j > i + 1` to read either, `j - 1 ≤ i + 1`, so `j ≤ i + 2`; but `j = i + 2`
165
+ requires `cp[i+2] = Q`, which C4 excludes. For `j < i`, `j + 2 ≥ i` means `j = i - 2` and
166
+ `cp[j+2] = cp[i]`, which was `Q` and is not `NONE` or `SPACELIKE`, so `j` was not a candidate
167
+ before and is not one after. Two candidates are never adjacent for the same reason. Hence
168
+ `T(T(x)) = T(x)` for this rule on its own, and `I₅ₐ(y)` — "no pair in `y` satisfies C1–C4" — holds
169
+ on its output.
170
+
171
+ ### Composition obligation
172
+
173
+ Per [pipeline-idempotency.md](pipeline-idempotency.md) §5. This rule is **R₅ₐ**; it runs after
174
+ `quotes` (R₅) and before `apostrophe` (R₆), so the obligation runs against `spaces`, `ellipsis`,
175
+ `ranges`, `dashes`, `hyphen` and `quotes` (its output must satisfy their invariants), and `I₅ₐ`
176
+ must survive `apostrophe`, `symbols` and `nbsp`.
177
+
178
+ **What this rule emits.** The same two code points it consumed, swapped: `Q` moves right by one
179
+ index and U+002C or U+002E moves left by one. **No code point is inserted or deleted**, and the
180
+ neighbours of the pair are `cp[i-1] ∈ LETTER` on the left and `NONE` or `SPACELIKE` on the right,
181
+ both before and after the edit.
182
+
183
+ - **`I₁` (`spaces`).** Discharged. No U+0020 is created and none is removed. A U+0020 before the
184
+ punctuation is impossible (`cp[i-1]` is a letter before the edit, and after it the punctuation's
185
+ left neighbour is that same letter). `spaces` removes a run of U+0020 when the code point to
186
+ its right is in `STRIP-BEFORE`; no run ends at `cp[i]` or `cp[i+1]` either before or after the
187
+ edit, because `cp[i-1]` is a letter and the swapped pair is adjacent.
188
+ - **`I₂` (`ellipsis`).** Discharged. A single dot is moved; C4 excludes a following dot and C3
189
+ excludes a preceding one (`…”.` and `”...` are both declined), so no run of dots is formed or
190
+ split.
191
+ - **`I₂ₐ` (`ranges`), `I₃` (`dashes`).** Discharged by class membership: `Q`, U+002C and U+002E
192
+ are in none of `DASH`, `INERT-DASH`, `DIGIT`, `SPACE`, `NOBREAK-SPACE`, `JOINER` or `ROMAN`, so
193
+ a token's `cp[L]`, `cp[R]`, `before`, `after` and cluster never move between classes. The one
194
+ place `dashes` reads a full stop is §3.4a's segment boundary, excluded by **QP-2**.
195
+ - **`I₄` (`hyphen`).** Discharged. A listed form is bounded by `¬WORDISH` on both sides; `Q`, `,`
196
+ and `.` are all outside `WORDISH`, so the boundary does not move.
197
+ - **`I₅` (`quotes`).** Discharged by comparing the verdict inputs `quotes` reads at the mark.
198
+ For the mark itself: `Lskip` changes from a letter (`ALNUM`) to the punctuation mark (neither
199
+ `NONE` nor `SPACELIKE`) and `closeRight` from the punctuation mark (`CLOSEISH`) to `NONE` or
200
+ `SPACELIKE`; `canClose` accepts both before and after, and `canOpen` rejects both (`openLeft` is
201
+ a letter before, and `,` or `.` — in `CLOSEISH` but not `OPENISH` — after). For a candidate to
202
+ the right, across the spaces: `Lskip` changes from the punctuation mark to `Q`, and
203
+ `canClose`/`canOpen` read it only against `NONE` and `SPACELIKE`. The elision vetoes read
204
+ `NARROW` marks and `ALNUM` neighbours, and none of the code points that moved is either. The
205
+ gap test `gapInsertable` is vacuous because **QP-3** forbids a spaced pair. So the candidates,
206
+ their verdicts and their pairing are the same on the second pass, and the certification gate
207
+ (`quotes.md` §3.5) sees the same document modulo this swap.
208
+ - **`I₅ₐ` against `apostrophe` (R₆).** Discharged. `apostrophe` emits only U+2019, never `Q`
209
+ (QP-1 excludes a `Q` equal to U+2019), so it creates no candidate; and it changes a code point
210
+ to U+2019 only where it stood as U+0027, which is not `LETTER`, so it cannot make `cp[i-1]` a
211
+ letter.
212
+ - **`I₅ₐ` against `symbols` (R₇).** Discharged. `symbols` emits U+00A9, U+00AE, U+2122, U+00D7
213
+ and U+00B1, none in `LETTER` or `SPACELIKE`, and replaces spans bounded by non-`ALNUM`
214
+ neighbours, so it cannot make `cp[i-1]` a letter or `cp[i+2]` a space.
215
+ - **`I₅ₐ` against `nbsp` (R₈).** Discharged. `nbsp` converts one space to another or inserts a
216
+ space; `SPACELIKE` accepts either, so C4 holds both ways. `nbsp` can insert a space between
217
+ `Q` and the punctuation (N1/N2) only if the locale lists that punctuation in
218
+ `beforePunctuation` or `narrowBeforePunctuation`, which `en-US` does not; if a locale did, the
219
+ insertion would make `cp[i+1]` a space, which fails C2, so the pair is no longer a candidate.
220
+ `nbsp`'s N5 also deletes a single separator (`nbsp.md` §3.7, spec 1.22.0), but only one that
221
+ follows a `DIGIT`; C4 needs the space to follow a comma or full stop, so a deleted separator is
222
+ never the code point C4 reads.
223
+
224
+ **What is argued and what is measured.** The discharges against `ellipsis`, `ranges`, `dashes`,
225
+ `hyphen` and `nbsp` are class-membership arguments over the alphabet `{Q, U+002C, U+002E}` and
226
+ the two neighbour classes, in the shape of `symbols.md` §5, not CO-S proofs, and each runtime's
227
+ idempotency sweep with the rule enabled is the control (`pipeline-idempotency.md` §5.1a). A
228
+ throwaway reference implementation of §3.2 (not a runtime) was applied to the **finished output** of
229
+ the `polytypo` 1.20.1 pipeline — that is, after `apostrophe`, `symbols` and `nbsp` had run, not
230
+ between `quotes` and `apostrophe` where the rule sits — over the released `en-US` text fixtures,
231
+ 1,128 variants of them with a comma or stop added after each quotation mark, and 400,000 random
232
+ strings of letters, quotation marks, commas, stops, spaces, brackets and dashes. For each, the
233
+ scanned output was re-run through the pipeline and the scan, and came back unchanged. No violation
234
+ was found. That checks that the pipeline leaves a scanned text alone; it does **not** check the
235
+ rule's composition against `apostrophe`, `symbols` or `nbsp` in its real position, and it is no
236
+ proof. Those checks belong to the runtimes' own sweeps.
237
+
238
+ ---
239
+
240
+ ## 6. Worked examples
241
+
242
+ `⟶` = no change. Every row is a conformance fixture in `spec/fixtures/en-US.json` with
243
+ `rules: { "quote-punctuation": true }`, unless it says otherwise. Input is the author's text; the
244
+ output is what the whole pipeline produces, so a row shows `quotes`' conversion and this rule's
245
+ move together.
246
+
247
+ ### `en-US` — `punctuationPlacement: "inside"`, text mode
248
+
249
+ | # | Input | Output | Why |
250
+ | --- | ----------------------------------- | ----------------------------------- | --------------------------------------------------------- |
251
+ | 1 | `She said "hello", then left.` | `She said “hello,” then left.` | C1–C4 |
252
+ | 2 | `He called it "done". Then he left.`| `He called it “done.” Then he left.`| a stop, followed by a space |
253
+ | 3 | `Call it "ready".` | `Call it “ready.”` | C4: end of the text is `NONE` |
254
+ | 4 | `Call it "ready".` + U+000A + `Next`| `Call it “ready.”` + U+000A + `Next`| C4: a line break is `SPACELIKE` |
255
+ | 5 | `The "first", the "second".` | `The “first,” the “second.”` | two independent edits |
256
+ | 6 | `"Go home".` | `“Go home.”` | **a complete sentence in the quotation is not special** |
257
+ | 7 | `Both "a", "b" and "c".` | `Both “a,” “b” and “c.”` | the middle quotation has nothing to move |
258
+ | 8 | `She said “hello,” then left.` | ⟶ | already inside: nothing at `cp[i+1]` |
259
+ | 9 | `Broken pair”, then` | `Broken pair,” then` | **an unpaired closing mark is moved too** (accepted cost) |
260
+ | 10 | `"Stop!".` | `“Stop!”.` | C3: the glyph on the left is `!` |
261
+ | 11 | `It said "wait…".` | `It said “wait…”.` | C3: `…` |
262
+ | 12 | `Use "e.g.", then` | `Use “e.g.”, then` | C3: `.` |
263
+ | 13 | `"Route 66".` | `“Route 66”.` | C3: a digit |
264
+ | 14 | `"He said 'hi'".` | `“He said ‘hi’”.` | C3: `’`; nested quotation, accepted miss |
265
+ | 15 | `Say "a"; say "b": say "c"?` | `Say “a”; say “b”: say “c”?` | C2: `;` `:` `?` are never moved |
266
+ | 16 | `"file".txt` | `“file”.txt` | C4: a letter follows |
267
+ | 17 | `He said ("hi".)` | `He said (“hi”.)` | C4: a bracket follows |
268
+ | 18 | `He said "wait"...` | `He said “wait”…` | `ellipsis` runs first; C2 fails on U+2026 |
269
+ | 19 | `Check the dogs’, bowls and cats.` | ⟶ | U+2019 is the secondary close, not `Q` (QP-1) |
270
+ | 20 | `She said "hello", then left.`, rule not enabled | `She said “hello”, then left.` | the default: off |
271
+
272
+ ### Document modes and `protect`
273
+
274
+ | # | Mode | Input | Output | Why |
275
+ | --- | ---------- | ---------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------ |
276
+ | H1 | `html` | `<p>She said "hello", then left.</p>` | `<p>She said “hello,” then left.</p>` | one text node |
277
+ | H2 | `html` | `<p>She said <em>"hello"</em>, then left.</p>` | `<p>She said <em>“hello”</em>, then left.</p>` | a marker at `cp[i+1]` fails C2 |
278
+ | H3 | `html` | `<p>She said "<em>hello</em>", then left.</p>` | `<p>She said “<em>hello</em>”, then left.</p>` | a marker at `cp[i-1]` fails C3 |
279
+ | H5 | `html` | `<p>She said "hello".</p><p>Next.</p>` | `<p>She said “hello”.</p><p>Next.</p>` | the gap between the paragraphs is a −1 marker at `cp[i+2]`: C4 fails |
280
+ | M1 | `markdown` | `She said "hello", then left.` + U+000A | `She said “hello,” then left.` + U+000A | one span |
281
+ | M2 | `markdown` | `*She said "hello"*, then left.` | `*She said “hello”*, then left.` | the closing `*` is a boundary |
282
+ | M3 | `markdown` | `*He said "hi".* Next` | `*He said “hi”.* Next` | the same, at `cp[i+2]` |
283
+ | Y1 | `yaml` | `title: She said "hello", then left.` | `title: She said “hello,” then left.` | a processable plain scalar is one span |
284
+ | P1 | `text`, `protect` | `Set "file".${ext} now` | `Set “file”.${ext} now` | the protected run is a marker at `cp[i+2]` |
285
+ | P2 | `text`, `protect` | `Use "${name}", then stop.` | `Use “${name}”, then stop.` | the protected run is a marker at `cp[i-1]` |
286
+ | P3 | `text`, `protect` | `Say "hi", then ${x}.` | `Say “hi,” then ${x}.` | the hole is elsewhere; `protectOut` equals `protect` |
287
+
288
+ Rows P1 to P3 give `protect` as the code-point ranges of `${ext}`, `${name}` and `${x}`.
289
+
290
+ ### Every other locale
291
+
292
+ For each of the other twenty-six locales a fixture enables the rule on text that is already in
293
+ that locale's quotation marks, with a comma after the closing mark, and expects it back unchanged;
294
+ `en-GB` is the one that starts from straight quotes (`She said "hello", then left.` becomes
295
+ `She said ‘hello’, then left.`). They prove `"none"` is a no-op in every locale and keep the
296
+ rule from silently becoming locale-dependent.
297
+
298
+ ### Accepted costs
299
+
300
+ These are the price of declining rather than deciding, named so a reader can weigh them:
301
+
302
+ - **A quoted literal absorbs the punctuation.** `set it to "strict".` becomes `set it to
303
+ “strict.”`. In `en-US` that is the rule Chicago states for prose; for a literal it is wrong,
304
+ and the manual makes an exception (CMOS Shop Talk, “Section 7.75 in the Spotlight”, a
305
+ 16th-edition text; whether it holds in the 18th was not checked) that this rule does not model.
306
+ Code spans are skipped by every mode, so a literal in code is safe. This is also why the rule
307
+ is off by default: with it on, 4 of the 201 `en-US` fixtures that are in text mode, have an
308
+ `out`, and set no `rules` override (counted before this rule's own cases were added) would
309
+ produce different output.
310
+ - **No duplicate removal.** `“Stop!”.` keeps both marks.
311
+ - **Nested and numeric quotations are missed** (rows 13 and 14): `“Route 66”.` and
312
+ `“He said ‘hi’”.` keep the stop outside.
313
+ - **A closing tag or an emphasis delimiter right after the stop blocks the move** (H5, M3), while
314
+ the same text at the very end of a document moves it. A markup boundary is not a space.
315
+ - **An unpaired curly closing mark moves its punctuation** (row 9). The rule trusts the glyph,
316
+ not the pairing.
317
+ - **Every locale but `en-US` is untouched.** For `en-GB` and `de-DE` the cited placement depends
318
+ on meaning (University of Oxford Style Guide (2014): “place any punctuation which does not
319
+ belong to the quote outside”; Rat für deutsche Rechtschreibung 2024 §79 E1); for the others no
320
+ convention has been verified. A caller who wants it applied there has no option to ask for it.
321
+
322
+ ---
323
+
324
+ ## 7. Open questions
325
+
326
+ 1. **`"outside"`.** German places a comma after the closing mark when a carrier sentence
327
+ follows the quotation (§79 E1(2)); that is the one position-only statement found. A
328
+ value that moved a comma from inside to outside would be positional there and could be added to
329
+ the enum without changing any existing value. Nothing is specified for it; recorded because it
330
+ is the one other position-only convention the sources established.
331
+ 2. **Is a Chicago exception for computer terms a hole in `"inside"`?** CMOS Shop Talk, 2015, 16th
332
+ ed.: punctuation that is not part of a quoted computer term stays outside. The 18th edition
333
+ was not read. If it keeps the exception, a locale entry cannot express it and the rule's
334
+ default-off status is the only protection.
335
+ 3. **The primary close only.** A single-quoted first-level quotation (`en-GB`) is not covered by
336
+ QP-1 because `en-GB` is `"none"`; if a locale ever declares `"inside"` with a `NARROW` primary
337
+ close, QP-1 has to be revisited together with the apostrophe argument.
@@ -1161,12 +1161,14 @@ rest of this rule's determinism.
1161
1161
 
1162
1162
  ### Lemma B — space-inertness at every position `nbsp` can reach
1163
1163
 
1164
- > Inserting a code point of `INLINE-SPACE`, or converting one `INLINE-SPACE` code point to
1165
- > another, at any position `nbsp` can act on, changes no capability of any candidate.
1164
+ > Inserting a code point of `INLINE-SPACE`, deleting one, or converting one `INLINE-SPACE`
1165
+ > code point to another, at any position `nbsp` can act on, changes no capability of any
1166
+ > candidate.
1166
1167
 
1167
1168
  *Proof.* Conversion is trivial: every test reads class membership and U+0020, U+00A0, U+202F are
1168
- all in `INLINE-SPACE`. For insertion, `nbsp` has exactly three insertion sites (`nbsp.ts`
1169
- `claimInsertion`):
1169
+ all in `INLINE-SPACE`. For insertion, `nbsp` has exactly three insertion sites **around quote
1170
+ marks**, items 1 to 3 below (N8 on either side of a glyph, and N1/N2 before a listed mark), and
1171
+ one site that is not around a quote mark, N5's, which item 4 covers together with N5's deletion:
1170
1172
 
1171
1173
  1. **N8, immediately right of an occurrence of `g ∈ SPACE-RIGHT`.**
1172
1174
  - *`g` itself*: `canOpen` reads `Rskip` (skips) and `openLeft` (untouched); `canClose` reads
@@ -1187,7 +1189,14 @@ all in `INLINE-SPACE`. For insertion, `nbsp` has exactly three insertion sites (
1187
1189
  `m ∈ CLOSEISH`, so both are accepted — same verdict. Its `Rskip` skips back to `m`. (`nbsp`'s
1188
1190
  own step 3 already declines to insert after an opening glyph.)
1189
1191
 
1190
- No other sub-rule inserts; N3–N7, N9, N10 only convert. ∎
1192
+ 4. **N5 (`spacedUnits` insertion, `closedUnits` deletion; `nbsp.md` §3.7).** The gap lies between
1193
+ a `DIGIT` and the first code point of a listed unit; a listed unit never begins or ends with one of the
1194
+ locale's own quote glyphs (`scripts/validate-spec.mjs` enforces it) and never begins with a
1195
+ straight U+0022 or U+0027 (`nbsp.md` §3.7 U2), so no
1196
+ quote mark is adjacent to the gap and no `Lskip` / `Rskip` read from a quote mark crosses it.
1197
+ No candidate's capability moves.
1198
+
1199
+ No other sub-rule inserts; N3, N4, N6, N7, N9, N10 only convert. ∎
1191
1200
 
1192
1201
  **V1's `gapInsertable` clause (§3.2) is what extends this proof to V1 itself.** The four
1193
1202
  capability tests above are the ones Lemma B's statement covers directly, but V1 is also a test a
@@ -1271,6 +1280,15 @@ still holds without re-verification.
1271
1280
  *sites* rather than its emission alphabet alone — the alphabet by itself is not enough, because
1272
1281
  a `SPACELIKE` insertion is *not* inert at an arbitrary position; it is inert at exactly the
1273
1282
  positions `nbsp` can reach).
1283
+ - **`I₅` against `quote-punctuation` (R₅ₐ), spec 1.21.0, when enabled.** The rule swaps a primary
1284
+ close with a comma or full stop that follows it. The verdict inputs this rule reads at the mark
1285
+ move only within classes it tests identically (`Lskip`: `ALNUM` → `,`/`.`, neither `NONE` nor
1286
+ `SPACELIKE`; `closeRight`: `,`/`.` → `NONE` or `SPACELIKE`, both accepted by `canClose`;
1287
+ `openLeft`: a letter → `,`/`.`, neither `OPENISH`), the vetoes read `NARROW` marks and `ALNUM`
1288
+ neighbours that the swap does not touch, and `gapInsertable` is vacuous because the locale
1289
+ constraint QP-3 forbids a spaced pair wherever the rule is enabled
1290
+ (`quote-punctuation.md` §2, §5). A case analysis, not CO-S; the runtimes' idempotency sweeps
1291
+ with the rule on are the control.
1274
1292
  - **`I₅` against `symbols` (R₇).** **Known-weak: a case analysis, not CO-S.** `symbols`
1275
1293
  collapses `(c)`/`(r)`/`(tm)` to a single sign, deleting code points, and converts `x` to `×`
1276
1294
  between numerals. A quote mark adjacent to a collapsed span sees `(` on its right (moving to
@@ -487,4 +487,10 @@ machinery rather than range-specific stay in [dashes.md](dashes.md) §7 (its can
487
487
  the locale sets **after a space** — `20 °C`, `20 %`. That is the spaced construction, out of
488
488
  scope here; `15°-20°` and `35%-50%`, with the symbol closed up, are the other one. The two
489
489
  never meet in the algorithm either: §3.2a's walk requires a `DIGIT` immediately beside the
490
- symbol, so `15 %-20 %` is not a candidate at all.
490
+ symbol, so `15 %-20 %` is not a candidate at all. A locale's `nbsp.spacedUnits` and
491
+ `nbsp.closedUnits` (spec 1.22.0) are in the same position, with one addition: `nbsp` N5 can
492
+ insert or delete the space itself, and so turn the spaced construction into the closed one or
493
+ the reverse, after `ranges` has run. They still never meet, but the reason is `nbsp.md` §3.7
494
+ and not the walk: its guard G-R declines both the insertion and the deletion whenever a `DASH`
495
+ or `INERT-DASH` is the first code point beyond the number and its unit on either side (past
496
+ any spaces and U+2060), which is where a range member's symbol would be read.
@@ -478,8 +478,10 @@ without emitting any U+0020. None does: `ellipsis` writes only `DOTLIKE` code po
478
478
  `dashes` and `hyphen` replace dashes, hyphens and spaces; `quotes` and `apostrophe` replace
479
479
  quotation marks; `symbols` replaces a trademark literal, which starts with `(`, and a `MUL-LETTER`,
480
480
  which is always preceded by a digit or a space and so never follows a dot directly; `nbsp` replaces
481
- or inserts spaces, and inserts only beside a listed punctuation mark or a quote glyph, never between
482
- a dot and a letter. A new rule that rewrites letters or digits must re-check this.
481
+ or inserts spaces, and inserts only beside a listed punctuation mark or a quote glyph or (N5, for a
482
+ `spacedUnits` entry) between a digit and a unit, never between a dot and a letter, and deletes only
483
+ the single separator between a digit and a `closedUnits` entry, whose neighbours are a digit and a
484
+ non-letter. A new rule that rewrites letters or digits must re-check this.
483
485
 
484
486
  ---
485
487
 
@@ -386,7 +386,8 @@ glyph, or deletes one from the *right* of a mark, this paragraph must be re-deri
386
386
  **A standing note for anyone adding a row here.** These rows become conformance fixtures
387
387
  verbatim, so each one must exercise **only** the rule it documents. Choose the surrounding words
388
388
  so that no _other_ rule fires: no unit or unit-like token (`mm`, `cm`, `см`, `km`, `%`, `°C`),
389
- which `nbsp.beforeUnits` binds to a preceding number with U+00A0; no abbreviation ending in a
389
+ which `nbsp` binds to a preceding number with U+00A0 (`beforeUnits`, `spacedUnits`), or whose
390
+ space it inserts or deletes (`spacedUnits`, `closedUnits`); no abbreviation ending in a
390
391
  full stop, which `nbsp.beforeNumber` / `beforeWord` bind; and no short function word, which
391
392
  `nbsp.afterShortWords` binds. A row reading `Tolerance ±5 mm` teaches a reader that `symbols`
392
393
  produces the space it does not produce — the true pipeline output carries a U+00A0 that belongs
@@ -156,6 +156,7 @@
156
156
  "dashes",
157
157
  "hyphen",
158
158
  "quotes",
159
+ "quote-punctuation",
159
160
  "apostrophe",
160
161
  "symbols",
161
162
  "nbsp"