Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add support for transform functions #83

Merged
merged 2 commits into from
Aug 29, 2016
Merged
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
30 changes: 30 additions & 0 deletions grammars/css.cson
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,36 @@
}
]
}
{
'begin': '''(?x)
(?<![\\w-])
(
matrix(?:3d)?
| (?:translate|scale|rotate)(?:[XYZ]|3d)?
| skew[XY]?
| perspective
)
\\s*(\\()
'''
'beginCaptures':
'1':
'name': 'support.function.transform.css'
'2':
'name': 'punctuation.section.function.css'
'end': '\\)'
'endCaptures':
'0':
'name': 'punctuation.section.function.css'
'patterns': [
{
'include': '#numeric-values'
}
{
'match': ','
'name': 'punctuation.separator.css'
}
]
}
{
'match': '\\!\\s*important'
'name': 'keyword.other.important.css'
Expand Down
21 changes: 21 additions & 0 deletions spec/css-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,24 @@ describe 'CSS grammar', ->
'''
expect(tokens[1][4]).toEqual value: 'orphan-black', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css']
expect(tokens[2][4]).toEqual value: 'line-scale', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css']

describe 'CSS Transforms', ->
it 'tokenizes transform functions', ->
tokens = grammar.tokenizeLines '''
.transformed {
transform: matrix(0, 1.5, -1.5, 0, 0, 100px);
transform: rotate(90deg) translateX(100px) scale(1.5);
}
'''
expect(tokens[1][1]).toEqual value: 'transform', scopes: ['source.css', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css']
expect(tokens[1][2]).toEqual value: ':', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'punctuation.separator.key-value.css']
expect(tokens[1][4]).toEqual value: 'matrix', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.function.transform.css']
expect(tokens[1][5]).toEqual value: '(', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'punctuation.section.function.css']
expect(tokens[1][6]).toEqual value: '0', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'constant.numeric.css']
expect(tokens[1][7]).toEqual value: ',', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'punctuation.separator.css']
expect(tokens[1][12]).toEqual value: '-1.5', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'constant.numeric.css']
expect(tokens[1][22]).toEqual value: 'px', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'constant.numeric.css', 'keyword.other.unit.css']
expect(tokens[1][23]).toEqual value: ')', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'punctuation.section.function.css']
expect(tokens[2][4]).toEqual value: 'rotate', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.function.transform.css']
expect(tokens[2][10]).toEqual value: 'translateX', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.function.transform.css']
expect(tokens[2][16]).toEqual value: 'scale', scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.function.transform.css']