Body & detail

The { } and [ ] slots: which constructs take each, what a slot accepts, what a scene keeps to each side, and inline content in attributes.

On this page

#The { } body and the [ ] detail

A construct holds content in two bracketed slots after its head: the { } body and the [ ] detail, written in that order. Most constructs take a body or nothing. Four also take a detail, and in each the detail is the second half of the construct:

  • scene — the body is the narrative, the detail the canvas.
  • task — the body sets the exercise, the detail holds a hint or solution, collapsed until revealed.
  • question — the body is the prompt, the detail the feedback shown when the question closes.
  • option — the body is the answer offered, the detail the feedback shown when it was picked.
scene{
    The narrative.
}[
    graph{
        curve(expression: x^2)
    }
]

#What a slot accepts

Each slot 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 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 whose slots accept it.

#A scene's body and detail

A scene's two slots 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 slots. The colour goes on the canvas, in the detail:

scene{
    The teal curve is the faster decay.
}[
    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. 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 detail takes one directly.

Last updated