mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-14 18:42:24 +03:00
fix(parser): tokenizer error with quotemark strings
This commit is contained in:
@@ -34,6 +34,25 @@ describe('Tokenizer', () => {
|
||||
expectOutput(output, tokens);
|
||||
});
|
||||
|
||||
test('tokenize string with quotemarks', () => {
|
||||
const input = '"Someone Like You" by Adele';
|
||||
const tokens = tokenize(input);
|
||||
|
||||
const output = [
|
||||
[TYPE.WORD, '"Someone', '0', '0'],
|
||||
[TYPE.SPACE, ' ', '8', '0'],
|
||||
[TYPE.WORD, 'Like', '8', '0'],
|
||||
[TYPE.SPACE, ' ', '13', '0'],
|
||||
[TYPE.WORD, 'You"', '13', '0'],
|
||||
[TYPE.SPACE, ' ', '18', '0'],
|
||||
[TYPE.WORD, 'by', '18', '0'],
|
||||
[TYPE.SPACE, ' ', '21', '0'],
|
||||
[TYPE.WORD, 'Adele', '21', '0'],
|
||||
];
|
||||
|
||||
expectOutput(output, tokens);
|
||||
});
|
||||
|
||||
test('tokenize tag as param', () => {
|
||||
const input = '[color="#ff0000"]Text[/color]';
|
||||
const tokens = tokenize(input);
|
||||
|
||||
@@ -42,6 +42,30 @@ describe('Parser', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('parse inconsistent tags', () => {
|
||||
const ast = parse('[h1 name=value]Foo [Bar] /h1]');
|
||||
|
||||
expect(ast).toBeInstanceOf(Array);
|
||||
expect(ast).toEqual(
|
||||
[
|
||||
{
|
||||
attrs: {},
|
||||
tag: 'h1',
|
||||
content: []
|
||||
},
|
||||
'Foo',
|
||||
' ',
|
||||
{
|
||||
tag: 'Bar',
|
||||
attrs: {},
|
||||
content: []
|
||||
},
|
||||
' ',
|
||||
'/h1',
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test('parse tag with value param', () => {
|
||||
const ast = parse('[url=https://github.com/jilizart/bbob]BBob[/url]');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user