It’s not a cat, not a bat, but rat: your terminal’s new best friend.
rat stands for Render All Text (at least, that is one way to read it): a lightweight CLI that turns Markdown and LaTeX into terminal-friendly Unicode text, with a Vim/Neovim plugin for live JSON-RPC rendering.
For best Unicode glyph rendering in terminals and editors, JuliaMono is recommended.
- Markdown to Unicode/plain-text output
- LaTeX to Unicode/plain-text output
- Works with files or stdin
- JSON-RPC mode for editor integrations
- Vim/Neovim live preview plugin included
macOS (Apple Silicon):
mkdir -p ~/.local/bin
curl -fL https://github.com/tani/rat/releases/download/nightly/rat-darwin-arm64 -o ~/.local/bin/rat
chmod +x ~/.local/bin/ratLinux x64:
mkdir -p ~/.local/bin
curl -fL https://github.com/tani/rat/releases/download/nightly/rat-linux-x64 -o ~/.local/bin/rat
chmod +x ~/.local/bin/ratIf needed, add this to your shell profile:
export PATH="$HOME/.local/bin:$PATH"Verify:
rat --helpRequirements: bun
git clone https://github.com/tani/rat.git
cd rat
bun install
bun run compileRender Markdown from stdin:
echo "# Hello\n\n*world*" | ratRender Markdown from a file:
rat examples/EXAMPLE.mdRender LaTeX from stdin:
echo 'Term: \(\alpha^2 + \beta\)' | rat --language=latexRender LaTeX from a file:
rat --language=latex examples/EXAMPLE.texLanguage options:
--language=markdown(default)--language=latex- Also accepted:
--language markdown/--language latex - Backward compatibility:
--latex
Install with vim-plug:
Plug 'tani/rat', { 'rtp': 'vim/' }Commands:
:RatOpen:RatClose:RatToggle
Behavior:
- Live preview updates on edit and cursor move (
TextChanged,TextChangedI,CursorMoved,CursorMovedI) - Cursor sync to preview (
CursorMoved,CursorMovedI) - Sends JSON-RPC
params.languageautomatically:latexfortex,plaintex,latexmarkdownfor everything else
Start server mode:
rat --json-rpcSupported methods:
renderwithparams: { text, cursor?, language? }shutdown
Example request:
{"jsonrpc":"2.0","id":1,"method":"render","params":{"text":"A: $\\alpha+\\beta$","language":"latex"}}Example response:
{"jsonrpc":"2.0","id":1,"result":{"text":"A: α+β","cursorMapping":{"sourceLine":1,"sourceColumn":1,"renderedLine":1,"renderedColumn":1,"strategy":"line-anchor","confidence":1}}}previewLine and sourcemap were removed in favor of cursorMapping.
@rat/unicode-sourcemap now exposes a mapper object API:
import { createUnicodeSourcemap } from "@rat/unicode-sourcemap";
const mapper = createUnicodeSourcemap(sourceText, renderedText);
const offset = mapper.mapOffset(42);
const cursor = mapper.mapCursor({ line: 10, column: 1 });
const line = mapper.mapLine(10);
const lines = mapper.mapLines();bun test
bun run test:vim
bun run lint
bun run typecheck
bun run format:checkMIT. See LICENSE.