Package Exports
- @bbob/parser
- @bbob/parser/dist/index.js
- @bbob/parser/es/index.js
- @bbob/parser/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bbob/parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@bbob/parser
Parses BBCode and returns array AST tree
Valid for use with posthtml-render
Install
npm i @bbob/parserUsage
API
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 to
[
{
"tag": "url",
"attrs": {
"url": "https://github.com"
},
"content": ["hello", " ", "world!"]
}
]PostHTML
import render from 'posthtml-render'
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);
const html = render(ast) // <url url="https://github.com">hello world!</url>