polytypo 1.17.4 → 1.18.0
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.
- checksums.yaml +4 -4
- data/lib/polytypo/data/VERSION +1 -1
- data/lib/polytypo/data/fixtures/bg.json +1 -1
- data/lib/polytypo/data/fixtures/cs.json +1 -1
- data/lib/polytypo/data/fixtures/de-CH.json +1 -1
- data/lib/polytypo/data/fixtures/de-DE.json +1 -1
- data/lib/polytypo/data/fixtures/el.json +1 -1
- data/lib/polytypo/data/fixtures/en-GB.json +64 -1
- data/lib/polytypo/data/fixtures/en-US.json +64 -1
- data/lib/polytypo/data/fixtures/es.json +272 -7
- data/lib/polytypo/data/fixtures/fi.json +1 -1
- data/lib/polytypo/data/fixtures/fr-CA.json +1 -1
- data/lib/polytypo/data/fixtures/fr.json +1 -1
- data/lib/polytypo/data/fixtures/hr.json +1 -1
- data/lib/polytypo/data/fixtures/hu.json +1 -1
- data/lib/polytypo/data/fixtures/it.json +1 -1
- data/lib/polytypo/data/fixtures/locale-resolution.json +1 -1
- data/lib/polytypo/data/fixtures/lt.json +1 -1
- data/lib/polytypo/data/fixtures/nl.json +1 -1
- data/lib/polytypo/data/fixtures/pl.json +1 -1
- data/lib/polytypo/data/fixtures/pt-BR.json +1 -1
- data/lib/polytypo/data/fixtures/pt-PT.json +1 -1
- data/lib/polytypo/data/fixtures/ro.json +1 -1
- data/lib/polytypo/data/fixtures/ru.json +1 -1
- data/lib/polytypo/data/fixtures/sk.json +1 -1
- data/lib/polytypo/data/fixtures/sl.json +1 -1
- data/lib/polytypo/data/fixtures/sr.json +1 -1
- data/lib/polytypo/data/fixtures/sv.json +1 -1
- data/lib/polytypo/data/fixtures/tr.json +1 -1
- data/lib/polytypo/data/fixtures/uk.json +1 -1
- data/lib/polytypo/data/locales/el.json +1 -1
- data/lib/polytypo/data/locales/es.json +2 -2
- data/lib/polytypo/data/locales/registry.json +1 -1
- data/lib/polytypo/data/rules/dashes.md +108 -16
- data/lib/polytypo/data/rules/modes.md +49 -4
- data/lib/polytypo/data/rules/order.json +2 -2
- data/lib/polytypo/data/rules/pipeline-idempotency.md +7 -0
- data/lib/polytypo/data/schema/locale.schema.json +2 -2
- data/lib/polytypo/engine/rules/dash_shared.rb +32 -21
- data/lib/polytypo/engine/rules/dashes.rb +4 -1
- data/lib/polytypo/engine/rules/dashes_paired.rb +160 -0
- data/lib/polytypo/modes/spans.rb +53 -2
- data/lib/polytypo/version.rb +1 -1
- metadata +2 -1
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"rule": "dashes",
|
|
53
53
|
"cite": "Διοργανικό εγχειρίδιο σύνταξης κειμένων (EL, 2011), §10.1.8 «Ενωτικό — Παύλα μεσαίου μεγέθους — Μεγάλη παύλα»: για τα αριθμητικά διαστήματα, «Παύλα μεσαίου μεγέθους ή μείον (–) […] γ) για να δηλώσει το διάστημα μεταξύ δύο ορίων (π.χ. άτομα ηλικίας 25–45 ετών) […] δ) στην αναφορά σε περιόδους τουλάχιστον δύο πλήρων ετών (π.χ. 1989–1991) […] Ωστόσο, και στην περίπτωση αυτή μπορεί να χρησιμοποιηθεί και ενωτικό». Ο ίδιος κανόνας για τα αριθμητικά διαστήματα εμφανίζεται ΔΥΟ ΦΟΡΕΣ στην §10.1.8, μία στην υποενότητα «Ενωτικό (-)» και μία στην υποενότητα «Παύλα μεσαίου μεγέθους (–)», και κάθε φορά η υποενότητα παραχωρεί ρητά το άλλο σημείο (paraphrase of the «Ενωτικό» occurrence — its verbatim text was not captured at review time; the «Παύλα» occurrence is quoted above verbatim)· για την παρενθετική χρήση, «Όπως η παρένθεση, η διπλή παύλα δεν χωρίζεται με κενά διαστήματα από τη λέξη, φράση ή πρόταση που περικλείει· αντίθετα, μπαίνουν διαστήματα πριν από την πρώτη και μετά τη δεύτερη παύλα»",
|
|
54
54
|
"url": "http://publications.europa.eu/resource/cellar/e774ea2a-ef84-4bf6-be92-c9ebebf91c1b.0015.03/DOC_2",
|
|
55
|
-
"note": "Justifies \"none\" on BOTH fields, which no other locale has — but for TWO DIFFERENT REASONS, and conflating them would misrepresent the source. Range: genuinely ambivalent. The rule appears twice in §10.1.8, once under «Ενωτικό (-)» and once under «Παύλα μεσαίου μεγέθους (–)», and each occurrence explicitly concedes the other mark. That mutual concession is the proof — a source that names both forms in both places is not being vague, it is declining to rank them, and substituting either would express a preference the citation does not carry. Parenthetical: NOT ambivalent. The guide prescribes a U+2014 pair (its own header gives «Alt 0151») with ordinary spaces outside the pair and none on the inner edges. \"none\" here is forced by
|
|
55
|
+
"note": "Justifies \"none\" on BOTH fields, which no other locale has — but for TWO DIFFERENT REASONS, and conflating them would misrepresent the source. Range: genuinely ambivalent. The rule appears twice in §10.1.8, once under «Ενωτικό (-)» and once under «Παύλα μεσαίου μεγέθους (–)», and each occurrence explicitly concedes the other mark. That mutual concession is the proof — a source that names both forms in both places is not being vague, it is declining to rank them, and substituting either would express a preference the citation does not carry. Parenthetical: NOT ambivalent. The guide prescribes a U+2014 pair (its own header gives «Alt 0151») with ordinary spaces outside the pair and none on the inner edges. \"none\" here is forced by the SOURCE CONFLICT below, not by a schema limit: the schema has expressed the spacing this sentence prescribes since \"em-paired\" (spec 1.18.0), but that value is an em dash, and the choice between em and en for Greek is not settled. See spec/rules/dashes.md §6 «el», which states the two justifications separately. SOURCE CONFLICT, recorded and deliberately not settled: this guide prescribes U+2014 for the parenthetical dash, while ΥΠΕΠΘ/ΙΤΥΕ Γραμματική Α΄–Γ΄ Γυμνασίου §3.3 appears to set U+2013 in the same role. The sources array has no way to represent a conflict — it models agreement, not disagreement — so it is recorded here in prose. Resolving it is with the operator and needs a source that ranks the two, not a third that adds a form. Retrieved 2026-08-15."
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"rule": "ellipsis",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dash": {
|
|
22
|
-
"parenthetical": "em-
|
|
22
|
+
"parenthetical": "em-paired",
|
|
23
23
|
"range": "none"
|
|
24
24
|
},
|
|
25
25
|
"ellipsis": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"rule": "dashes",
|
|
68
68
|
"cite": "RAE y ASALE, Diccionario panhispánico de dudas, entrada «raya», apartado 2: «Como el resto de los signos dobles, se escriben pegadas a la primera y a la última palabra del periodo que enmarcan, y separadas por un espacio de la palabra o signo que las precede o las sigue»",
|
|
69
69
|
"url": "https://www.rae.es/dpd/raya",
|
|
70
|
-
"note": "parenthetical = \"em-
|
|
70
|
+
"note": "parenthetical = \"em-paired\": la raya en U+2014 escrita como par, con un espacio ORDINARIO fuera del par y ninguno en los bordes interiores («Llegó —por fin— a casa»), que es lo que prescribe la fuente. La regla solo convierte una frase que contiene exactamente dos rayas candidatas; un guion suelto («Madrid - la capital») o una frase con más de dos rayas se deja como está, porque el DPD no describe el uso de la raya en esas posiciones y nada permite decidir cuál abre y cuál cierra. Las rayas de diálogo («—Hola —dijo—.») no se tocan. Hasta spec 1.17.5 el valor era \"em-spaced\", una aproximación que dejaba dos espacios interiores que el DPD no admite; hasta spec 1.16.0 era \"none\". Consultado el 18.09.2026."
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"rule": "ranges",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"spec": "1.
|
|
2
|
+
"spec": "1.18.0",
|
|
3
3
|
"$comment": "Locale resolution input. Algorithm is specified in spec/rules/locale-resolution.md and is identical in every runtime — never delegate it to a platform locale-negotiation library. \"spec\" here must track spec/VERSION exactly — it is not itself the global version source; scripts/validate-spec.mjs enforces the match.",
|
|
4
4
|
"locales": [
|
|
5
5
|
"en-US",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
**Spec version:** 0.6.0 (0.2.0 for everything except the 0.5.0/0.6.0 changes noted inline and in
|
|
5
5
|
§8 History), amended in **1.3.0**: §1 and §3.4's statement of what belongs to `ranges`, §3.2a's
|
|
6
6
|
re-entry condition, and §3.2 steps 7 and 8, all for [ranges.md](ranges.md) §3.2a's closed-up
|
|
7
|
-
symbols.
|
|
7
|
+
symbols, and again in **1.18.0**: the value `"em-paired"` and its own algorithm, §3.4a.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -39,14 +39,17 @@ in every prior spec version, since the two branches were always mutually exclusi
|
|
|
39
39
|
0.5.0 split makes that exclusivity a boundary between two rules instead of two branches of one.
|
|
40
40
|
|
|
41
41
|
The parenthetical form is governed by one enum in the locale file: a dash _length_ (`em` or `en`)
|
|
42
|
-
and a _spacing_ (`tight` or `spaced`),
|
|
42
|
+
and a _spacing_ (`tight` or `spaced`), the opt-out value `none`, or — since spec 1.18.0 — the one
|
|
43
|
+
value that is neither symmetric nor decided token by token, `em-paired` (§3.4a).
|
|
43
44
|
|
|
44
45
|
---
|
|
45
46
|
|
|
46
47
|
## 2. Locale data consumed
|
|
47
48
|
|
|
48
|
-
- `dash.parenthetical` — one of `"em-tight"`, `"em-spaced"`, `"
|
|
49
|
-
`"none"`.
|
|
49
|
+
- `dash.parenthetical` — one of `"em-tight"`, `"em-spaced"`, `"em-paired"`, `"en-tight"`,
|
|
50
|
+
`"en-spaced"`, `"none"`. `"em-paired"` (spec 1.18.0) writes the pair as an em dash with a space
|
|
51
|
+
**outside** the pair and none inside it (`a —b— c`); it is specified in §3.4a, because it is the
|
|
52
|
+
one value whose result depends on which stroke opens the pair and which closes it.
|
|
50
53
|
|
|
51
54
|
**As of spec 0.5.0, `dashes` no longer reads `dash.range`** — that field is now read exclusively
|
|
52
55
|
by `ranges` ([ranges.md](ranges.md) §2), under the same key, with the same values and the same
|
|
@@ -164,7 +167,9 @@ U+2011 they meant it.
|
|
|
164
167
|
then "counts on the left only") each fixed the witness in front of them and left the next
|
|
165
168
|
one reachable; §8.2 defect (d) records how.
|
|
166
169
|
|
|
167
|
-
4. **Symmetry guard.** If `lsp ≠ rsp`, emit nothing and continue.
|
|
170
|
+
4. **Symmetry guard.** If `lsp ≠ rsp`, emit nothing and continue. (`"em-paired"` is the one
|
|
171
|
+
exception: §3.4a counts such a stroke and, when it is a single U+2014, reads it as half of a
|
|
172
|
+
pair.) A stroke that is spaced on
|
|
168
173
|
one side and tight on the other is not a dash: it is `--force`, `-5 °C`, a Markdown bullet
|
|
169
174
|
`- item`, a signature `-- Iurii`, or an arrow `->`. This single guard removes the large
|
|
170
175
|
majority of false positives and it applies to both the range and the parenthetical
|
|
@@ -500,6 +505,7 @@ Emit one edit replacing `cp[s - lsp … e - 1 + rsp]` with:
|
|
|
500
505
|
| -------------------- | ------------------------------------------------------- |
|
|
501
506
|
| `"em-tight"` | U+2014 |
|
|
502
507
|
| `"em-spaced"` | U+0020 U+2014 U+0020 |
|
|
508
|
+
| `"em-paired"` | _(not a per-token replacement — see §3.4a)_ |
|
|
503
509
|
| `"en-tight"` | U+2013 |
|
|
504
510
|
| `"en-spaced"` | U+0020 U+2013 U+0020 |
|
|
505
511
|
| `"none"` | _(emit nothing — the token is left exactly as written)_ |
|
|
@@ -507,6 +513,55 @@ Emit one edit replacing `cp[s - lsp … e - 1 + rsp]` with:
|
|
|
507
513
|
**Subject to guards T1 and T2 (§3.2 steps 8 and 9), evaluated now that the form is known.** If the replacement is identical to the span it replaces, emit
|
|
508
514
|
nothing.
|
|
509
515
|
|
|
516
|
+
### 3.4a `"em-paired"` — the pair as a unit (spec 1.18.0)
|
|
517
|
+
|
|
518
|
+
When `dash.parenthetical` is `"em-paired"`, §3.4 is replaced by this section and the token loop
|
|
519
|
+
of §3.2 is replaced by a loop over **segments**. Everything else a stroke must satisfy — steps 2,
|
|
520
|
+
5, 6 and 7 of §3.2, §3.2a, P1, P4 and P5 — still applies, because those guards decide whether a
|
|
521
|
+
stroke is a dash at all.
|
|
522
|
+
|
|
523
|
+
**Segment.** A segment is a stretch of the text unit bounded by the unit's start and end and by
|
|
524
|
+
a *terminal*: U+002E, U+003F, U+0021 or U+2026 that is followed by U+0020, a `NOBREAK-SPACE`, a
|
|
525
|
+
`BREAK`, a marker, or the end of the unit. A `NOBREAK-SPACE` counts because `nbsp` (order 70) puts
|
|
526
|
+
one after a terminal (`Sr. Pérez`, `p. ej.`); if only U+0020 closed a segment, that edit would
|
|
527
|
+
move the boundary and a second pass would pair strokes the first had kept apart. A terminal followed by anything else (`3.5`, `—¿quién?—`) does not end a
|
|
528
|
+
segment. A `BREAK` is **not** a segment boundary.
|
|
529
|
+
|
|
530
|
+
**Counted strokes.** Every maximal `DASH` run of §3.2 step 1 in a segment is classified:
|
|
531
|
+
|
|
532
|
+
- *Not a stroke*, and not counted: a run with `k > 3`; a range candidate (§3.3, ranges.md §3.2),
|
|
533
|
+
decided by its flanks alone, **whether or not the run is symmetric** (`5 -10` is a candidate);
|
|
534
|
+
a single hyphen-shaped run (U+002D, U+2010, U+2212) with `lsp = rsp = 0`, which is a compound;
|
|
535
|
+
and the U+002D of the literal sequence `+/-`, which `symbols` (order 80) turns into `±`.
|
|
536
|
+
- *Counted and eligible:* every other run that passes steps 5, 6 and 7, §3.2a, P4 and P5 and is
|
|
537
|
+
either symmetric (`lsp = rsp`) or a **single U+2014** spaced on one side only.
|
|
538
|
+
- *Counted and ineligible:* every other run — including a stroke at the start or end of a line
|
|
539
|
+
(the dialogue dash), one next to a `NOBREAK-SPACE`, `-mente`, `pre-`, `--force`, a Markdown
|
|
540
|
+
bullet and a lone U+2013.
|
|
541
|
+
|
|
542
|
+
**Decision.** A segment is converted if and only if **all** of the following hold; otherwise the
|
|
543
|
+
whole segment is left exactly as typed:
|
|
544
|
+
|
|
545
|
+
1. it has **exactly two** counted strokes, and both are eligible;
|
|
546
|
+
2. no `BREAK` lies between them;
|
|
547
|
+
3. the first is not shaped like a closer (`lsp = 0`, `rsp = 1`) and the second is not shaped like
|
|
548
|
+
an opener (`lsp = 1`, `rsp = 0`);
|
|
549
|
+
4. T1 (§3.2 step 8) does not block a side on which a space is inserted (step 5 below).
|
|
550
|
+
|
|
551
|
+
**Emission.** For the first stroke (the opener) and the second (the closer), the glyph is U+2014
|
|
552
|
+
and the **inner** side — to the right of the opener, to the left of the closer — is made tight,
|
|
553
|
+
removing a U+0020 if there was one. The **outer** side keeps a U+0020 if it had one; if it had
|
|
554
|
+
none, a U+0020 is inserted when the neighbouring code point `cp[L]` (opener) or `cp[R]` (closer)
|
|
555
|
+
is in `LETTER` or `DIGIT`, and otherwise the side stays tight, so `(—`, `«—`, `—»` and
|
|
556
|
+
`—por fin—.` are produced without a space the `spaces` rule would remove. T2 (§3.2 step 9) is
|
|
557
|
+
therefore vacuous: a space is only ever inserted beside a letter or a digit. A replacement
|
|
558
|
+
identical to the span it replaces is not emitted.
|
|
559
|
+
|
|
560
|
+
**What is left alone, by construction.** A lone stroke (`Madrid - la capital`); three or more
|
|
561
|
+
strokes in a segment; a pair split by a terminal (`p. ej.`) or by a line break; the dialogue dash
|
|
562
|
+
and any segment holding it (`—Hola —dijo—.`); affix hyphens; a pair whose strokes are separated by
|
|
563
|
+
a `NOBREAK-SPACE`. These are the accepted cost of not guessing which stroke opens which (§7.8).
|
|
564
|
+
|
|
510
565
|
### 3.5 Continue, and the non-overlap guarantee
|
|
511
566
|
|
|
512
567
|
Set `i` to the index just past the token's run in the **input** array and continue from §3.2
|
|
@@ -689,6 +744,33 @@ Every input to a declined token's verdict is therefore unaffected by any edit `T
|
|
|
689
744
|
pass: `T(T(x))` declines exactly where `T(x)` declined. The historical counterexamples that led to
|
|
690
745
|
this guard set — before it closed every gap — are summarised in §8.2.
|
|
691
746
|
|
|
747
|
+
### 5.2a `"em-paired"` — the segment verdict is stable (spec 1.18.0)
|
|
748
|
+
|
|
749
|
+
Under `"em-paired"` the verdict is made per segment (§3.4a), not per token, so §5.1's table does
|
|
750
|
+
not apply and the argument is rebuilt on the three facts a segment verdict reads.
|
|
751
|
+
|
|
752
|
+
- **Fixed points.** The output form has two U+2014 strokes, each spaced on its outer side only (or
|
|
753
|
+
tight beside a non-letter), which is eligible and correctly shaped, and the replacement of each
|
|
754
|
+
is byte-identical to its span: nothing is emitted.
|
|
755
|
+
- **The segment boundaries do not move.** Edits touch only a dash run and the U+0020 beside it.
|
|
756
|
+
A U+0020 is inserted only after a letter, a digit or a dash, never after a terminal, and the
|
|
757
|
+
first stroke after a terminal is an opener whose outer U+0020 is kept, so a terminal followed by
|
|
758
|
+
a space stays followed by one. No edit creates or removes a terminal.
|
|
759
|
+
- **The counted set does not change in the dangerous direction.** A converted segment can become
|
|
760
|
+
declined on the next pass (`a - 5 - b` gives `a —5— b`, whose two strokes then share a
|
|
761
|
+
cluster with the digit, §3.2 step 7), and that is harmless: a declined segment emits nothing, so
|
|
762
|
+
the text is already a fixed point. What would break idempotency is "declined → converted" on a
|
|
763
|
+
later pass, which needs a counted stroke to disappear, or the segment to change. A stroke that
|
|
764
|
+
was declined stays declined for the reasons of §5.2.
|
|
765
|
+
- **Composition obligation on later rules.** Every rule after `dashes` must leave the count of
|
|
766
|
+
counted strokes in a segment alone. `hyphen` (order 35) emits only `INERT-DASH`, which is not a
|
|
767
|
+
`DASH`; `symbols` rewrites `+/-` into `±`, which is why that hyphen is *not a stroke* above;
|
|
768
|
+
`nbsp` changes only U+0020 into `NOBREAK-SPACE`, which can make a stroke ineligible but moves
|
|
769
|
+
no segment boundary, because a terminal closes a segment before either.
|
|
770
|
+
|
|
771
|
+
The one direction that would break idempotency is "declined → converted" on the second pass. It
|
|
772
|
+
needs a counted stroke to disappear or a segment boundary to move; neither can happen.
|
|
773
|
+
|
|
692
774
|
### 5.3 Interaction with `ranges` is stable
|
|
693
775
|
|
|
694
776
|
`ranges` (order 25) runs before `dashes` (order 30) in every pass. Three guarantees hold between
|
|
@@ -903,8 +985,8 @@ never reaches a digit-flanked token at all.
|
|
|
903
985
|
The first locale with `"none"` on **both** fields, so the rule is a **total no-op** for it in the
|
|
904
986
|
same provable sense `hyphen` is a no-op for a locale with empty lists. It is no longer the only
|
|
905
987
|
one: `tr` (spec 1.6.0) is both-`none` too, and `es` was from spec 1.3.0 until 1.17.1, each for its
|
|
906
|
-
own reason and each recorded in its own locale file. (`es`
|
|
907
|
-
|
|
988
|
+
own reason and each recorded in its own locale file. (`es` sets `parenthetical` to `"em-paired"` since spec 1.18.0 — it was
|
|
989
|
+
`"em-spaced"`, an approximation, from 1.17.0 — and keeps `range` at `"none"`.) This section stays written about `el` because its two fields are
|
|
908
990
|
`"none"` for two *different* reasons, which is what makes it worth reading. Tokens are still
|
|
909
991
|
classified — §3.3's "a range token is never reconsidered as a parenthetical" still holds — but no
|
|
910
992
|
classification has an emission to make. The rows below are therefore all "no change" rows by
|
|
@@ -922,18 +1004,18 @@ the guide is explicit.
|
|
|
922
1004
|
that names both forms in both places is not being vague; it is declining to rank them.
|
|
923
1005
|
Emitting either would express a preference the citation does not carry, so the rule emits
|
|
924
1006
|
nothing.
|
|
925
|
-
- **`parenthetical: "none"` — a
|
|
1007
|
+
- **`parenthetical: "none"` — a source conflict, no longer a schema limit.** The guide prescribes a U+2014
|
|
926
1008
|
pair (its own header gives «Alt 0151») and states the spacing exactly: «Όπως η παρένθεση, η
|
|
927
1009
|
διπλή παύλα δεν χωρίζεται με κενά διαστήματα από τη λέξη, φράση ή πρόταση που περικλείει·
|
|
928
1010
|
αντίθετα, μπαίνουν διαστήματα πριν από την πρώτη και μετά τη δεύτερη παύλα.» — ordinary spaces
|
|
929
|
-
**outside** the pair, none on the **inner** edges.
|
|
930
|
-
that asymmetry
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
In both cases `"none"` is the honest encoding, not a placeholder awaiting a default (§2) —
|
|
936
|
-
|
|
1011
|
+
**outside** the pair, none on the **inner** edges. Until spec 1.18.0 the enum had no value for
|
|
1012
|
+
that asymmetry; `"em-paired"` (§3.4a) is that value. `el` stays `"none"` all the same, because
|
|
1013
|
+
`"em-paired"` is an em dash and the state school grammar appears to set an en dash in the same
|
|
1014
|
+
role: choosing between them needs a source that ranks the two, and is not a licence to
|
|
1015
|
+
approximate.
|
|
1016
|
+
|
|
1017
|
+
In both cases `"none"` is the honest encoding, not a placeholder awaiting a default (§2) — and
|
|
1018
|
+
both are now waiting on a _source_. `spec/locales/el.json`'s `dashes.note` carries the
|
|
937
1019
|
detail, including a **source conflict** this document does not try to settle: the EU guide sets
|
|
938
1020
|
U+2014 parenthetically while the state school grammar appears to set U+2013.
|
|
939
1021
|
|
|
@@ -1038,6 +1120,16 @@ development, the compound-label widening's original acceptance) moved to §8.
|
|
|
1038
1120
|
exists, a port could transcribe either set and stay green. (T2 is shared with `ranges`, §3.3
|
|
1039
1121
|
there — the same gap applies to a `-spaced` range replacement before U+2026.)
|
|
1040
1122
|
|
|
1123
|
+
8. **`"em-paired"` converts only a segment with exactly two strokes (spec 1.18.0).** The rule has
|
|
1124
|
+
no syntax to read, so which stroke opens and which closes can only be inferred from there being
|
|
1125
|
+
two. The price, measured on fixtures and not yet on a corpus, is that these stay as typed:
|
|
1126
|
+
a lone spaced hyphen (`Madrid - la capital`), a sentence with two incisos (four strokes), an
|
|
1127
|
+
inciso holding an abbreviation or a `?`/`!` followed by a space, an inciso split by a line break,
|
|
1128
|
+
and any sentence that also holds a dialogue dash. The converse risk is a list written with
|
|
1129
|
+
spaced hyphens: `Madrid - Barcelona - Sevilla` becomes `Madrid —Barcelona— Sevilla`. The DPD
|
|
1130
|
+
names neither case, so both are recorded here and pinned by fixtures in `fixtures/es.json`
|
|
1131
|
+
rather than decided by a heuristic.
|
|
1132
|
+
|
|
1041
1133
|
---
|
|
1042
1134
|
|
|
1043
1135
|
## 8. History
|
|
@@ -19,7 +19,7 @@ step 9 with §3.8.5's content-line condition, added in 1.10.0, §3.8.4's carriag
|
|
|
19
19
|
continuation line with the bails of §3.8.6 that use it, added in 1.11.0, and §3.8.4's node lines,
|
|
20
20
|
declined keys, node markers and own-line region, with the changes to steps 1, 3, 4, 5, 6, 7 and 8
|
|
21
21
|
that go with them, added in 1.11.0, and §3.9 with the amendments it carries to §3.1, §3.5 step 2,
|
|
22
|
-
§4, §5, §7 item 7 and §8, added in 1.13.0, and §3.4's delimiter-neighbour rule with §3.7.3's autolink-literal tail, terminator guard and reference labels, and the amendments they carry to §3.4's deletion paragraph, §5 items 2 and 3, its fifth-part note and testing obligation, and §6, added in 1.17.2, and §3.4's escape-and-reference rule with the amendments it carries to §3.6, §3.7.3, §5 item 2's fifth-part note, §5 item 3 and the testing obligation, added in 1.17.4).
|
|
22
|
+
§4, §5, §7 item 7 and §8, added in 1.13.0, and §3.4's delimiter-neighbour rule with §3.7.3's autolink-literal tail, terminator guard and reference labels, and the amendments they carry to §3.4's deletion paragraph, §5 items 2 and 3, its fifth-part note and testing obligation, and §6, added in 1.17.2, and §3.4's escape-and-reference rule with the amendments it carries to §3.6, §3.7.3, §5 item 2's fifth-part note, §5 item 3 and the testing obligation, added in 1.17.4, and §3.4's bracket-shape rule, added in 1.17.5).
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
@@ -460,6 +460,48 @@ in five runtimes; it is therefore stricter than a parser: `AT&T ;x` (en-US) keep
|
|
|
460
460
|
though `&T;` is no reference. **That is the accepted cost**, together with a literal backslash
|
|
461
461
|
before a space and punctuation, which is rare in prose.
|
|
462
462
|
|
|
463
|
+
**The bracket-shape rule (`markdown` only, spec 1.17.5).** Three more shapes are made by joining
|
|
464
|
+
what a deleted space kept apart, and both dialects, which enable GFM (§3.7), read the joined form
|
|
465
|
+
as structure where the spaced form is literal text: a task-list marker, `[x]`, `[X]` or `[ ]` at the
|
|
466
|
+
start of a list item, and a footnote reference or definition, `[^label]`. Measured, with the
|
|
467
|
+
pre-1.17.5 behaviour:
|
|
468
|
+
|
|
469
|
+
| Mode | Input | Locale | Output before 1.17.5 | What changed |
|
|
470
|
+
| ---------- | ------------- | ------- | -------------------- | --------------------------------------------------------------- |
|
|
471
|
+
| `markdown` | `- [ x] item` | `en-GB` | `- [x] item` | the text of a literal bracket becomes a checked task-list item |
|
|
472
|
+
| `markdown` | `- [x ] item` | `en-GB` | `- [x] item` | the same item, from the other side |
|
|
473
|
+
| `markdown` | `- [ ] item` | `en-GB` | `- [ ] item` | two spaces become one, and the text becomes an unchecked item |
|
|
474
|
+
| `markdown` | `a [ ^1] b` | `en-GB` | `a [^1] b` | a footnote reference, if a definition `[^1]: …` exists |
|
|
475
|
+
|
|
476
|
+
Write `SKIP(i, +1)` for the smallest index greater than `i` whose code point is not U+0020, and
|
|
477
|
+
`SKIP(i, −1)` for the largest index smaller than `i` whose code point is not U+0020; a marker, or a
|
|
478
|
+
position outside the array, belongs to no class below. With `p`, `q` and `r` as before, and
|
|
479
|
+
`a = SKIP(p, −1)` and `b = SKIP(q, +1)` (so that `a` and `b` are the nearest code points that are
|
|
480
|
+
not U+0020 on either side of the deleted run):
|
|
481
|
+
|
|
482
|
+
> **A deletion (`r = 0`) is discarded if either of these holds, evaluated on the array the rule read.**
|
|
483
|
+
>
|
|
484
|
+
> 1. `cp[a]` is U+005B, and either `cp[b]` is U+005E or U+005D, or `cp[b]` is U+0078 or U+0058 and
|
|
485
|
+
> `cp[SKIP(b, +1)]` is U+005D.
|
|
486
|
+
> 2. `cp[b]` is U+005D, and either `cp[a]` is U+0078 or U+0058 and `cp[SKIP(a, −1)]` is U+005B, or
|
|
487
|
+
> the **label run** is at least two code points long, its leftmost code point is U+005E, and
|
|
488
|
+
> the nearest code point left of the run that is not U+0020 is U+005B. The label run is the
|
|
489
|
+
> longest run ending at `a` of code points that are none of U+0020, U+005B, U+005D, and not a
|
|
490
|
+
> marker.
|
|
491
|
+
>
|
|
492
|
+
> **An edit whose replacement is the single code point U+0020 is discarded** when `cp[a]` is U+005B
|
|
493
|
+
> and `cp[b]` is U+005D: `spaces` collapses a run of spaces to one rather than deleting it, and
|
|
494
|
+
> `[ ]` becoming `[ ]` is the unchecked marker.
|
|
495
|
+
|
|
496
|
+
The skip over U+0020 is what keeps `[ x ]` whole: the two deletions are evaluated on the same
|
|
497
|
+
array, and each sees the other space as absent. The rule reads no parser state and no dialect, so it
|
|
498
|
+
fires identically on every run (§5 item 3), and it tests deletions only because `spaces` is the
|
|
499
|
+
only rule that deletes. It is a test of _shape_, not of whether a footnote definition or a list item
|
|
500
|
+
exists. **The accepted costs:** `a [ x] b` in the middle of a sentence keeps its space although no
|
|
501
|
+
list item is there, as do `[ x ]`, `[ ^1]` and `[ ]` in prose; `a [ ^ ] b` loses its second space only,
|
|
502
|
+
because a label run needs two code points; and a footnote label that contains an inline element
|
|
503
|
+
(`[^*a*b ]`) is missed, because a marker ends the label run.
|
|
504
|
+
|
|
463
505
|
### 3.5 Applying the result
|
|
464
506
|
|
|
465
507
|
1. Extract the span sequence from the source. Record each span's **source offsets**.
|
|
@@ -1830,7 +1872,8 @@ they do not carry it over for free either. Write `M` for the whole mode transfor
|
|
|
1830
1872
|
can also create a backslash escape or a character reference from literal text (`foo\ ,`
|
|
1831
1873
|
becomes `foo\,` and `AT& ;T` becomes `AT&T`): the parse tree keeps its shape and its
|
|
1832
1874
|
text changes, which a shape comparison does not see. That class was not closed by 1.17.2 and
|
|
1833
|
-
is closed by §3.4's escape-and-reference rule (spec 1.17.4).
|
|
1875
|
+
is closed by §3.4's escape-and-reference rule (spec 1.17.4). A deletion can also join
|
|
1876
|
+
`[` and `x` or `^` into a shape a GFM parser reads as structure, and §3.4's bracket-shape rule (spec 1.17.5) closes that.
|
|
1834
1877
|
- **Deletion** is only ever of a U+0020, and structural whitespace borders a `BREAK` — a real
|
|
1835
1878
|
one in `text` mode, a −2 marker in the others — where `spaces` refuses to act
|
|
1836
1879
|
(`spaces.md` §3.2 step 4). A deletion therefore cannot turn `- item` into `-item`, collapse
|
|
@@ -1904,7 +1947,7 @@ they do not carry it over for free either. Write `M` for the whole mode transfor
|
|
|
1904
1947
|
to a side. The discard is a pure function of the array and its span table (since 1.17.2: of
|
|
1905
1948
|
`(p, q, r, s₀, s₁)`, of the code points beside the edit for §3.4's delimiter-neighbour rule, of
|
|
1906
1949
|
the same code points and the run of letters and digits around the join for §3.4's
|
|
1907
|
-
escape-and-reference rule (since 1.17.4), and of whether the span begins at the end of a web address for §3.7.3's terminator guard), so it
|
|
1950
|
+
escape-and-reference rule (since 1.17.4), of the code points around the join for §3.4's bracket-shape rule (since 1.17.5), and of whether the span begins at the end of a web address for §3.7.3's terminator guard), so it
|
|
1908
1951
|
happens identically on every run: a rule that was declined at an edge once is declined there always, and the output
|
|
1909
1952
|
contains nothing for the next run to reconsider.
|
|
1910
1953
|
|
|
@@ -1944,7 +1987,9 @@ must include an address with `_`, `*` and `~` inside it after `"`, `'` and `(`,
|
|
|
1944
1987
|
directly after a digit. **Since 1.17.4 the comparison also covers the text values of the tree**, not only its shape: the
|
|
1945
1988
|
defect behind the escape-and-reference rule left the shape unchanged. The alphabet must then include
|
|
1946
1989
|
U+005C, `&`, `#`, `;`, `,` and a letter, and the templates a literal backslash and a literal
|
|
1947
|
-
`&name` each followed by a space and by each punctuation mark. **
|
|
1990
|
+
`&name` each followed by a space and by each punctuation mark. **Since 1.17.5 the alphabet also includes** U+005B, U+005D, U+005E,
|
|
1991
|
+
`x` and `X`, and the templates a list item and a footnote definition each holding every
|
|
1992
|
+
combination of those with zero, one or two spaces inside the brackets. **Two classes are carved out because they are accepted, not because
|
|
1948
1993
|
they are untested**: a text that matched no definition in the input and matches one in the output
|
|
1949
1994
|
(§3.7.3's accepted case), and an e-mail address, whose end only the parser decides.
|
|
1950
1995
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"spec": "1.
|
|
2
|
+
"spec": "1.18.0",
|
|
3
3
|
"$comment": "Single source of truth for pipeline order. Rules run in ascending `order`. Disabling a rule removes it from the sequence and never reorders the rest. Rule ids are public API (see docs/ARCHITECTURE.md section 5). \"spec\" here must track spec/VERSION exactly — it is not itself the global version source; scripts/validate-spec.mjs enforces the match.",
|
|
4
4
|
"rules": [
|
|
5
5
|
{
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"default": "on",
|
|
33
33
|
"modes": ["text", "html", "markdown", "yaml"],
|
|
34
34
|
"localeData": ["dash"],
|
|
35
|
-
"summary": "Parenthetical dash per locale convention (dash.parenthetical). Never reinterprets a range candidate as a parenthetical dash — that shape belongs to `ranges` alone, whether or not `ranges` is enabled (spec 0.5.0; range detection moved out of this rule). A candidate is digit-flanked, or flanked by a closed-up symbol matched on the opposite member (spec 1.3.0; ranges.md §3.2a)."
|
|
35
|
+
"summary": "Parenthetical dash per locale convention (dash.parenthetical). Never reinterprets a range candidate as a parenthetical dash — that shape belongs to `ranges` alone, whether or not `ranges` is enabled (spec 0.5.0; range detection moved out of this rule). A candidate is digit-flanked, or flanked by a closed-up symbol matched on the opposite member (spec 1.3.0; ranges.md §3.2a). The value `em-paired` (spec 1.18.0) is decided per sentence rather than per token: it converts a sentence holding exactly two eligible strokes (dashes.md §3.4a)."
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "hyphen",
|
|
@@ -190,6 +190,13 @@ or G3.
|
|
|
190
190
|
violates `I₃` when it changes the **spacing** around a U+002D/U+2013/U+2014, because spacing
|
|
191
191
|
is what `dashes` reads to decide whether a stroke is a parenthetical dash at all.
|
|
192
192
|
|
|
193
|
+
Under `dash.parenthetical = "em-paired"` (spec 1.18.0) the verdict is no longer local to a token:
|
|
194
|
+
`dashes` decides per segment, from the count and eligibility of the strokes in it (`dashes.md`
|
|
195
|
+
§3.4a, §5.2a). A later rule violates `I₃` there only by changing the count of counted strokes
|
|
196
|
+
or moving a segment boundary. `nbsp` changes U+0020 into a `NOBREAK-SPACE`, which dashes.md §3.4a
|
|
197
|
+
treats as closing a segment exactly as U+0020 does; `symbols` consumes the hyphen of `+/-`, which
|
|
198
|
+
§3.4a already excludes; `hyphen` emits only an `INERT-DASH`.
|
|
199
|
+
|
|
193
200
|
**Who can violate it.** Nobody, since spec 0.1.0 — and it is worth recording that this line
|
|
194
201
|
previously read _"`nbsp`, which inserts and converts space-like code points"_, which was true
|
|
195
202
|
and was the source of two defects. `dashes` now treats both U+00A0 and U+202F as making an
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"required": ["parenthetical", "range"],
|
|
39
39
|
"properties": {
|
|
40
40
|
"parenthetical": {
|
|
41
|
-
"enum": ["em-tight", "em-spaced", "en-tight", "en-spaced", "none"],
|
|
42
|
-
"description": "Dash used for a parenthetical break. `-tight` means no surrounding spaces, `-spaced` means a regular space on each side (the leading one may later be made non-breaking by the nbsp rule). `none` means the rule must not substitute anything: either the locale has no verified convention, or the cited sources attest more than one form and rank none."
|
|
41
|
+
"enum": ["em-tight", "em-spaced", "em-paired", "en-tight", "en-spaced", "none"],
|
|
42
|
+
"description": "Dash used for a parenthetical break. `-tight` means no surrounding spaces, `-spaced` means a regular space on each side (the leading one may later be made non-breaking by the nbsp rule). `em-paired` is the em dash written as a pair, with a space outside the pair and none inside it (`a —b— c`). `none` means the rule must not substitute anything: either the locale has no verified convention, or the cited sources attest more than one form and rank none."
|
|
43
43
|
},
|
|
44
44
|
"range": {
|
|
45
45
|
"enum": ["em-tight", "em-spaced", "en-tight", "en-spaced", "none"],
|
|
@@ -131,7 +131,7 @@ module Polytypo
|
|
|
131
131
|
|
|
132
132
|
# The target dash glyph for a style value.
|
|
133
133
|
def dash_code_point(style)
|
|
134
|
-
style == "em-tight" || style == "em-spaced" ? EM_DASH : EN_DASH
|
|
134
|
+
style == "em-tight" || style == "em-spaced" || style == "em-paired" ? EM_DASH : EN_DASH
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
# Whether cp[start...end] is exactly `next`, code point for code point.
|
|
@@ -285,36 +285,47 @@ module Polytypo
|
|
|
285
285
|
# `dashes` token becoming spaced can insert a space next to a `ranges` token's digit run,
|
|
286
286
|
# and vice versa.
|
|
287
287
|
def spacing_transition_blocked?(cp, left, right)
|
|
288
|
+
spacing_transition_blocked_left?(cp, left) || spacing_transition_blocked_right?(cp, right)
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# The left half of T1, for a form that inserts a space on one side only (`em-paired`).
|
|
292
|
+
def spacing_transition_blocked_left?(cp, left)
|
|
288
293
|
n = cp.length
|
|
289
294
|
|
|
290
295
|
# Spec 1.3.0, position p1: step over a CLOSED-SYMBOL between the token and the run.
|
|
291
296
|
left -= 1 if left >= 0 && left < n && closed_up_symbol?(cp[left]) && left.positive? &&
|
|
292
297
|
digit?(cp[left - 1])
|
|
298
|
+
|
|
299
|
+
return false unless left >= 0 && left < n && digit?(cp[left])
|
|
300
|
+
|
|
301
|
+
d = left
|
|
302
|
+
d -= 1 while d.positive? && digit?(cp[d - 1])
|
|
303
|
+
# Position p2: and over one at the far end of the run.
|
|
304
|
+
i1 = effective_index(cp, skip_closed_up_symbol(cp, d - 1, -1), -1)
|
|
305
|
+
one = i1.nil? ? Polytypo::Engine::NONE : cp[i1]
|
|
306
|
+
two = i1.nil? ? Polytypo::Engine::NONE : effective_neighbour(cp, i1 - 1, -1)
|
|
307
|
+
return true if dash_union?(one)
|
|
308
|
+
|
|
309
|
+
(one == SPACE || no_break_space?(one)) && dash_union?(two)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# The right half of T1; see spacing_transition_blocked_left?.
|
|
313
|
+
def spacing_transition_blocked_right?(cp, right)
|
|
314
|
+
n = cp.length
|
|
315
|
+
|
|
293
316
|
right += 1 if right >= 0 && right < n && closed_up_symbol?(cp[right]) &&
|
|
294
317
|
right + 1 < n && digit?(cp[right + 1])
|
|
295
318
|
|
|
296
|
-
|
|
297
|
-
d = left
|
|
298
|
-
d -= 1 while d.positive? && digit?(cp[d - 1])
|
|
299
|
-
# Position p2: and over one at the far end of the run.
|
|
300
|
-
i1 = effective_index(cp, skip_closed_up_symbol(cp, d - 1, -1), -1)
|
|
301
|
-
one = i1.nil? ? Polytypo::Engine::NONE : cp[i1]
|
|
302
|
-
two = i1.nil? ? Polytypo::Engine::NONE : effective_neighbour(cp, i1 - 1, -1)
|
|
303
|
-
return true if dash_union?(one)
|
|
304
|
-
return true if (one == SPACE || no_break_space?(one)) && dash_union?(two)
|
|
305
|
-
end
|
|
319
|
+
return false unless right >= 0 && right < n && digit?(cp[right])
|
|
306
320
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return true if dash_union?(one)
|
|
314
|
-
return true if (one == SPACE || no_break_space?(one)) && dash_union?(two)
|
|
315
|
-
end
|
|
321
|
+
d = right
|
|
322
|
+
d += 1 while d + 1 < n && digit?(cp[d + 1])
|
|
323
|
+
i1 = effective_index(cp, skip_closed_up_symbol(cp, d + 1, 1), 1)
|
|
324
|
+
one = i1.nil? ? Polytypo::Engine::NONE : cp[i1]
|
|
325
|
+
two = i1.nil? ? Polytypo::Engine::NONE : effective_neighbour(cp, i1 + 1, 1)
|
|
326
|
+
return true if dash_union?(one)
|
|
316
327
|
|
|
317
|
-
|
|
328
|
+
(one == SPACE || no_break_space?(one)) && dash_union?(two)
|
|
318
329
|
end
|
|
319
330
|
|
|
320
331
|
# dashes.md 3.2 steps 1-7 and 3.2a, exactly as they read before the `ranges` split -- the
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "dash_shared"
|
|
4
|
+
require_relative "dashes_paired"
|
|
4
5
|
require_relative "../edits"
|
|
5
6
|
require_relative "../registry"
|
|
6
7
|
require_relative "../unicode_util"
|
|
@@ -66,8 +67,10 @@ module Polytypo
|
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
def scan(cp, locale_data, _ctx)
|
|
69
|
-
edits = []
|
|
70
70
|
style = locale_data["dash"]["parenthetical"]
|
|
71
|
+
return DashesPaired.scan(cp) if style == "em-paired"
|
|
72
|
+
|
|
73
|
+
edits = []
|
|
71
74
|
|
|
72
75
|
DashShared.find_tokens(cp).each do |token|
|
|
73
76
|
# A digit-flanked token is `ranges`' territory, never `dashes`' -- declined
|