lines

A chunk of literal code lines inside a canvas.code environment — the unit cues wrap and the unit everything else addresses. Chunks rather than line numbers, because choreography shifts line numbers: the moment a cue inserts three lines, every number below it points at the wrong line. Common indentation is stripped, so the chalk source can be indented normally.

linesNode

#Attributes

indentImplicit
Indentation levels (four spaces each) restored on assembly — the compiler dedents every literal body to its own margin, so a chunk continuing a block states its depth.
Also written: indent-levelCan be written as shorthand: lines:value
Default0
highlightAnimatable
The continuous highlight: these lines carry a wash for as long as they are shown. For a momentary one, wrap the chunk in a cue.highlight.
Defaultfalse
error-lines
Lines to flag with the gutter’s error marker — 1-based within THIS chunk.
Also written: error-line, errors
error-message
The diagnostic the interpreter would give — rendered inline at the end of the chunk's first error line, the way an IDE annotates a broken line.
Also written: diagnostic, error-note
added-lines
Diff wash: these lines carry the green added treatment — 1-based within THIS chunk.
Also written: added-line, added
removed-lines
Diff wash: these lines carry the red removed treatment — 1-based within THIS chunk.
Also written: removed-line, removed
hiddenAnimatable
Declared but not assembled.
Defaultfalse
setup
The chunk never displays and always executes — prepended to a run in source order, outside cue gating and hidden.
Defaultfalse
lock
Reserved for editable-environment rules.
Also written: locked
Defaultfalse

#Allowed content

Body { }Literal code lines, kept verbatim.

#Allowed in

#Examples

A Python function whose return line is highlighted.A Python function whose return line is highlighted.
canvas.code{
    lines{
def f(x):
    }
    lines{
return x * 2
    }(
        indent: 1
        highlight: true
    )
}(
    language: python
)
A Python function whose second line is flagged with a NameError, the message beneath it.A Python function whose second line is flagged with a NameError, the message beneath it.
canvas.code{
    lines{
def f(x):
    return undefined_name
    }(
        error-lines: 2
        error-message: NameError: name 'undefined_name' is not defined
    )
}(
    language: python
)
A Python function whose indented return line is washed green as added.A Python function whose indented return line is washed green as added.
canvas.code{
    lines{
def mean(values):
    total = sum(values)
    }
    lines{
return total / len(values)
    }(
        indent: 1
        added-lines: 1
    )
}(
    language: python
)

Last updated