bbcode-to-react
A utility for turning raw BBCode into React elements.
Installation
Install bbcode-to-react
and peer dependencies via NPM
npm install --save bbcode-to-react react
Import bbcode-to-react
, example:
;;; const Example = { return <p>parser</p> ;} // render: <p><strong>strong</strong></p>console;
Add new tag example
;; { // using this.getContent(true) to get it's inner raw text. const attributes = src: this width: thisparamswidth || 420 height: thisparamsheight || 315 ; return <iframe ...attributes frameBorder="0" allowFullScreen /> ; } { // using this.getComponents() to get children components. return <b>this</b> ; } parser; // add new tagparser; // replace exists tag const Example = { return <p>parser</p> ;}
Development
Install dependencies:
npm install
Run examples at http://localhost:8080/ with webpack dev server:
npm start
Run tests & coverage report:
npm test
Watch tests:
npm run test-watch
Credits
- bbcodejs:
bbcode-to-react
uses the parser from bbcodejs, so much of the credit is due there. - reactstrap:
bbcode-to-react
uses the webpack config and publish scripts from reactstrap.