Skip to content

Add configurable piecewise and bounded operator shortcuts - #3056

Open
Shrookin wants to merge 4 commits into
arnog:masterfrom
Shrookin:agent/piecewise-shortcut
Open

Add configurable piecewise and bounded operator shortcuts#3056
Shrookin wants to merge 4 commits into
arnog:masterfrom
Shrookin:agent/piecewise-shortcut

Conversation

@Shrookin

@Shrookin Shrookin commented Aug 4, 2026

Copy link
Copy Markdown

What

Adds configurable piecewise and bounded-operator LaTeX shortcuts while preserving normal MathLive editing behavior:

  • \piecewise{n} creates an editable native cases structure with n rows.
  • \int{x}{y}, \sum{x}{y}, and \prod{x}{y} create bounded operators.
  • Deleting content from a bounded lower or upper argument leaves an editable \placeholder{} instead of removing the bound.
  • After the body and both bounds are cleared, Backspace traverses to the operator and removes it cleanly instead of getting stuck at the leading sentinel.
  • Text-mode LaTeX commands now wait for completion instead of eagerly committing a prefix. For example, typing \piecewise no longer commits \pi while the command is incomplete.
  • Adds the compact virtual-keyboard keycap class for tall structured labels.

Why

MathLive users need parameterized structural shortcuts that remain editable after insertion. Prefix commands must also behave like ordinary LaTeX input: a shared prefix should remain pending until the command is complete or explicitly finalized. Structural deletion must preserve editable placeholders without making an empty operator impossible to remove.

Implementation

  • Registers a parameterized piecewise parser that builds the same native cases-array structure used by regular editing.
  • Registers bounded parsers for int, sum, and prod while preserving their existing unbounded forms.
  • Uses editable bounded argument atoms and deletion handling to retain placeholders when bound contents are removed.
  • Removes an empty bounded operator only after its body, lower bound, and upper bound have been traversed.
  • Defers the backslash in text mode into LaTeX command mode through the native keybinding definitions.
  • Prevents custom structured commands from being serialized as opaque verbatim source.
  • Keeps the compact keycap styling generic and independent of inserted LaTeX.

Consumer synchronization

The dependent applications remain compatible with MathLive 0.110 while consuming the shared behavior:

  • NDQ: 86eda86 keeps structural LaTeX command caret handling visible and preserves bounded-operator editing through its adapter.
  • Skillboard: 976e0582 marks the shared piecewise key as compact while retaining the legacy styling hook.
  • Parse Tree: 8edfa46 applies the same keyboard-key compatibility update.

Verification

  • npx tsc --noEmit -p tsconfig.json — passed.
  • npx jest test/ --runInBand — 344 tests passed.
  • Focused Chromium Playwright coverage for piecewise insertion, deferred text-mode commands, bounded placeholder deletion, and full bounded-operator deletion order — passed.
  • Focused Chromium Playwright coverage for compact structured virtual-keyboard labels — passed.
  • NDQ full suite — 255 tests passed; targeted adapter follow-up — 15 tests passed.
  • Skillboard MathLive integration tests — 3 passed; production build passed.
  • Parse Tree production build passed.

The branch remains draft while the behavior is reviewed.

@Shrookin
Shrookin marked this pull request as ready for review August 4, 2026 18:36
lofcz added a commit to lofcz/mathlive that referenced this pull request Aug 9, 2026
@Shrookin Shrookin changed the title Add configurable piecewise command Add configurable piecewise and bounded operator shortcuts Aug 11, 2026
@Shrookin
Shrookin marked this pull request as draft August 11, 2026 02:03
@Shrookin
Shrookin marked this pull request as ready for review August 11, 2026 04:39
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.

1 participant