diff --git a/packages/bbob-parser/Parser.js b/packages/bbob-parser/Parser.js index 104d6c6..1044dce 100644 --- a/packages/bbob-parser/Parser.js +++ b/packages/bbob-parser/Parser.js @@ -66,7 +66,7 @@ module.exports = class Parser { return this.curTagsAttrName[this.curTagsAttrName.length - 1]; } - return null; + return this.getCurTag().tag; } clearCurTagAttrName() { diff --git a/packages/bbob-parser/Parser.test.js b/packages/bbob-parser/Parser.test.js index c703935..52498de 100644 --- a/packages/bbob-parser/Parser.test.js +++ b/packages/bbob-parser/Parser.test.js @@ -1,7 +1,9 @@ const Parser = require('./Parser'); const TOKEN = require('./token'); +const Tokenizer = require('./Tokenizer'); const parse = input => (new Parser(input).parse()); +const tokenize = input => (new Tokenizer(input).tokenize()); describe('Parser', () => { 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'], + }, + ]); + }); });