ReferencedisplayDoenetML

<displayDoenetML>

Displays a DoenetML source string verbatim

<displayDoenetML> shows a snippet of DoenetML source as text rather than rendering it. The contents are reproduced verbatim — every tag, attribute, and reference is preserved — and rendered with syntax highlighting in viewers that support it.

The most common pattern is <pre> wrapping a <displayDoenetML> so that whitespace and indentation are preserved. Use this when you want to talk about DoenetML inside a DoenetML document without the document parsing and executing the snippet you are explaining.

For an editor in which the viewer can change the source and see the preview, use <codeEditor> instead. For short inline tag references, use <tag>, <tage>, or <tagc>.

Attributes and Properties

Attributes for <displayDoenetML>

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <displayDoenetML name="d">

Other (8)
$d.backgroundColor

text. Human-readable name for this component's background color, derived from the active style and theme.

$d.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$d.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$d.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$d.hidden

boolean. Whether this component is hidden from the rendered output.

$d.text

text. The verbatim text content.

$d.textColor

text. Human-readable name for this component's text color, derived from the active style and theme.

$d.textStyleDescription

text. Human-readable description of this component's text styling (color and any background color).

Common to all components (4)
$d.doenetML

text. The DoenetML source code that produced this component.

$d.hide

boolean. Whether to hide this component from the rendered output.

$d.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$d.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Show a small DoenetML snippet

The children of <displayDoenetML> are rendered as text without being parsed as DoenetML. Wrapping in <pre> preserves the newlines and indentation.


Example: Show a single inline reference

<displayDoenetML> is also useful inline (here inside a <c>) when you need a single reference or fragment to appear verbatim instead of being expanded.


Example: Side-by-side source and rendering

Showing the source above the rendered output is the standard pattern for “here’s the code, here’s the result” walkthroughs.