Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; # # W3C CSS Validator by Philippe Le Hégaret & Sijtsche de Jong # use HTTP::Request::Common qw(POST); use HTML::Parser; use LWP::UserAgent; use Getopt::Long; use vars qw( $validator $ua $req $parser $error $VERSION $file $warnings $usermedium $profile $help ); $VERSION = 0.02; my $inside = 0; $error = 0; # Script return code. 0: CSS OK, 2: CSS has problems $file = undef; $warnings = 2; $profile = 'css2'; $usermedium = 'all'; $help = undef; my $results = GetOptions ( "file=s" => \$file, "warnings=s" => \$warnings, "profile=s" => \$profile, "usermedium=s"=> \$usermedium, "help" => \&usage, ); $file ||= usage(); $validator = 'http://jigsaw.w3.org/css-validator/validator'; $ua = LWP::UserAgent->new; $req = POST $validator, Content_Type => 'form-data', Content => [ file => [ $file ], warning => $warnings, profile => $profile, usermedium => $usermedium, ]; $parser = HTML::Parser->new( report_tags => [qw(div ul li p)], ignore_elements => [qw(h2 h3)], start_h => [ \&start_h, 'tagname, attr' ], end_h => [ sub { $inside-- if shift eq 'div'; }, 'tagnam +e' ], text_h => [ sub { print shift if $inside > 0 }, 'dtext' ] ); $parser->parse( $ua->request($req)->content ); print "\n"; exit $error; sub start_h { my ( $tag, $attr ) = @_; if ( $tag eq 'div' && $attr->{id} && ( $attr->{id} eq 'warnings' || $attr->{id} eq 'errors' ) ) { $error = 2; $inside = -1; print "\n*** ", uc( $attr->{id} ), "\n"; } $inside++ if $tag eq 'div'; } sub usage { die <<"DIE"; W3 CSS Validator Wrapper v.$VERSION usage: $0 -f stylesheet.css [-w 2] [-p css2] [-u all] [-h] -f, --file : Filename of the CSS -w, --warnings : Warnings level 2 : All 1 : Normal report 0 : Most important no : No warnings -p, --profile : Stylesheet Profile none : No special profile css1 : CSS version 1 mobile : mobile css2 : CSS version 2 css3 : CSS version 3 (unsupported) svg : SVG -u, --usermedium : User Medium all, aural, braille, embossed, handheld, print, projec +tion, screen, tty, tv, presentation, atsc-tv (unsupported) -h, --help : Dislay this screen and exits DIE }

In reply to W3 CSS Validator by OeufMayo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-16 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found