@hammad.fauz/parser
v1.0.10
Published
Fast, flexible, and lean implementation of BBcode parser
Downloads
2,903
Maintainers
Readme
@hammad.fauz/parser
fork of @bbob/parser
Parses BBCode and returns array AST tree
Valid for use with posthtml-render
Usage
import parse from '@hammad.fauz/parser'
const options = {
onlyAllowTags: ['url', 'h'],
onError: (err) => console.warn(err.message, err.lineNumber, err.columnNumber)
}
const ast = parse('[url=https://github.com]hello world![/url]', options)
Results
[
{
"tag": "url",
"attrs": {
"url": "https://github.com"
},
"content": ["hello", " ", "world!"]
}
]