Skip to content

Crisis82/calcifer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calcifer

A Rust CLI tool that renders LaTeX math expressions as ASCII art in markdown files.

Features

  • Inline math: $x^2$
  • Display math: $$\frac{a}{b}$$ → multi-line ASCII art fractions
  • Multiline display math: $$ ... \\\\ ... $$ → vertically stacked equations
  • Full Unicode support: Greek letters, operators, sub/superscripts
  • Scaling delimiters: \left( ... \right) scales to content height
  • Limit display: \lim_{x \to a} shows limit below "lim"
  • Blackboard bold: \mathbb{R}, \mathbb{N}, etc.
  • Pipe to glow: calcifer file.md | glow or calcifer --glow file.md

Installation

cargo install --path .

Or build from source:

cargo build --release
# Binary at target/release/calcifer

Usage

# Render a file
calcifer README.md

# Pipe to glow
calcifer README.md | glow

# Auto-pipe to glow
calcifer --glow README.md

# Read from stdin
echo '$\alpha + \beta = \gamma$' | calcifer

Supported LaTeX

Inline Math ($...$)

LaTeX Rendered
$x^2$
$x_i$ xᵢ
$\alpha + \beta$ α + β
$\frac{a}{b}$ a/b
$\sqrt{x}$ √(x)

Display Math ($$...$$)

$$\frac{a + b}{c}$$

Renders as:

a + b
─────
  c  
$$\sum_{i=1}^{n} i^2$$

Renders as:

 n    
 ∑  i²
i=1   
$$\lim_{x \to 0} \frac{\sin x}{x} = 1$$

Renders as:

      sin  x
 lim  ────── = 1
x → 0   x
$$\left( \frac{a}{b} \right)$$

Renders as:

⎛ a ⎞
⎜ ─ ⎟
⎝ b ⎠

Supported Commands

Greek letters: \alpha, \beta, \gamma, \delta, \epsilon, \theta, \lambda, \mu, \pi, \sigma, \omega, and uppercase variants

Operators: \sum, \prod, \int, \bigcup, \bigcap

Relations: \leq, \geq, \neq, \approx, \equiv, \in, \subset, \supset

Arrows: \rightarrow, \leftarrow, \Rightarrow, \Leftrightarrow, \mapsto, \to

Functions: \sin, \cos, \tan, \log, \ln, \exp, \lim, \max, \min

Structures: \frac{}{}, \sqrt{}, \sqrt[n]{}, ^{} (superscript), _{} (subscript)

Delimiters: \left( ... \right), \left[ ... \right], \left\{ ... \right\}, \langle, \rangle, \lceil, \rceil, \lfloor, \rfloor

Environments: matrix, pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix, array, cases, align, aligned

Number sets: \mathbb{R}, \mathbb{N}, \mathbb{Z}, \mathbb{Q}, \mathbb{C}, etc.

Misc: \infty, \partial, \nabla, \forall, \exists, \emptyset, \pm, \times, \cdot

Spacing: \,, \;, \:, \!, \quad, \qquad

See SYMBOLS.md for the complete list of 300+ supported symbols.

How It Works

  1. Parse markdown with pulldown-cmark (with math extension)
  2. Tokenize LaTeX expressions
  3. Build an AST (fractions, sums, roots, etc.)
  4. Render to a 2D character grid with proper baseline alignment
  5. Output as markdown with math replaced by ASCII art in code blocks

License

MIT

About

Latex math processor for markdown

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages