2
0
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:
Nikolay Kost
2023-01-27 05:26:09 +02:00
committed by GitHub
parent 6b2810fcf4
commit 19e8dd659e
11 changed files with 215 additions and 79 deletions
+42
View File
@@ -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 = [