mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-02 16:04:04 +03:00
31 lines
930 B
Markdown
31 lines
930 B
Markdown
# @bbob/parser
|
|
[](https://packagephobia.now.sh/result?p=@bbob/parser) [](https://snyk.io/test/github/JiLiZART/bbob?targetFile=packages%2Fbbob-parser%2Fpackage.json)
|
|
|
|
Parses BBCode and returns AST Tree looks like
|
|
|
|
## Usage
|
|
|
|
```js
|
|
import parse from '@bbob/parser'
|
|
|
|
const options = {
|
|
onlyAllowTags: ['url', 'h'],
|
|
onError: (err) => console.warn(err.message, err.lineNumber, err.columnNumber)
|
|
}
|
|
const ast = parse('[url=https://github.com/JiLiZART/bbob/tree/master/packages/bbob-parser]hello world![/url]')
|
|
```
|
|
|
|
## Results
|
|
|
|
```json
|
|
[
|
|
{
|
|
"tag": "url",
|
|
"attrs": {
|
|
"url": "https://github.com/JiLiZART/bbob/tree/master/packages/bbob-parser"
|
|
},
|
|
"content": ["hello", " ", "world!"]
|
|
}
|
|
]
|
|
```
|