Code panes
The canvas.code pane: lines, chunked reveals, the typing cue, and splicing data into code.
#The code pane
canvas.code puts code on the canvas with the full editor experience — syntax highlighting, line numbers, a line/column readout, error markers — and lets it be choreographed like everything else on the board. Its implicit attribute is language; title names the pane, editable lets the reader touch it, and continue: #id carries session state forward from an earlier pane.
canvas.code{
lines{
import numpy as np
area = np.array([25.09, 1.24, 903.82])
}
}(
language: python
)#Lines
Code lives in lines chunks — the unit cues wrap and the unit everything else addresses. Chunks rather than line numbers, because choreography survives edits: inserting a line above a chunk does not renumber what a cue points at. A chunk takes indent (its implicit attribute), highlight, and error/diff dressing: error-lines with an error-message, added-lines and removed-lines.
#Typing animation
cue.type is the code pane's own verb: the chunks it wraps are typed in character by character on the timeline. in: anchors when the typing starts and speed: is characters per second (20 by default).
canvas.code{
lines{
z, log_c = np.polyfit(log_area, log_species, 1)
}
cue.type{
lines{
print(z) # ≈ 0.34
}
}(
in: 1
)
}(
language: python
)#Splicing values into code
{{ }} substitution reaches literal code bodies exactly as it reaches prose — it is a preprocessor over source text, so an constant or a fully-qualified dataset column splices into a chunk before anything is parsed:
@data#survey:galapagos-plants-1973.csv
canvas.code{
lines{
area = np.array([{{#survey.area}}])
}
}(
language: python
)The column arrives as its cells joined with commas — exactly the shape a Python list literal wants.