mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-07 12:28:57 -05:00
29 lines
752 B
JavaScript
29 lines
752 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
import React, {isValidElement} from 'react';
|
|
import CodeBlock from '@theme/CodeBlock';
|
|
export default function MDXCode(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')) ||
|
|
(isValidElement(el) && inlineElements.includes(el.props?.mdxType)),
|
|
);
|
|
return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
|
|
}
|