From 41c59329459cb628e491c247f077e0d335317743 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 15 Sep 2015 18:01:52 +0300 Subject: [PATCH] Keep indentation when keepBlockTags is true --- lib/block.js | 4 ++-- test/buffer.js | 8 ++++++++ test/stream.js | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/block.js b/lib/block.js index 446fe9f..a9c52c5 100644 --- a/lib/block.js +++ b/lib/block.js @@ -91,8 +91,8 @@ Block.prototype.compile = function (tasks) { var buildResult = this.build(); if (this.config.keepBlockTags) { - buildResult.unshift(this.beginTag); - buildResult.push(this.endTag); + buildResult.unshift(this.indent + this.beginTag); + buildResult.push(this.indent + this.endTag); } buildResult.unshift(null); diff --git a/test/buffer.js b/test/buffer.js index cb5d59a..c9bb6ac 100644 --- a/test/buffer.js +++ b/test/buffer.js @@ -137,6 +137,14 @@ describe('Buffer mode', function () { var stream = plugin({lorem: 'ipsum'}); compare(new Buffer(fixture), expected, stream, done); }); + + it('Should keep indentation', function (done) { + var fixture = '\n \n Some text\n \n'; + var expected = '\n \n \n'; + + var stream = plugin({}, {keepBlockTags: true}); + compare(new Buffer(fixture), expected, stream, done); + }); }); describe('resolvePaths', function () { diff --git a/test/stream.js b/test/stream.js index d1982de..06e6793 100644 --- a/test/stream.js +++ b/test/stream.js @@ -144,6 +144,14 @@ describe('Stream mode', function () { var stream = plugin({lorem: 'ipsum'}); compare(stringToStream(fixture), expected, stream, done); }); + + it('Should keep indentation', function (done) { + var fixture = '\n \n Some text\n \n'; + var expected = '\n \n \n'; + + var stream = plugin({}, {keepBlockTags: true}); + compare(stringToStream(fixture), expected, stream, done); + }); }); describe('resolvePaths', function () {