Marcli (Marcli v0.3.1)

View Source

Converts CommonMark Markdown to ANSI-escaped terminal output.

Parses Markdown via MDEx and produces strings with ANSI escape sequences suitable for terminal rendering.

Supported Elements

  • Headings (h1: bold yellow, h2: bold cyan, h3+: bold white)
  • Bold, italic, strikethrough, inline code
  • Bullet lists (triangle markers) and ordered lists (circled numbers)
  • Code blocks with optional language headers (syntax-highlighted when a makeup_lang lexer is available)
  • Block quotes (vertical bar prefix)
  • Thematic breaks (horizontal rules)
  • Links (underlined blue with dimmed URL)
  • Images (bracketed alt text with URL)
  • Task list items (checkbox markers)

Syntax Highlighting

When a makeup_<lang> lexer library is present (e.g. makeup_elixir, makeup_erlang, makeup_html), fenced code blocks tagged with a language identifier are rendered with full ANSI syntax highlighting via Marcli.Formatter.

Add the desired lexer(s) to your mix.exs dependencies:

{:makeup_elixir, ">= 0.0.0", optional: true}

No configuration is required -- the lexer is detected at runtime via Makeup.Registry. If no matching lexer is loaded, the block is rendered without highlighting.

Options

  • :newline -- the line ending to use (default: "\n"). Pass "\r\n" for xterm.js or other terminals that require CRLF.
  • :theme -- a Marcli.Theme struct controlling all visual styles. Defaults to Marcli.Theme.default().

Example

output = Marcli.render("# Hello\n\nSome **bold** text.")
output = Marcli.render(markdown, newline: "\r\n")

theme = Marcli.Theme.load(".marcli.exs")
output = Marcli.render(markdown, theme: theme)

Summary

Functions

Renders a Markdown string as ANSI-escaped terminal output.

Types

option()

@type option() ::
  {:newline, String.t()}
  | {:theme, Marcli.Theme.t()}
  | {:escape_sequences, boolean()}

Functions

render(markdown, opts \\ [])

@spec render(String.t(), [option()]) :: String.t()

Renders a Markdown string as ANSI-escaped terminal output.

Returns a string with embedded ANSI escape sequences. Line endings default to "\n" but can be overridden with the :newline option.

Options

  • :newline -- the line ending sequence (default: "\n")
  • :theme -- a Marcli.Theme struct (default: Marcli.Theme.default())
  • :escape_sequences -- when false, strips all ANSI escape sequences from the output (default: true)