Is more lenient about closing tags and mismatched tags. Instead of throwing an error, it will turn the entire node into a TextNode with the text of the entire node.
The list of supported tag names. Any tags that are not in this list will be treated like text.
Private
getConvert a chunk of BBCode to a RootNode.
The chunk of BBCode to convert.
The RootNode representing the BBCode.
If the BBCode is not valid (missing a closing tag).
const parsed = parser.parse("[b]Hello, world![/b]");
console.log(parsed.toString()); // [b]Hello, world![/b]
console.log(parsed.nodeTree());
// RootNode {
// Node [b] {
// TextNode {
// Hello, world!
// }
// }
// }
const parsed = parser.parse("[b][i]Hi![/i][/b][img width=100 height=100]https://example.com/image.png[/img]");
console.log(parsed.toString()); // [b][i]Hi![/i][/b][img width=100 height=100]https://example.com/image.png[/img]
console.log(parsed.nodeTree());
// RootNode {
// Node [b] {
// Node [i] {
// TextNode {
// Hi!
// }
// }
// }
// Node [img] (width=100, height=100) {
// TextNode {
// https://example.com/image.png
// }
// }
// }
const parsed = parser.parse('[size=50][quote=JohnDoe message=1]Hello, world![/quote][/size][img alt="World said hi!" width=100 height=100]https://example.com/image.png[/img]');
console.log(parsed.toString()); // [size=50][quote=JohnDoe message=1]Hello, world![/quote][/size][img alt="World said hi!" width=100 height=100]https://example.com/image.png[/img]
console.log(parsed.nodeTree());
// RootNode {
// Node [size] {
// Node [quote] (JohnDoe, message=1) {
// TextNode {
// Hello, world!
// }
// }
// }
// Node [img] (alt="World said hi!", width=100, height=100) {
// TextNode {
// https://example.com/image.png
// }
// }
// }
Generated using TypeDoc
Whether the parser should be case-sensitive or not regarding tag names and supportedTagNames.