react-kode
A react component that integrates highlight.js with advance. See examples on Codepen or Storybook.
- Support theme by highlight.js
- Support line number.
Usage
Dependencies
CRA
Getting start with$ npx create-react-app demo$ cd demo$ npm i highlight.js react-kode
Open src/index.js
;; // Import theme stylesheet.and react-kode;; const html = `<html> <div class="navbar"> <a href="#">Go</a> </div></html>`; const App = <div> <Kode lang="html" isEnableLineNumber=true > html </Kode> </div>; ReactDOM;
Installation
NPM
Install react-kode
.
# Install dependencies. $ npm i react highlight.js # Install react-kode. $ npm i react-kode
CDN
<!-- highlight.js https://highlightjs.org/download/--><!-- React https://reactjs.org/docs/cdn-links.html --><!-- react-kode-->
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
# Build $ npm run build # Dev $ npm run storybook