React Component of code-block in HTML with highlight.js
npm install react-kodeA react component that integrates highlight.js with advance.
See examples on Codepen or Storybook.
* Support theme by highlight.js
* Support line number.
#### Dependencies
#### Getting start with CRA
``bath`
$ npx create-react-app demo
$ cd demo
$ npm i highlight.js react-kode
Open src/index.js
`js
import React from 'react';
import ReactDOM from 'react-dom';
// Import theme stylesheet.and react-kode
import 'highlight.js/styles/solarized-dark.css';
import Kode from 'react-kode';
const html =
;const App = () => (
lang="html"
isEnableLineNumber={true}
>
{html}
);ReactDOM.render( , document.getElementById('root'));
`Installation
#### NPM
Install
react-kode.`bash
Install dependencies.
$ npm i react highlight.jsInstall react-kode.
$ npm i react-kode
`#### CDN
`html
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
`Properties
| Property | Type | Description |
| ------------------ | ------ | ------------------------------------------------------------ |
| lang | string | Specify language of code. e.g. html, javascript. To get language list reference highlight.js docs or github |
| isEnableLineNumber | bool | Set
true to enable line number. |
| initialLineNumber | number | Set initial number of line. |
| diff | object | Coming soon... |Development
`bash
Build
$ npm run buildDev
$ npm run storybook
``