Skip to content

Commit 626e1cd

Browse files
chore(doc-gen): fix blank line trimming for Jade docs
Closes angular#4217
1 parent 34aa142 commit 626e1cd

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

β€Ždocs/angular.io-package/rendering/trimBlankLines.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module.exports = function(encodeCodeBlock) {
1+
module.exports = function() {
22
return {
33
name: 'trimBlankLines',
44
process: function(str) {
55
var lines = str.split(/\r?\n/);
6-
while(lines[0] === '') {
6+
while(lines.length && (lines[0].trim() === '')) {
77
lines.shift();
88
}
99
return lines.join('\n');
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var factory = require('./trimBlankLines');
2+
3+
describe('trimBlankLines filter', function() {
4+
var filter;
5+
6+
beforeEach(function() {
7+
filter = factory();
8+
});
9+
10+
it('should be called "trimBlankLines"', function() {
11+
expect(filter.name).toEqual('trimBlankLines');
12+
});
13+
14+
it('should remove all empty lines from the start of the string', function() {
15+
expect(filter.process('\n\n\nsome text\n\nmore text\n\n'))
16+
.toEqual('some text\n\nmore text\n\n');
17+
});
18+
});

0 commit comments

Comments
 (0)