Skip to content

Commit

Permalink
Merge pull request #36 from jgerigmeyer/fix-semicolon
Browse files Browse the repository at this point in the history
Fix parsing of variable values containing semicolons.
  • Loading branch information
pascalduez authored Feb 3, 2018
2 parents 1027ba3 + 566e28e commit 9e217c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var addCodeToContext = function (context, ctxCode, match) {
* SCSS Context Parser
*/
var scssContextParser = (function () {
var ctxRegEx = /^(@|%|\$)([\w-_]+)*(?:\s+([\w-_]+)|[\s\S]*?:([\s\S]*?)(?:\s!(\w+))?;)?/
var ctxRegEx = /^(@|%|\$)([\w-_]+)*(?:\s+([\w-_]+)|[\s\S]*?:([\s\S]*?)(?:\s!(\w+))?;[ \t]*?(?=\/\/|\n|$))?/
var parser = function (ctxCode, lineNumberFor) {
var match = ctxRegEx.exec(ctxCode.trim())
var startIndex, endIndex
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/variableWithSemicolon.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$name: 'separated;value';
12 changes: 11 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('scss-comment-parser', function () {
})
})

it('should work for a variable that is build of of variabels', function () {
it('should work for a variable that is built of variables', function () {
var context = parser.contextParser(getContent('variableAsListOfVariables.test.scss'))
assert.deepEqual(context, {
type: 'variable',
Expand All @@ -135,6 +135,16 @@ describe('scss-comment-parser', function () {
scope: 'private'
})
})

it('should work for a variable that contains a semicolon', function () {
var context = parser.contextParser(getContent('variableWithSemicolon.test.scss'))
assert.deepEqual(context, {
type: 'variable',
name: 'name',
value: '\'separated;value\'',
scope: 'private'
})
})
})

describe('css rule', function () {
Expand Down

0 comments on commit 9e217c1

Please sign in to comment.