react-highlight

React component for syntax highlighting

react-highlight downloads react-highlight version react-highlight license

react-highlight유사 패키지:
npm 다운로드 트렌드
3 년
🌟 react-highlight의 README.md에 실시간 사용 차트를 표시하려면 아래 코드를 복사하세요.
## Usage Trend
[![Usage Trend of react-highlight](https://npm-compare.com/img/npm-trend/THREE_YEARS/react-highlight.png)](https://npm-compare.com/react-highlight#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 react-highlight의 README.md에 GitHub Stars 트렌드 차트를 표시하려면 아래 코드를 복사하세요.
## GitHub Stars Trend
[![GitHub Stars Trend of react-highlight](https://npm-compare.com/img/github-trend/react-highlight.png)](https://npm-compare.com/react-highlight)
통계 세부사항
패키지
다운로드
Stars
크기
Issues
발행일
라이선스
react-highlight78,44776518.4 kB29-MIT
react-highlight의 README

react-highlight

React component for syntax highlighting using highlight.js

Build Status

Latest version

0.11.1

Documentation

CodeSandbox Example

Edit new

Installation

  npm install react-highlight --save

Usage

Importing component

import Highlight from 'react-highlight'

Adding styles

Choose the theme for syntax highlighting and add corresponding styles of highlight.js

  <link rel="stylesheet" href="/path/to/styles/theme-name.css">

The styles will most likely be in node_modules/highlight.js/styles folder.

Props:

  • className: custom class name
  • innerHTML: enable to render markup with dangerouslySetInnerHTML
  • element: render code snippet inside specified element

Syntax highlighting of single code snippet

Code snippet that requires syntax highlighting should be passed as children to Highlight component in string format. Language name of code snippet should be specified as className.

<Highlight className='language-name-of-snippet'>
  {"code snippet to be highlighted"}
</Highlight>

Syntax highlighting of mutiple code snippets

Set innerHTML=true to highlight multiple code snippets at a time. This is especially usefull if html with multiple code snippets is generated from preprocesser tools like markdown.

Warning: If innerHTML is set to true, make sure the html generated with code snippets is from trusted source.

<Highlight innerHTML={true}>
  {"html with multiple code snippets"}
</Highlight>