
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
bbcode-to-react
Advanced tools
A utility for turning raw BBCode into React elements.
Install bbcode-to-react
and peer dependencies via NPM
npm install --save bbcode-to-react react
Import bbcode-to-react
, example:
import React from 'react';
import parser from 'bbcode-to-react';
import { renderToString } from 'react-dom/server';
const Example = (props) => {
return (
<p>{parser.toReact('[b]strong[/b]')}</p>
);
}
// render: <p><strong>strong</strong></p>
console.log(renderToString(<Example />));
import React from 'react';
import parser, { Tag } from 'bbcode-to-react';
class YoutubeTag extends Tag {
toReact() {
// using this.getContent(true) to get it's inner raw text.
const attributes = {
src: this.getContent(true),
width: this.params.width || 420,
height: this.params.height || 315,
};
return (
<iframe
{...attributes}
frameBorder="0"
allowFullScreen
/>
);
}
}
class BoldTag extends Tag {
toReact() {
// using this.getComponents() to get children components.
return (
<b>{this.getComponents()}</b>
);
}
}
parser.registerTag('youtube', YoutubeTag); // add new tag
parser.registerTag('b', BoldTag); // replace exists tag
const Example = (props) => {
return (
<p>{parser.toReact('[youtube width="400"]https://www.youtube.com/embed/AB6RjNeDII0[/youtube]')}</p>
);
}
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
bbcode-to-react
uses the parser from bbcodejs, so much of the credit is due there.bbcode-to-react
uses the webpack config and publish scripts from reactstrap.0.2.9 (2018-04-24)
<a name="0.2.8"></a>
FAQs
A utility for turning raw BBCode into React elements.
The npm package bbcode-to-react receives a total of 3,157 weekly downloads. As such, bbcode-to-react popularity was classified as popular.
We found that bbcode-to-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.