Skip to content
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: node_js
node_js:
- '0.10'
- '0.12'
- '4.2'
- 'stable'

sudo: false
Expand Down
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,21 @@ var filterAndGroup = function (lines) {
var group = false

lines.forEach(function (line) {
var isAnnotation = line.indexOf('@') === 0
var trimmedLine = line.trim()
var isAnnotation = trimmedLine.indexOf('@') === 0

if (line.trim().indexOf('---') !== 0) { // Ignore lines that start with "---"
if (trimmedLine.indexOf('---') !== 0) { // Ignore lines that start with "---"
if (group) {
if (isAnnotation) {
nLines.push(line)
nLines.push(trimmedLine)
} else {
nLines[nLines.length - 1] += '\n' + line
}
} else if (isAnnotation) {
group = true
nLines.push(line)
nLines.push(trimmedLine)
} else {
nLines.push(line)
nLines.push(trimmedLine)
}
}
})
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/annotationsNestedBlock.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.foo {
/// Test description
/// @test TestType
$test-variable: blue;
}
22 changes: 22 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,28 @@ describe('scss-comment-parser', function () {
})
})

it('should parse annotations on a nested block', function () {
var annotationName = 'test'
var annotations = {
_: {
alias: {
'test': annotationName
}
},
'test': {
name: annotationName,
parse: function (text) {
return text
}
}
}

var result = new ScssCommentParser(annotations).parse(getContent('annotationsNestedBlock.test.scss'))
assert.equal(result.length, 1)
assert.equal(result[0].description, 'Test description\n')
assert.equal(result[0][annotationName], 'TestType')
})

it('should ignore lines that start with "---"', function () {
var result = parser.parse(getContent('ignoreLine.test.scss'))
assert.equal(result.length, 1)
Expand Down