react-code-dataset / wp-calypso /client /sites /deployments /components /code-highlighter /index.tsx
react-code-dataset / wp-calypso /client /sites /deployments /components /code-highlighter /index.tsx
Download wp-calypso/client/sites/deployments/components/code-highlighter/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 663 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/components/code-highlighter/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/deployments/components/code-highlighter/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/components/code-highlighter/index.tsx
663 Bytes
| import Prism from 'prismjs'; | |
| import { useEffect, useRef } from 'react'; | |
| import 'prismjs/themes/prism.css'; | |
| import 'prismjs/components/prism-yaml'; | |
| import './style.scss'; | |
| interface CodeHighlighterProps { | |
| content: string; | |
| } | |
| export const CodeHighlighter = ( { content }: CodeHighlighterProps ) => { | |
| const yamlCodeRef = useRef< HTMLElement | null >( null ); | |
| useEffect( () => { | |
| if ( yamlCodeRef.current ) { | |
| Prism.highlightElement( yamlCodeRef.current ); | |
| } | |
| }, [ content ] ); | |
| return ( | |
| <> | |
| <pre className="github-workflow-code-highlighter"> | |
| <code ref={ yamlCodeRef } className="language-yaml"> | |
| { content } | |
| </code> | |
| </pre> | |
| </> | |
| ); | |
| }; | |