diff --git a/src/core/parser.js b/src/core/parser.js index c383a7656..84d17f798 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -734,16 +734,16 @@ var Lexer = (function LexerClosure() { } else if (ch === 0x2B) { // '+' ch = this.nextChar(); } - if (ch === 0x2E) { // '.' - divideBy = 10; - ch = this.nextChar(); - } if (ch === 0x0A || ch === 0x0D) { // LF, CR // Ignore line-breaks (this is consistent with Adobe Reader). do { ch = this.nextChar(); } while (ch === 0x0A || ch === 0x0D); } + if (ch === 0x2E) { // '.' + divideBy = 10; + ch = this.nextChar(); + } if (ch < 0x30 || ch > 0x39) { // '0' - '9' throw new FormatError( `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`); diff --git a/test/unit/parser_spec.js b/test/unit/parser_spec.js index 95fa81ef6..86e775c88 100644 --- a/test/unit/parser_spec.js +++ b/test/unit/parser_spec.js @@ -58,11 +58,15 @@ describe('parser', function() { it('should ignore line-breaks between operator and digit in number', function() { - var input = new StringStream('-\r\n205.88'); - var lexer = new Lexer(input); - var result = lexer.getNumber(); + let minusInput = new StringStream('-\r\n205.88'); + let minusLexer = new Lexer(minusInput); - expect(result).toEqual(-205.88); + expect(minusLexer.getNumber()).toEqual(-205.88); + + let plusInput = new StringStream('+\r\n205.88'); + let plusLexer = new Lexer(plusInput); + + expect(plusLexer.getNumber()).toEqual(205.88); }); it('should handle glued numbers and operators', function() {