Browse Source

Replace standalone CR with LF when normalizing newlines

fix #252
pull/259/head
Alex Kocharin 9 years ago
parent
commit
6dbe532460
  1. 2
      lib/rules_core/normalize.js
  2. 17
      test/misc.js

2
lib/rules_core/normalize.js

@ -3,7 +3,7 @@
'use strict'; 'use strict';
var NEWLINES_RE = /\r[\n\u0085]|[\u2424\u2028\u0085]/g; var NEWLINES_RE = /\r[\n\u0085]?|[\u2424\u2028\u0085]/g;
var NULL_RE = /\u0000/g; var NULL_RE = /\u0000/g;

17
test/misc.js

@ -213,6 +213,23 @@ describe('Misc', function () {
assert.strictEqual(md.render('[foo](bar)'), '<p><a href="bar" target="_blank">foo</a></p>\n'); assert.strictEqual(md.render('[foo](bar)'), '<p><a href="bar" target="_blank">foo</a></p>\n');
}); });
it('Should normalize CR to LF', function () {
var md = markdownit();
assert.strictEqual(
md.render('# test\r\r - hello\r - world\r'),
md.render('# test\n\n - hello\n - world\n')
);
});
it('Should normalize CR+LF to LF', function () {
var md = markdownit();
assert.strictEqual(
md.render('# test\r\n\r\n - hello\r\n - world\r\n'),
md.render('# test\n\n - hello\n - world\n')
);
});
}); });

Loading…
Cancel
Save