Skip to content

Commit 50d2fb2

Browse files
authored
Merge pull request #25 from phil-lgr/fix-crlf
add support for windows style carriage return
2 parents f66c21a + 20307d7 commit 50d2fb2

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

lib/__tests__/__snapshots__/token-stream.spec.js.snap

+18
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,24 @@ Array [
480480
]
481481
`;
482482
483+
exports[`#next tokens space carriage return character 1`] = `
484+
Object {
485+
"next": Object {
486+
"column": 2,
487+
"cursor": 4,
488+
"line": 2,
489+
},
490+
"start": Object {
491+
"column": 0,
492+
"cursor": 0,
493+
"line": 1,
494+
},
495+
"type": "space",
496+
"value": "
497+
",
498+
}
499+
`;
500+
483501
exports[`#next tokens space multiple spaces 1`] = `
484502
Object {
485503
"next": Object {

lib/__tests__/token-stream.spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ describe('#next', () => {
5656
let t = createTokenStream(createInputStream('\n\n\t hello'))
5757
expect(t.next()).toMatchSnapshot()
5858
})
59+
it('carriage return character', () => {
60+
let t = createTokenStream(createInputStream('\r\n hello'))
61+
expect(t.next()).toMatchSnapshot()
62+
})
5963
})
6064
describe('comment', () => {
6165
it('single comment', () => {

lib/token-stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let is_char = (c) => (cc) => c === cc
4141
* @param {string} c
4242
* @returns {boolean}
4343
*/
44-
let is_whitespace = (c) => '\t\n '.indexOf(c) >= 0
44+
let is_whitespace = (c) => '\t\r\n '.indexOf(c) >= 0
4545

4646
/**
4747
* Return true if the character matches a newline

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scss-parser",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A library to parse/stringify SCSS",
55
"main": "lib/index.js",
66
"license": "SEE LICENSE IN README",

0 commit comments

Comments
 (0)