Skip to content

Commit

Permalink
πŸ‘¨πŸ»β€πŸ’» Allow inline code to have children (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Feb 8, 2024
1 parent 89d5489 commit 227326a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-hornets-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-react': patch
---

Allow inline code to have children.
9 changes: 9 additions & 0 deletions packages/myst-to-react/src/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dark from 'react-syntax-highlighter/dist/esm/styles/hljs/vs2015.js';
import { DocumentIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';
import { CopyIcon } from './components/index.js';
import { MyST } from './MyST.js';

type Props = {
value: string;
Expand Down Expand Up @@ -152,6 +153,14 @@ const inlineCode: NodeRenderer<InlineCode> = ({ node }) => {
</code>
);
}
if (node.children && node.children.length > 0) {
// The inline code can potentially have children
return (
<code>
<MyST ast={node.children} />
</code>
);
}
return <code>{node.value}</code>;
};

Expand Down

0 comments on commit 227326a

Please sign in to comment.