CSS-SAC
view release on metacpan or search on metacpan
lib/CSS/SAC/Writer.pm view on Meta::CPAN
$string = 'child';
}
# get the first part right
if ($cond->Position == 1) {
return ':first-' . $string;
}
elsif ($cond->Position == -1) {
return ':last-' . $string;
}
else {
$string = ':nth-' . $string;
}
# add the expression
$string .= '(' . $cond->Position . ')';
return $string;
}
}
#---------------------------------------------------------------------#
#---------------------------------------------------------------------#
# stringify_lexical_unit($sel)
# returns a string of that lexical unit
#---------------------------------------------------------------------#
sub stringify_lexical_unit {
my $dh = shift;
my $lu = shift;
# dimensions
if (
$lu->is_type(CENTIMETER) or $lu->is_type(DEGREE) or
$lu->is_type(DIMENSION) or $lu->is_type(EM) or
$lu->is_type(EX) or $lu->is_type(GRADIAN) or
$lu->is_type(HERTZ) or $lu->is_type(INCH) or
$lu->is_type(KILOHERTZ) or $lu->is_type(MILLIMETER) or
$lu->is_type(MILLISECOND) or $lu->is_type(PERCENTAGE) or
$lu->is_type(PICA) or $lu->is_type(PIXEL) or
$lu->is_type(POINT) or $lu->is_type(RADIAN) or
$lu->is_type(SECOND)
) {
return $lu->Value . $lu->DimensionUnitText;
}
# functions
elsif (
$lu->is_type(ATTR) or $lu->is_type(COUNTER_FUNCTION) or
$lu->is_type(URI) or $lu->is_type(COUNTERS_FUNCTION) or
$lu->is_type(FUNCTION) or $lu->is_type(RECT_FUNCTION)
) {
return $lu->FunctionName . '(' . $lu->Value . ')';
}
# inherit
elsif ($lu->is_type(INHERIT)) {
return 'inherit';
}
# ident, number, unicoderange
elsif ($lu->is_type(IDENT) or $lu->is_type(INTEGER) or
$lu->is_type(REAL) or $lu->is_type(UNICODERANGE)) {
return $lu->Value;
}
# string
elsif ($lu->is_type(STRING_VALUE)) {
return "'" . $lu->Value . "'";
}
# rgbcolor
elsif ($lu->is_type(RGBCOLOR)) {
if ($lu->FunctionName eq 'rgb') {
return 'rgb(' . $lu->Value . ')';
}
else {
return '#' . $lu->Value;
}
}
}
#---------------------------------------------------------------------#
# #
# #
### Helpers ###########################################################
### Error Callbacks ###################################################
# #
# #
#---------------------------------------------------------------------#
# warning($warning)
#---------------------------------------------------------------------#
sub warning {
my $eh = shift;
my $warning = shift;
warn "[WARN] $warning\n";
}
#---------------------------------------------------------------------#
#---------------------------------------------------------------------#
# error($error)
#---------------------------------------------------------------------#
sub error {
my $eh = shift;
my $error = shift;
warn "[ERROR] $error\n";
}
#---------------------------------------------------------------------#
#---------------------------------------------------------------------#
# fatal_error($error)
( run in 0.519 second using v1.01-cache-2.11-cpan-39bf76dae61 )