lib/csscss/parser/css.rb in csscss-1.2.0 vs lib/csscss/parser/css.rb in csscss-1.3.0
- old
+ new
@@ -34,16 +34,34 @@
}).as(:value) >>
str(";").maybe >>
space?
}
+ rule(:mixin_attributes) {
+ (
+ str('/* CSSCSS START MIXIN') >>
+ (str('*/').absent? >> any).repeat >>
+ str('*/') >>
+ (str('/* CSSCSS END MIXIN').absent? >> any).repeat >>
+ str('/* CSSCSS END MIXIN') >>
+ (str('*/').absent? >> any).repeat >>
+ str('*/') >>
+ space?
+ ).as(:mixin)
+ }
+
rule(:ruleset) {
(
match["^{}"].repeat(1).as(:selector) >>
str("{") >>
space? >>
- (comment | attribute | blank_attribute).repeat(0).as(:properties) >>
+ (
+ mixin_attributes |
+ comment |
+ attribute |
+ blank_attribute
+ ).repeat(0).as(:properties) >>
str("}") >>
space?
).as(:ruleset)
}
@@ -56,20 +74,37 @@
str("}") >>
space?
).as(:nested_ruleset)
}
+ rule(:import) {
+ (
+ stri("@import") >>
+ match["^;"].repeat(1) >>
+ str(";") >>
+ space?
+ ).as(:import)
+ }
+
rule(:blocks) {
- space? >> (comment | nested_ruleset | ruleset).repeat(1).as(:blocks) >> space?
+ space? >> (
+ comment |
+ import |
+ nested_ruleset |
+ ruleset
+ ).repeat(1).as(:blocks) >> space?
}
root(:blocks)
end
class Transformer < Parslet::Transform
rule(nested_ruleset: sequence(:rulesets)) {
rulesets
}
+
+ rule(import: simple(:import)) { [] }
+ rule(mixin: simple(:mixin)) { nil }
rule(comment: simple(:comment)) { nil }
rule(ruleset: {
selector: simple(:selector),