Skip to content

Commit

Permalink
fix(theme-classic): allow code tags containing inline elements to sta…
Browse files Browse the repository at this point in the history
…y inline (#6767)
  • Loading branch information
Josh-Cena committed Mar 2, 2022
1 parent 2e3eec2 commit c1fb3de
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,22 @@ const MDXComponents: MDXComponentsObject = {
return <Head {...props}>{unwrappedChildren}</Head>;
},
code: (props) => {
const inlineElements = [
'a',
'b',
'big',
'i',
'span',
'em',
'strong',
'sup',
'sub',
'small',
];
const shouldBeInline = React.Children.toArray(props.children).every(
(el) => typeof el === 'string' && !el.includes('\n'),
(el) =>
(typeof el === 'string' && !el.includes('\n')) ||
(React.isValidElement(el) && inlineElements.includes(el.props.mdxType)),
);

return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
Expand Down

0 comments on commit c1fb3de

Please sign in to comment.