import { atomDark } from 'react-syntax-highlighter/dist/esm/styles/prism'; ``` 这里使用的是Prism组件作为语法高亮的引擎,使用atomDark样式。 3.在需要进行语法高亮的地方使用SyntaxHighlighter组件: ```javascript <SyntaxHighlighter language="javascript" style={atomDark}> {`function helloWorld() { console...
One of the biggest pain points for me trying to find a syntax highlighter for my own projects was the need to put a stylesheet tag on my page. I wanted to provide out of the box code styling with my modules without requiring awkward inclusion of another libs stylesheets. The styles in ...
import{LightasSyntaxHighlighter}from'react-syntax-highlighter';importjsfrom'react-syntax-highlighter/dist/esm/languages/hljs/javascript';importdoccofrom'react-syntax-highlighter/dist/esm/styles/hljs/docco';SyntaxHighlighter.registerLanguage('javascript', js);...
在这个示例中,我们导入了Prism作为SyntaxHighlighter,并从react-syntax-highlighter/dist/esm/styles/prism中导入了dark主题。然后,我们创建了一个CodeHighlighter组件,它接受code和language作为props,并使用SyntaxHighlighter来高亮显示代码。 使用syntaxhighlighter组件高亮代码: 现在,你可以在你的应用中使用CodeHighlighter组件来高...
As an example: <SyntaxHighlighter language="typescript" useInlineStyles={false} wrapLongLines > {multiline` import { useSearchParams } from '@remix-run/react'; import { type SetStateAction, useEffect, useState } from 'react'; export cons...
Javascript Styles! One of the biggest pain points for me trying to find a syntax highlighter for my own projects was the need to put a stylesheet tag on my page. I wanted to provide out of the box code styling with my modules without requiring awkward inclusion of another libs stylesheets...
棱镜'选项,我得到的文本颜色太:import {dark} from "react-syntax-highlighter/dist/esm/styles/prism...
language - 高亮显示的代码语言,例如css、javascript、jsx等。其他选项可以查看hljs和prism style - styles/hljs或styles/prism目录中需要的样式对象。需要导入 import{style}from'react-syntax-highlighter/dist/styles/{hljs|prism}' 选项可以查看hljs和prism ...
Screenshots Code Example: import{useEffect,useState}from"react";import{PrismLightasSyntaxHighlighter}from"react-syntax-highlighter";import{solarizedDarkAtom}from"react-syntax-highlighter/dist/esm/styles/prism";constlanguageMapping:Record<string,()=>Promise<any>>={go:()=>import('react-syntax-highlighter/...
Note:react-syntax-highlighterprovides an automated build wrapper around styles and languages provided byhighlight.js(vialowlight) andprism(viarefractor). Changes here are simply describing what's changed in those libraries. If you'd like to see another language or style added, please contribute to...