From f3bd2c688fc03f5543f9943aeb50735b8570aa5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Knezi=C4=87?= Date: Tue, 1 Nov 2016 15:30:10 +0100 Subject: [PATCH 1/2] Fix annotation parsing in nested comment blocks --- index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index b99b1fa..b2d4bf1 100644 --- a/index.js +++ b/index.js @@ -168,20 +168,21 @@ var scssContextParser = (function () { var filterAndGroup = function (lines) { var nLines = []; var group = false; - lines.forEach(function (line){ - var isAnnotation = line.indexOf('@') === 0; - if (line.trim().indexOf('---') !== 0) { // Ignore lines that start with "---" - if (group){ - if ( isAnnotation ) { - nLines.push(line); + lines.forEach(function (line) { + var trimmedLine = line.trim(); + var isAnnotation = trimmedLine.indexOf('@') === 0; + if (trimmedLine.trim().indexOf('---') !== 0) { // Ignore lines that start with "---" + if (group) { + if (isAnnotation) { + nLines.push(trimmedLine); } else { - nLines[nLines.length - 1] += '\n' + line ; + nLines[nLines.length - 1] += '\n' + line; } } else if (isAnnotation) { group = true; - nLines.push(line); + nLines.push(trimmedLine); } else { - nLines.push(line); + nLines.push(trimmedLine); } } }); From d08dc1d0e79f057c8a6b4a95f7018aac295e2464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Knezi=C4=87?= Date: Tue, 1 Nov 2016 15:55:33 +0100 Subject: [PATCH 2/2] Don't trim line twice in filterAndGroup function --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b2d4bf1..0cadb5e 100644 --- a/index.js +++ b/index.js @@ -171,7 +171,7 @@ var filterAndGroup = function (lines) { lines.forEach(function (line) { var trimmedLine = line.trim(); var isAnnotation = trimmedLine.indexOf('@') === 0; - if (trimmedLine.trim().indexOf('---') !== 0) { // Ignore lines that start with "---" + if (trimmedLine.indexOf('---') !== 0) { // Ignore lines that start with "---" if (group) { if (isAnnotation) { nLines.push(trimmedLine);