diff --git a/src/index.js b/src/index.js
index 3938c5c..1a7ec7e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -47,7 +47,7 @@ export default function parse(md, prevLinks) {
return str;
}
- md = md.replace(/^\[(.+?)\]:\s*(.+)$/gm, (s, name, url) => {
+ md = md.replace(/\r\n?/g, '\n').replace(/^\[(.+?)\]:\s*(.+)$/gm, (s, name, url) => {
links[name.toLowerCase()] = url;
return '';
}).replace(/^\n+|\n+$/g, '');
diff --git a/test/index.js b/test/index.js
index 5262b16..ba15520 100644
--- a/test/index.js
+++ b/test/index.js
@@ -102,6 +102,12 @@ describe('snarkdown()', () => {
it('parses two spaces as a line break', () => {
expect(snarkdown('Something with \na line break')).to.equal('Something with
a line break');
});
+
+ it('parses CRLF line endings like LF line endings (fixes #69)', () => {
+ expect(snarkdown('Something with\r\n\r\na line break')).to.equal('Something with
a line break');
+ expect(snarkdown('Something with\r\ra line break')).to.equal('Something with
a line break');
+ expect(snarkdown('# Title\r\n\r\ntext')).to.equal('