Skip to content

Commit 1193552

Browse files
committed
add single-line comments
1 parent 03bc1f5 commit 1193552

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

examples/example.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ body
88
background: black
99
color: white
1010

11+
// just an example comment
12+
1113
button
14+
// moar comments
15+
// hurrrrrrrr
1216
border-radius: 5px
1317
padding: 5px 10px
1418
box-shadow:
@@ -17,9 +21,10 @@ button
1721
inset 0 0 3px blue
1822

1923
@media print
24+
// some stuff
2025
body
2126
padding: 0
2227

2328
button
2429
border-radius: 0
25-
width: 100%
30+
width: 100%

lib/lexer.js

+13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module.exports = function(str) {
4444
function next() {
4545
return stashed()
4646
|| blank()
47+
|| comment()
4748
|| indentation()
4849
|| prop()
4950
|| rule();
@@ -68,6 +69,18 @@ module.exports = function(str) {
6869
return next();
6970
}
7071

72+
/**
73+
* Comment.
74+
*/
75+
76+
function comment() {
77+
var m = str.match(/^\/\/([^\n]*)/);
78+
if (!m) return;
79+
str = str.slice(m[0].length);
80+
return next();
81+
}
82+
83+
7184
/**
7285
* INDENT
7386
* | OUTDENT

0 commit comments

Comments
 (0)