Skip to content

Commit a42a816

Browse files
committed
Implement text promotion and keyword expansion for logical operators
- Added support for `\text{and}`, `\text{or}`, `\text{iff}`, and `\text{if and only if}` as infix operators in the LaTeX parser. - Implemented multi-word keyword support for `\text{such that}`, `\text{for all}`, and `\text{there exists}` with appropriate parsing logic. - Enhanced the `InvisibleOperator` to promote surrounding math expressions into a single `Text` expression when `\text{}` is used. - Updated tests to cover new functionality, including keyword recognition and text promotion scenarios. - Adjusted existing tests and snapshots to reflect changes in output structure and behavior.
1 parent 1833974 commit a42a816

File tree

10 files changed

+1260
-66
lines changed

10 files changed

+1260
-66
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
symbol validation.
1313
- **`Text` operator type**: The `Text` operator now has return type `string`
1414
instead of `expression`.
15+
- **`\textcolor` inside `\text{}`**: `\textcolor{red}{RED}` inside `\text{}`
16+
now correctly parses the body as text (`'RED'`) instead of switching to math
17+
mode and treating each letter as a separate symbol.
18+
- **`parseSyntaxError` token consumption**: Non-command tokens (like `#`, `&`)
19+
are now consumed when producing errors, preventing potential parser loops.
20+
- **`parseSymbolToken` hardening**: Raw tokens are pre-validated against
21+
`\p{XIDC}` before being consumed as symbols, providing defense-in-depth
22+
against future `isValidSymbol` regressions.
1523

1624
#### Added
1725

@@ -23,6 +31,14 @@
2331
`\text{if and only if}` are now recognized as infix operators that produce
2432
`And`, `Or`, and `Equivalent` expressions respectively, following the existing
2533
`\text{where}` pattern.
34+
- **Additional text keywords**: `\text{such that}` (maps to `Colon`),
35+
`\text{for all}` (maps to `ForAll`), and `\text{there exists}` (maps to
36+
`Exists`) are now recognized as operators.
37+
- **`Text` serializer**: `Text` expressions now round-trip back to proper
38+
`\text{...}` LaTeX with inline `$...$` for math sub-expressions, instead of
39+
falling through to the default `\mathrm{Text}(...)` output.
40+
- **`Text` evaluate handler**: Evaluating a `Text` expression now concatenates
41+
all operands into a single string.
2642

2743
### 0.55.1 _2026-03-04_
2844

0 commit comments

Comments
 (0)