ElixirOpentui.Widgets.Code (ElixirOpentui v0.2.0)

Copy Markdown View Source

Code display widget with syntax highlighting via Makeup.

Renders source code with syntax highlighting for supported languages. Uses the Makeup library for tokenization and applies terminal-compatible colors to different token types.

Props

  • :content — source code string
  • :filetype — language identifier for highlighting (e.g., "elixir", "html")
  • :id — element id
  • :show_line_numbers — show line number gutter (default: true)
  • :scroll_offset — vertical scroll position (default: 0)
  • :visible_lines — number of visible lines (default: nil, show all)

Summary

Functions

Tokenize source code using Makeup for the given filetype.

Functions

highlight(content, filetype)

@spec highlight(String.t() | nil, String.t() | nil) :: list() | nil

Tokenize source code using Makeup for the given filetype.

Returns a list of {token_type, metadata, text} tuples, or the raw content string if no lexer is available for the filetype.