CSS-Prepare

 view release on metacpan or  search on metacpan

lib/CSS/Prepare.pm  view on Meta::CPAN

use version;
our $VERSION = qv( 0.9.2.4 );

use constant MAX_REDIRECT       => 3;
use constant RE_IS_URL          => qr{^ http s? : // }x;
use constant RE_MATCH_HOSTNAME  => qr{^ ( http s? : // [^/]+ ) /? .* $}x;
use constant RE_MATCH_DIRECTORY => qr{^ (.*?) (?: / [^/]* )? $}x;
use constant NOT_VENDOR_PREFIX  => qw(
        background  border   empty    font  letter
        list        margin   padding  page  table
        text        unicode  white    z
    );

my @MODULES = qw(
        Background
        Border
        BorderRadius
        Color
        Effects
        Font
        Formatting

lib/CSS/Prepare/Property/Formatting.pm  view on Meta::CPAN

    
    &$valid_property_or_error( 'vertical_align' )
        if 'vertical-align' eq $property;
    
    &$valid_property_or_error( 'line_height' )
        if 'line-height' eq $property;
    
    &$valid_property_or_error( 'direction' )
        if 'direction' eq $property;
    
    &$valid_property_or_error( 'unicode_bidi' )
        if 'unicode-bidi' eq $property;
    
    &$valid_property_or_error( 'z_index' )
        if 'z-index' eq $property;
    
    foreach my $offset qw( top right bottom left ) {
        &$valid_property_or_error( 'offset' )
            if $offset eq $property;
    }
    
    return \%canonical, \@errors;

lib/CSS/Prepare/Property/Formatting.pm  view on Meta::CPAN

    my $self  = shift;
    my $block = shift;
    my @output;
    
    # line-height is dealt with in Font.pm not here; this so
    # it can be collapsed into font shorthand if possible
    my @properties = qw(
            bottom      clear       direction     display
            float       height      left          max-height
            max-width   min-height  min-width     position
            right       top         unicode-bidi  vertical-align
            width       z-index
        );
    
    foreach my $property ( @properties ) {
        my $value = $block->{ $property };
        
        push @output, sprintf $self->output_format, "${property}:", $value
            if defined $value;
    }
    

lib/CSS/Prepare/Property/Values.pm  view on Meta::CPAN

        is_outline_width_value
        is_overflow_value
        is_padding_width_value
        is_position_value
        is_quotes_value
        is_table_layout_value
        is_text_align_value
        is_text_decoration_value
        is_text_indent_value
        is_text_transform_value
        is_unicode_bidi_value
        is_vertical_align_value
        is_visibility_value
        is_white_space_value
        is_width_value
        is_word_spacing_value
        is_z_index_value
        
        @standard_directions
        @standard_corners
        

lib/CSS/Prepare/Property/Values.pm  view on Meta::CPAN

my $text_align_value
    = qr{ (?: left | right | center | justify | inherit ) }x;
my $text_decoration_value = qr{
       (?: none | underline | overline | line-through | blink | inherit )
   }x;
my $text_indent_value
    = qr{ (?: $length_value | $percentage_value | inherit ) }x;
my $text_transform_value
    = qr{ (?: capitalize | uppercase | lowercase | none | inherit ) }x;

my $unicode_bidi_value
    = qr{ (?: normal | embed | bidi-override | inherit ) }x;
my $vertical_align_value = qr{
        (?:
              baseline | sub    | super  | top
            | text-top | middle | bottom | text-bottom
            | $length_value | $percentage_value
            | inherit
        )
    }x;
my $visibility_value = qr{ (?: visible | hidden | collapse | inherit ) }x;

lib/CSS/Prepare/Property/Values.pm  view on Meta::CPAN

    return $value =~ m{^ $text_decoration_value $}x;
}
sub is_text_indent_value {
    my $value = shift;
    return $value =~ m{^ $text_indent_value $}x;
}
sub is_text_transform_value {
    my $value = shift;
    return $value =~ m{^ $text_transform_value $}x;
}
sub is_unicode_bidi_value {
    my $value = shift;
    return $value =~ m{^ $unicode_bidi_value $}x;
}
sub is_vertical_align_value {
    my $value = shift;
    return $value =~ m{^ $vertical_align_value $}x;
}
sub is_visibility_value {
    my $value = shift;
    return $value =~ m{^ $visibility_value $}x;
}
sub is_white_space_value {

t/01.values.t  view on Meta::CPAN

    
    foreach my $value qw( ltr  rtl  inherit ) {
        ok( is_direction_value( $value ),
            "direction: '$value'" );
    }
    ok( ! is_direction_value( 'backwards' ),
        "not direction: 'backwards'" );
    
    
    foreach my $value qw( embed  bidi-override  inherit  normal ) {
        ok( is_unicode_bidi_value( $value ),
            "unicode-bidi: '$value'" );
    }
    ok( ! is_unicode_bidi_value( 'bidi-curious' ),
        "not unicode-bidi: 'bidi-curious'" );
    
    
    # other lengths and percentages are tested above
    my @vertical_align_values = qw(
          baseline  sub     super   top
          text-top  middle  bottom  text-bottom
          5px       20%     inherit
        );
    foreach my $value ( @vertical_align_values ) {
        ok( is_vertical_align_value( $value ),

t/02.formatting.t  view on Meta::CPAN

                block     => { 'direction' => 'rtl', },
            },
        );

    @parsed = $preparer->parse_string( $css );
    is_deeply( \@structure, \@parsed )
        or say "direction property was:\n" . Dumper \@parsed;
}
{
    $css = <<CSS;
        div { unicode-bidi: embed; }
CSS
    @structure = (
            {
                original  => ' unicode-bidi: embed; ',
                errors    => [],
                selectors => [ 'div' ],
                block     => { 'unicode-bidi' => 'embed', },
            },
        );

    @parsed = $preparer->parse_string( $css );
    is_deeply( \@structure, \@parsed )
        or say "unicode-bidi property was:\n" . Dumper \@parsed;
}
{
    $css = <<CSS;
        div { vertical-align: baseline; }
CSS
    @structure = (
            {
                original  => ' vertical-align: baseline; ',
                errors    => [],
                selectors => [ 'div' ],

t/04.formatting.t  view on Meta::CPAN

CSS
    
    $output = $preparer_pretty->output_as_string( @structure );
    ok( $output eq $css )
        or say "direction property was:\n" . $output;
}
{
    @structure = (
            {
                selectors => [ 'div' ],
                block     => { 'unicode-bidi' => 'embed', },
            },
        );
    $css = <<CSS;
div{unicode-bidi:embed;}
CSS
    
    $output = $preparer_concise->output_as_string( @structure );
    ok( $output eq $css )
        or say "unicode-bidi property was:\n" . $output;
    
    $css = <<CSS;
div {
    unicode-bidi:           embed;
}
CSS
    
    $output = $preparer_pretty->output_as_string( @structure );
    ok( $output eq $css )
        or say "unicode-bidi property was:\n" . $output;
}
{
    @structure = (
            {
                selectors => [ 'div' ],
                block     => { 'vertical-align' => 'text-top', },
            },
        );
    $css = <<CSS;
div{vertical-align:text-top;}



( run in 0.547 second using v1.01-cache-2.11-cpan-88abd93f124 )