mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-08 17:22:26 +03:00
feat(parser): context free tag mode (#165)
* feat(parser): initial context free tag mode * fix: tests coverage * chore: update readme * chore: remove unused badge from readme
This commit is contained in:
@@ -25,6 +25,23 @@ describe('Parser', () => {
|
||||
expectOutput(ast, output);
|
||||
});
|
||||
|
||||
test('parse paired tags tokens 2', () => {
|
||||
const ast = parse('[bar]Foo Bar[/bar]');
|
||||
const output = [
|
||||
{
|
||||
tag: 'bar',
|
||||
attrs: {},
|
||||
content: [
|
||||
'Foo',
|
||||
' ',
|
||||
'Bar',
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
expectOutput(ast, output);
|
||||
});
|
||||
|
||||
describe('onlyAllowTags', () => {
|
||||
test('parse only allowed tags', () => {
|
||||
const ast = parse('[h1 name=value]Foo [Bar] [/h1]', {
|
||||
@@ -126,6 +143,31 @@ describe('Parser', () => {
|
||||
});
|
||||
})
|
||||
|
||||
describe('contextFreeTags', () => {
|
||||
test('context free tag [code]', () => {
|
||||
const ast = parse('[code] [b]some string[/b][/code]', {
|
||||
contextFreeTags: ['code']
|
||||
});
|
||||
const output = [
|
||||
{
|
||||
tag: 'code',
|
||||
attrs: {},
|
||||
content: [
|
||||
' ',
|
||||
'[',
|
||||
'b]some',
|
||||
' ',
|
||||
'string',
|
||||
'[',
|
||||
'/b]'
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
expectOutput(ast, output);
|
||||
})
|
||||
})
|
||||
|
||||
test('parse inconsistent tags', () => {
|
||||
const ast = parse('[h1 name=value]Foo [Bar] /h1]');
|
||||
const output = [
|
||||
|
||||
Reference in New Issue
Block a user