#!/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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.