React.js + Prism.js syntax highlight component
npm i --save react-prism
Static hosted demo site on GitHub.
Please refer to the client folder for an example.
This module is intended to be bundled with webpack/browserify.
First, you have to include prismjs in your index.html
:
<script src="path/to/your/prism.js"></script>
Why not require Prism by CommonJS? It's because prism.js will try to run itself as a Web Worker. It won't take affect if we require it into the source.
Then:
import {PrismCode} from "react-prism";
// In a react component:
render () {
return (
<PrismCode className="language-javascript">
{require("raw-loader!./PrismCode")}
</PrismCode>
);
}
git clone ...
npm install
cd examples/gh-pages
npm install
npm start
Then open http://localhost:8080.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new pull request