Expand description
TeX-quality display math inside scrolling Ratatui interfaces.
ratatex turns completed Markdown display-math regions into cell-aligned
PNGs on a bounded background worker. It parses, lays out, and rasterizes math
in-process with embedded fonts—without a system TeX installation or
rendering subprocess. The PNGs are cached on disk, uploaded through the
Kitty graphics protocol, and placed with Unicode-placeholder cells. Because
the placeholders are ordinary terminal cells, equations naturally scroll,
clip, and redraw with the rest of a Ratatui buffer.
The crate deliberately leaves surrounding Markdown rendering to the
application. Use display_math to find renderable regions, call
Ratatex::request for each expression, reserve Formula::rows lines,
flush terminal commands when the update callback fires, and render a
FormulaWidget over the reserved cells.
For a streaming document, pass a temporary
heal_streaming_display_math view to display_math and retain the
latest ready Formula while a newer prefix renders. When a formula is
partially outside the viewport, use SignedPosition rather than slicing
its placeholder grid; this preserves the Kitty source-tile coordinates.
FormulaWidget::compact_source_fallback swaps the same reserved cells
back to selectable LaTeX for a native terminal-selection pass.
Structs§
- Availability
- Runtime capability summary.
- Color
Scheme - Foreground/background colors used by raster post-processing.
- Display
Math - One closed Markdown display-math region.
- Formula
- One immutable prepared formula.
- Formula
Widget - A clipping Ratatui widget for one prepared formula.
- Limits
- Resource and input bounds owned by the renderer.
- Pixel
Padding - Extra pixels around the tight TeX bounding box.
- Pixel
Size - Pixel dimensions of one terminal cell.
- Ratatex
- Cloneable request/cache handle.
- Ratatex
Builder - Builder for a background renderer.
- Render
Failure - Cloneable, typed rendering failure retained by the memory cache.
- Rgb
- An RGB color used by the raster post-processor.
- Signed
Position - Signed formula origin relative to a widget viewport.
- Terminal
Command - Bytes that must be written to the terminal outside the Ratatui buffer.
- Terminal
Profile - Everything about the terminal that affects a rendered formula.
Enums§
- Antialiasing
- Formula antialiasing mode.
- Display
Math Delimiter - Delimiter that introduced a display-math region.
- Formula
State - Current state of a formula request.
- Graphics
Support - Terminal support for the image-placement half of the pipeline.
- Markdown
Segment - Alternating prose and display-math regions from a Markdown document.
- Render
Failure Kind - Why a formula could not be rendered.
Functions§
- compact_
latex - Collapses runs of source whitespace into single spaces.
- display_
math - Finds completed display math while ignoring fenced and inline code.
- heal_
streaming_ display_ math - Completes a trailing, currently open display-math region for previewing a streaming Markdown document.
- is_
formula_ placeholder - Returns whether a Ratatui cell symbol is a Kitty graphics placeholder.
- markdown_
segments - Splits Markdown into ordinary text and completed display formulas.