less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.01k stars 3.41k forks source link

Comments with doubleslash are not stripped before compile #4264

Open matthew-dean opened 7 months ago

matthew-dean commented 7 months ago

Discussed in https://github.com/less/less.js/discussions/4262

Originally posted by **mperry2** February 29, 2024 I've got a variable that's a list of several hundred items. I'd like to add comments between blocks of the items like I would in a regular programming language. I read at https://github.com/less/less.js/issues/202#issuecomment-775536 that `// comment` will be removed, so I used those. However, the comments are not being stripped out before processing and are becoming part of the list. I'm wondering if something's wrong with my syntax and I'm just not seeing it. Here's a contrived test case. [Link to Less-To-CSS Playground](https://lesscss.org/less-preview/#eyJjb2RlIjoiQGl0ZW1zOlxuLy8gRnJ1aXRcbiAgICBhcHBsZSxcbiAgICBiYW5hbmEsXG4gICAgY2hlcnJ5LFxuXG4vLyBWZWdldGFibGVzXG4gICAgY2Fycm90LFxuICAgIHBvdGF0byxcbjtcblxuZWFjaChAaXRlbXMsIHtcbiAgZGl2I0B7dmFsdWV9IHtcbiAgICBjb2xvcjogYmx1ZTtcbiAgfVxufSkiLCJhY3RpdmVWZXJzaW9uIjoiNC4yLjAiLCJtYXRoIjoicGFyZW5zLWRpdmlzaW9uIiwic3RyaWN0VW5pdHMiOmZhbHNlfQ==) less source: ``` @items: // Fruit apple, banana, cherry, // Vegetables carrot, potato, ; each(@items, { div#@{value} { color: blue; } }) ``` Output: ``` div#apple { color: blue; } div#banana { color: blue; } div#cherry { color: blue; } div#// Vegetables carrot { color: blue; } div#potato { color: blue; } ``` Notice that line 10 has `div#// Vegetables carrot` as the selector when it should be `div#carrot`. Any idea on how to fix this? I don't want to use multiple lists.