diff options
Diffstat (limited to 'js/lib/blocks.js')
-rw-r--r-- | js/lib/blocks.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js index a7b75aa..e2b4033 100644 --- a/js/lib/blocks.js +++ b/js/lib/blocks.js @@ -1,6 +1,7 @@ var Node = require('./node'); var C_GREATERTHAN = 62; +var C_NEWLINE = 10; var C_SPACE = 32; var C_OPEN_BRACKET = 91; @@ -675,8 +676,12 @@ var parse = function(input) { this.doc = Document(); this.tip = this.doc; this.refmap = {}; - var lines = input.replace(/\n$/, '').split(reLineEnding); + var lines = input.split(reLineEnding); var len = lines.length; + if (input.charCodeAt(input.length - 1) === C_NEWLINE) { + // ignore last blank line created by final newline + len -= 1; + } for (var i = 0; i < len; i++) { this.incorporateLine(lines[i], i + 1); } |