Yet another BBCode parser.
npm install ya-bbcode --save
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>
parser.registerTag('url', {
type: 'replace',
open: (attr) => {
return `<a href="${attr || '#'}" rel="noopener norefer">`;
},
close: '</a>'
});
// Remove all default or registered tags
parser.clearTags();
- Supports nested BBCode
- Has no dependencies
- All BBCode is replaced in a nested format, meaning that parent nodes are parsed before children.
- Allows custom tags to be replaced or added.
- Performance improvements
- Clean code up for improved readability
- Improve docs