Skip to content

Add \textcolor as a 2-argument alias of \color#252

Merged
kostub merged 1 commit into
masterfrom
feature/textcolor-alias
Jul 3, 2026
Merged

Add \textcolor as a 2-argument alias of \color#252
kostub merged 1 commit into
masterfrom
feature/textcolor-alias

Conversation

@kostub

@kostub kostub commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Adds support for the standard LaTeX \textcolor{color}{content} command, closing #157.

iosMath's existing \color is already implemented as a two-argument command (\color{#RRGGBB}{content} — colors just the content), which is exactly the semantics of standard LaTeX/xcolor \textcolor. So \textcolor is a true alias of the existing path — no new parsing logic or display type.

Change

  • iosMath/lib/MTMathListBuilder.m — widened the atomForCommand: dispatch from [command isEqualToString:@"color"] to also match @"textcolor", so both share the identical readColor + buildInternal:true + MTMathColor path. \colorbox untouched.
  • iosMathTests/MTMathListBuilderTest.m — three new tests mirroring the existing \color tests: valid hex → MTMathColor; structural equivalence to \color; malformed named color fails loud with MTParseErrorInvalidCommand.

Verification

  • swift build → Build complete.
  • swift test --filter MTMathListBuilderTest → 157 tests, 0 failures. Existing color/colorbox tests unchanged and passing.

Scope note

This is the minimal alias only. Aligning \color itself to LaTeX's switch semantics (a separate, breaking change) was considered and deliberately deferred — see docs/reqs/2026-07-03-color-textcolor.md.

Closes #157

🤖 Generated with Claude Code

\textcolor{color}{content} is standard LaTeX for the two-argument color
form, which is exactly what iosMath's \color already implements. Match
"textcolor" in the same atomForCommand: dispatch branch as "color" so it
shares the identical readColor + buildInternal + MTMathColor parse path.

\color behavior is unchanged (still 2-argument); \colorbox is untouched.

Adds parser tests covering \textcolor valid hex, structural equivalence to
\color, and fail-loud on a named (non-hex) color.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kostub
kostub merged commit c27737a into master Jul 3, 2026
1 check passed
@kostub
kostub deleted the feature/textcolor-alias branch July 3, 2026 19:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the \textcolor command as an alias of the \color command in MTMathListBuilder.m, along with comprehensive unit tests to verify its behavior, equivalence to \color, and error handling. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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.

\textcolor command not working on cocoapods latest version

1 participant