Skip to content

yaml mode, the edge-growth character clause, and spec 1.3.0 - #8

Merged
rogulia merged 2 commits into
mainfrom
feat/yaml-mode
Sep 20, 2026
Merged

rogulia merged 2 commits into
mainfrom
feat/yaml-mode

Conversation

@rogulia

@rogulia rogulia commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Three things, in descending order of how much they matter.

The modes.md §3.4 repair — live in shipped html

The edge-growth filter tested r > d. That is not the rule its own normative sentence states, and it misses r = d: dashes P3 admits a run of three, so --- → ␣–␣ is 3 → 3 and lands U+0020 on both extremities with the length test seeing nothing.

a<em>---</em>b   de-DE   before: a<em> – </em>b   after: unchanged
<p>a---b</p>     de-DE   unchanged — interior to a span the edit still applies
a<em>---</em>b   en-US   a<em>—</em>b — em-tight emits no U+0020, so the clause does not fire

filter_boundary_edits now tests the replacement's first and last code point as well as its length.

yaml mode

A specified left-to-right scan, no parser — two of the five ecosystems' YAML libraries cannot report the source offsets the round-trip guarantee needs, so the locator is written per runtime like a rule. It takes a required keys option naming which mapping keys hold prose, no default, exactly as markdown requires dialect.

from polytypo.yaml import transform

transform("summary: Rates -- all of them...\nrun: git diff -- a--b\n",
          locale="en-US", keys=["summary"])
# summary: Rates—all of them…
# run: git diff -- a--b

polytypo.yaml joins the per-mode entry points and is the lightest of the four: it has no parser to import.

Spec 1.3.0, vendored complete

Nineteen locales, es and it included. One canonical fixture had to be repaired first: unknown-es asserted that es throws POLYTYPO_UNKNOWN_LOCALE while the registry carried it — a direct contradiction of locale-resolution.md §3.4 step 1 that would have failed every runtime the moment 1.3.0 was vendored. Twelve resolution cases were added with it; the eight locales carried since 1.2.0 had no resolution coverage at all.

Verification

1545 tests, ruff and mypy clean, every canonical 1.3.0 fixture green including all 49 new yaml and edge-growth cases.

🤖 Generated with Claude Code

rogulia and others added 2 commits September 20, 2026 18:27
Three things, in descending order of how much they matter.

The edge-growth rule of modes.md 3.4 tested `r > d`, which is not the rule
its own normative sentence states and misses `r == d`. `dashes` P3 admits a
run of three, so `---` -> U+0020 en-dash U+0020 is 3 -> 3 and lands U+0020 on
both span extremities with the length test seeing nothing. In `html`, shipped
at v1.0.0, that turned `a<em>---</em>b` into `a<em> – </em>b` — an element
beginning and ending with a space it never held. `filter_boundary_edits` now
tests the replacement's first and last code point as well as its length.

`yaml` mode (modes.md 3.8): a specified left-to-right scan in
`_modes/yaml.py`, no parser, plus a required `keys` option naming which
mapping keys hold prose. YAML is a data format with islands of prose in it —
the inverse of HTML and Markdown — and nothing in its syntax separates
`description:` from `run:`. `polytypo.yaml` joins the per-mode entry points
and is the lightest of the four, since it has no parser to import.

The vendored spec moves to 1.3.0, complete: nineteen locales, `es` and `it`
included. One canonical fixture had to be repaired first — `unknown-es`
asserted that `es` throws POLYTYPO_UNKNOWN_LOCALE while the registry carried
it, which contradicts locale-resolution.md 3.4 step 1 and would have failed
every runtime on contact. Twelve resolution cases were added with it: the
eight locales carried since 1.2.0 had no resolution coverage at all.

1545 tests, ruff and mypy clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ruff format checks Python code blocks in Markdown too, and CI runs it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rogulia
rogulia merged commit 2249ba9 into main Sep 20, 2026
4 checks passed
@rogulia
rogulia deleted the feat/yaml-mode branch September 20, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant