mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-14 20:24:56 +02:00
41 lines
1000 B
JavaScript
41 lines
1000 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 from 'react';
|
|
import clsx from 'clsx';
|
|
import styles from './styles.module.css';
|
|
export default function CodeBlockLine({
|
|
line,
|
|
classNames,
|
|
showLineNumbers,
|
|
getLineProps,
|
|
getTokenProps,
|
|
}) {
|
|
if (line.length === 1 && line[0].content === '\n') {
|
|
line[0].content = '';
|
|
}
|
|
const lineProps = getLineProps({
|
|
line,
|
|
className: clsx(classNames, showLineNumbers && styles.codeLine),
|
|
});
|
|
const lineTokens = line.map((token, key) => (
|
|
<span key={key} {...getTokenProps({token, key})} />
|
|
));
|
|
return (
|
|
<span {...lineProps}>
|
|
{showLineNumbers ? (
|
|
<>
|
|
<span className={styles.codeLineNumber} />
|
|
<span className={styles.codeLineContent}>{lineTokens}</span>
|
|
</>
|
|
) : (
|
|
lineTokens
|
|
)}
|
|
<br />
|
|
</span>
|
|
);
|
|
}
|