#!/usr/bin/perl
#===============================================================================
#
#         FILE: pod6xhtml
#
#  DESCRIPTION:  save Perl pod as pod6xhtml
#       AUTHOR:  Aliaksandr P. Zahatski ,  <zahatski@gmail.com>
#===============================================================================
#$Id: pod6docbook 573 2009-07-11 12:54:28Z zag $
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Perl6::Pod::To;
use Perl6::Pod::To::XHTML;
my ( $help, $man, $doctype, $add_head, $css_file );
my %opt = ( help => \$help, man => \$man, );
GetOptions(
    \%opt, 'help|?', 'man',
    'doctype|t=s' => \$doctype,
    'add_head|ah' => \$add_head,
    'css|t=s' => \$css_file
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;

my %args = ( header => $add_head, doctype => $doctype, body=>1 );

if ($css_file) {
    $args{head} = [
        link => {
            rel  => "stylesheet",
            href => "$css_file"
        }
    ];
}

my $infile = shift;
my $in_fd;
if ($infile) {
    $in_fd = new IO::File:: "< $infile" or die "$infile: $!";
}
else {
    $in_fd = \*STDIN;
}

my $p = Perl6::Pod::To::to_abstract( 'Perl6::Pod::To::XHTML', \*STDOUT, %args );
$p->parse($in_fd);

exit;

=head1 NAME

    pod6xhtml  - convert Perl pod to XHTML

=head1 SYNOPSIS

  pod6xhtml < somefile.pod > somefile.xhtml
  pod6xhtml somefile.pod  > somefile.xhtml
  pod6xhtml -css main.css somefile.pod  > somefile.xhtml


   options:
    -doctype|t - set doc type . Default html;
    -add_head|ah - If this option is set , pod6xhtml will emit a DOCTYPE as the first line of output.
    -css <css_file> - add stylesheet link to head of xhtml file.
    -help  - print help message
    -man   - print man page

=head1 OPTIONS

=over 8

=item B<-help>

Print a brief help message and exits

=item B<-man>

Prints manual page and exits

=item B<-doctype>, B<-t>

Set docbook type . Default html

=item B<-add_head>,B<-ah>

If this option is set , pod6xhtml will emit a DOCTYPE as the first line of output

=item B<-css> cssfile 

Add stylesheet link to head of xhtml file

=back

=head1 DESCRIPTION

  B<pod6xhtml>  - convert Perl pod to XHTML

=head1 EXAMPLE

  pod6xhtml < somefile.pod > somefile.xhtml


=head1 AUTHOR

Zahatski Aliaksandr, E<lt>zahatski@gmail.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2009-2010 by Zahatski Aliaksandr

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. 

=cut

