From 28bcd24c39226fa2d459d8d4a15768083db6b02a Mon Sep 17 00:00:00 2001 From: Iurii Rogulia Date: Thu, 17 Sep 2026 20:25:37 +0300 Subject: [PATCH] Implement spec 1.2.0: dot-initial tokens, nbsp across span boundaries, elision before a quotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vendors canonical spec 1.2.0 (`spec-v1.2.0`) and implements the rule changes it specifies. Bumps the package to 1.2.0. **Observable change** | input | before | after | | --- | --- | --- | | `Use .NET, .NET Core` | `Use.NET,.NET Core` | unchanged | | `gel : il` (`fr`, html) | `gel: il` | `gel⍽: il` | | `d'« urine »` (`fr`) | `d'«⍽urine⍽»` | `d’«⍽urine⍽»` | - `spaces`: the lone-dot condition gains the word-start clause (spaces.md §3.4) — the space before a single dot is kept when the dot is followed by a letter or an ASCII digit. - `nbsp`: the inline span boundary marker is now in nbsp's `CLOSEISH`, read only by N1/N2's right-context guard, and still not in its `OPENISH` (nbsp.md §3.1, §7 item 12; modes.md §3.3). - `apostrophe`: new fixed class `OPENQUOTE` and case 3a — a letter followed by U+0027 and an opening quotation glyph converts to U+2019 (apostrophe.md §3.1, §3.3). Reads no locale data. --- pyproject.toml | 2 +- src/polytypo/_engine/rules/apostrophe.py | 9 +- src/polytypo/_engine/rules/nbsp.py | 14 +-- src/polytypo/_engine/rules/spaces.py | 9 +- tests/test_rules/test_apostrophe.py | 9 ++ tests/test_rules/test_nbsp.py | 7 ++ tests/test_rules/test_spaces.py | 6 + vendor/polytypo-spec/VERSION | 2 +- vendor/polytypo-spec/fixtures/de-CH.json | 10 +- vendor/polytypo-spec/fixtures/de-DE.json | 34 +++++- vendor/polytypo-spec/fixtures/el.json | 10 +- vendor/polytypo-spec/fixtures/en-GB.json | 18 ++- vendor/polytypo-spec/fixtures/en-US.json | 66 ++++++++++- vendor/polytypo-spec/fixtures/fi.json | 10 +- vendor/polytypo-spec/fixtures/fr-CA.json | 27 ++++- vendor/polytypo-spec/fixtures/fr.json | 108 +++++++++++++++++- .../fixtures/locale-resolution.json | 2 +- vendor/polytypo-spec/fixtures/ru.json | 26 ++++- vendor/polytypo-spec/fixtures/sv.json | 10 +- vendor/polytypo-spec/locales/registry.json | 2 +- vendor/polytypo-spec/rules/order.json | 2 +- 21 files changed, 358 insertions(+), 25 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1a3d234..9543405 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "polytypo" -version = "1.1.0" +version = "1.2.0" description = "Normalize typography across languages: locale-correct quotes, dashes, ellipses and no-break spaces." readme = "README.md" license = "MIT" diff --git a/src/polytypo/_engine/rules/apostrophe.py b/src/polytypo/_engine/rules/apostrophe.py index 4405d85..bba304b 100644 --- a/src/polytypo/_engine/rules/apostrophe.py +++ b/src/polytypo/_engine/rules/apostrophe.py @@ -1,7 +1,8 @@ """spec/rules/apostrophe.md -- order 50, default on. Reads no locale data and skips no position as of spec 1.1.0: 0.5.0's preserve set (apostrophe.md 3.4) existed to stop the case ladder from converting the marks `quotes` had vetoed, and conversion is now the specified outcome for exactly -those marks -- cases 4 and 3 are what turn `rock 'n' roll` into `rock ’n’ roll`.""" +those marks -- cases 4 and 3 are what turn `rock 'n' roll` into `rock ’n’ roll`. Case 3a (spec +1.2.0) reads a fixed OPENQUOTE set, not locale data.""" from __future__ import annotations @@ -63,6 +64,9 @@ 0x2014, } ) +# The quotation glyphs of OPENISH, without its brackets, dashes and MARKER (apostrophe.md 3.1, +# spec 1.2.0): `f'(x)` must stay a prime, and a letter + U+0027 + dash is already case 3. +OPENQUOTE = frozenset({0xAB, 0x2018, 0x201A, 0x201B, 0x201C, 0x201E, 0x201F, 0x2039}) def _at(cp: list[int], i: int) -> int: @@ -95,6 +99,9 @@ def scan(cp: list[int], locale_data: dict[str, Any], ctx: RuleContext) -> list[E ): edits.append(Edit(i, i + 1, [0x2019], RULE_ID)) # case 3: trailing continue + if left != NONE and is_letter(left) and right in OPENQUOTE: + edits.append(Edit(i, i + 1, [0x2019], RULE_ID)) # case 3a: before a quotation + continue if (left == NONE or left in SPACELIKE or left in OPENISH) and _is_alnum(right): edits.append(Edit(i, i + 1, [0x2019], RULE_ID)) # case 4: leading continue diff --git a/src/polytypo/_engine/rules/nbsp.py b/src/polytypo/_engine/rules/nbsp.py index 691a170..b792679 100644 --- a/src/polytypo/_engine/rules/nbsp.py +++ b/src/polytypo/_engine/rules/nbsp.py @@ -8,7 +8,7 @@ from polytypo._engine.edits import Edit from polytypo._engine.registry import RuleContext -from polytypo._engine.sentinels import LINE_MARKER, NONE +from polytypo._engine.sentinels import LINE_MARKER, MARKER, NONE from polytypo._engine.unicode import is_letter, is_upper, simple_uppercase from polytypo.errors import POLYTYPO_MALFORMED_LOCALE_DATA, PolytypoError @@ -35,9 +35,9 @@ 0x3000, } ) -# Includes LINE_MARKER: a member of BREAK for every rule everywhere (modes.md 3.2). nbsp's own -# OPENISH/CLOSEISH (brackets + locale quote glyphs, see _openish_closeish) do NOT get MARKER -- -# unlike quotes/apostrophe, matching the reference implementation exactly. +# Includes LINE_MARKER: a member of BREAK for every rule everywhere (modes.md 3.2). As of spec +# 1.2.0 the inline MARKER is a member of nbsp's own CLOSEISH (read only by N1/N2's right-context +# guard) and NOT of its OPENISH (nbsp.md 3.1, 7 item 12; modes.md 3.3) -- see _openish_closeish. BREAK = frozenset({0x0A, 0x0D, 0x0B, 0x0C, 0x85, 0x2028, 0x2029, LINE_MARKER}) SPACELIKE = frozenset({SP, 0x09}) | NOBREAK | OTHER_SPACE | BREAK DIGIT = frozenset(range(0x30, 0x3A)) @@ -59,7 +59,7 @@ def _is_alnum(v: int) -> bool: def _openish_closeish(locale_data: dict[str, Any]) -> tuple[frozenset[int], frozenset[int]]: quotes = locale_data["quotes"] openish = {0x28, 0x5B, 0x7B} - closeish = {0x29, 0x5D, 0x7D} + closeish = {MARKER, 0x29, 0x5D, 0x7D} for pair in (quotes["primary"], quotes["secondary"]): openish.add(ord(pair["open"])) closeish.add(ord(pair["close"])) @@ -124,8 +124,8 @@ def _before_punctuation_common( prev = _at(cp, i - 1) if prev in target_set or prev in other_set: continue - # Right-context guard. nbsp.md's own CLOSEISH (brackets + locale close glyphs), NOT - # quotes.md's broader CLOSEISH -- the two documents define the class name differently. + # Right-context guard. nbsp.md's own CLOSEISH (brackets + locale close glyphs + MARKER), + # NOT quotes.md's broader CLOSEISH -- the two documents define the class name differently. after = _at(cp, i + 1) if ( after != NONE diff --git a/src/polytypo/_engine/rules/spaces.py b/src/polytypo/_engine/rules/spaces.py index 288dca7..dafdc78 100644 --- a/src/polytypo/_engine/rules/spaces.py +++ b/src/polytypo/_engine/rules/spaces.py @@ -112,7 +112,9 @@ def scan(cp: list[int], locale_data: dict[str, Any], ctx: RuleContext) -> list[E def _lone_dot_condition_holds(cp: list[int], e: int, right: int) -> bool: """3.4: if right is U+002E, replacement length may be 0 only if the maximal DOTLIKE run - starting at e has length exactly 1. Any other STRIP-BEFORE member is unaffected.""" + starting at e has length exactly 1 and cp[e+1] is neither a LETTER nor an ASCII digit (the + word-start clause, spec 1.2.0: `.NET`, `.5`). A span boundary marker after the dot is neither, + so it still strips. Any other STRIP-BEFORE member is unaffected.""" if right != 0x2E: return True j = e @@ -121,4 +123,7 @@ def _lone_dot_condition_holds(cp: list[int], e: int, right: int) -> bool: while j < n and cp[j] in DOTLIKE: run_len += 1 j += 1 - return run_len == 1 + if run_len != 1: + return False + after = _at(cp, e + 1) + return after == NONE or not (is_letter(after) or _is_ascii_digit(after)) diff --git a/tests/test_rules/test_apostrophe.py b/tests/test_rules/test_apostrophe.py index ce1ef59..4d87a1b 100644 --- a/tests/test_rules/test_apostrophe.py +++ b/tests/test_rules/test_apostrophe.py @@ -23,3 +23,12 @@ def test_prime_guard_leaves_feet_and_inches_alone() -> None: def test_case_5_nothing_inferable_is_left_alone() -> None: assert polytypo.transform("a ' b", locale="en-US") == "a ' b" + + +def test_case_3a_elision_before_opening_quotation_glyph() -> None: + # apostrophe.md 3.3 case 3a (spec 1.2.0). + assert polytypo.transform("l'“idea”", locale="en-US") == "l’“idea”" + + +def test_case_3a_excludes_brackets() -> None: + assert polytypo.transform("f'(x) = 2", locale="en-US") == "f'(x) = 2" diff --git a/tests/test_rules/test_nbsp.py b/tests/test_rules/test_nbsp.py index 3bb4a19..713bb5e 100644 --- a/tests/test_rules/test_nbsp.py +++ b/tests/test_rules/test_nbsp.py @@ -4,6 +4,7 @@ from __future__ import annotations import polytypo +import polytypo.html NBSP = " " NNBSP = " " @@ -27,3 +28,9 @@ def test_n5_before_units() -> None: def test_n3_after_short_words_does_not_fire_mid_abbreviation() -> None: assert polytypo.transform("p. 12", locale="fr") == "p. 12" + + +def test_n1_right_context_accepts_span_boundary_marker() -> None: + # nbsp.md 3.3 step 2 (spec 1.2.0): the inline marker is in nbsp's CLOSEISH. + out = polytypo.html.transform("gel : il", locale="fr") + assert out == f"gel{NBSP}: il" diff --git a/tests/test_rules/test_spaces.py b/tests/test_rules/test_spaces.py index 12bd1e7..a2c9e7e 100644 --- a/tests/test_rules/test_spaces.py +++ b/tests/test_rules/test_spaces.py @@ -42,3 +42,9 @@ def test_empty_bracket_guard_collapses_but_does_not_delete() -> None: def test_open_bracket_strips_trailing_space() -> None: assert polytypo.transform("( a)", locale="en-US") == "(a)" + + +def test_word_start_clause_keeps_space_before_dot_initial_token() -> None: + # spaces.md 3.4 (spec 1.2.0): a dot followed by a letter or digit starts a word. + assert polytypo.transform("Use .NET, .NET Core", locale="en-US") == "Use .NET, .NET Core" + assert polytypo.transform("a .5 b", locale="en-US") == "a .5 b" diff --git a/vendor/polytypo-spec/VERSION b/vendor/polytypo-spec/VERSION index 9084fa2..867e524 100644 --- a/vendor/polytypo-spec/VERSION +++ b/vendor/polytypo-spec/VERSION @@ -1 +1 @@ -1.1.0 +1.2.0 \ No newline at end of file diff --git a/vendor/polytypo-spec/fixtures/de-CH.json b/vendor/polytypo-spec/fixtures/de-CH.json index a5de5b1..9b35c23 100644 --- a/vendor/polytypo-spec/fixtures/de-CH.json +++ b/vendor/polytypo-spec/fixtures/de-CH.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "de-CH", "cases": [ { @@ -496,6 +496,14 @@ "in": "rock 'n' roll", "out": "rock ’n’ roll", "note": "spec 1.1.0, quotes.md §3.2's universal medial-n elision veto: by operator decision the idiom is international, so `quotes` declines the pairing in every locale rather than only where a cited quotes.elisionIdioms entry exists, and `apostrophe` (order 50) converts each mark by its own case ladder — leading elision (apostrophe.md §3.3 case 4), then trailing elision (case 3). Same output and same two case decisions as en-us-quotes-rock-n-roll, which reaches them through the cited idiom instead. History: spec 0.5.0's general ambiguous-medial-span veto preserved both marks here as literal U+0027; before 0.5.0 `quotes` paired them as an ordinary depth-1 quotation in this locale's primary glyphs." + }, + { + "id": "de-ch-apostrophe-elision-before-guillemet", + "rule": "apostrophe", + "mode": "text", + "in": "die Zeitung l'\"Express\"", + "out": "die Zeitung l’«Express»", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): `quotes` gives de-CH's « », and the elision before « converts." } ] } diff --git a/vendor/polytypo-spec/fixtures/de-DE.json b/vendor/polytypo-spec/fixtures/de-DE.json index c8cbced..9797bae 100644 --- a/vendor/polytypo-spec/fixtures/de-DE.json +++ b/vendor/polytypo-spec/fixtures/de-DE.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "de-DE", "cases": [ { @@ -542,6 +542,38 @@ "in": "rock 'n' roll", "out": "rock ’n’ roll", "note": "spec 1.1.0, quotes.md §3.2's universal medial-n elision veto: by operator decision the idiom is international, so `quotes` declines the pairing in every locale rather than only where a cited quotes.elisionIdioms entry exists, and `apostrophe` (order 50) converts each mark by its own case ladder — leading elision (apostrophe.md §3.3 case 4), then trailing elision (case 3). Same output and same two case decisions as en-us-quotes-rock-n-roll, which reaches them through the cited idiom instead. History: spec 0.5.0's general ambiguous-medial-span veto preserved both marks here as literal U+0027; before 0.5.0 `quotes` paired them as an ordinary depth-1 quotation in this locale's primary glyphs." + }, + { + "id": "de-de-spaces-dot-word-start-dotfile", + "rule": "spaces", + "mode": "text", + "in": "Die Datei .gitignore ist leer .", + "out": "Die Datei .gitignore ist leer.", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0): the space before `.gitignore` survives because a letter follows the dot; the space before the final dot is deleted because nothing follows it." + }, + { + "id": "de-de-apostrophe-possessive-before-closing-quote", + "rule": "apostrophe", + "mode": "text", + "in": "Er sagte „Hans'“ und ging.", + "out": "Er sagte „Hans’“ und ging.", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0), §6 row 17: U+201C closes a de-DE quotation but is not in CLOSEISH, so case 3 missed the possessive; case 3a reaches the same U+2019 without reading locale data." + }, + { + "id": "de-de-apostrophe-closing-single-before-closing-double-not-elision", + "rule": "apostrophe", + "mode": "text", + "in": "\"Er sagte 'Hans'\" und ging.", + "out": "„Er sagte ‚Hans‘“ und ging.", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0), §7 item 7: in de-DE the closing double quote U+201C is in OPENQUOTE, so a closing single quote directly before it has exactly case 3a's shape. `quotes` (order 40) pairs both levels first, so no U+0027 reaches this rule and the nested quotation keeps its de-DE glyphs." + }, + { + "id": "de-de-apostrophe-mixed-curly-and-straight-closing-single", + "rule": "apostrophe", + "mode": "text", + "in": "„Er sagte ‚Hans'“ und ging.", + "out": "„Er sagte ‚Hans‘“ und ging.", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): the same shape with the outer pair and the opening single quote already curly. `quotes` still pairs the straight closing single quote with ‚, so case 3a never sees it." } ] } diff --git a/vendor/polytypo-spec/fixtures/el.json b/vendor/polytypo-spec/fixtures/el.json index 0712f8a..294d44f 100644 --- a/vendor/polytypo-spec/fixtures/el.json +++ b/vendor/polytypo-spec/fixtures/el.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "el", "cases": [ { @@ -234,6 +234,14 @@ "ranges": true }, "note": "spec 0.5.0: el's dash.range is \"none\" (no verified convention), so `ranges` substitutes nothing even when explicitly enabled (ranges.md §2, §3.3) — the same invariant the pre-0.5.0 `dashes`-tagged no-op fixtures for this locale already proved for the combined rule." + }, + { + "id": "el-apostrophe-elision-before-guillemet", + "rule": "apostrophe", + "mode": "text", + "in": "η εφημερίδα l'\"Humanité\"", + "out": "η εφημερίδα l’«Humanité»", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): `quotes` gives el's « », and the elision before « converts." } ] } diff --git a/vendor/polytypo-spec/fixtures/en-GB.json b/vendor/polytypo-spec/fixtures/en-GB.json index 5c9c5fb..9d6a5c9 100644 --- a/vendor/polytypo-spec/fixtures/en-GB.json +++ b/vendor/polytypo-spec/fixtures/en-GB.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "en-GB", "cases": [ { @@ -1269,6 +1269,22 @@ "in": "'90s were fun,' he said", "out": "‘90s were fun,’ he said", "note": "quotes.md §6 row E2s: the straight-input control, confirming the corruption in E2 predates mandate 1." + }, + { + "id": "en-gb-spaces-dot-word-start-file-extensions", + "rule": "spaces", + "mode": "text", + "in": "CAD files (.DWG, .STEP) on request", + "out": "CAD files (.DWG, .STEP) on request", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0), §6 row 10g: `.STEP` starts a token, so the space after the comma survives. Spec 1.1.0 produced `(.DWG,.STEP)`." + }, + { + "id": "en-gb-apostrophe-elision-before-curly-quote", + "rule": "apostrophe", + "mode": "text", + "in": "dell'“arte” moderna", + "out": "dell’‘arte’ moderna", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0), §6 row 16: `quotes` re-typesets the curly pair as en-GB's primary single quotes, and the elision before the opening glyph converts to U+2019." } ] } diff --git a/vendor/polytypo-spec/fixtures/en-US.json b/vendor/polytypo-spec/fixtures/en-US.json index 5c2f127..af5aebe 100644 --- a/vendor/polytypo-spec/fixtures/en-US.json +++ b/vendor/polytypo-spec/fixtures/en-US.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "en-US", "cases": [ { @@ -1802,6 +1802,70 @@ "ranges": true }, "note": "ranges.md §3.2, G3 — not part of a decimal or a path. `before` is U+002E (.) for the first candidate and U+002F (/) for the second; `after` is U+002F (/) for the second. This is currently the only canonical fixture exercising G3 — previously untested by any canonical case even before the spec 0.5.0 ownership correction (dashes.test.ts's engine-level 'must not touch' list covered it, but no fixture did)." + }, + { + "id": "en-us-spaces-dot-word-start-dotnet", + "rule": "spaces", + "mode": "text", + "in": "Use .NET, .NET Core or .NET Framework", + "out": "Use .NET, .NET Core or .NET Framework", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0), §6 row 10f: each dot is followed by a letter, so it starts a token and the space before it is not deleted. Spec 1.1.0 produced `Use.NET,.NET Core or.NET Framework`." + }, + { + "id": "en-us-spaces-dot-word-start-decimal", + "rule": "spaces", + "mode": "text", + "in": "the values .5 and .9 apply", + "out": "the values .5 and .9 apply", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0), §6 row 10h: an ASCII digit after the dot counts the same as a letter." + }, + { + "id": "en-us-spaces-dot-word-start-misplaced-full-stop", + "rule": "spaces", + "mode": "text", + "in": "the end .Next sentence", + "out": "the end .Next sentence", + "note": "spaces.md §3.4, §6 row 10i: the accepted cost of the word-start clause. A misplaced full stop followed directly by a letter keeps its stray space, because deleting it would glue two words that a later pass cannot separate again." + }, + { + "id": "en-us-spaces-dot-terminal-still-strips", + "rule": "spaces", + "mode": "text", + "in": "See p. 12 . Next", + "out": "See p. 12. Next", + "note": "spaces.md §3.4, §6 row 10j: a dot followed by a space is terminal punctuation, so the space before it is still deleted under spec 1.2.0." + }, + { + "id": "en-us-nbsp-span-boundary-no-punctuation-data", + "rule": "nbsp", + "mode": "html", + "in": "Note : read this", + "out": "Note: read this", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0): accepting the marker changes nothing in a locale whose punctuation lists are empty. `spaces` deletes the space and nothing is put back, the same result as in text mode." + }, + { + "id": "en-us-apostrophe-elision-before-quote", + "rule": "apostrophe", + "mode": "text", + "in": "the magazine l'\"Uomo\" today", + "out": "the magazine l’“Uomo” today", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): `quotes` converts the straight double quotes to U+201C/U+201D, and the elision before U+201C converts to U+2019." + }, + { + "id": "en-us-apostrophe-prime-before-bracket-untouched", + "rule": "apostrophe", + "mode": "text", + "in": "f'(x) = 2x", + "out": "f'(x) = 2x", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0), §6 row 18: `(` is in OPENISH but not in OPENQUOTE, so a prime on a function name is left alone." + }, + { + "id": "en-us-spaces-dot-before-span-boundary-is-terminal", + "rule": "spaces", + "mode": "html", + "in": "Use .NET today", + "out": "Use.NET today", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0): the code point after the dot is the −1 span boundary marker, which is neither a LETTER nor an ASCII digit (modes.md §3.3), so the dot counts as terminal and the space before it is deleted." } ] } diff --git a/vendor/polytypo-spec/fixtures/fi.json b/vendor/polytypo-spec/fixtures/fi.json index 9316eed..07cd4df 100644 --- a/vendor/polytypo-spec/fixtures/fi.json +++ b/vendor/polytypo-spec/fixtures/fi.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "fi", "cases": [ { @@ -1309,6 +1309,14 @@ "in": "'90s were fun,' he said", "out": "”90s were fun,” he said", "note": "quotes.md §6 row E3s: the straight-input control for E3." + }, + { + "id": "fi-apostrophe-elision-before-shared-quote-glyph", + "rule": "apostrophe", + "mode": "text", + "in": "lehti l'\"Humanité\"", + "out": "lehti l’”Humanité”", + "note": "apostrophe.md §3.3 cases 3 and 3a (spec 1.2.0): fi opens and closes with U+201D, which is in CLOSEISH, so case 3 already converted this before 1.2.0. Pinned so that case 3a is not read as changing a shared-glyph locale." } ] } diff --git a/vendor/polytypo-spec/fixtures/fr-CA.json b/vendor/polytypo-spec/fixtures/fr-CA.json index b54b53a..f279d06 100644 --- a/vendor/polytypo-spec/fixtures/fr-CA.json +++ b/vendor/polytypo-spec/fixtures/fr-CA.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "fr-CA", "cases": [ { @@ -263,6 +263,31 @@ "ranges": true }, "note": "spec 0.5.0: fr-CA's dash.range is \"none\" (no verified convention), so `ranges` substitutes nothing even when explicitly enabled (ranges.md §2, §3.3) — the same invariant the pre-0.5.0 `dashes`-tagged no-op fixtures for this locale already proved for the combined rule." + }, + { + "id": "fr-ca-nbsp-span-boundary-strong-colon", + "rule": "nbsp", + "mode": "html", + "in": "Résistant au gel : il reste souple", + "out": "Résistant au gel : il reste souple", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0): same as the `fr` case; `fr-CA` lists `:` in its own punctuation data." + }, + { + "id": "fr-ca-nbsp-span-boundary-markdown-strong-colon", + "rule": "nbsp", + "mode": "markdown", + "dialect": "commonmark", + "in": "**Note :** voir plus bas\n", + "out": "**Note :** voir plus bas\n", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0): the colon ends the strong span; the −1 marker after it is in CLOSEISH, so N1 restores the U+00A0 that `spaces` deleted. (fr-CA lists no punctuation for N2, so `?` would take nothing back in any mode.)" + }, + { + "id": "fr-ca-apostrophe-elision-before-straight-quote", + "rule": "apostrophe", + "mode": "text", + "in": "l'\"idée\" est simple", + "out": "l’« idée » est simple", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): same as `fr`." } ] } diff --git a/vendor/polytypo-spec/fixtures/fr.json b/vendor/polytypo-spec/fixtures/fr.json index e8ac883..6fc8fcb 100644 --- a/vendor/polytypo-spec/fixtures/fr.json +++ b/vendor/polytypo-spec/fixtures/fr.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "fr", "cases": [ { @@ -598,6 +598,112 @@ "ranges": true }, "note": "spec 0.5.0: fr's dash.range is \"none\" (no verified convention), so `ranges` substitutes nothing even when explicitly enabled (ranges.md §2, §3.3) — the same invariant the pre-0.5.0 `dashes`-tagged no-op fixtures for this locale already proved for the combined rule." + }, + { + "id": "fr-spaces-dot-word-start-dotfile", + "rule": "spaces", + "mode": "text", + "in": "Voir le fichier .htaccess .", + "out": "Voir le fichier .htaccess.", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0): the space before `.htaccess` survives, the space before the terminal dot is deleted. `.` is in no `nbsp` list for `fr`, so nothing is put back." + }, + { + "id": "fr-nbsp-span-boundary-strong-colon", + "rule": "nbsp", + "mode": "html", + "in": "Résistant au gel : il reste souple", + "out": "Résistant au gel : il reste souple", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0), §6 row 6c; modes.md §3.3: `spaces` deletes the typed space before `:`, and the −1 span boundary marker after the mark is in `nbsp`'s CLOSEISH, so N1 inserts U+00A0 at the mark's index, inside the span. Spec 1.1.0 runtimes produced `gel:`." + }, + { + "id": "fr-nbsp-span-boundary-br-question", + "rule": "nbsp", + "mode": "html", + "in": "Et la réglementation ?
Oui", + "out": "Et la réglementation ?
Oui", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0), §6 row 6d: `
` leaves no line terminator in the gap, so the marker is −1; it is in CLOSEISH and N2 restores U+202F." + }, + { + "id": "fr-nbsp-span-boundary-link-question", + "rule": "nbsp", + "mode": "html", + "in": "Comment ? Oui", + "out": "Comment ? Oui", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0): the mark ends the link text, the marker follows it, and N2 restores U+202F instead of leaving `Comment?`." + }, + { + "id": "fr-nbsp-span-boundary-markdown-strong-colon", + "rule": "nbsp", + "mode": "markdown", + "dialect": "commonmark", + "in": "**Résistant au gel :** il reste souple\n", + "out": "**Résistant au gel :** il reste souple\n", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0): the Markdown form of the French definition pattern; the closing `**` is a skipped region with no line terminator, so the marker is −1 and N1 restores U+00A0." + }, + { + "id": "fr-nbsp-span-boundary-not-openish-em", + "rule": "nbsp", + "mode": "html", + "in": "Il dit non ! Oui", + "out": "Il dit non ! Oui", + "note": "nbsp.md §3.3 step 3 (spec 1.2.0), §6 row 6e; modes.md §3.3: the marker is not in `nbsp`'s OPENISH, so the quote-glyph guard does not decline and N2 converts the space. A port that applied the quote-glyph guard to the marker would leave a plain U+0020 here." + }, + { + "id": "fr-nbsp-span-boundary-not-openish-link", + "rule": "nbsp", + "mode": "markdown", + "dialect": "commonmark", + "in": "Voir [ceci](http://example.org) : oui\n", + "out": "Voir [ceci](http://example.org) : oui\n", + "note": "nbsp.md §3.3 step 3 (spec 1.2.0): the second witness that the quote-glyph guard does not decline at a span boundary. The link text ends two places left of `:`, and N1 still converts the space. The marker's absence from the rest of `nbsp`'s OPENISH is pinned by ru-nbsp-span-boundary-not-openish-short-word." + }, + { + "id": "fr-nbsp-span-boundary-mark-alone-in-span", + "rule": "nbsp", + "mode": "html", + "in": "mot!", + "out": "mot!", + "note": "nbsp.md §3.3 step 2; modes.md §3.4 edge-growth rule: the mark is alone in its span, so the insertion point is the span edge and the insertion is discarded, as it was before spec 1.2.0." + }, + { + "id": "fr-nbsp-span-boundary-colon-before-digit-span", + "rule": "nbsp", + "mode": "html", + "in": "Il est 12:30", + "out": "Il est 12 :30", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0), §6 row 6f: the stated cost of accepting the marker. Step 2 cannot see past the span boundary, so a colon that ends one span while a digit starts the next is treated as sentence punctuation." + }, + { + "id": "fr-apostrophe-elision-before-guillemet", + "rule": "apostrophe", + "mode": "text", + "in": "un mélange d'« urine diluée »", + "out": "un mélange d’« urine diluée »", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0), §6 row 15: letter left, opening quotation glyph right. Spec 1.1.0 left the apostrophe straight, because no case matched a letter followed by an OPENISH-only glyph." + }, + { + "id": "fr-apostrophe-elision-before-straight-quote", + "rule": "apostrophe", + "mode": "text", + "in": "l'\"idée\" est simple", + "out": "l’« idée » est simple", + "note": "apostrophe.md §3.2, §3.3 case 3a (spec 1.2.0): `quotes` (order 40) turns the straight `\"` into `«` first, so the mark reaches this rule next to an opening glyph and case 3a converts it." + }, + { + "id": "fr-apostrophe-elision-qu-before-guillemet", + "rule": "apostrophe", + "mode": "text", + "in": "Il faut qu'« il vienne »", + "out": "Il faut qu’« il vienne »", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): `qu'` before a quotation." + }, + { + "id": "fr-nbsp-span-boundary-colon-before-url-span", + "rule": "nbsp", + "mode": "html", + "in": "Voir http://x.org", + "out": "Voir http ://x.org", + "note": "nbsp.md §3.3 step 2 (spec 1.2.0): the second stated cost of accepting the marker. Step 2 cannot see the `/` in the next span, so the colon is treated as sentence punctuation and N1 inserts U+00A0." } ] } diff --git a/vendor/polytypo-spec/fixtures/locale-resolution.json b/vendor/polytypo-spec/fixtures/locale-resolution.json index e46ae2e..60a787d 100644 --- a/vendor/polytypo-spec/fixtures/locale-resolution.json +++ b/vendor/polytypo-spec/fixtures/locale-resolution.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "cases": [ { "id": "exact-en-us", diff --git a/vendor/polytypo-spec/fixtures/ru.json b/vendor/polytypo-spec/fixtures/ru.json index 7c81154..e6677b1 100644 --- a/vendor/polytypo-spec/fixtures/ru.json +++ b/vendor/polytypo-spec/fixtures/ru.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "ru", "cases": [ { @@ -691,6 +691,30 @@ "in": "rock ’n’ roll", "out": "rock ’n’ roll", "note": "quotes.md §3.2, the regression witness for spec 1.1.0's widening of the veto from straight ASCII to the whole NARROW class. This is the output of ru-quotes-rock-n-roll fed back in, so it is that case's idempotency obligation made explicit — and it is the case a naive implementation gets wrong. A port that matches U+0027 only (as spec 0.5.0's withdrawn predicate did, correctly for its own preserve-then-stop outcome) does not recognise the U+2019 marks it just produced: the pair falls through to ordinary NARROW quotation and this input becomes `rock «n» roll`, ru's primary pair at depth 1. Measured, not hypothesised. `apostrophe` emits U+2019 only in place of U+0027 (apostrophe.md §1), so once the veto matches, nothing edits these marks and the form is stable." + }, + { + "id": "ru-spaces-dot-word-start-dotfile", + "rule": "spaces", + "mode": "text", + "in": "Проверьте файл .env сейчас", + "out": "Проверьте файл .env сейчас", + "note": "spaces.md §3.4 word-start clause (spec 1.2.0): a dot followed by a letter starts a token in every locale; `spaces` reads no locale data (§2)." + }, + { + "id": "ru-apostrophe-elision-before-guillemet", + "rule": "apostrophe", + "mode": "text", + "in": "газета l'\"Humanité\"", + "out": "газета l’«Humanité»", + "note": "apostrophe.md §3.3 case 3a (spec 1.2.0): a French title in Russian text; `quotes` gives « », and the elision before « converts." + }, + { + "id": "ru-nbsp-span-boundary-not-openish-short-word", + "rule": "nbsp", + "mode": "html", + "in": "Он живёт в Москве", + "out": "Он живёт в Москве", + "note": "nbsp.md §3.1, §7 item 12 (spec 1.2.0); modes.md §3.3: the −1 span boundary marker is not in `nbsp`'s OPENISH, so N3's following-token guard does not accept it and the space after `в` stays U+0020. This pins the membership split itself: a port that also put the marker in OPENISH would bind here." } ] } diff --git a/vendor/polytypo-spec/fixtures/sv.json b/vendor/polytypo-spec/fixtures/sv.json index dc4318d..95a9748 100644 --- a/vendor/polytypo-spec/fixtures/sv.json +++ b/vendor/polytypo-spec/fixtures/sv.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "locale": "sv", "cases": [ { @@ -1285,6 +1285,14 @@ "in": "'90s were fun,' he said", "out": "”90s were fun,” he said", "note": "quotes.md §6 row E4s: the straight-input control for E4." + }, + { + "id": "sv-apostrophe-elision-before-shared-quote-glyph", + "rule": "apostrophe", + "mode": "text", + "in": "tidningen l'\"Humanité\"", + "out": "tidningen l’”Humanité”", + "note": "apostrophe.md §3.3 cases 3 and 3a (spec 1.2.0): same as fi; U+201D is in CLOSEISH and the output is unchanged from spec 1.1.0." } ] } diff --git a/vendor/polytypo-spec/locales/registry.json b/vendor/polytypo-spec/locales/registry.json index 9da2ded..a680b67 100644 --- a/vendor/polytypo-spec/locales/registry.json +++ b/vendor/polytypo-spec/locales/registry.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "$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.", "locales": ["en-US", "en-GB", "de-DE", "de-CH", "fr", "fr-CA", "ru", "fi", "sv", "el"], "aliases": { diff --git a/vendor/polytypo-spec/rules/order.json b/vendor/polytypo-spec/rules/order.json index 73fb107..fa2a5b4 100644 --- a/vendor/polytypo-spec/rules/order.json +++ b/vendor/polytypo-spec/rules/order.json @@ -1,5 +1,5 @@ { - "spec": "1.1.0", + "spec": "1.2.0", "$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.", "rules": [ {