mirror of
https://github.com/tenrok/BBob.git
synced 2026-05-27 14:45:03 +03:00
33 lines
926 B
Markdown
33 lines
926 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 array AST tree
|
|
|
|
Valid for use with [posthtml-render](https://github.com/posthtml/posthtml-render)
|
|
|
|
## 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]hello world![/url]', options)
|
|
```
|
|
|
|
## Results
|
|
|
|
```json
|
|
[
|
|
{
|
|
"tag": "url",
|
|
"attrs": {
|
|
"url": "https://github.com"
|
|
},
|
|
"content": ["hello", " ", "world!"]
|
|
}
|
|
]
|
|
```
|