diff --git a/lib/rules_core/normalize.js b/lib/rules_core/normalize.js index bff5d51..60fc3a4 100644 --- a/lib/rules_core/normalize.js +++ b/lib/rules_core/normalize.js @@ -3,7 +3,7 @@ '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; diff --git a/test/misc.js b/test/misc.js index fd7ba6d..0497642 100644 --- a/test/misc.js +++ b/test/misc.js @@ -213,6 +213,23 @@ describe('Misc', function () { assert.strictEqual(md.render('[foo](bar)'), '
\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') + ); + }); });