Re: CSS parser perl module

Hello Len,

> Actually, I hadn't tried it <blush />.  I just spotted it and sent the info 
> to you. Would you send me the code you were testing it with?

Here is the program:

#

use CSS::Parser;

sub css_com {
  my $self = shift;
  my $comment = shift;
  print "comment: $comment\n";
}

sub sel {
  my $self = shift;
  my $selector = shift;
  print "selector: $selector\n";
}

sub blk_s {
  my $self = shift;
  print "block start\n";
}

sub prop {
  my $self = shift;
  my $property = shift;
  print "property: $property\n";
}

sub val {
  my $self = shift;
  my $value = shift;
  print "value: $value\n";
}

sub blk_e {
  my $self = shift;
  print "block end\n";
}

sub atr {
  my $self = shift;
  my $rule = shift;
  print "at-rule: $rule\n";
}

sub ats {
  my $self = shift;
  my $symbol = shift;
  print "at-symbol: $symbol\n";
}

sub error {
  my $self = shift;
  my $rest = shift;
  my $err = shift;
  print "Error: $err\n";
}

my $css = CSS::Parser->new(
			   handlers => {
					css_comment      => \&css_com,
					selector_string  => \&sel,
					block_start      => \&blk_s,
					property         => \&prop,
					value            => \&val,
					block_end        => \&blk_e,
					at_rule          => \&atr,
					at_symbol        => \&ats,
					error            => \&error
				       }
			  );

$/ = undef;
my $buf = <>;
$css->parse(\$buf);






-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Friday, 14 April 2000 07:28:49 UTC