2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-02 16:04:04 +03:00
Files
bbob/packages/bbob-parser/README.md
T
2018-07-20 09:51:14 +02:00

31 lines
930 B
Markdown

# @bbob/parser
[![install size](https://packagephobia.now.sh/badge?p=@bbob/parser)](https://packagephobia.now.sh/result?p=@bbob/parser) [![Known Vulnerabilities](https://snyk.io/test/github/JiLiZART/bbob/badge.svg?targetFile=packages%2Fbbob-parser%2Fpackage.json)](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!"]
}
]
```