<extractMathOperator>
<extractMathOperator> returns the top-level operator of a math
expression as a text value. For a sum it returns "+", for a product
"*", for an equation "=", for a vector "vector", and so on. If the
expression is a single value (number, variable, or constant) with no
top-level operator, the result is the empty string.
Unlike <extractMath>, which pulls out operands or
function names and returns them as math expressions,
<extractMathOperator> returns the operator itself as plain text —
useful for branching on the kind of expression you have.
Attributes and Properties
Attributes for <extractMathOperator>
Positioning (2)
anchorpoint. Default value: . Coordinates of the anchor point used to position this component on a graph.
positionFromAnchorkeyword. Where this component sits relative to its anchor point.
| Value | Description |
|---|---|
upperRight | Place the component above and to the right of the anchor point. |
upperLeft | Place the component above and to the left of the anchor point. |
lowerRight | Place the component below and to the right of the anchor point. |
lowerLeft | Place the component below and to the left of the anchor point. |
top | Place the component directly above the anchor point. |
bottom | Place the component directly below the anchor point. |
left | Place the component directly to the left of the anchor point. |
right | Place the component directly to the right of the anchor point. |
center (default) | Center the component on the anchor point. |
Other (3)
draggableboolean. Default value: true. Whether the text can be dragged on a graph.
isLatexboolean. Default value: false. Whether the text content is treated as LaTeX.
layernumber. Default value: 0. Z-order layer index when shown on a graph.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <extractMathOperator name="e">
Positioning (2)
$e.anchorpoint. The coordinates where this component is anchored on the graph.
$e.positionFromAnchortext. Where this component sits relative to its anchor point.
Other (20)
$e.backgroundColortext. Human-readable name for this component's background color, derived from the active style and theme.
$e.characters[ text ]. The text value split into characters (graphemes).
$e.disabledboolean. Whether this component is disabled and cannot be interacted with.
$e.draggableboolean. Whether the text can be dragged on a graph.
$e.fixedboolean. Whether this component's value is fixed and cannot be modified.
$e.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$e.isLatexboolean. Whether the text content is treated as LaTeX.
$e.layernumber. Z-order layer index when shown on a graph.
$e.list[ text ]. The text value split into items at commas.
$e.mathmath. The text parsed as a math expression.
$e.numbernumber. The text parsed as a number.
$e.numCharactersinteger. The number of characters (graphemes) in the text value.
$e.numListItemsinteger. The number of comma-separated items when the text is interpreted as a list.
$e.numWordsinteger. The number of words in the text value.
$e.texttext. The text rendered as a plain text string.
$e.textColortext. Human-readable name for this component's text color, derived from the active style and theme.
$e.textStyleDescriptiontext. Human-readable description of this component's text styling (color and any background color).
$e.valuetext. The text result of applying this operator to its child math values.
$e.words[ text ]. The text value split into words.
Common to all components (4)
$e.doenetMLtext. The DoenetML source code that produced this component.
$e.hideboolean. Whether to hide this component from the rendered output.
$e.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$e.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Operator of a sum, product, and equation
For each expression the top-level operator (+, *, or =) is returned as
text. The result of <extractMathOperator> is a regular
<text> value, so it can be compared, displayed, or used in a
condition.
Example: Operator from a <mathInput>
The operator updates live as the learner edits the input — try entering a
vector (1,2,3), a function call f(x), a power x^2, or just a single
number to see how the operator changes.
Example: Branch on the kind of expression
Comparing the result of <extractMathOperator> against string literals
lets <conditionalContent> show different content for different kinds
of expressions.