diff --git a/packages/remark-stringify/lib/visitors/root.js b/packages/remark-stringify/lib/visitors/root.js index 33f30feb0..ff471a393 100644 --- a/packages/remark-stringify/lib/visitors/root.js +++ b/packages/remark-stringify/lib/visitors/root.js @@ -7,5 +7,9 @@ var lineFeed = '\n' // Stringify a root. // Adds a final newline to ensure valid POSIX files. */ function root(node) { - return this.block(node) + lineFeed + var block = this.block(node) + if (block.substr(lineFeed.length * -1) === lineFeed) { + return block + } + return block + lineFeed } diff --git a/packages/remark/test.js b/packages/remark/test.js index 9bcc2dc69..3fcfc3976 100644 --- a/packages/remark/test.js +++ b/packages/remark/test.js @@ -33,6 +33,14 @@ test('remark().processSync(value)', function(t) { 'should accept stringify options' ) + t.equal( + remark() + .processSync('