Skip to content

feat(tui): LaTeX environments, text, and command support for math rendering - #4981

Open
SparkofSpike wants to merge 10 commits into
Hmbown:mainfrom
SparkofSpike:feat/latex-enhancement
Open

feat(tui): LaTeX environments, text, and command support for math rendering#4981
SparkofSpike wants to merge 10 commits into
Hmbown:mainfrom
SparkofSpike:feat/latex-enhancement

Conversation

@SparkofSpike

@SparkofSpike SparkofSpike commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Extend the existing LaTeX math rendering with full environment-block support, common inline commands, accent commands, command-aware subscripts/superscripts, and case-insensitive environment matching.

Changes

  • Environment rendering: New render_environment() dispatcher and try_render_env() integration detecting begin{aligned/pmatrix/bmatrix/vmatrix/Bmatrix/cases/array/smallmatrix). Two-pass column-width alignment. Opening/closing brackets on their own lines for multi-row.

  • Cases: Unicode brace extension chars (U+23A7/U+23A8/U+23A9). Trailing commas stripped from left cells.

  • Array: Parse column spec {c|c|l|r} with vertical bar separators.

  • Multi-line env auto-newline: Envs start on fresh line. Fixed: out.trim() -> trim_end() so leading newline survives final trim.

  • Case-insensitive env names: to_ascii_lowercase() matching.

  • Text/operatorname: Render braced arg as plain text.

  • Left/right/big brackets: Consume size modifiers, output bracket.

  • Font commands: mathbf/mathrm/mathit/mathsf/textbf/textrm/textit, recursively render.

  • Accent commands: hat/bar/tilde/dot/ddot/vec/breve/check/acute/grave with Unicode combining marks.

  • Spacing: quad(4)/qquad(8)/thinspace/semicolon(2)/!(skip). Fixed: backslash-comma now renders as space.

  • Fraction aliases: dfrac/tfrac/cfrac dispatch to frac.

  • Binomial: binom{n}{k} renders as (n/k).

  • Command-aware sub/superscripts: _mu/_nu/^dagger/^rho reads full command. Extended Unicode superscript letters a-z.

  • Underbrace/Overbrace/Phantom: Passthrough rendered content. Phantom no-op.

  • Substack: Renders as-is.

  • Styled symbols: Extended mathcal{A-Z} and mathbb{set}.

  • Extended symbol table: 80+ new symbols.

  • Markdown code span preservation: Split by backticks.

  • Currency/escape protection: Rejects $ followed by digit; detects backslash-$.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change
  • Documentation update
  • Refactoring (no functional changes)
  • Tests

Testing

  • cargo check --workspace --all-features --locked (0 errors, 0 warnings)
  • cargo fmt --all -- --check
  • cargo test --workspace --all-features --locked
  • Manual testing: incremental check after each edit; existing tests pass

Checklist

  • Updated docs or comments as needed
  • Added or updated tests where relevant
  • Verified TUI behavior manually if UI changes
  • Harvested/co-authored credit uses a GitHub numeric noreply address

Related Issues

No-Issue: Continues from #4957 (feature request), #4974 (previous foundation). Adds environment blocks and inline command support on top of the existing math rendering.

Notice

🤖 Desc generated by Deepseek

@SparkofSpike
SparkofSpike requested a review from Hmbown as a code owner July 30, 2026 03:57
@SparkofSpike
SparkofSpike marked this pull request as draft July 30, 2026 04:06
@Hmbown Hmbown added this to the v0.9.3 milestone Jul 30, 2026
@SparkofSpike
SparkofSpike marked this pull request as ready for review July 30, 2026 08:07
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.

2 participants