diff --git a/.travis.yml b/.travis.yml index d7cdecc..4195b41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: node_js node_js: - '0.10' - '0.12' - - '4.2' - 'stable' sudo: false diff --git a/index.js b/index.js index 50bc711..2ca02b3 100644 --- a/index.js +++ b/index.js @@ -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) } } }) diff --git a/test/fixtures/annotationsNestedBlock.test.scss b/test/fixtures/annotationsNestedBlock.test.scss new file mode 100644 index 0000000..7b235c2 --- /dev/null +++ b/test/fixtures/annotationsNestedBlock.test.scss @@ -0,0 +1,5 @@ +.foo { + /// Test description + /// @test TestType + $test-variable: blue; +} \ No newline at end of file diff --git a/test/test.js b/test/test.js index b78edf2..3b62e0f 100644 --- a/test/test.js +++ b/test/test.js @@ -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)