File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ module.exports = {
99 let last ;
1010
1111 while ( token ) {
12- if ( / \n / . test ( token [ 1 ] ) ) {
12+ if ( / \r ? \ n/ . test ( token [ 1 ] ) ) {
1313 // If there are quotes, fix tokenizer creating one token from start quote to end quote
14- if ( / [ ' " ] .* \n / . test ( token [ 1 ] ) ) {
14+ if ( / [ ' " ] .* \r ? \ n/ . test ( token [ 1 ] ) ) {
1515 // Add string before newline to inline comment token
1616 bits . push ( token [ 1 ] . substring ( 0 , token [ 1 ] . indexOf ( '\n' ) ) ) ;
1717
Original file line number Diff line number Diff line change @@ -15,6 +15,22 @@ test('inline comment', (t) => {
1515 t . is ( nodeToString ( root ) , less ) ;
1616} ) ;
1717
18+ test ( 'two-line inline comment with a single quote and windows EOL' , ( t ) => {
19+ const less = `// it's first comment (this line should end with Windows new line symbols)\r\n// it's second comment` ;
20+ const root = parse ( less ) ;
21+ const [ first , second , ...rest ] = root . nodes ;
22+
23+ t . truthy ( root ) ;
24+ t . true ( first instanceof Comment ) ;
25+ t . true ( first . inline ) ;
26+ t . is ( first . text , `it's first comment (this line should end with Windows new line symbols)` ) ;
27+ t . true ( second instanceof Comment ) ;
28+ t . true ( second . inline ) ;
29+ t . is ( second . text , `it's second comment` ) ;
30+ t . is ( nodeToString ( root ) , less ) ;
31+ t . is ( rest . length , 0 ) ;
32+ } ) ;
33+
1834test ( 'inline comment without leading space' , ( t ) => {
1935 const less = '//batman' ;
2036 const root = parse ( less ) ;
You can’t perform that action at this time.
0 commit comments