11'use strict' ;
22
3+ const openBracket = '{' . charCodeAt ( 0 ) ;
4+ const closeBracket = '}' . charCodeAt ( 0 ) ;
35const openParen = '(' . charCodeAt ( 0 ) ;
46const closeParen = ')' . charCodeAt ( 0 ) ;
57const singleQuote = '\'' . charCodeAt ( 0 ) ;
@@ -11,15 +13,17 @@ const colon = ':'.charCodeAt(0);
1113const asterisk = '*' . charCodeAt ( 0 ) ;
1214const minus = '-' . charCodeAt ( 0 ) ;
1315const plus = '+' . charCodeAt ( 0 ) ;
16+ const pound = '#' . charCodeAt ( 0 ) ;
1417const newline = '\n' . charCodeAt ( 0 ) ;
1518const space = ' ' . charCodeAt ( 0 ) ;
1619const feed = '\f' . charCodeAt ( 0 ) ;
1720const tab = '\t' . charCodeAt ( 0 ) ;
1821const cr = '\r' . charCodeAt ( 0 ) ;
1922const at = '@' . charCodeAt ( 0 ) ;
2023const atEnd = / [ \n \t \r \{ \( \) ' " \\ ; , / ] / g;
21- const wordEnd = / [ \n \t \r \( \) \* : ; @ ! & ' " \+ \| ~ > , \[ \] \\ ] | \/ (? = \* ) / g;
22- const wordEndNum = / [ \n \t \r \( \) \* : ; @ ! & ' " \- \+ \| ~ > , \[ \] \\ ] | \/ / g;
24+ const wordEnd = / [ \n \t \r \( \) \{ \} \* : ; @ ! & ' " \+ \| ~ > , \[ \] \\ ] | \/ (? = \* ) / g;
25+ const wordEndNum = / [ \n \t \r \( \) \{ \} \* : ; @ ! & ' " \- \+ \| ~ > , \[ \] \\ ] | \/ / g;
26+ const alphaNum = / ^ [ a - z 0 - 9 ] / i;
2327
2428const util = require ( 'util' ) ;
2529const TokenizeError = require ( './errors/TokenizeError' ) ;
@@ -107,6 +111,22 @@ module.exports = function tokenize (input, options) {
107111 pos = next - 1 ;
108112 break ;
109113
114+ case openBracket :
115+ tokens . push ( [ '{' , '{' ,
116+ line , pos - offset ,
117+ line , next - offset ,
118+ pos
119+ ] ) ;
120+ break ;
121+
122+ case closeBracket :
123+ tokens . push ( [ '}' , '}' ,
124+ line , pos - offset ,
125+ line , next - offset ,
126+ pos
127+ ] ) ;
128+ break ;
129+
110130 case openParen :
111131 tokens . push ( [ '(' , '(' ,
112132 line , pos - offset ,
@@ -251,6 +271,17 @@ module.exports = function tokenize (input, options) {
251271 pos = next ;
252272
253273 }
274+ else if ( code === pound && ! alphaNum . test ( css . slice ( pos + 1 , pos + 2 ) ) ) {
275+ next = pos + 1 ;
276+
277+ tokens . push ( [ '#' , css . slice ( pos , next ) ,
278+ line , pos - offset ,
279+ line , next - offset ,
280+ pos
281+ ] ) ;
282+
283+ pos = next - 1 ;
284+ }
254285 // catch a regular slash, that isn't a comment
255286 else if ( code === slash ) {
256287 next = pos + 1 ;
0 commit comments