Port iosMath 2026 commits to CSharpMath - #264
Open
Happypig375 wants to merge 13 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,\overbracerender via horizontal glyph variants/assembly;\overset,\underset,\stackrel,\stackbinuse 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(+mathaliases), and the cancel family\cancel,\bcancel,\xcancel,\soutwith 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 publicLaTeXSettings.AddMacroregistration API (arity/template validation, replace-on-reregister) andMacroDefinitionForCommandintrospection.TeX-faithful brace grouping (#177, 086d345) —
{…}parses to an Ord group so\scriptstyleno 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, so1\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\hlinewith rule rendering. Ruled arrays now honour their column alignment spec (r/c/lshifts 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/\hskipaccept em or mu; amsmath named spaces\thinspace…\negthickspace.Colors (c27737a, 3471a4f, REN-2, REN-7) —
\textcoloras an alias of\color, CSS#RGBshorthand expansion, loud errors on invalid colors.Parser hardening — recursion-depth cap against stack overflow (SEC-1), lone
\sqrtat 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,\dotsmand amssymb additions not previously covered.Testing
IosMath2026PortTestscover every ported feature: parsing, round-trips, error cases and semantics.