# pi-terminal-math

`pi-terminal-math` renders LaTeX equations as terminal-native text in [pi](https://pi.dev) assistant messages. It uses Unicode characters and ordinary terminal cells rather than image protocols, so equations remain readable in terminal transcripts.

## Install

```bash
pi install npm:pi-terminal-math
```

Restart pi or run `/reload` after installation.

## Usage

Math rendering starts off in each session. Enable it when you need to read LaTeX output:

```text
/math on       Enable rendering
/math off      Disable rendering
/math          Toggle rendering
```

The footer shows `∑ math` while rendering is enabled.

Write equations with standard LaTeX delimiters:

```text
Inline: $x^2 + y^2 = z^2$

Display: $$CC_{\mathrm{norm}} = \frac{CC_{\mathrm{abs}}}{CC_{\max}}$$
```

The extension renders common notation directly in assistant output:

```text
x² + y² = z²
```

```text
         CC
           abs
CC     = ─────
  norm   CC
           max
```

It supports common fractions, roots, sums, limits, subscripts, superscripts, Greek letters, and operators. Wide expressions wrap to the available terminal width. Incomplete, malformed, or unsupported LaTeX remains visible as source text instead of interrupting the transcript.

Math inside inline code or fenced code blocks is left unchanged. Currency-like dollar expressions are not treated as math.

## Scope

Rendering is available in pi's interactive TUI and defaults to off. Enabling it loads MathJax and adds brief prompt guidance encouraging display math for substantial equations. The extension does not modify stored assistant messages or add duplicate preview messages.

## Development

```bash
npm install
npm test
npm run check
```

## License

MIT
