| 1 | #!/usr/bin/perl | ||||||||||
| 2 | # $Id: Wrap.pm,v 1.3 2004/01/08 03:20:16 nothingmuch Exp $ | ||||||||||
| 3 | |||||||||||
| 4 | package Pod::Wrap; | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Text::Wrap; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use base 'Pod::Parser'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | our $VERSION = 0.01; | |||||||||
| 13 | |||||||||||
| 14 | 150 | ▶ | sub begin_input { | ||||||||
|
Subroutine
begin_input: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 15 | 150 | my $self = shift; | |||||||||
| 16 | |||||||||||
| 17 | 150 | $self->parseopts( # we need some special options: | |||||||||
| 18 | '-want_nonPODs' => 1, # want the perl code | ||||||||||
| 19 | '-process_cut_cmd' => 9, # want to preserve cuts so pod is properly terminated | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 150 | return undef; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 20062 | ▶ | sub preprocess_paragraph { # used to catch | ||||||||
|
Subroutine
preprocess_paragraph: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 26 | 20062 | my $self = shift; | |||||||||
| 27 | 20062 | my $text = shift; | |||||||||
| 28 | |||||||||||
| 29 | 20062 | my $fh = $self->output_handle; | |||||||||
| 30 | 20062 | ▶ | print $fh $text if $self->cutting(); # this is not pod, so we print it. | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 20062 | return $text; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 11237 | ▶ | sub textblock { | ||||||||
|
Subroutine
textblock: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 36 | 11237 | my $self = shift; | |||||||||
| 37 | 11237 | my $text = shift; | |||||||||
| 38 | |||||||||||
| 39 | 11237 | my $fh = $self->output_handle; | |||||||||
| 40 | 11237 | ▶ | if ($text =~ /^=/mg){ # when 'command' is not defined, commands are passed as paragraphs to here. Which means we don't have to recreate them. | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 5300 | print $fh $text; # we just don't wrap them. | |||||||||
| 42 | } else { | ||||||||||
| 43 | 5937 | print $fh wrap('','',$text), "\n"; # wrap 'regular' text, without indenting, and end with another newline.. | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | # sub new { $_[0]->SUPER::new() } # force no arguments to new? | ||||||||||
| 48 | # sub verbatim { print $_[1] } # will be printed automatically if not defined | ||||||||||
| 49 | # sub command { my $self = shift; print "=", $_[0], " ", $_[1], "\n" } # ce n'est past bien | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; # keep your mother happy | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||