$code ( element -- ) (original) (raw)

Vocabulary
help.markup

Inputs

element a markup element of the form { string... }

Outputs
None

Word description
Prints code examples, as seen in many help articles. The markup element must be an array of strings.

Notes
The code becomes clickable if the output stream supports it, and clicking it opens a listener window with the text inserted at the input prompt.

If you want to show code along with sample output, use the $example element.

Examples

{ $code "2 2 + ." } print-element

2 2 + .

Definition

USING: io io.styles kernel splitting ;

IN: help.markup

: $code ( element -- )
join-lines dup [ write ] ($code) ;