ya-bbcode
v4.0.0
Published
Yet another BBCode Parser
Downloads
1,081
Readme
ya-bbcode
Yet another BBCode parser.
npm install ya-bbcode --save
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="${attr || '#'}" rel="noopener norefer">`;
},
close: '</a>'
});
// Remove all default or registered tags
parser.clearTags();
Why another BBCode Parser?
- 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.
Roadmap
- Performance improvements
- Clean code up for improved readability
- Improve docs