npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-bbcode

v1.0.0

Published

Simple BBCode package

Downloads

52

Readme

Node-BBCode

Simple and easy BBCode library

license paypal

Node-BBCode is simple library for BBCode rendering, designed for Node.JS.

Contents

Installation ^

  $ npm install node-bbcode

Usage ^

First step is to require this package.

  const BBCode = require('node-bbcode')

Now you can use BBCode as a namespace for the module. Node-BBCode contains one method, which takes two parameters; content and options.

render(content, options)

  • content - BBCode string you want to render. This can be either whole text or single BBC tag.
  • options - An object containing your settings for current rendering process.

Options ^

  • classPrefix - prefix class to be inserted on all rendered tags. (Default: 'bbcode'): String
  • newLine - whether or not to break line <br> on \n new line. (Default: false): Boolean
  • allowData - whether or not to allow custom data- tags on BBCode tag. (Default: false): Boolean
  • allowClasses - whether or not to allow custom classes on BBCode tag. (Default: false): Boolean

For more details about data-* and class tags, see 'tags' section.

Tags ^

List of tags supported by Node-BBCode

  • quote - renders to: <div class="quote" data-author="ID" data-name="NAME">NAME wrote:<blockquote>TEXT</blockquote></div>
    • ID - quoted post's author ID (Number) (Optional)
    • NAME - quoted post's author Name (String) (Optional)
  • url - renders to: <a href="URL">TEXT</a>
    • URL - destination link (String)
  • email - renders to: <a href="mailto:EMAIL">TEXT</a>
    • EMAIL - email address (String)
  • b - renders to: <strong>TEXT</strong>
  • i - renders to: <em>TEXT</em>
  • u - renders to: <span style="text-decoration:underline">TEXT</span>
  • s - renders to: <span style="text-decoration:line-through">TEXT</span>
  • indent - renders to: <blockquote>TEXT</blockquote>
  • ul and list - renders to: <ul><li>item 1</li><li>item 2</li></ul>
  • ol - renders to: <ol><li>item 1</li><li>item 2</li></ol>
  • code, php, java, javascript, cpp, ruby, python - renders to: <pre>CODE</pre>
  • highlight - renders to: <span style="background-color: COLOR">TEXT</span>
    • COLOR - color (String)
  • color - renders to: <span style="color: COLOR">TEXT</span>
    • COLOR - color (String)
  • span - renders to: <span>TEXT</span>
  • h1 - renders to: <h1>TEXT</h1>
  • h2 - renders to: <h2>TEXT</h2>
  • h3 - renders to: <h3>TEXT</h3>
  • h4 - renders to: <h4>TEXT</h4>
  • h5 - renders to: <h5>TEXT</h5>
  • h6 - renders to: <h6>TEXT</h6>
  • img - renders to: <img src="SRC" title="TITLE" alt="ALT" height="HEIGHT" width="WIDTH">
    • SRC - source (String)
    • TITLE - title (String) (Optional)
    • ALT - alternative text (String) (Optional)
    • HEIGHT - height (Number) (Optional)
    • WIDTH - width (Number) (Optional)

All BBC tags support class and data-* attributes:

  •   [span class="large" data-id="1"]TEXT[/span]

will end up as:

  •   <span class="large" data-id="1">TEXT</span>

BOTH ATTRIBUTES HAVE TO BE ALLOWED ON options OBJECT (see 'options' section).