mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-08 17:22:26 +03:00
chore: v2.5.1 (#21)
* fix(parser): fix issue with escaping backslashes when enableEscapeTags is set (#20) there is a bug in the lexer where when enableEscapeTags is set, backslashes are not always escaped (ie. \\[b] is treated as an escaped tag, rather than a literal backslash, and then a tag). * chore: v2.5.1
This commit is contained in:
committed by
GitHub
parent
3b46fbe23c
commit
c4a88e5036
@@ -305,6 +305,29 @@ describe('lexer', () => {
|
||||
expectOutput(output, tokens);
|
||||
});
|
||||
|
||||
test('escaped tag and escaped backslash', () => {
|
||||
const tokenizeEscape = input => (createLexer(input, {
|
||||
enableEscapeTags: true
|
||||
}).tokenize());
|
||||
const input = '\\\\\\[b\\\\\\]test\\\\\\[/b\\\\\\]';
|
||||
const tokens = tokenizeEscape(input);
|
||||
const output = [
|
||||
[TYPE.WORD, '\\', '0', '0'],
|
||||
[TYPE.WORD, '[', '0', '0'],
|
||||
[TYPE.WORD, 'b', '0', '0'],
|
||||
[TYPE.WORD, '\\', '0', '0'],
|
||||
[TYPE.WORD, ']', '0', '0'],
|
||||
[TYPE.WORD, 'test', '0', '0'],
|
||||
[TYPE.WORD, '\\', '0', '0'],
|
||||
[TYPE.WORD, '[', '0', '0'],
|
||||
[TYPE.WORD, '/b', '0', '0'],
|
||||
[TYPE.WORD, '\\', '0', '0'],
|
||||
[TYPE.WORD, ']', '0', '0'],
|
||||
];
|
||||
|
||||
expectOutput(output, tokens);
|
||||
});
|
||||
|
||||
describe('html', () => {
|
||||
const tokenizeHTML = input => createLexer(input, { openTag: '<', closeTag: '>' }).tokenize();
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('Parser', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('parse escaped tags tags', () => {
|
||||
test('parse escaped tags', () => {
|
||||
const ast = parse('\\[b\\]test\\[/b\\]', {
|
||||
enableEscapeTags: true
|
||||
});
|
||||
@@ -199,5 +199,25 @@ describe('Parser', () => {
|
||||
']',
|
||||
]);
|
||||
});
|
||||
|
||||
test('parse escaped tags and escaped backslash', () => {
|
||||
const ast = parse('\\\\\\[b\\\\\\]test\\\\\\[/b\\\\\\]', {
|
||||
enableEscapeTags: true
|
||||
});
|
||||
|
||||
expectOutput(ast, [
|
||||
'\\',
|
||||
'[',
|
||||
'b',
|
||||
'\\',
|
||||
']',
|
||||
'test',
|
||||
'\\',
|
||||
'[',
|
||||
'/b',
|
||||
'\\',
|
||||
']',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user