Repository navigation
ranges: admit a symbol repeated closed up on both members - #6
Merged
Merged
Conversation
Implements spec 1.3.0's ranges.md 3.2a and the dashes.md step 8 amendment it forced (polytypo/polytypo@bb9a54e, canonical issue #23), porting polytypo-js@5bf847f. `$15-$20` and `35%-50%` are range candidates now; through 1.2.0 `$15-20` converted and `$15-$20` did not, because the flank next to the dash was the symbol. The discriminator is closed-up versus spaced, per Chicago 9.19 — so `$` and `%` are one rule and `15 kg-20 kg` is out of scope. isClosedUpSymbol is a literal code-point predicate, never a preg_match on \p{Sc}: the currency part is the U+20A0-U+20CF block by its own bounds, because the assigned subset drifts between runtimes built against different UCD releases and block bounds do not. Tests pin both sides — U+20B9/U+20B4, which no other case names, and U+058F/U+FFE5, currency signs deliberately outside the set. rangeFlanks is the whole feature: both sides decided from the original flanks simultaneously, a side's walk taken only if the symbol is matched on the opposite member, null for a non-candidate — which is the signal `dashes` reads to stay out. So `$15-€20` and `15-$20` never change hands, and G4/G5 still compare digit runs and never see a symbol. T1 (isSpacingTransitionBlocked) is the part that could not be skipped. Widening a range member widens what a `dashes` edit elsewhere can disturb: an unamended T1 reads the symbol as the neighbour, stops one code point short of the dash, lets a tight token become spaced, and that U+0020 flips a neighbouring range's guard on the next pass. The reach is now CLOSED-SYMBOL-transparent at two positions per side, with a test for the composed shape the canonical exhaustive sweep could not reach — it needs eleven tokens. Verified beyond the suite: all 1219 runnable text/html canonical fixture cases at spec 1.3.0, across all 18 locales, pass and are idempotent against this build. 1138 tests, 2953 assertions; PHPStan level 8 and phpcs clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements spec 1.3.0's
ranges.md§3.2a and thedashes.mdstep 8 amendment it forced (polytypo/polytypo@bb9a54e, canonical issue polytypo/polytypo#23). Fifth and last runtime, after polytypo/polytypo-js#15, polytypo/polytypo-python#6, polytypo/polytypo-go#6 and polytypo/polytypo-ruby#6.$15-$20and35%-50%become range candidates. The line is closed-up versus spaced, not currency versus unit (Chicago 9.19), so$and%are one rule and15 kg-20 kgis out of scope.isClosedUpSymbolis a literal code-point predicate, never apreg_matchon\p{Sc}— the currency part is the U+20A0–U+20CF block by its bounds, because the assigned subset drifts between runtimes built against different UCD releases. Tests pin both sides, including two currency signs deliberately outside the set that a category test would wrongly admit.rangeFlanksdecides both sides from the original flanks simultaneously and takes a side's walk only if the symbol is matched on the opposite member;nullis whatdashesreads to stay out, so$15-€20and15-$20never change hands.T1 is the part that could not be skipped. Widening a range member widens what a
dashesedit elsewhere can disturb — an unamended T1 reads the symbol as the neighbour, stops one code point short of the dash, and a neighbouring range converts on the next pass. The reach is nowCLOSED-SYMBOL-transparent at two positions per side; four witnesses, plus the composed eleven-token shape the canonical sweep could not reach.Checks: 1138 tests, 2953 assertions, 21 skipped (the markdown cases this runtime declines); PHPStan level 8 and phpcs clean — PHP 8.3.32. Beyond the suite: all 1219 runnable text/html canonical 1.3.0 fixture cases across 18 locales pass and are idempotent against this build.
The vendored
resources/spec/snapshot stays at 1.2.0; it is re-vendored in the 1.3.0 release round.🤖 Generated with Claude Code