Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-syntax-highlight

zlargon1.7kMIT15.3.1

React component for syntax highlighting

react, reactjs, syntax, highlight, highlight.js, highlighting

readme

react-highlight

React component for syntax highlighting

Change Log

Please see CHANGELOG.

Installation

$ npm install --save react react-dom          # peer dependencies
$ npm install --save react-syntax-highlight

Compatibility: React 15.3.0+

This package is compatible with React 15.3.0 and higher. (https://github.com/facebook/prop-types#compatibility)

npm install --save react@^15.3.0 react-dom@^15.3.0

Usage

Highlight Theme

include a highlight.js theme in your HTML file

<link rel='stylesheet' href='https://highlightjs.org/static/demo/styles/default.css'/>
<link rel='stylesheet' href='https://highlightjs.org/static/demo/styles/xxxx.css'/>

or if you're using webpack, you can require themes like is:

require('highlight.js/styles/default.css');
require('highlight.js/styles/xxxx.css');

see all the highlight theme here

React Part

const Highlight = require('react-syntax-highlight');

<Highlight lang={language} value={content} />

Example

License

MIT

changelog

15.3.1 (July 10, 2017)

  • fix build error with UglifyJs. issue#2

15.3.0 (July 07, 2017)

0.0.6 (March 30, 2017)

  • add yarn.lock file

0.0.5 (Dec 12, 2016)

  • move packages highlight.js back to dependencies

0.0.4 (Dec 11, 2016)

  • fix bug: it does not work with webpack

0.0.3 (Dec 11, 2016)

<script type="text/javascript" src="https://unpkg.com/react-syntax-highlight@0.0.3"></script>