nodecraft / ya-bbcode

Yet another BBCode Parser
MIT License
17 stars 5 forks source link
bbc bbcode hacktoberfest parser

ya-bbcode

Yet another BBCode parser. npm install ya-bbcode --save

npm version Actions Status Coverage Status

Usage

const yabbcode = require('ya-bbcode');
const parser = new yabbcode();

const bbc = '[url=https://nodecraft.com]Visit Nodecraft[/url]';
parser.parse(bbc);
// <a href="https://nodecraft.com">Visit Nodecraft</a>
Add Custom Tags
parser.registerTag('url', {
    type: 'replace',
    open: (attr) => {
        return `<a href="https://github.com/nodecraft/ya-bbcode/blob/main/${attr || '#'}" rel="noopener norefer">`;
    },
    close: '</a>'
});

// Remove all default or registered tags
parser.clearTags();

Why another BBCode Parser?

Roadmap