## code_block (`poetry_code_block`)

A syntax-highlighted code panel with a copy button and optional line numbers.

Class: Poetry::Ui::CodeBlock::Component - BEM block `poetry-ui-code_block`.
- `code:` (string) - required - The source text to highlight - required.
- `copy:` (boolean) - default true - Renders the copy button in the panel's corner.
- `highlight_lines:` () - 1-based line numbers to tint via the theme's highlight hook.
- `label:` (string) - The scroll region's accessible name; defaults to the localized "Code" (a focusable scrollable region must be named - axe).
- `language:` (string) - default "text" - The lexer name ("ruby", "js", ...); unknown languages fall back to plain text.
- `line_numbers:` (boolean) - default false - Renders CSS-counter line numbers - never part of selection or copied text.
- PART `code-block` - Root - the syntax-palette surface (cn-code-block) | states: data-language (always - the lexer name, a styling/tooling hook); data-line-numbers (line_numbers: - turns on the ::before CSS counters); data-copied (copy: only - stamped for a beat after a successful copy (the clipboard-text engine))
- PART `code-block-pre` - The scroll container - tabindex 0 + role region + label (a scrollable region must be keyboard-reachable and named)
- PART `code-block-code` - The code element - rouge's .line/.hll spans and the seven --syntax-* token maps live under it; the copy affordance reads ITS textContent
- WIRING root (if copy): `poetry--core--clipboard-text` registers; values message
- WIRING source (if copy): `poetry--core--clipboard-text` targets source
- WIRING copy_button: `poetry--core--clipboard-text` actions copy on click
- RULE: Blocks of code are a CodeBlock (poetry_code_block) - never a hand-rolled pre/code with utility classes; the syntax palette, line counters, and copy affordance ride it.
- RULE: Highlighting needs `gem "rouge"` in the host Gemfile - without it the block renders plain (same markup, no colors). Inline code stays plain <code> typography.
- RULE: highlight_lines: takes 1-based line numbers; line numbers are CSS counters and never pollute copied text.
