Raxol. UI. Components. CodeBlock
(Raxol v2.6.1)
View Source
Renders a block of code with structured syntax highlighting for the terminal.
Reuses Raxol.UI.SyntaxHighlighter — the same Makeup-backed, token-based
path that Pierre-style diffs (Harness.DiffViewer) use. Tokens carry
hex fg + font styles and are painted as styled text/1 spans; raw
ANSI is never embedded (only applied at the final Terminal.Renderer).
The previous implementation called Makeup.highlight_inner_html/2 and
then stripped the HTML tags, which discarded every color. That path is
gone.
Props
:content(string) — source code (default""):language(string) — language name or extension forMakeup.Registry(e.g."elixir","ex","python"). Unknown languages degrade to unstyled plain text, never raise.:theme(atom |%Makeup.Styles.HTML.Style{}) — Makeup style (default:one_dark, same as DiffViewer)
Summary
Functions
Handles events for the component. No events are handled by default.
Initializes the component state from props.
Renders the code block as a column of token-span rows.
Highlights source and returns one row element per line (token spans).
Updates the component state. No updates are handled by default.
Functions
Handles events for the component. No events are handled by default.
Initializes the component state from props.
Renders the code block as a column of token-span rows.
Highlights source and returns one row element per line (token spans).
Public so other renderers (e.g. MarkdownRenderer fenced blocks) can
reuse the exact CodeBlock line shape without nesting a full column.
Empty lines yield a single empty text cell so vertical spacing holds.
Updates the component state. No updates are handled by default.