mirror of
https://github.com/tenrok/BBob.git
synced 2026-05-15 11:59:37 +03:00
fix(parser): only allowed tags error
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const {
|
const {
|
||||||
convertTokenToText,
|
convertTagToText,
|
||||||
getTagName,
|
getTagName,
|
||||||
getTokenColumn,
|
getTokenColumn,
|
||||||
getTokenLine,
|
getTokenLine,
|
||||||
@@ -187,7 +187,7 @@ const handleTagToken = (token) => {
|
|||||||
// [/tag]
|
// [/tag]
|
||||||
handleTagEnd(token);
|
handleTagEnd(token);
|
||||||
} else {
|
} else {
|
||||||
appendNode(convertTokenToText(token));
|
appendNode(convertTagToText(token));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,28 @@ describe('Parser', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parse only allowed tags', () => {
|
||||||
|
const ast = parse('[h1 name=value]Foo [Bar] [/h1]', {
|
||||||
|
onlyAllowTags: ['h1']
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(ast).toBeInstanceOf(Array);
|
||||||
|
expect(ast).toEqual([
|
||||||
|
{
|
||||||
|
tag: 'h1',
|
||||||
|
attrs: {
|
||||||
|
name: 'value',
|
||||||
|
},
|
||||||
|
content: [
|
||||||
|
'Foo',
|
||||||
|
' ',
|
||||||
|
'[Bar]',
|
||||||
|
' '
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
test('parse tag with value param', () => {
|
test('parse tag with value param', () => {
|
||||||
const ast = parse('[url=https://github.com/jilizart/bbob]BBob[/url]');
|
const ast = parse('[url=https://github.com/jilizart/bbob]BBob[/url]');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user