Skip to content

Commit

Permalink
Fix bug with escapes in interpolation (#119)
Browse files Browse the repository at this point in the history
Fixes #118.
  • Loading branch information
jathak committed Mar 5, 2021
1 parent bda653f commit 1c1c262
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/scss-tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = function scssTokenize (input, options = {}) {
stringQuote = false
stringEscaped = false
} else if (code === BACKSLASH) {
stringEscaped = !escaped
stringEscaped = !stringEscaped
} else if (stringEscaped) {
stringEscaped = false
}
Expand Down
12 changes: 12 additions & 0 deletions test/tokenize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ it('tokenizes interpolation', () => {
run('#{a\nb}', [['word', '#{a\nb}', 0, 5]])
})

it('tokenizes interpolation with escaped brace', () => {
run('#{"\\}"}', [['word', '#{"\\}"}', 0, 6]])
})

it('tokenizes interpolation with escaped quote', () => {
run('#{"\\""}', [['word', '#{"\\""}', 0, 6]])
})

it('tokenizes interpolation with escaped backslash', () => {
run('#{"\\\\"}', [['word', '#{"\\\\"}', 0, 6]])
})

it('tokenizes recursively interpolations', () => {
run('#{#{#{}}}', [['word', '#{#{#{}}}', 0, 8]])
})
Expand Down

0 comments on commit 1c1c262

Please sign in to comment.