Raxol.UI.Components.CodeBlock (Raxol v2.0.1)

View Source

Renders a block of code with syntax highlighting.

Requires the makeup_elixir dependency (and potentially other lexers). Uses HTML output from Makeup.

Summary

Functions

Handles events for the component. No events are handled by default.

Initializes the component state from props.

Mount hook - called when component is mounted. No special setup needed for CodeBlock.

Renders the code block.

Unmount hook - called when component is unmounted. No cleanup needed for CodeBlock.

Updates the component state. No updates are handled by default.

Functions

broadcast(msg)

command(cmd)

handle_event(event, state, context)

@spec handle_event(term(), map(), map()) :: {map(), list()}

Handles events for the component. No events are handled by default.

init(props)

@spec init(map()) :: map()

Initializes the component state from props.

mount(state)

@spec mount(map()) :: {map(), list()}

Mount hook - called when component is mounted. No special setup needed for CodeBlock.

render(state, context)

@spec render(map(), map()) :: any()

Renders the code block.

Props:

  • content (required): The source code string.
  • language (required): The language name (e.g., "elixir", "html").
  • style: The Makeup HTML style module (e.g., Makeup.Styles.GithubLight). Defaults to :github_light style lookup.
  • class: Optional CSS class for the outer pre tag.

schedule(msg, delay)

unmount(state)

@spec unmount(map()) :: map()

Unmount hook - called when component is unmounted. No cleanup needed for CodeBlock.

update(message, state)

@spec update(term(), map()) :: map()

Updates the component state. No updates are handled by default.