App-perlhl

 view release on metacpan or  search on metacpan

lib/App/perlhl.pm  view on Meta::CPAN

sub _do_highlighting {
    my $self  = shift;
    my @files = @_;

    if (@files) {
        foreach my $filename (@files) {
            open my $in, '<', $filename;
            # Use a separate object for each file - otherwise,
            # highlighting for anything after the first file
            # will be suboptimal.
            my $formatter = $self->{formatter}->new();
            while (<$in>) {
                print $formatter->format_string;
            }
        }
    }
    else {
        while (<STDIN>) {
            print $self->{formatter}->format_string while (<STDIN>);
        }
    }
    print "\n";
}

1;

__END__

=pod

=encoding utf-8

=head1 NAME

App::perlhl - application class for syntax highlighting Perl source code

=head1 VERSION

version 0.007

=head1 SYNOPSIS

    use App::perlhl;
    App::perlhl->new({})->run({}, \@ARGV);

=head1 DESCRIPTION

B<App::perlhl> is the application class backing L<perlhl>.

=head1 METHODS

=head2 new

This instantiates a new App::perlhl object. It takes a hashref
of options:

=over 4

=item * html

If true, the output will be an HTML fragment suitable for publishing as part
of a web page. B<NOTE:> In the future, this might output a whole valid document.

=back

The default is to output ANSI colour codes suitable for printing to any
reasonable shell or terminal (which probably means you have the one that'll
break -- well it works on mine, so neener neener).

=head2 run

Unsurprisingly, this runs the application. The method takes a hashref of options,
and an arrayref of filenames to highlight. If there are no filenames, defaults to
C<STDIN>.

=head2 Options

=over 4

=item * version

If present, the application will print version data and exit.

=back

=head1 AVAILABILITY

The project homepage is L<http://metacpan.org/release/App-perlhl/>.

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you, or see L<https://metacpan.org/module/App::perlhl/>.

=head1 SOURCE

The development version is on github at L<http://github.com/doherty/App-perlhl>
and may be cloned from L<git://github.com/doherty/App-perlhl.git>

=head1 BUGS AND LIMITATIONS

You can make new bug reports, and view existing ones, through the
web interface at L<https://github.com/doherty/App-perlhl/issues>.

=head1 AUTHOR

Mike Doherty <doherty@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Mike Doherty.

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

=cut



( run in 1.135 second using v1.01-cache-2.11-cpan-b16cb0d3907 )