Skip to content

Port iosMath 2026 commits to CSharpMath - #264

Open
Happypig375 wants to merge 13 commits into
masterfrom
port-iosmath-2026
Open

Port iosMath 2026 commits to CSharpMath#264
Happypig375 wants to merge 13 commits into
masterfrom
port-iosmath-2026

Conversation

@Happypig375

@Happypig375 Happypig375 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Port iosMath 2026 commits to CSharpMath

Ports the substantive math-rendering changes from kostub/iosMath made during 2026. ObjC-specific packaging, CI, demo-app and changelog commits are excluded; everything affecting the LaTeX → atoms → layout pipeline is ported.

New features

Fraction family (upstream 58b1f8d, 28dce0c) — \dfrac, \tfrac, \dbinom, \tbinom, \cfrac[l|c|r] with style override, cfrac struts + 3mu thinspace wrap and numerator alignment.

Generic over/under Stack atom (43626a4, 94d8edf) — \overrightarrow, \overleftarrow, \overleftrightarrow, \underrightarrow, \underleftarrow, \underleftrightarrow, \overbrace render via horizontal glyph variants/assembly; \overset, \underset, \stackrel, \stackbin use MathList rows with class inheritance (\overset{x}{+} inherits Binary) and reverse canonicalization on round-trip.

Box atom family (9f53483, d49f251, 57f867f) — \phantom, \hphantom, \vphantom, \mathstrut, \smash[t/b], \llap/\rlap/\clap (+ math aliases), and the cancel family \cancel, \bcancel, \xcancel, \sout with strike overlays.

Built-in macros (035a9e2, 4091668, b2b19a8) — amsmath's \pmod, \mod, \pod, argument-free \implies, \impliedby, \iff, \idotsint, \varliminf, \varlimsup, \varinjlim, \varprojlim; script transfer to the expansion and required-argument parse errors. Plus a public LaTeXSettings.AddMacro registration API (arity/template validation, replace-on-reregister) and MacroDefinitionForCommand introspection.

TeX-faithful brace grouping (#177, 086d345) — {…} parses to an Ord group so \scriptstyle no longer leaks past a closing brace and scripts target the whole group; \over-family transforms still replace the group. The evaluator dissolves AngouriMath's cosmetic braces on visualize so evaluation round-trips are unchanged.

No fusion across font-style changes (76fd773, c9afaad) — Rule 14 merging and number fusion require equal FontStyle, so 1\mathit{2} keeps the italic face instead of corrupting it; italic correction goldens pin per-face script positioning.

New environments (8d52b86, dd76eb5, cc62444–d9e24c9) — smallmatrix (script cells, 5mu gap), gathered, alignedat{ n}, array vertical rules (|) and \hline with rule rendering. Ruled arrays now honour their column alignment spec (r/c/l shifts within shared column offsets).

Table cell-style scaling (b84c171) — matrix/cases pin textstyle, smallmatrix script; inter-column gaps and row leading scale with the cell style, so a nested matrix keeps its metrics.

Spacing in math mode (f644371) — \kern/\hspace/\hskip accept em or mu; amsmath named spaces \thinspace\negthickspace.

Colors (c27737a, 3471a4f, REN-2, REN-7) — \textcolor as an alias of \color, CSS #RGB shorthand expansion, loud errors on invalid colors.

Parser hardening — recursion-depth cap against stack overflow (SEC-1), lone \sqrt at EOF no longer crashes (da9abdd), empty glyph variant lists fall through to assembly instead of crashing (FUN-4, 9ca84b0), generalized fraction commands (\over, \atop, \choose, \brack, \brace) in one-character script slots (x^\over y) error like TeX instead of swallowing input (801af6f).

New symbols/aliases (48f6fca, 19d98d3) — \lt, \gt, \restriction, \dotsc, \dotsm and amssymb additions not previously covered.

Testing

  • New IosMath2026PortTests cover every ported feature: parsing, round-trips, error cases and semantics.
  • Existing suites updated for the intentional behavior changes (brace grouping, cell-style tables).
  • Rendering golden baselines regenerated where output intentionally changed; layout verified byte-identical between Debug and Release via full-display signature dump.
  • All suites green locally: Core 1600, Rendering 1234.

Ports the substantive math-rendering changes from kostub/iosMath made
during 2026 (ObjC-specific packaging/CI/demo commits excluded):

- Fraction family: \dfrac, \tfrac, \dbinom, \tbinom, \cfrac with style
  override, cfrac struts/thinspace and numerator alignment (58b1f8d,
  28dce0c)
- Generic over/under Stack atom: \overrightarrow, \overleftarrow,
  \overleftrightarrow, \underrightarrow, \underleftarrow,
  \underleftrightarrow, \overbrace, plus \overset, \underset,
  \stackrel, \stackbin with class inheritance and reverse
  canonicalization (43626a4, 94d8edf)
- Box atom family: \phantom, \hphantom, \vphantom, \mathstrut,
  \smash[t/b], \llap/\rlap/\clap (+ math* aliases) and the
  \cancel/\bcancel/\xcancel/\sout strike overlays (9f53483, d49f251,
  57f867f)
- Built-in macro system with amsmath's argument-bearing (\pmod, \mod,
  \pod) and argument-free (\implies, \impliedby, \iff, \idotsint,
  \varliminf and friends) macros, script transfer and required-
  argument errors (035a9e2, 4091668)
- TeX-faithful brace grouping: braces parse to an Ord group so styles
  are scoped and scripts target the whole group (#177 / 086d345); the
  evaluator dissolves AngouriMath's cosmetic braces on visualize
- Environments: smallmatrix, gathered, alignedat and array vertical
  rules + \hline support with rule rendering (8d52b86, dd76eb5,
  cc62444, e651850, 6c74585, d9e24c9)
- Table cell-style scaling: matrix/cases pin textstyle, smallmatrix
  script; inter-column and row-leading gaps scale with the cell style
  (b84c171)
- Spacing commands in math mode: \kern/\hspace/\hskip accept em or mu;
  amsmath named spaces \thinspace ... \negthickspace (f644371)
- \textcolor as an alias of \color; #RGB hex shorthand expansion;
  invalid colors now error loudly (c27737a, 3471a4f, REN-2, REN-7)
- Parser hardening: recursion-depth cap against stack overflow (SEC-1),
  lone \sqrt at EOF no longer crashes (da9abdd), prime shorthand,
  empty variant lists fall through to glyph assembly (FUN-4/9ca84b0)
- New symbols/aliases: \lt, \gt, \restriction, \dotsc, \dotsm and the
  amssymb batches (48f6fca, 19d98d3)

Rendering golden baselines updated where brace grouping and cell-style
changes intentionally alter output. New IosMath2026PortTests cover every
ported feature.
- AddMacro public registration API (iosMath b2b19a8): registers into
  BuiltinMacros with arity/template validation, replaces on re-register,
  MacroDefinitionForCommand exposes definitions; caller-template parse
  errors reclassified as caller errors.
- No fusing across font-style changes (iosMath 76fd773): Rule 14 merging
  and number fusion now require equal FontStyle so \mathit digits keep
  their face.
- ItalicCorrectionStyles golden case (iosMath c9afaad).
- Regenerate QuarticSolutions baselines from Release; verified layout is
  identical between Debug and Release via full-display signature dump.
Caught in self-review: the two new public members added in b994e2e
were missing from the declared public API surface.
MakeRuledRowWithColumns compared each cell against its own width, so the
Right/Center alignment shifts were always zero and \begin{array}{|r|c|}
rendered every cell left-aligned. Pass the shared column widths through
so shifts are computed within the full column, matching MakeRowWithColumns.

Also tighten LapsParse: replace the Assert.Contains round-trip check that
passed on any output with an exact per-command round-trip theory.
Port iosMath 801af6f: \over, \atop, \choose, \brack and \brace used as
the implicit one-token argument of ^ or _ (e.g. x^\over y) previously
swallowed the rest of the input into the denominator. They now return a
parse error telling the user to brace the argument, matching TeX; the
braced form x^{a \over b} still parses as a fraction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant