View on GitHub

CSS-Module-raku

Raku property-specific and extension grammars

CSS::Module

# Parse a sample stylesheet as CSS 2.1. Dump the AST.
use v6;
use CSS::Module::CSS21;
my $css = 'h1 { color: orange; text-align: center }';
my $module = CSS::Module::CSS21.module;
my $actions = $module.actions.new;
$module.grammar.parse( $css, :$actions);
say $/.ast.perl;

CSS::Module is a set of Raku classes for parsing and and manipulation CSS Levels 1, 2.1 and 3.

It contains modules CSS::Module::CSS1.module, CSS::Module::CSS21.module and CSS::Module::CSS3.modules for CSS levels 1.0, 2.1 and 3.0;

CSS::Module::CSS3.module.property-metadata is a generated summary of property information, e.g.:

% perl6 -M CSS::Module::CSS3 -e'say CSS::Module::CSS3.module.property-metadata<azimuth>.perl'
{:default("center"), :inherit, :synopsis("<angle> | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards")}

Note: CSS::Module::CSS3.module is composed from the following grammars.

This corresponds to the sub-modules described in CSS Snapshot 2010.

Installation

This module works with Rakudo Star 2015.09 or better [download from http://rakudo.org/downloads/star/ - don’t forget the final make install]:

You can then use Perl6 zef module installer to test and install CSS::Module:

% zef install CSS::Module

Examples

    use v6;
    use CSS::Module::CSS21;
    my $ast = CSS::Module::CSS21.module.parse-property('azimuth', 'center-left behind');

Property Definitions

Property definitions are built from the sources in the src directory using the CSS::Specification tools. These implement the W3C Property Definition Syntax.

Generated modules are written under the gen/lib directory.

For example CSS::Module:CSS1::Spec::Grammar, CSS::Module:CSS1::Spec::Actions and CSS::Module:CSS1::Spec::Interface are generated from etc/css1-properties.txt.

See make-modules.pl.

Actions Options

References