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. Elements
  2. Code
  3. Code canvas

Code canvas

canvas.codeBlock elementCode

Code as a canvas pane: the full editor experience — syntax highlighting, line numbers, a line/column readout, error markers — with the code choreographed like everything else on a canvas. Content is written as `lines{}` chunks; cues wrap chunks to bring them in and out on the timeline, and the pane assembles whatever is visible into one document, numbering the lines actually shown. With `editable: true`, the reader’s first keystroke forks the assembled text into their own copy (kept between visits); choreography freezes until they reset.

Attributes

languageImplicit
programming-language
Also written: langDrives the syntax highlighting, the header icon, and the display name.The head shorthand supplies it: canvas.code:value
Defaultauto
title
string
Also written: name, filename, file-name, fileThe filename shown in the header tab, beside the language’s own mark.
editable
boolean
The reader may edit the code (v1 edits are text only; nothing runs).
Defaultfalse
show-line-numbers
boolean
Also written: line-numbersThe gutter.
Defaulttrue
wrap
boolean
Start with soft wrap on.
Defaultfalse
continue
Inherit an earlier same-type pane's state: `continue: #that-pane`.

Allowed content

Body { }
linescuecue.drawcue.highlightcue.type

Allowed in

scene [ ]

Examples

canvas.code{
    lines{
def greet(name):
    return f"Hello, {name}!"
    }
}(
    language: python
    title: greet.py
)
canvas.code{
    lines{
x = 1
    }
    cue{
        lines{
y = x + 1
        }
    }(
        in: 1
    )
}(
    language: python
)
On this page
AttributesAllowed contentAllowed inExamples
Code canvas · Internote