Skip to content

Commit

Permalink
Merge pull request #154 from dafrito/pod-simple-upgrade
Browse files Browse the repository at this point in the history
Upgrade Parrot's Pod::Simple to latest upstream
  • Loading branch information
cotto committed Sep 12, 2011
2 parents 7b78212 + f9b1812 commit 9056dcb
Show file tree
Hide file tree
Showing 29 changed files with 2,466 additions and 203 deletions.
42 changes: 30 additions & 12 deletions lib/Pod/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use Carp ();
BEGIN { *DEBUG = sub () {0} unless defined &DEBUG }
use integer;
use Pod::Escapes 1.03 ();
use Pod::Escapes 1.04 ();
use Pod::Simple::LinkSection ();
use Pod::Simple::BlackBox ();
#use utf8;
Expand All @@ -18,7 +18,7 @@ use vars qw(
);

@ISA = ('Pod::Simple::BlackBox');
$VERSION = '3.07';
$VERSION = '3.19';

@Known_formatting_codes = qw(I B C L E F S X Z);
%Known_formatting_codes = map(($_=>1), @Known_formatting_codes);
Expand Down Expand Up @@ -67,7 +67,7 @@ __PACKAGE__->_accessorize(

'hide_line_numbers', # For some dumping subclasses: whether to pointedly
# suppress the start_line attribute

'line_count', # the current line number
'pod_para_count', # count of pod paragraphs seen so far

Expand All @@ -80,13 +80,12 @@ __PACKAGE__->_accessorize(
'bare_output', # For some subclasses: whether to prepend
# header-code and postpend footer-code

'fullstop_space_harden', # Whether to turn ". " into ".[nbsp] ";

'nix_X_codes', # whether to ignore X<...> codes
'merge_text', # whether to avoid breaking a single piece of
# text up into several events

'preserve_whitespace', # whether to try to keep whitespace as-is
'strip_verbatim_indent', # What indent to strip from verbatim

'content_seen', # whether we've seen any real Pod content
'errors_seen', # TODO: document. whether we've seen any errors (fatal or not)
Expand All @@ -95,10 +94,14 @@ __PACKAGE__->_accessorize(

'code_handler', # coderef to call when a code (non-pod) line is seen
'cut_handler', # coderef to call when a =cut line is seen
'pod_handler', # coderef to call when a =pod line is seen
#Called like:
# $code_handler->($line, $self->{'line_count'}, $self) if $code_handler;
# $cut_handler->($line, $self->{'line_count'}, $self) if $cut_handler;

# $pod_handler->($line, $self->{'line_count'}, $self) if $pod_handler;

'parse_empty_lists', # whether to acknowledge empty =over/=back blocks

);

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Expand Down Expand Up @@ -357,7 +360,8 @@ sub parse_string_document {
next unless defined $line_group and length $line_group;
pos($line_group) = 0;
while($line_group =~
m/([^\n\r]*)((?:\r?\n)?)/g
m/([^\n\r]*)(\r?\n?)/g # supports \r, \n ,\r\n
#m/([^\n\r]*)((?:\r?\n)?)/g
) {
#print(">> $1\n"),
$self->parse_lines($1)
Expand Down Expand Up @@ -398,7 +402,7 @@ sub parse_file {
} else {
{
local *PODSOURCE;
open(PODSOURCE, "<", "$source") || Carp::croak("Can't open $source: $!");
open(PODSOURCE, "<$source") || Carp::croak("Can't open $source: $!");
$self->{'source_filename'} = $source;
$source = *PODSOURCE{IO};
}
Expand All @@ -407,16 +411,30 @@ sub parse_file {
# By here, $source is a FH.

$self->{'source_fh'} = $source;

my($i, @lines);
until( $self->{'source_dead'} ) {
splice @lines;

for($i = MANY_LINES; $i--;) { # read those many lines at a time
local $/ = $NL;
push @lines, scalar(<$source>); # readline
last unless defined $lines[-1];
# but pass thru the undef, which will set source_dead to true
}

my $at_eof = ! $lines[-1]; # keep track of the undef
pop @lines if $at_eof; # silence warnings

# be eol agnostic
s/\r\n?/\n/g for @lines;

# make sure there are only one line elements for parse_lines
@lines = split(/(?<=\n)/, join('', @lines));

# push the undef back after popping it to set source_dead to true
push @lines, undef if $at_eof;

$self->parse_lines(@lines);
}
delete($self->{'source_fh'}); # so it can be GC'd
Expand Down Expand Up @@ -452,7 +470,7 @@ sub parse_from_file {
require Symbol;
my $out_fh = Symbol::gensym();
DEBUG and print "Write-opening to $to\n";
open($out_fh, ">", "$to") or Carp::croak "Can't write-open $to: $!";
open($out_fh, ">$to") or Carp::croak "Can't write-open $to: $!";
binmode($out_fh)
if $self->can('write_with_binmode') and $self->write_with_binmode;
$self->output_fh($out_fh);
Expand All @@ -475,7 +493,7 @@ sub whine {
return $self->_complain_errata(@_);
}

sub scream { # like whine, but not suppressable
sub scream { # like whine, but not suppressible
#my($self,$line,$complaint) = @_;
my $self = shift(@_);
++$self->{'errors_seen'};
Expand Down Expand Up @@ -983,7 +1001,7 @@ sub _treat_Ls { # Process our dear dear friends, the L<...> sequences
# L<text|name/"sec"> or L<text|name/sec>
# L<text|/"sec"> or L<text|/sec> or L<text|"sec">
# L<scheme:...>
# Ltext|scheme:...>
# L<text|scheme:...>

my($self,@stack) = @_;

Expand Down
Loading

0 comments on commit 9056dcb

Please sign in to comment.