Body & content attributes

The { } body and the content attributes written in braces: which constructs declare them, what each accepts, what a scene keeps to its body or its canvas, and inline content in attributes.

On this page

#The { } body and content attributes

A construct holds content in its { } body, written straight after its head. A construct that holds a second block of content declares a content attribute: an attribute in the ( ) group whose value is written in braces, name: { … }, and holds constructs as a body does. The value may span lines, and the braces are required. Five constructs declare one or more:

  • scene — the body is the narrative, canvas: the canvas.
  • task — the body sets the exercise; hint: and solution: each hold a fold, collapsed until revealed, the hint first.
  • theorem — the body is the statement, proof: the proof, collapsed until revealed.
  • question — the body is the prompt, feedback: the feedback shown when the question closes.
  • option — the body is the answer offered, feedback: the feedback shown when it was picked.
scene{
    The narrative.
}(
    canvas: {
        graph{
            curve(expression: x^2)
        }
    }
)

Written without braces, the value is refused: `canvas` takes block content, written in braces — `canvas: { … }`.

#What each accepts

A body accepts one of four kinds of content, and every reference page states which under Allowed content:

  • Constructs, from a list. Anything else written there is an error. A graph body takes marks, cues and controls, and no prose.
  • Inline text: prose with micronodes, such as a box's label or a !link's words.
  • Literal text, kept as written: the code in lines, the TeX in equation. Micronodes, delimiters and // comments are not read there.
  • Nothing. Marks take no body; a mark's words are its label: attribute.

A content attribute accepts constructs only, from a list of its own, and refuses anything else as a body does.

A sentence written in a graph body is refused: node `paragraph` is not allowed in `graph` when `plane: xy`.

The same list read the other way round is printed on every node's page under Allowed in: the constructs that accept it.

#A scene's body and canvas

A scene's body and its canvas: share some constructs and keep others to one side:

Four micronodes are refused in the body, wherever in it they are written: the text colours, !highlight with its ==…== spelling, !symbol and !cue.highlight. Bold, italic, code and maths are read in both. The colour goes on the canvas, in canvas::

scene{
    The teal curve is the faster decay.
}(
    canvas: {
        The !teal{teal} curve is the faster decay.

        graph{
            curve(f: e^(-2x); colour: teal)
            curve(f: e^(-x))
        }
    }
)

Written in the body, it is refused:

scene{
    The !teal{teal} curve is the faster decay.
}

[semantic]'!teal' is not allowed in the narrative; colour, highlighting and symbols belong in the canvas

#Inline content in an attribute

An attribute of type rich-text takes inline text, read as a paragraph's is: formatting, $maths$, micronodes and {{…}} expressions. It is written without braces. Every mark's label: is rich text, as are a graph's axis labels, a control's name:, a callout's title:, a definition's term: and an image's caption:. The type column of each reference page says which attributes are.

A parabola of height against time labelled h = 20t − 5t² in maths, its top point labelled highest point in teal, a text label reading peak 20 m in bold, and axes labelled t (s) and h (m).A parabola of height against time labelled h = 20t − 5t² in maths, its top point labelled highest point in teal, a text label reading peak 20 m in bold, and axes labelled t (s) and h (m).
graph{
    curve#h(expression: 20x - 5x^2; label: $h = 20t - 5t^2$)
    point(x: 2; y: 20; label: !teal{highest point})
    text(x: 2; y: 8; label: peak **{{round(#h.max, 1)}} m**)
}(
    x domain: [0, 4]
    y domain: [0, 25]
    x axis label: $t$ (s)
    y axis label: $h$ (m)
)

A rich-text value holds inline content only. Where a canvas needs a paragraph, a list or an equation, the scene's canvas: takes one directly.

Last updated