diff --git a/packages/parser/lib/lexer.js b/packages/parser/lib/lexer.js index e7e0686e..b792c770 100644 --- a/packages/parser/lib/lexer.js +++ b/packages/parser/lib/lexer.js @@ -103,7 +103,7 @@ const INVALID_SLASH_OPEN = createToken({ const PROCESSING_INSTRUCTION = createToken({ name: "PROCESSING_INSTRUCTION", - pattern: makePattern`<\\?${f.Name}.*\\?>`, + pattern: makePattern`<\\?${f.Name}.*?\\?>`, }); const OPEN = createToken({ name: "OPEN", pattern: / { const lexAndParseResult = parse(inputText); expect(lexAndParseResult.parseErrors).to.be.empty; }); + + it("should tokenize processing instructions in sibling elements separately", () => { + const inputText = + ''; + const { lexErrors, parseErrors, tokenVector } = parse(inputText); + const processingInstructionImages = tokenVector.reduce( + (images, token) => + token.tokenType.name === "PROCESSING_INSTRUCTION" + ? [...images, token.image] + : images, + [] + ); + + expect(lexErrors).to.be.empty; + expect(parseErrors).to.be.empty; + expect(processingInstructionImages).to.deep.equal([ + "", + "", + "", + "", + ]); + }); });