Boxart.CodeNode (Boxart v0.3.2)

Copy Markdown View Source

Helpers for rendering syntax-highlighted code blocks inside graph nodes.

Summary

Functions

Formats source code for display inside a node box.

Renders a code block into a canvas region with a border.

Functions

format_label(source, opts \\ [])

@spec format_label(
  String.t(),
  keyword()
) :: Boxart.CodeNode.CodeLabel.t()

Formats source code for display inside a node box.

Options

  • :start_line — first line number (default: 1)
  • :language — atom for syntax highlighting (e.g. :elixir)

Returns a %CodeLabel{} with line number / code pairs and dimensions.

render_to_canvas(canvas, x, y, width, height, code_label, charset)

@spec render_to_canvas(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  Boxart.CodeNode.CodeLabel.t(),
  any()
) :: Boxart.Canvas.t()

Renders a code block into a canvas region with a border.