mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-20 20:00:33 +03:00
bugfix one param [url=param_value] tag support
This commit is contained in:
@@ -66,7 +66,7 @@ module.exports = class Parser {
|
|||||||
return this.curTagsAttrName[this.curTagsAttrName.length - 1];
|
return this.curTagsAttrName[this.curTagsAttrName.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return this.getCurTag().tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCurTagAttrName() {
|
clearCurTagAttrName() {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
const Parser = require('./Parser');
|
const Parser = require('./Parser');
|
||||||
const TOKEN = require('./token');
|
const TOKEN = require('./token');
|
||||||
|
const Tokenizer = require('./Tokenizer');
|
||||||
|
|
||||||
const parse = input => (new Parser(input).parse());
|
const parse = input => (new Parser(input).parse());
|
||||||
|
const tokenize = input => (new Tokenizer(input).tokenize());
|
||||||
|
|
||||||
describe('Parser', () => {
|
describe('Parser', () => {
|
||||||
test('parse paired tags tokens', () => {
|
test('parse paired tags tokens', () => {
|
||||||
@@ -32,4 +34,20 @@ describe('Parser', () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('parse tag with value param', () => {
|
||||||
|
const tokens = tokenize('[url=https://github.com/jilizart/bbob]BBob[/url]');
|
||||||
|
const ast = parse(tokens);
|
||||||
|
|
||||||
|
expect(ast).toBeInstanceOf(Array);
|
||||||
|
expect(ast).toEqual([
|
||||||
|
{
|
||||||
|
tag: 'url',
|
||||||
|
attrs: {
|
||||||
|
url: 'https://github.com/jilizart/bbob',
|
||||||
|
},
|
||||||
|
content: ['BBob'],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user