Skip to content

Commit

Permalink
Merge pull request #669 from hannu/ignore-block-line-nums
Browse files Browse the repository at this point in the history
Fix: Ignored blocks should not change line numbering
  • Loading branch information
hannu committed Jun 16, 2015
2 parents e32e149 + dfc2088 commit bb40b7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/modules/ignore-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ function removeIgnoredBlocks(string) {
ignoreEnabled = false;
lines.forEach(function(line) {
if (line.indexOf('styleguide:ignore:start') !== -1) {
results.push('');
ignoreEnabled = true;
} else if (line.indexOf('styleguide:ignore:end') !== -1) {
results.push('');
ignoreEnabled = false;
} else if (!ignoreEnabled) {
} else if (ignoreEnabled) {
results.push('');
} else {
results.push(line);
}
});
Expand Down
8 changes: 4 additions & 4 deletions test/unit/modules/ignore-block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ styleguide:ignore:end
Last line
*/
});
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nLast line');
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line');
});

it('should remove everything on the same line as tags', function() {
Expand All @@ -32,7 +32,7 @@ Ignore 2
Last line
*/
});
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nLast line');
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line');
});

it('should support multiple blocks', function() {
Expand All @@ -49,7 +49,7 @@ styleguide:ignore:end
Last line
*/
});
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nMiddle line\nLast line');
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\nMiddle line\n\n\n\nLast line');
});

it('should remove everything after start tag even if it is not closed', function() {
Expand All @@ -62,6 +62,6 @@ Ignore 2
Ignore 3
*/
});
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line');
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n');
});
});

0 comments on commit bb40b7d

Please sign in to comment.