Manual
Overview
Language
IntroductionScenes & structureText & inlineGraphsCode panesAnimationDataReuse & logicExpressions & parameters
Elements
Text
ParagraphHeading 1Heading 2Heading 3Heading 4Unordered ListDivider
Media
ImageTableEquation
Callouts
NoteDefinitionExampleTask
Graph
GraphLinePolygonCurveIntegralScatterHistogramPointSegmentVectorCircleSquareRectangleTriangleStarDiamondHexagonTextAxis labelAxis BraceFitResidualsContourHeatmapParameter
Code
Code canvasLines
Animation
CueDraw cueTrace cueHighlight cueSpotlight cueType cue
Structure
SceneStep
Reference
Internote Reference
Inline
Formatting
BoldItalicsInline CodeHighlightLink
Text colour
Red textOrange textYellow textGreen textTeal textBlue textPurple textPink textGrey text
Maths
Maths
Reference
Internote ReferenceValueConstant
Other
FootnoteIcon
Directives
DatasetIncludeConstantsTemplatePresetConditionalForIgnore
Keyframes
KeyframeZoom keyframe
Attribute types
?
  1. Language
  2. Code panes

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
)
A code pane does not execute anything. An output shown to the reader is authored — a comment or a later chunk asserting what an interpreter would print.

#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 @let 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.

On this page
The code paneLinesTyping animationSplicing values into code
Code panes · Internote