mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-17 19:21:20 +03:00
feat: new @bbob/html api (#4)
This commit is contained in:
committed by
GitHub
parent
bf993813fc
commit
575c1bb932
@@ -21,9 +21,6 @@
|
||||
"dependencies": {
|
||||
"@bbob/parser": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bbob/html": "^2.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@bbob/html": "^1.x",
|
||||
"@bbob/preset-html5": "^1.x",
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import render from '@bbob/html'
|
||||
import { TagNode } from '@bbob/parser'
|
||||
import core from '../src'
|
||||
|
||||
const stringify = val => JSON.stringify(val);
|
||||
|
||||
const process = (plugins, input) => core(plugins).process(input, { render });
|
||||
const process = (plugins, input) => core(plugins).process(input, { render: stringify });
|
||||
|
||||
describe('@bbob/core', () => {
|
||||
test('parse bbcode string to ast and html', () => {
|
||||
const res = process([], '[style size="15px"]Large Text[/style]');
|
||||
const ast = res.tree;
|
||||
|
||||
expect(res.html).toBe(`<style size="15px">Large Text</style>`);
|
||||
expect(res.html).toBe('[{"tag":"style","attrs":{"size":"15px"},"content":["Large"," ","Text"]}]');
|
||||
expect(ast).toBeInstanceOf(Array);
|
||||
expect(stringify(ast)).toEqual(stringify([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user