lines

A chunk of code inside a code environment.

linesNode
On this page
A Python function shown as a diff: a three-line loop washed red as removed, its one-line replacement washed green as added, and the return line flagged with a NameError.A Python function shown as a diff: a three-line loop washed red as removed, its one-line replacement washed green as added, and the return line flagged with a NameError.

#Attributes

indentImplicit
Levels of four spaces added to every line, for a chunk that continues a block: lines:1{…}.
Also written: indent-levelCan be written as shorthand: lines:value
Default0
emphasisAnimatable
A wash over every line of the chunk, blank lines included, for as long as it is shown. A cue.highlight around the chunk washes it once instead.
Defaultfalse
error-lines
Lines that carry the gutter's error marker, counted from 1 within this chunk.
Also written: error-line, errors
error-message
A diagnostic set at the end of the chunk's first error line, or its first line when error-lines is unwritten.
Also written: diagnostic, error-note
added-lines
Lines washed green as added, counted from 1 within this chunk.
Also written: added-line, added
removed-lines
Lines washed red as removed, counted from 1 within this chunk.
Also written: removed-line, removed
hiddenAnimatable
The chunk is left out of the file. Animatable.
Defaultfalse
setup
The chunk is never shown and always runs: on a runnable environment, every setup chunk is prepended to a run in source order, whatever cues and hidden say.
Defaultfalse
lock
Has no effect.
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.
code{
    lines{
def f(x):
    }
    lines{
return x * 2
    }(
        indent: 1
        emphasis: 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.
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.
code{
    lines{
def mean(values):
    total = sum(values)
    }
    lines{
return total / len(values)
    }(
        indent: 1
        added-lines: 1
    )
}(
    language: python
)

#Notes

  • A chunk is the unit a cue wraps and the unit every mark addresses.
  • The environment joins the chunks on show into one file, so a chunk keeps its marks when another arrives above it.
  • The body is kept verbatim apart from its indentation, which is dedented to the chunk's own margin.
  • A blank line at the start of the body is kept and one at the end dropped; lines{} is one blank line.

Last updated