Skip to content

Commit 571203e

Browse files
TimothyGuForbesLindesay
authored andcommitted
Explicitly allow class names starting with "--" (#73)
Fixes pugjs/pug#2423.
1 parent 7a7fb78 commit 571203e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,14 @@ Lexer.prototype = {
403403
*/
404404

405405
className: function() {
406-
var tok = this.scan(/^\.(\-?[_a-z][_a-z0-9\-]*)/i, 'class');
406+
var tok = this.scan(/^\.(-?-?[_a-z][_a-z0-9\-]*)/i, 'class');
407407
if (tok) {
408408
this.tokens.push(tok);
409409
this.incrementColumn(tok.val.length);
410410
return true;
411411
}
412412
if (/^\.\-/i.test(this.input)) {
413-
this.error('INVALID_CLASS_NAME', 'If a class name begins with a "-", it must be followed by a letter or underscore.');
413+
this.error('INVALID_CLASS_NAME', 'If a class name begins with a "-" or "--", it must be followed by a letter or underscore.');
414414
}
415415
if (/^\.[0-9]/i.test(this.input)) {
416416
this.error('INVALID_CLASS_NAME', 'Class names must begin with "-", "_" or a letter.');

test/errors/invalid-class-name-2.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"msg": "If a class name begins with a \"-\", it must be followed by a letter or underscore.",
2+
"msg": "If a class name begins with a \"-\" or \"--\", it must be followed by a letter or underscore.",
33
"code": "PUG:INVALID_CLASS_NAME",
44
"line": 1,
55
"column": 1
6-
}
6+
}

0 commit comments

Comments
 (0)