From b1f9a06fbf1a4c3a1964e9127af575259ce07551 Mon Sep 17 00:00:00 2001 From: Duane Nykamp Date: Thu, 1 Aug 2024 17:25:38 -0500 Subject: [PATCH 1/7] Created nextra codeblocks for doenet-example, doenet-viewer, and doenet-editor. --- .../docs-nextra/components/doenet-example.tsx | 24 ++++++++++ packages/docs-nextra/components/doenet.tsx | 29 ++++++++++-- .../docs-nextra/components/doenetInternal.tsx | 27 ----------- .../components/doenetml-example.tsx | 37 --------------- .../components/iframe-doenetml.tsx | 23 --------- packages/docs-nextra/components/index.ts | 3 +- packages/docs-nextra/next.config.mjs | 14 +++++- packages/docs-nextra/pages/style.css | 11 ++++- packages/docs-nextra/scripts/index.ts | 3 ++ .../docs-nextra/scripts/wrap-doenet-editor.ts | 47 +++++++++++++++++++ .../scripts/wrap-doenet-example.ts | 45 ++++++++++++++++++ .../docs-nextra/scripts/wrap-doenet-viewer.ts | 42 +++++++++++++++++ packages/doenetml-iframe/src/index.tsx | 2 +- packages/doenetml/src/Viewer/PageViewer.jsx | 2 +- 14 files changed, 211 insertions(+), 98 deletions(-) create mode 100644 packages/docs-nextra/components/doenet-example.tsx delete mode 100644 packages/docs-nextra/components/doenetInternal.tsx delete mode 100644 packages/docs-nextra/components/doenetml-example.tsx delete mode 100644 packages/docs-nextra/components/iframe-doenetml.tsx create mode 100644 packages/docs-nextra/scripts/wrap-doenet-editor.ts create mode 100644 packages/docs-nextra/scripts/wrap-doenet-example.ts create mode 100644 packages/docs-nextra/scripts/wrap-doenet-viewer.ts diff --git a/packages/docs-nextra/components/doenet-example.tsx b/packages/docs-nextra/components/doenet-example.tsx new file mode 100644 index 000000000..8a21dfd71 --- /dev/null +++ b/packages/docs-nextra/components/doenet-example.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import { DoenetViewer } from "./doenet"; +import { Tabs } from "nextra/components"; + +/** + * Render DoenetML as an example in documentation. + */ +export function DoenetExample({ + source, + children, +}: React.PropsWithChildren<{ source: string }>) { + return ( +
+ + +
+ +
+
+ {children} +
+
+ ); +} diff --git a/packages/docs-nextra/components/doenet.tsx b/packages/docs-nextra/components/doenet.tsx index f778044e7..365b64b49 100644 --- a/packages/docs-nextra/components/doenet.tsx +++ b/packages/docs-nextra/components/doenet.tsx @@ -1,6 +1,27 @@ import React from "react"; -import dynamic from "next/dynamic"; +import { + DoenetViewer as DoenetViewerOrig, + DoenetEditor as DoenetEditorOrig, +} from "@doenet/doenetml-iframe"; +import "@doenet/virtual-keyboard/style.css"; -export const DoenetML = dynamic(() => import("./doenetInternal"), { - ssr: false, -}); +/** + * Render DoenetML in an iframe so that its styling/state is completely isolated from the page. + */ +export function DoenetViewer({ + source, +}: React.PropsWithChildren<{ source: string }>) { + return ; +} + +export function DoenetEditor({ + source, + showFormatter = false, +}: React.PropsWithChildren<{ source: string; showFormatter?: boolean }>) { + console.log("source for editor", JSON.stringify(source)); + return ( +
+ +
+ ); +} diff --git a/packages/docs-nextra/components/doenetInternal.tsx b/packages/docs-nextra/components/doenetInternal.tsx deleted file mode 100644 index 93789240d..000000000 --- a/packages/docs-nextra/components/doenetInternal.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; - -//import { renderDoenetToContainer } from "doenet-standalone-test"; -declare module window { - function renderDoenetToContainer( - domNode: HTMLElement, - content: string, - ): void; -} - -export function DoenetInternal({ children }: React.PropsWithChildren<{}>) { - return ( -
{ - if (domNode) { - console.log("rendering the doenet"); - window.renderDoenetToContainer( - domNode, - String(children || ""), - ); - } - }} - >
- ); -} - -export default DoenetInternal; diff --git a/packages/docs-nextra/components/doenetml-example.tsx b/packages/docs-nextra/components/doenetml-example.tsx deleted file mode 100644 index 4985f4061..000000000 --- a/packages/docs-nextra/components/doenetml-example.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from "react"; -import { IframeDoenetML } from "./iframe-doenetml"; -import { Tabs } from "nextra/components"; - -/** - * Render DoenetML as an example in documentation. - */ -export function DoenetMLExample({ children }: React.PropsWithChildren<{}>) { - if (typeof children !== "string") { - console.error( - "Error with DoenetML component. Expected a string child containing DoenetML source code, but found", - children, - ); - return ( -
- Error with DoenetML component. Expected a string child - containing DoenetML source code, but found {typeof children}. - Check the console for details -
- ); - } - const source = children.trim(); - return ( -
- - -
- {source} -
-
- -
{source}
-
-
-
- ); -} diff --git a/packages/docs-nextra/components/iframe-doenetml.tsx b/packages/docs-nextra/components/iframe-doenetml.tsx deleted file mode 100644 index 7677965fc..000000000 --- a/packages/docs-nextra/components/iframe-doenetml.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -import { DoenetViewer } from "@doenet/doenetml-iframe"; -import "@doenet/virtual-keyboard/style.css"; - -/** - * Render DoenetML in an iframe so that its styling/state is completely isolated from the page. - */ -export function IframeDoenetML({ children }: React.PropsWithChildren<{}>) { - if (typeof children !== "string") { - console.error( - "Error with DoenetML component. Expected a string child containing DoenetML source code, but found", - children, - ); - return ( -
- Error with DoenetML component. Expected a string child - containing DoenetML source code, but found {typeof children}. - Check the console for details -
- ); - } - return ; -} diff --git a/packages/docs-nextra/components/index.ts b/packages/docs-nextra/components/index.ts index b9c1ce464..cfcddad52 100644 --- a/packages/docs-nextra/components/index.ts +++ b/packages/docs-nextra/components/index.ts @@ -1,2 +1,3 @@ -export * from "./doenetml-example"; +export * from "./doenet-example"; export * from "./props-display"; +export * from "./doenet"; diff --git a/packages/docs-nextra/next.config.mjs b/packages/docs-nextra/next.config.mjs index 76671ee12..c2107d582 100644 --- a/packages/docs-nextra/next.config.mjs +++ b/packages/docs-nextra/next.config.mjs @@ -1,5 +1,10 @@ import nextraConfig from "nextra"; -import { autoInsertAttrPropDescriptions } from "./dist/index.js"; +import { + autoInsertAttrPropDescriptions, + wrapDoenetExample, + wrapDoenetEditor, + wrapDoenetViewer, +} from "./dist/index.js"; import { getHighlighter, bundledLanguages, bundledThemes } from "shiki"; import fs from "node:fs"; @@ -58,7 +63,12 @@ const withNextra = nextraConfig({ return await highlighter; }, }, - remarkPlugins: [autoInsertAttrPropDescriptions], + remarkPlugins: [ + autoInsertAttrPropDescriptions, + wrapDoenetExample, + wrapDoenetEditor, + wrapDoenetViewer, + ], rehypePlugins: [ /** * Add any data in `extraSearchData` to `structurizedData` so that it shows up in the search box. diff --git a/packages/docs-nextra/pages/style.css b/packages/docs-nextra/pages/style.css index 33ba85d58..970703b9e 100644 --- a/packages/docs-nextra/pages/style.css +++ b/packages/docs-nextra/pages/style.css @@ -1,8 +1,15 @@ -.doenetml-example-container { - border: 2px dashed black; +.doenet-example-container { + border: 2px solid rgb(229, 231, 235); border-radius: 10px; + padding: 0px; + margin-top:1.5rem; } +.doenet-editor-container { + margin-top:1.5rem; +} + + .attr-table, .prop-table { margin-left: auto; diff --git a/packages/docs-nextra/scripts/index.ts b/packages/docs-nextra/scripts/index.ts index 0e992abda..42a93e6b9 100644 --- a/packages/docs-nextra/scripts/index.ts +++ b/packages/docs-nextra/scripts/index.ts @@ -1 +1,4 @@ export * from "./auto-insert-attr-prop-descriptions"; +export * from "./wrap-doenet-editor"; +export * from "./wrap-doenet-example"; +export * from "./wrap-doenet-viewer"; diff --git a/packages/docs-nextra/scripts/wrap-doenet-editor.ts b/packages/docs-nextra/scripts/wrap-doenet-editor.ts new file mode 100644 index 000000000..0f90beb81 --- /dev/null +++ b/packages/docs-nextra/scripts/wrap-doenet-editor.ts @@ -0,0 +1,47 @@ +import { visit } from "unist-util-visit"; +import { Plugin } from "unified"; + +import { Root as MdastRoot } from "mdast"; +// Importing this automatically imports all the types from `mdast-util-mdx-jsx`. +import "mdast-util-mdx-jsx"; + +/** + * Wraps codeblocks of type `doenet-editor` with a JSX element that renders the editor with the output. + */ +export const wrapDoenetEditor: Plugin = + function () { + return (tree) => { + visit(tree, (node) => { + type MdxJsxFlowElement = typeof node & { + type: "mdxJsxFlowElement"; + }; + if (node?.type !== "code") { + return; + } + if (node.lang !== "doenet-editor") { + return; + } + + console.log( + "value for wrapped editor", + JSON.stringify(node.value), + ); + + const newNode: MdxJsxFlowElement = { + type: "mdxJsxFlowElement", + name: "DoenetEditor", + attributes: [ + { + type: "mdxJsxAttribute", + name: "source", + value: node.value, + }, + ], + children: [], + }; + + // Override the original node with the new one. + Object.assign(node, newNode); + }); + }; + }; diff --git a/packages/docs-nextra/scripts/wrap-doenet-example.ts b/packages/docs-nextra/scripts/wrap-doenet-example.ts new file mode 100644 index 000000000..3c869552c --- /dev/null +++ b/packages/docs-nextra/scripts/wrap-doenet-example.ts @@ -0,0 +1,45 @@ +import { visit } from "unist-util-visit"; +import { Plugin } from "unified"; + +import { Root as MdastRoot } from "mdast"; +// Importing this automatically imports all the types from `mdast-util-mdx-jsx`. +import "mdast-util-mdx-jsx"; + +/** + * Wraps codeblocks of type `doenet-example` with a JSX element that renders the code and the output. + */ +export const wrapDoenetExample: Plugin = + function () { + return (tree) => { + visit(tree, (node) => { + type MdxJsxFlowElement = typeof node & { + type: "mdxJsxFlowElement"; + }; + if (node?.type !== "code") { + return; + } + if (node.lang !== "doenet-example") { + return; + } + + // Make sure to change `lang` away from `doenet-example` to avoid infinite recursion. + const origNode = { ...node, lang: "doenet" }; + + const newNode: MdxJsxFlowElement = { + type: "mdxJsxFlowElement", + name: "DoenetExample", + attributes: [ + { + type: "mdxJsxAttribute", + name: "source", + value: origNode.value, + }, + ], + children: [origNode], + }; + + // Override the original node with the new one. + Object.assign(node, newNode); + }); + }; + }; diff --git a/packages/docs-nextra/scripts/wrap-doenet-viewer.ts b/packages/docs-nextra/scripts/wrap-doenet-viewer.ts new file mode 100644 index 000000000..c95d62c6b --- /dev/null +++ b/packages/docs-nextra/scripts/wrap-doenet-viewer.ts @@ -0,0 +1,42 @@ +import { visit } from "unist-util-visit"; +import { Plugin } from "unified"; + +import { Root as MdastRoot } from "mdast"; +// Importing this automatically imports all the types from `mdast-util-mdx-jsx`. +import "mdast-util-mdx-jsx"; + +/** + * Wraps codeblocks of type `doenet-editor` with a JSX element that renders the output. + */ +export const wrapDoenetViewer: Plugin = + function () { + return (tree) => { + visit(tree, (node) => { + type MdxJsxFlowElement = typeof node & { + type: "mdxJsxFlowElement"; + }; + if (node?.type !== "code") { + return; + } + if (node.lang !== "doenet-viewer") { + return; + } + + const newNode: MdxJsxFlowElement = { + type: "mdxJsxFlowElement", + name: "DoenetViewer", + attributes: [ + { + type: "mdxJsxAttribute", + name: "source", + value: node.value, + }, + ], + children: [], + }; + + // Override the original node with the new one. + Object.assign(node, newNode); + }); + }; + }; diff --git a/packages/doenetml-iframe/src/index.tsx b/packages/doenetml-iframe/src/index.tsx index e4e558e6d..c8d0b757c 100644 --- a/packages/doenetml-iframe/src/index.tsx +++ b/packages/doenetml-iframe/src/index.tsx @@ -259,7 +259,7 @@ export function DoenetViewer({ boxSizing: "border-box", overflow: "hidden", border: "none", - minHeight: 200, + minHeight: 50, }} height={height} /> diff --git a/packages/doenetml/src/Viewer/PageViewer.jsx b/packages/doenetml/src/Viewer/PageViewer.jsx index 1f7cf937e..c0f00b4a4 100644 --- a/packages/doenetml/src/Viewer/PageViewer.jsx +++ b/packages/doenetml/src/Viewer/PageViewer.jsx @@ -1392,7 +1392,7 @@ export function PageViewer({ if (!coreCreated.current) { if (!documentRenderer) { noCoreWarning = ( -
+

Initializing....

); From d8c309d8268577db874e9d4a2dfca781d25fc636 Mon Sep 17 00:00:00 2001 From: Duane Nykamp Date: Thu, 1 Aug 2024 17:26:14 -0500 Subject: [PATCH 2/7] update documentation to use new nextra codeblocks --- .../reference/doenetML_components/abs.mdx | 10 ++-- .../reference/doenetML_components/alert.mdx | 4 +- .../reference/doenetML_components/and.mdx | 8 +-- .../reference/doenetML_components/angle.mdx | 2 +- .../animateFromSequence.mdx | 2 +- .../reference/doenetML_components/answer.mdx | 2 +- .../reference/doenetML_components/aside.mdx | 2 +- .../reference/doenetML_components/boolean.mdx | 58 +++++++++---------- .../doenetML_components/componentIndex.mdx | 2 +- .../doenetML_components/mathInput.mdx | 8 +-- .../pages/reference/essentialConcepts.mdx | 4 +- .../intermediateTutorial/iT2-1-cartesian.mdx | 24 ++++---- .../intermediateTutorial/iT2-2-points.mdx | 22 ++++--- .../intermediateTutorial/iT2-3-lines.mdx | 28 +++++---- .../intermediateTutorial/iT2-4-properties.mdx | 31 +++++----- .../iT1-1-writing-mathematics.mdx | 18 +++--- .../introdTutorial/iT1-10-advice.mdx | 12 ++-- .../introdTutorial/iT1-2-creating-docs.mdx | 2 +- .../iT1-3-variables-numbers.mdx | 22 +++---- .../introdTutorial/iT1-4-comparison-math.mdx | 18 +++--- .../introdTutorial/iT1-5-setup-blocks.mdx | 6 +- .../introdTutorial/iT1-6-user-input.mdx | 18 +++--- .../introdTutorial/iT1-7-functions.mdx | 22 +++---- .../introdTutorial/iT1-8-domains.mdx | 24 ++++---- .../introdTutorial/iT1-9-sliders.mdx | 16 +++-- .../pages/tutorials/quickStart.mdx | 18 +++--- .../tutorials/quickStart/quickStart-1.mdx | 7 +-- .../tutorials/quickStart/quickStart-2.mdx | 38 ++++-------- 28 files changed, 203 insertions(+), 225 deletions(-) diff --git a/packages/docs-nextra/pages/reference/doenetML_components/abs.mdx b/packages/docs-nextra/pages/reference/doenetML_components/abs.mdx index f8840be15..76f572011 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/abs.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/abs.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` @@ -18,7 +18,7 @@ The `` component has no attibutes or properties. ### Example: Render the absolute value of a math expression -```html +```doenet |5 - 8| = 5 - 8 ``` The `` component is used to render the absolute value of a math expression. Test code [here](https://www.doenet.org/portfolioeditor/_J1J2N530LyIvVWx64xB8V/_AgzWwqGV6Yy9DfqMyGlFm). @@ -26,7 +26,7 @@ The `` component is used to render the absolute value of a math expression. ### Example: Absolute value of `` -```html +```doenet

Type any number:

|$userN| = $userN

``` @@ -34,7 +34,7 @@ The `` component is used to render the absolute value of a named ` ### Example: Absolute value of numerical properties -```html {5} +```doenet {5}

Move the point in the third quadrant.

(-5,-5) @@ -47,7 +47,7 @@ Children of the `` component can include references to `` values ### Example: Absolute value of a function -```html {4} +```doenet {4} (1/4)x^2 - 4 diff --git a/packages/docs-nextra/pages/reference/doenetML_components/alert.mdx b/packages/docs-nextra/pages/reference/doenetML_components/alert.mdx index 18ff90417..e2a7d8aa6 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/alert.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/alert.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` @@ -10,7 +10,7 @@ The `` component has no attributes or properties. ### Example: Basic use -```html +```doenet

Take the right turn.

``` diff --git a/packages/docs-nextra/pages/reference/doenetML_components/and.mdx b/packages/docs-nextra/pages/reference/doenetML_components/and.mdx index 8bf372e83..97877032b 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/and.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/and.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` @@ -15,7 +15,7 @@ The `` component has no attributes or properties. ### Example: `` in a `` -```html {10} +```doenet {10}

Enter a number between 5 and 10, excluding 7:

@@ -33,7 +33,7 @@ The `` component functions as the boolean operator `and` or `&`, and checks ### Example: `` in an `` -```html {18} +```doenet {18}

Move the point to the intersection of the circle and the line in the first quadrant. (Scroll down to check work.)

@@ -69,7 +69,7 @@ An `` component is used to construct a compound boolean from three referenc ### Example: An alternative to `` -```html {9} +```doenet {9}

Enter a number between 5 and 10, excluding 7:

diff --git a/packages/docs-nextra/pages/reference/doenetML_components/angle.mdx b/packages/docs-nextra/pages/reference/doenetML_components/angle.mdx index b1e8f2466..01ae5de29 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/angle.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/angle.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" import { AttrDisplay, PropDisplay } from "../../../components" # `{:dn}` diff --git a/packages/docs-nextra/pages/reference/doenetML_components/animateFromSequence.mdx b/packages/docs-nextra/pages/reference/doenetML_components/animateFromSequence.mdx index 83895aa6d..75fb5b45c 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/animateFromSequence.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/animateFromSequence.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" {` diff --git a/packages/docs-nextra/pages/reference/doenetML_components/answer.mdx b/packages/docs-nextra/pages/reference/doenetML_components/answer.mdx index f4df42996..548809a2f 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/answer.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/answer.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` diff --git a/packages/docs-nextra/pages/reference/doenetML_components/aside.mdx b/packages/docs-nextra/pages/reference/doenetML_components/aside.mdx index f4df42996..548809a2f 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/aside.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/aside.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` diff --git a/packages/docs-nextra/pages/reference/doenetML_components/boolean.mdx b/packages/docs-nextra/pages/reference/doenetML_components/boolean.mdx index 98c1cdaf1..c864aaa6c 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/boolean.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/boolean.mdx @@ -1,4 +1,4 @@ -import { DoenetMLExample } from "../../../components" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` @@ -9,7 +9,7 @@ The `` component renders the boolean value of `true` or `false` of the ### Example: Check if an equation is `true` or `false` - + {`

The following equation is 1 + 1 = $input. @@ -18,13 +18,13 @@ The `` component renders the boolean value of `true` or `false` of the 1 + 1 = `} - + A `` component is used to render whether an equation is `true` or `false` for a user-supplied response. ### Example: Boolean value of a geometric property - + {`

The slope of the line is greater than or equal to 1: @@ -36,7 +36,7 @@ A `` component is used to render whether an equation is `true` or `fals `} - + A `` component is used to render whether a statement regarding the geometric slope of a named `` is `true` or `false`. Drag the point to adjust the slope of the line which in turn will affect the value of the ``. @@ -44,7 +44,7 @@ A `` component is used to render whether a statement regarding the geom ### Example: Constructing compound booleans - + {`

Enter a number that is less than 100, greater than 20, and divisible by 3.

@@ -60,7 +60,7 @@ A `` component is used to render whether a statement regarding the geom !

`} -
+ References to `boolean` components can be combined with logical operators to create more complex boolean expressions. @@ -83,7 +83,7 @@ References to `boolean` components can be combined with logical operators to cre ### Example: `symbolicEquality` attribute - + {`

Enter x^2 + 2x + 1 exactly:

@@ -91,7 +91,7 @@ References to `boolean` components can be combined with logical operators to cre

Now, enter (x + 1)^2 instead...

`} -
+ Comparing two values with the `symbolicEquality` attribute switches the default comparison method to one which demands exact syntactical equality. Without this attribute, a value of `true` would be returned both for `x^2 + 2x + 1` as well as `(x + 1)^2`. @@ -99,14 +99,14 @@ switches the default comparison method to one which demands exact syntactical eq ### Example: `expandOnCompare` attribute - + {`

Enter (x + 1)^2:

$mi = x^2 + 2x + 1
`} -
+ Comparing two values with the `expandOnCompare` and `symbolicEquality` attributes allows expressions that are @@ -115,7 +115,7 @@ equivalent after expanding to evaluate to `true`. It is a partial relaxation of ### Example: `simplifyOnCompare` attribute - + {`

Enter x*x + x + x + 1: @@ -123,7 +123,7 @@ equivalent after expanding to evaluate to `true`. It is a partial relaxation of $mi = x^2 + 2x + 1 `} - + Comparing two values with the `simplifyOnCompare` and `symbolicEquality` attributes allows expressions that are @@ -131,7 +131,7 @@ equivalent after simplifying to evaluate to `true`. It is a partial relaxation o ### Example: `unorderedCompare` attribute - + {`

Enter 1,2,3,4,5 in that exact order:

@@ -141,14 +141,14 @@ equivalent after simplifying to evaluate to `true`. It is a partial relaxation o

$mi2 = 1 2 3 4 5

`} -
+ When multiple values are compared within a single ``tag, the default behavior is to match the order of the listed values. If order is irrelevant, use the `unorderedCompare` attribute. ### Example: `matchByExactPositions` attribute - + {`

Enter 1,2,3 in that exact order: @@ -159,13 +159,13 @@ When multiple values are compared within a single ``tag, the default be

Now, observe what happens when you switch the order

`} -
+ When multiple responses are evaluated by comparison with a vector of correct values inside a ``, the `matchByExactPositions` attribute enforces a strict order onto the validation. Only correct values in the correct answer blanks will allow the `` to evaluate to `true`. ### Example: `allowedErrorInNumbers` and `allowedErrorIsAbsolute` attributes - + {`

Enter a number within 10\% of 100:

@@ -175,7 +175,7 @@ When multiple responses are evaluated by comparison with a vector of correct val $mi2 = 100
`} -
+ The `allowedErrorInNumbers` attribute may be used to specify the acceptable error of an approximate response when comparing numerical values. By default, the error is specified as a fractional value. @@ -184,7 +184,7 @@ To specify an allowed error with a specific numerical value (rather than as a fr ### Example: `caseInsensitiveMatch` attribute - + {`

Enter tTkLp:

@@ -194,7 +194,7 @@ To specify an allowed error with a specific numerical value (rather than as a fr tTkLp = $ti2
`} -
+ Use the `caseInsensitiveMatch` attribute if capitalization is not relevant for comparison. @@ -202,7 +202,7 @@ is not relevant for comparison. ### Example: `matchBlanks` attribute - + {`

Compare two expressions with blanks

@@ -213,7 +213,7 @@ is not relevant for comparison.

$mi = /x

`} -
+ Use the `matchBlanks` attribute to accurately compare two expressions containing blanks. @@ -228,7 +228,7 @@ Use the `matchBlanks` attribute to accurately compare two expressions containing ### Example: `text` property - + {`

Enter "1" for true, not "1" for false:

@@ -237,13 +237,13 @@ Use the `matchBlanks` attribute to accurately compare two expressions containing

text = $bool.text

`} -
+ The `text` property of a named `` returns the value of "true" or "false" as a string. ### Example: `value` property - + {`

Enter "1" for true, not "1" for false:

@@ -252,13 +252,13 @@ value of "true" or "false" as a string.

value = $bool.value

`} -
+ The `value` property of a named `` returns its value of `true` or `false`. ### Example: Attributes as properties - + {` x^2 + 2x + 1 = @@ -275,7 +275,7 @@ value of `true` or `false`.

matchByExactPositions = $bool.matchByExactPositions

`} -
+ All attributes of a `` are also available as properties. diff --git a/packages/docs-nextra/pages/reference/doenetML_components/componentIndex.mdx b/packages/docs-nextra/pages/reference/doenetML_components/componentIndex.mdx index 4285d6de1..3c4550ca3 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/componentIndex.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/componentIndex.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # Alphabetical Component Index diff --git a/packages/docs-nextra/pages/reference/doenetML_components/mathInput.mdx b/packages/docs-nextra/pages/reference/doenetML_components/mathInput.mdx index 168af5292..d92f77004 100644 --- a/packages/docs-nextra/pages/reference/doenetML_components/mathInput.mdx +++ b/packages/docs-nextra/pages/reference/doenetML_components/mathInput.mdx @@ -1,4 +1,4 @@ -import { DoenetML} from "../../../components/doenet" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # `` @@ -41,7 +41,7 @@ In addition, a `` cannot function if nested within any [Display Math ### Example: Assign a name to user-input math expression -```html {2} +```doenet {2}

Type x^2 + sqrt4 - 1/y:

You've typed: $userExpression

@@ -50,7 +50,7 @@ A `` renders an input field for storing and naming user-provided mat ### Example: Do some math with user-input -```html {3} +```doenet {3}

Enter pi/4:

sin($userAngle) = @@ -62,7 +62,7 @@ A named `` can be referenced within a `` for computations. Tes ### Example: `` with structured prefill -```html {4} +```doenet {4}

Simplify.

2/10 = diff --git a/packages/docs-nextra/pages/reference/essentialConcepts.mdx b/packages/docs-nextra/pages/reference/essentialConcepts.mdx index ab8ad8db4..1a64821ff 100644 --- a/packages/docs-nextra/pages/reference/essentialConcepts.mdx +++ b/packages/docs-nextra/pages/reference/essentialConcepts.mdx @@ -11,7 +11,7 @@ DoenetML is a **markup language** much like HTML. When creating content in Doene * **Properties** - information stored internally relating to a component that may be accessed by referencing the component by name, followed by the name of the property. -```html +```doenet

This is a graphical component: (1,2)

@@ -74,7 +74,7 @@ Components can communicate information between one another by means of reference When you need to access the value of the named component or one of its stored properties, use the notation `$componentName` to create a reference to the component itself, and use the notation `$componentName.propertyName` to create a reference to one of its properties. -```html +```doenet

Referencing the line component on a graph:

diff --git a/packages/docs-nextra/pages/tutorials/intermediateTutorial/iT2-1-cartesian.mdx b/packages/docs-nextra/pages/tutorials/intermediateTutorial/iT2-1-cartesian.mdx index e64725a29..7ea3519d6 100644 --- a/packages/docs-nextra/pages/tutorials/intermediateTutorial/iT2-1-cartesian.mdx +++ b/packages/docs-nextra/pages/tutorials/intermediateTutorial/iT2-1-cartesian.mdx @@ -1,11 +1,11 @@ -import { DoenetMLExample } from "../../../components" +import { DoenetViewer, DoenetEditor, DoenetExample } from "../../../components" # Cartesian Grids and Function Graphs One of the most powerful features of DoenetML is the ability to create complicated graphics with a few lines of code. This section covers the basics of the `` tag and its attributes, and shows you how to graph a function $y = f(x)$. Later sections will demonstrate how to graph points, lines, polygons, circles, and other objects. By default, the following code creates the Cartesian grid, which goes from -10 to 10 in both the $x$ and $y$ directions. -```html +```doenet ``` Test code [here](https://www.doenet.org/portfolioeditor/_J1J2N530LyIvVWx64xB8V/_AgzWwqGV6Yy9DfqMyGlFm). @@ -22,8 +22,7 @@ DoenetML has attributes to adjust various features of a graph: the range of $x$ Rather that listing out all of the possible attributes and values, documentation-style, you can learn these options by experimenting with the controls below. Try adjusting values and see how the graph changes. Doenet also provides you with the corresponding code to create the graph; you can copy and paste that code into your own documents. - -{` +```doenet-example xmin= @@ -88,8 +87,7 @@ Rather that listing out all of the possible attributes and values, documentation showNavigation="$showControls" showBorder="$showBorder" horizontalAlign="$alignChoice"/> -`} - +``` Notice that the `` code above includes `grid` (which is equivalent to `grid="true"`) when you check the grid box, but the tag does not include `grid="false"` if the grid is turned off. That's because `false` is the default value for `grid`; hence the attribute doesn't need to be included in that case. Similarly, the other attributes are suppressed if their default values are chosen: @@ -101,14 +99,14 @@ Notice that the `` code above includes `grid` (which is equivalen One additional attribute which was not demonstrated above is `identicalAxisScales`. By default, Deonet will always display a square graph. If you adjust the ranges of $x$ and $y$, that often means the axes are scaled differently. That's true in the following graph; $x$ ranges from -10 to 10, but $y$ only stretches from -4 to 4. -```html +```doenet ``` By including the `identicalAxisScales` attribute (equivalent to `identicalAxisScales="true"`), we force Doenet to use the same scaling for both axes, which results in a rectangular graph. -```html +```doenet ``` Test code [here](https://www.doenet.org/portfolioeditor/_J1J2N530LyIvVWx64xB8V/_AgzWwqGV6Yy9DfqMyGlFm). @@ -117,7 +115,7 @@ Test code [here](https://www.doenet.org/portfolioeditor/_J1J2N530LyIvVWx64xB8V/_ By default, the axes in Doenet graphs are unlabeled. You can adjust this behavior, but not with an attribute. Similar to the `