Skip to content

Commit

Permalink
normalize line endings to lf
Browse files Browse the repository at this point in the history
  • Loading branch information
tmont committed Jun 6, 2012
1 parent a83f8a5 commit 462b06d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function parseNext(context) {
}

exports.parse = function(string, options) {
string = string.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
var context = parseContext.create(string, options);
do {
parseNext(context);
Expand Down
16 changes: 16 additions & 0 deletions tests/miscellaneous-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var should = require('should');
var helpers = require('./helpers');

describe('Miscellany', function() {
it('should normalize line endings to lf', function() {
var textCount = 0;
helpers.parseString('foo\r\nbar\nbaz\r\r\n', {
text: function(value) {
value.should.equal('foo\nbar\nbaz\n\n');
textCount++;
}
});

textCount.should.equal(1);
});
});

0 comments on commit 462b06d

Please sign in to comment.