aboutsummaryrefslogtreecommitdiff
path: root/lib/parse.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parse.js')
-rw-r--r--lib/parse.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 931e5f66..c3f0822c 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -206,7 +206,7 @@ var EX_EOF = {};
function tokenizer($TEXT, filename, html5_comments) {
var S = {
- text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/\uFEFF/g, ''),
+ text : $TEXT.replace(/\uFEFF/g, ''),
filename : filename,
pos : 0,
tokpos : 0,
@@ -225,10 +225,15 @@ function tokenizer($TEXT, filename, html5_comments) {
var ch = S.text.charAt(S.pos++);
if (signal_eof && !ch)
throw EX_EOF;
- if (ch == "\n") {
+ if ("\r\n\u2028\u2029".indexOf(ch) >= 0) {
S.newline_before = S.newline_before || !in_string;
++S.line;
S.col = 0;
+ if (!in_string && ch == "\r" && peek() == "\n") {
+ // treat a \r\n sequence as a single \n
+ ++S.pos;
+ ch = "\n";
+ }
} else {
++S.col;
}