GithubHelp home page GithubHelp logo

bitter-bbcode's Introduction

bitter-bbcode

A simple BBCode parser. It's "bitter" because it's written in CoffeeScript, you see.

The concept is to support some form of "generic" BBCode out of the box that covers the majority of software platforms out there, while being extensible enough that new BBCodes can be added without breaking anything.

Because it parses to a "DOM" it should be possible to export to destinations that aren't BBCode, for example, it should be possible to write a BBCode to Markdown translator.

It supports very simplistic BBCode at present:

[b]Bold[/b]
[i]Italic[/i]
[u]Underline[/u]
[url=https://www.github.com/]GitHub[/url]

Becomes:

<p><b>Bold</b><br>
<i>Italic</i><br>
<u>Underline</u><br>
<a href="https://www.github.com/">GitHub</a></p>

Basic Usage

var bbcode = require('bitter-bbcode');

bbcode("Some [b]text[/b]");
// Result: "<p>Some <b>text</b></p>");

More advanced use

var bbcode = require('bitter-bbcode');
var parser = bbcode();
var bbdom = parser.parse("[b]Some BB Code[/b]");
blocks = bbdom.toBlocks();
blocks.toHTML();

BBCode Compatibility

This is currently targeted at supporting phpBB-style BBCode. The ultimate goal is to make it configurable enough that various BBCode styles can be supported, including a default "global" mode that accepts the majority of BBCode used by the majority of forums that support BBCode.

Supported BBCode Table

The following describes the BBCode available in popular BBCode implementations compared to this implementation. If the tag is in the table and unless otherwise noted, it is planned to be implemented in the future.

BBCode Description Supported?
[b] Bold text
[i] Italic text
[u] Underline text
[s] Strike-though text
[sub] Subscript text
[super] Superscript text
[fixed] Fixed-width text
[color=color] Text in the specified color
[size=size] Change text size
[url] Link
[url=url] Link
[email] Link an email address
[email=email] Link an email address
[img] Image
[timg] Thumbnailed image ❌¹
[flash] Embedding flash content ❌²
[video] Embedding video content ❌¹
[list] Unordered List
[list=1] Numerically Ordered List
[list=a] Alphabetically Ordered List
[quote] Quote
[quote="name"] Quote with a given name
[code] BBCode ignored code block
[code=language] BBCode ignored code block with syntax highlighting ⚠️³
[php] Same as [code=php]

¹ It is unlikely this tag will ever be enabled by default
² It is unlikely that embedding Flash will ever be supported by this library
³ Syntax highlighting is not supported at present

BBCode by bulletin board software

Check out the [full comparison tables](compat/Comparison Tables.md) for details about how this library differs from other BBCode implementations.

bitter-bbcode's People

Contributors

xenoveritas avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.