Rewrite Rulesbase/small-spacer-merge-to-enspace

base/small-spacer-merge-to-enspace

Merge exact half-em small-spacer chunks into enspace in one pass.

Rewrite patterns#

  1. thin-triple\,\,\,\enspace
  2. colon-semicolon\:\;\enspace
  3. semicolon-colon\;\:\enspace

Examples#

Each example shows this rule applied in isolation. A complete normalization profile may make additional changes.

Thin triple#

Before

A\,\,\,B

After this rule

A\enspace B

Rendering verified with the declared packages.

Colon semicolon#

Before

A\:\;B

After this rule

A\enspace B

Rendering verified with the declared packages.

Semicolon colon#

Before

A\;\:B

After this rule

A\enspace B

Rendering verified with the declared packages.

Thin multiple one pass#

Before

A\,\,\,\,\,\,\,B

After this rule

A\enspace\enspace\,B

The rendered result has pixel differences from the input.

Mixed pair multiple one pass#

Before

A\:\;\;\:B

After this rule

A\enspace\enspace B

Rendering verified with the declared packages.

Text run preserved#

Before

\text{A\,\,\,B}

After this rule

\text{A\,\,\,B}

Rendering verified with the declared packages.

Upstream rules#

Downstream rules#

Same family#

Notes#

Authoring-level exact-width canonicalization for math-mode sibling runs. Starting at the first matching Spacer in a maximal run, scan left to right and replace every non-overlapping declared chunk in one rule application: each three consecutive \, commands become one \enspace, and each \:\; or \;\: pair becomes one \enspace. Process all available multiples at once instead of relying on later fixed-point iterations; for example, seven consecutive \, commands become \enspace\enspace\,, and \:\;\;\: becomes \enspace\enspace. Preserve unmatched remainder commands in their original order. MathJax defines \, as exactly 3/18 em and \enspace as exactly 0.5 em, so the declared width algebra is exact. The reviewed inline mismatch for repeated thin-space chunks is an accepted browser layout quantization exception: separately positioned mspace elements can accumulate to a one-pixel raster size difference even though their MathJax lengths are equal. Do not generalize this exception beyond these declared chunks or relax the global rendering threshold. Do not generalize this rule into arbitrary width decomposition or reorder other equal-width runs. Text-mode records, groups, scripts, cells, other slots, negative spacing, ActiveSpace, control space, hspace, and mspace remain unchanged. Every Applied result consumes at least one complete source chunk and produces no touched small-spacer target, so the total count of touched source spacer nodes strictly decreases.

Disable this rule#

TransformEngine(profile="corpus", disable_rules=["base/small-spacer-merge-to-enspace"])
new TransformEngine({ profile: 'corpus', disableRules: ['base/small-spacer-merge-to-enspace'] })

Open in Playground