use CSS::Parser::Regexp;
use Data::Dumper;
$\ = "\n";
my $css = <<CSS
.someclass {
color: limegreen;
font-size: 12pt;
}
CSS
;
my $p = CSS::Parser::Regexp->new;
$p->parse($css);
print Dumper($p->rules);
print Dumper($p->to_tree);
print $p->stringify;
This module parses CSS with at-rules into rule lists or trees, and stringifies it back
my $p = CSS::Parser::Regexp->new;
Creates a new CSS::Parser::Regexp instance.
$p->parse($css);
Parses a CSS string. Returns the CSS::Parser::Regexp object.
my $rules = $p->parse($css)->rules
Returns the list of parsed rules as an arrayref.
my $rules = $p->parse($css)->stringify
Returns the list of parsed rules stringified into CSS.
my $rules = $p->parse($css)->to_tree
Returns the list of parsed rules as a tree of hashrefs
- better sorting of rules in stringify
- documenting the rule list and tree structures
- functionality for adding/removing rules
- CSS
- CSS::DOM
- CSS::Tiny
This module is tested against Bootstrap, Normalize.css and Pure.css. I don't know if there is gnarly CSS out there that this module fails against.
Simone Cesano [email protected]
For testing purposes, this distribution includes files from Bootstrap, Pure.css and Normalize.css.
This software is copyright (c) 2021 by Simone Cesano.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.