Inline Rendering

leaf provides an --inline mode that renders Markdown content directly to your terminal’s standard output. This is useful for previewing files quickly or piping rendered output to other tools.

Basic Usage

To render a file to stdout:

leaf --inline README.md

You can also pipe Markdown content directly into leaf:

echo "# Hello World" | leaf --inline

Options

The --inline flag accepts an optional specification in the format [format][:width].

Formats

  • auto (default): ANSI colors when stdout is a terminal, plain text when piping.
  • ansi: Force terminal colors and styles.
  • plain: Force plain text without ANSI escape codes.
leaf --inline ansi README.md
leaf --inline plain README.md

Custom Width

By default, leaf uses your terminal width. You can override this by specifying a width in characters:

# Render with 80 columns width
leaf --inline 80 README.md

# Render as ANSI with 60 columns width
leaf --inline ansi:60 README.md

# Render as plain text with 60 columns width
leaf --inline plain:60 README.md

Integration

Inline rendering is perfect for combining with other CLI tools:

# Preview the first few lines of a rendered document
leaf --inline README.md | head -n 20

# Use as a fzf preview
find . -name '*.md' | fzf --preview 'leaf --inline ansi {}'
find . -name '*.md' | fzf --preview 'leaf --inline ansi:$FZF_PREVIEW_COLUMNS {}'