OptionalcaseSensitive:booleanOptionallenient:booleanWhether the parser should be case-sensitive or not regarding tag names andsupportedTagNames.
Is more lenient about closing tags and mismatched tags. Instead of throwing an error, it will turn the entire nodeinto aTextNode 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.
PrivategetConvert a chunk of BBCode to aRootNode.
The chunk of BBCode to convert.
TheRootNode representing the BBCode.
If the BBCode is not valid (missing a closing tag).
constparsed =parser.parse("[b]Hello, world![/b]");
console.log(parsed.toString());// [b]Hello, world![/b]
console.log(parsed.nodeTree());
// RootNode {
// Node [b] {
// TextNode {
// Hello, world!
// }
// }
// }constparsed =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
// }
// }
// }constparsed =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 usingTypeDoc