diff --git a/.changeset/healthy-birds-itch.md b/.changeset/healthy-birds-itch.md new file mode 100644 index 000000000..8be428491 --- /dev/null +++ b/.changeset/healthy-birds-itch.md @@ -0,0 +1,5 @@ +--- +'myst-to-react': patch +--- + +Add inline expressions diff --git a/packages/myst-to-react/src/index.tsx b/packages/myst-to-react/src/index.tsx index ced8de72f..b73b50145 100644 --- a/packages/myst-to-react/src/index.tsx +++ b/packages/myst-to-react/src/index.tsx @@ -18,6 +18,7 @@ import HEADING_RENDERERS from './heading'; import CROSS_REFERENCE_RENDERERS from './crossReference'; import TAB_RENDERERS from './tabs'; import EXT_RENDERERS from './extensions'; +import INLINE_EXPRESSION_RENDERERS from './inlineExpression'; export { CopyIcon } from './components/CopyIcon'; export { CodeBlock } from './code'; @@ -42,6 +43,7 @@ export const DEFAULT_RENDERERS: Record = { ...DROPDOWN_RENDERERS, ...CARD_RENDERERS, ...GRID_RENDERERS, + ...INLINE_EXPRESSION_RENDERERS, ...EXT_RENDERERS, }; diff --git a/packages/myst-to-react/src/inlineExpression.tsx b/packages/myst-to-react/src/inlineExpression.tsx new file mode 100644 index 000000000..9c3747534 --- /dev/null +++ b/packages/myst-to-react/src/inlineExpression.tsx @@ -0,0 +1,23 @@ +import type { NodeRenderer } from '@myst-theme/providers'; +import { InlineError } from './inlineError'; + +export const InlineExpression: NodeRenderer = (node, children) => { + if (!node.result) { + return ; + } + if (node.result?.status !== 'ok') { + return ; + } + // TODO: something with Thebe in the future! + return ( + + {children} + + ); +}; + +const INLINE_EXPRESSION_RENDERERS = { + inlineExpression: InlineExpression, +}; + +export default INLINE_EXPRESSION_RENDERERS;