Skip to content

UnicodeMath: write what reads back, and read two spaces after a comma - #37

Merged
simonebortolin merged 1 commit into
mainfrom
ccr-f0e25fb4-eczbl3-unicodemath-writer
Nov 11, 2026
Merged

simonebortolin merged 1 commit into
mainfrom
ccr-f0e25fb4-eczbl3-unicodemath-writer

Conversation

@simonebortolin

Copy link
Copy Markdown
Owner

Four equations that read from UnicodeMath but were written as text that read back to another equation (found with the formulas of the math tools app):

Read Written before Read back as Written now
(■(a&b@c&d))^2 ⒨(𝑎&𝑏@𝑐&𝑑)² the matrix, then a ² apart (and ^−1 did not parse) 〖⒨(𝑎&𝑏@𝑐&𝑑)〗²
a/sinα 𝑎/ sin𝛼 a slash: the space after the bar ends the fraction 𝑎/sin𝛼
1/(4πε_0) (q_1 q_2)/r^2 1/4𝜋𝜀₀ 𝑞₁𝑞₂/𝑟² 𝑞₁𝑞₂/𝑟² in the denominator: the space ends the script, not the denominator 1/(4𝜋𝜀₀) 𝑞₁𝑞₂/𝑟²
a, b 𝑎,𝑏 the space lost: it was read as an empty <mo/> 𝑎, 𝑏 (U+2002)
  • Script of a matrix in brackets (⒨ ⒱ ⒩ ⓢ Ⓢ): the matrix is grouped as a script base, in ScriptBase and Binary, as the other bases a script would not apply to whole.
  • Function in a denominator: the space before the function name is not written after the fraction bar.
  • Denominator ending with a script: parenthesized only when an operand follows the fraction. Not when an operator follows, which ends both, and not after superscript digits (𝜕²/𝜕𝑥² 𝜓), which a space ends. Subscript digits (𝑥₁) do need it.
  • , : the grammar reads it as a comma and a space of 9/18 em, {space: 9}, which TransformSpaces did not handle. It is now the character of that width, U+2002, as , reads. Width 0 (the empty cell of a matrix) stays an empty <mo/>, as before.

The parentheses rule changes the text written only in those cases. The 738 examples of the corpus and the round trips stay at 100%.

Tests

  • Regression/WriterRoundTripTests.UnicodeMathReadsBackWhatItWrites: 12 cases. 9 failed before the fix (3 already passed), all pass now.
  • Regression/WriterRoundTripTests.UnicodeMathReadsTwoSpacesAfterACommaAsASpace.
  • dotnet test --project tests/SharpEquations.Tests: 6984/6984 on net10.0 and net8.0.

[no-new-version]: bump VersionPrefix if you want it released.


Generated by Claude Code

…ces after a comma

Four equations that read from UnicodeMath and were written as text that read back
to another equation:

- a script of a matrix in brackets: ⒨(𝑎&𝑏@𝑐&𝑑)² read the ² apart from the
  matrix (and ^−1 did not parse); the matrix is grouped, 〖⒨(…)〗², as the other
  bases that a script would not apply to whole
- a function in a denominator: 𝑎/ sin⁡𝛼 read as a slash, the space after the
  bar ending the fraction; the space is not written, 𝑎/sin⁡𝛼
- a denominator that ends with a script before an operand: 1/4𝜋𝜀₀ 𝑞₁𝑞₂/𝑟²
  took 𝑞₁𝑞₂/𝑟² into the denominator, the space ending the script and not the
  denominator; it is in parentheses, 1/(4𝜋𝜀₀) (but not after superscript
  digits, 𝜕²/𝜕𝑥² 𝜓, which a space ends, nor before an operator)
- ",  " (a comma and two spaces, a space of ½ em after the comma in the
  grammar) was read as an empty <mo/>, which nothing writes: it is the space of
  that width, U+2002, as ", " reads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio8afJsGwHW9i5v5HDs
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Pre-release removed now that this PR is closed.

@simonebortolin
simonebortolin merged commit 89003c5 into main Nov 11, 2026
17 checks passed
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.

2 participants