Rewrite Rulesbase/control-space-to-tilde

base/control-space-to-tilde

Rewrite math-mode control space to the canonical active space token.

Rewrite patterns#

  1. \ ~

Examples#

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

Math control space#

Before

a\ b

After this rule

a~b

Rendering verified with the declared packages.

Text control space preserved#

Before

\text{A\ B}

After this rule

\text{A\ B}

Rendering verified with the declared packages.

Same family#

Notes#

This is a partial matcher because the same command name has different base/math and textmacros/text semantics, so it touches rather than eliminates cmd: . The rule derives the actual content mode from the AST parent and slot and rewrite only math content; active_command() and match_command() are not sufficient mode tests. Text-mode control space remains an ordinary U+0020. Produces is empty because ~ is an ActiveSpace token rather than a knowledge target. Every Applied result replaces one math-mode control-space command with an ActiveSpace node; text-mode and otherwise ineligible nodes return Skipped, so the number of eligible control-space commands strictly decreases.

Disable this rule#

TransformEngine(profile="corpus", disable_rules=["base/control-space-to-tilde"])
new TransformEngine({ profile: 'corpus', disableRules: ['base/control-space-to-tilde'] })

Open in Playground