Skip to content

canonicalize: read "∣" (\mid) as "|" in set builders and in P(A ∣ B) - #1168

Open
pablgonz wants to merge 1 commit into
daisy:mainfrom
pablgonz:mid-bar
Open

pablgonz wants to merge 1 commit into
daisy:mainfrom
pablgonz:mid-bar

Conversation

@pablgonz

@pablgonz pablgonz commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #956.

LaTeX writes \mid as ∣ (U+2223). With | these are read well; with ∣ they were read as "divides":

input before now
{x ∣ x > 0} open brace, x divides x is greater than 0; close brace the set of all x such that x is greater than 0
{n ∈ ℕ ∣ 3 ∣ n} the set n in, the natural numbers divides 3 divides n the set of all n in the natural numbers such that 3 divides n
P(A ∣ B) p, open paren, a divides b, close paren p, open paren a given b, close paren
3 ∣ 12, f(a ∣ b) 3 divides 12 no change

In clean_mathml, a ∣ becomes | only when:

  • it is the first bar between { and } (a second one, as in 3 ∣ n, stays "divides"), or
  • it is the only bar between ( and ) right after P.

If there is already a | at the same level, nothing changes.

Tests:

  • New: mid_set_builder, mid_conditional_probability, mid_divides_kept in src/canonicalize.rs.
  • ignore_period_and_space (en, es, fi, fr, hu, nb, pl, ru, sv, zh-tw) used ∣ in P(A ∣ B) and expected "divides"; it now expects "given" in each language (the same words as each language's given test with |).
  • cargo test and cargo clippy --tests pass.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor
Linux library size: 0.61 MiB (-0.03%)
Revision Release liblibmathcat.so
Base (fcc2f04) 0.61 MiB (635,928 bytes)
PR (9e10d37) 0.61 MiB (635,728 bytes)
Change -200 bytes (-0.03%)

Built with default features, Rust 1.96.0, and Ubuntu 24.04. Workflow run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

\mid (U+2223) is not read like | in set builder and conditional probability

1 participant