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="https://github.com/nodecraft/ya-bbcode/blob/main/${attr || '#'}" rel="noopener norefer">`;
},
close: '</a>'
});
// Remove all default or registered tags
parser.clearTags();