You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to register some languages . (like ts or tsx or json....)
I use this CodeBlock Component to customize my react-syntax-highlighter
below is my codes. help me plz
//use codeblock component in this compoment<ReactMarkdownrehypePlugins={[rehypeRaw]}components={{img: ({ node, ...props})=>(<imgsrc={props.src}alt={props?.alt||'마크다운 이미지'}style={{maxWidth: '100%',objectFit: 'cover',height: 'auto',}}sizes="(max-width: 560px) 360px, (max-width: 1023px) 700px, (max-width: 1260px) 1024px, (min-width: 1261px) 1260px"/>),code({ children }){return<CodeBlock>{childrenasstring}</CodeBlock>;},}
'use client';importdynamicfrom'next/dynamic';importbashfrom'react-syntax-highlighter/dist/cjs/languages/prism/bash';importjavascriptfrom'react-syntax-highlighter/dist/cjs/languages/prism/javascript';importjsonfrom'react-syntax-highlighter/dist/cjs/languages/prism/json';importtsxfrom'react-syntax-highlighter/dist/cjs/languages/prism/tsx';importtypescriptfrom'react-syntax-highlighter/dist/cjs/languages/prism/typescript';import{materialDark}from'react-syntax-highlighter/dist/esm/styles/prism';//how to set mutliple languages..>?constPrismLight=dynamic(()=>import('react-syntax-highlighter/dist/cjs/prism-light').then((res)=>{res.default.registerLanguage('bash',bash);res.default.registerLanguage('json',json);res.default.registerLanguage('tsx',tsx);res.default.registerLanguage('typescript',typescript);res.default.registerLanguage('javascript',javascript);returnres;}),);functionCodeBlock({ children }: {children: string|string[]}){return(<PrismLightstyle={materialDark}customStyle={{fontFamily: '__Do_Hyeon_7b3cf7',maxWidth: '100vw',wordBreak: 'break-all',fontSize: '1rem',overflowWrap: 'break-word',}}codeTagProps={{style: {fontFamily: 'inherit',wordBreak: 'break-all',overflowWrap: 'break-word',transform: 'translateZ(0)',minWidth: '100%',float: 'left',},}}>{children}</PrismLight>);}exportdefaultCodeBlock;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to register some languages . (like ts or tsx or json....)
I use this CodeBlock Component to customize my react-syntax-highlighter
below is my codes. help me plz
Beta Was this translation helpful? Give feedback.
All reactions