feat(tui): LaTeX environments, text, and command support for math rendering - #4981
Open
SparkofSpike wants to merge 10 commits into
Open
feat(tui): LaTeX environments, text, and command support for math rendering#4981SparkofSpike wants to merge 10 commits into
SparkofSpike wants to merge 10 commits into
Conversation
SparkofSpike
marked this pull request as draft
July 30, 2026 04:06
…x clippy manual_strip
… find_matching_end
SparkofSpike
marked this pull request as ready for review
July 30, 2026 08:07
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.
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 andtry_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
Testing
cargo check --workspace --all-features --locked(0 errors, 0 warnings)cargo fmt --all -- --checkcargo test --workspace --all-features --lockedChecklist
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