Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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+))?;[ \t]*?(?=\/\/|\n|$))?/
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
3 changes: 3 additions & 0 deletions test/fixtures/functionNameWithBackslash.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@function function\with\backslash(){
$some : "code";
}
3 changes: 3 additions & 0 deletions test/fixtures/mixinNameWithBackslash.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@mixin mixin\with\backslash(){
$some : "code";
}
3 changes: 3 additions & 0 deletions test/fixtures/placeholderNameWithBackslash.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%placeholder\with\backslash {
$some : "code";
}
1 change: 1 addition & 0 deletions test/fixtures/variableNameWithBackslash.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$variable\with\backslash : 'value';
37 changes: 37 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ describe('scss-comment-parser', function () {
code: '\n $some : "code";\n'
})
})

it('should work for a name that contains a backslash', function () {
var context = parser.contextParser(getContent('placeholderNameWithBackslash.test.scss'))
assert.deepEqual(context, {
type: 'placeholder',
name: 'placeholder\\with\\backslash',
code: '\n $some : "code";\n'
})
})
})

describe('mixin', function () {
Expand All @@ -58,6 +67,15 @@ describe('scss-comment-parser', function () {
var context = parser.contextParser(getContent('mixinLinebreaks.test.scss'))
assert.deepEqual(context, expected)
})

it('should work for a name that contains a backslash', function () {
var context = parser.contextParser(getContent('mixinNameWithBackslash.test.scss'))
assert.deepEqual(context, {
type: 'mixin',
name: 'mixin\\with\\backslash',
code: '\n $some : "code";\n'
})
})
})

describe('function', function () {
Expand All @@ -76,6 +94,15 @@ describe('scss-comment-parser', function () {
var context = parser.contextParser(getContent('functionLinebreaks.test.scss'))
assert.deepEqual(context, expected)
})

it('should work for a name that contains a backslash', function () {
var context = parser.contextParser(getContent('functionNameWithBackslash.test.scss'))
assert.deepEqual(context, {
type: 'function',
name: 'function\\with\\backslash',
code: '\n $some : "code";\n'
})
})
})

describe('variable', function () {
Expand Down Expand Up @@ -145,6 +172,16 @@ describe('scss-comment-parser', function () {
scope: 'private'
})
})

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

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