Permalink
Browse files

import Pod::Simple 0.97 from CPAN

git-cpan-module: Pod::Simple
git-cpan-version: 0.97
git-cpan-authorid: SBURKE
  • Loading branch information...
1 parent 67346fe commit 79695b4c3f02e44e1c9e9d0ad0a51bee075009ae Sean M. Burke committed with schwern Aug 13, 2003
View
@@ -1,5 +1,33 @@
-# ChangeLog for Pod::Simple dist # Time-stamp: "2002-11-20 00:28:53 MST"
-
+# ChangeLog for Pod::Simple dist # Time-stamp: "2003-08-12 22:40:31 ADT"
+
+2003-08-12 Sean M. Burke <sburke@cpan.org>
+ * Release 0.97
+ * Loooking goooooood. Not smelling so much like beta anymore!
+ * I think this might be the last version before I go
+ putting "use utf8" all over the place.
+
+ * Added placefolders for "=encoding" support. If you use
+ "=encoding", you'll get an error about "not yet implemented"
+ instead of "unknown directive".
+
+ * Rewrote Pod::Simple::Pullparser's get_title, and added
+ get_version, get_author, and get_description. Documented them.
+ Thanks to Graham Barr for contributing an initial get_title and
+ then being patient while I seemed to do nothing with it for months
+ on end!
+
+ * More tests.
+
+ Otherwise just minor changes since last version:
+ * Fixed error in Pod::Simple::RTF.
+ * Added new but undocumented methods to Pod::Simple:
+ unaccept_directive(s) unaccept_target(s) unaccept_code(s)
+ * Corrected '=back without =open' error to '=back without =over'
+ * A little tweaking to the _verbatim_format code.
+ * Dump routines may use \x{NN} instead of \xNN format.
+ * Pod::Simple::HTML now uses VerbatimFormatted
+ * A few changes ot DEBUG messages -- nothing you'd normally see.
+
2002-11-19 Sean M. Burke <sburke@cpan.org>
* Release 0.96
* Still kinda sorta beta.
View
@@ -34,6 +34,7 @@ t/basic.t
t/beginend.t
t/cbacks.t
t/chunking.t
+t/encoding_not_error.t
t/fcodes.t
t/fcodes_ee.t
t/fcodes_ell.t
@@ -62,5 +63,6 @@ t/test_old_perlfaq3.pod
t/test_old_perlfaq3_out.txt
t/test_old_perlvar.pod
t/test_old_perlvar_out.txt
+t/verbatim_formatted.t
t/verbatims.t
t/x_nixer.t
View
@@ -16,7 +16,7 @@ use vars qw(
);
@ISA = ('Pod::Simple::BlackBox');
-$VERSION = '0.96';
+$VERSION = '0.97';
@Known_formatting_codes = qw(I B C L E F S X Z);
%Known_formatting_codes = map(($_=>1), @Known_formatting_codes);
@@ -196,6 +196,26 @@ sub _accept_directives {
return;
}
+#--------------------------------------------------------------------------
+# TODO: document these:
+
+sub unaccept_directive { shift->unaccept_directives(@_) };
+
+sub unaccept_directives {
+ my $this = shift;
+ foreach my $d (@_) {
+ next unless defined $d and length $d;
+ Carp::croak "\"$d\" isn't a valid directive name"
+ unless $d =~ m/^[a-zA-Z][a-zA-Z0-9]*$/s;
+ Carp::croak "But you must accept \"$d\" directives -- it's a builtin!"
+ if exists $Known_directives{$d};
+ delete $this->{'accept_directives'}{$d};
+ DEBUG > 2 and print "OK, won't accept \"=$d\" as directive.\n";
+ }
+ return sort keys %{ $this->{'accept_directives'} } if wantarray;
+ return
+}
+
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#
# And now targets (not directives)
@@ -221,6 +241,20 @@ sub _accept_targets {
return;
}
+#--------------------------------------------------------------------------
+sub unaccept_target { shift->unaccept_targets(@_) }
+
+sub unaccept_targets {
+ my $this = shift;
+ foreach my $t (@_) {
+ next unless defined $t and length $t;
+ # TODO: enforce some limitations on what a target name can be?
+ delete $this->{'accept_targets'}{$t};
+ DEBUG > 2 and print "OK, won't accept \"$t\" as target.\n";
+ }
+ return sort keys %{ $this->{'accept_targets'} } if wantarray;
+ return;
+}
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#
@@ -260,6 +294,38 @@ sub accept_codes { # Add some codes
return;
}
+#--------------------------------------------------------------------------
+sub unaccept_code { shift->unaccept_codes(@_) }
+
+sub unaccept_codes { # remove some codes
+ my $this = shift;
+
+ foreach my $new_code (@_) {
+ next unless defined $new_code and length $new_code;
+ if(ASCII) {
+ # A good-enough check that it's good as an XML Name symbol:
+ Carp::croak "\"$new_code\" isn't a valid element name"
+ if $new_code =~
+ m/[\x00-\x2C\x2F\x39\x3B-\x40\x5B-\x5E\x60\x7B-\x7F]/
+ # Characters under 0x80 that aren't legal in an XML Name.
+ or $new_code =~ m/^[-\.0-9]/s
+ or $new_code =~ m/:[-\.0-9]/s;
+ # The legal under-0x80 Name characters that
+ # an XML Name still can't start with.
+ }
+
+ Carp::croak "But you must accept \"$new_code\" codes -- it's a builtin!"
+ if grep $new_code eq $_, @Known_formatting_codes;
+
+ delete $this->{'accept_codes'}{$new_code};
+
+ DEBUG > 2 and print "OK, won't accept the code $new_code<...>.\n";
+ }
+
+ return;
+}
+
+
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -313,9 +379,10 @@ sub parse_file {
until( $self->{'source_dead'} ) {
splice @lines;
for($i = MANY_LINES; $i--;) { # read those many lines at a time
- push @lines, scalar(<$source>);
+ push @lines, scalar(<$source>); # readline
last unless defined $lines[-1];
# but pass thru the undef, which will set source_dead to true
+ #TODO: encoding thing here, to do stuff if $lines[-1] =~ m/=encoding/
}
$self->parse_lines(@lines);
}
View
@@ -691,7 +691,7 @@ sub _ponder_paragraph_buffer {
join(', ', map $_->[0], @$curr_open), ").\n";
$self->whine(
$para->[1]{'start_line'},
- '=back without =open'
+ '=back without =over'
);
next; # and ignore it
}
@@ -879,6 +879,17 @@ sub _ponder_paragraph_buffer {
} elsif($para_type eq '=extend') {
# Well, might as well implement it here.
$self->_ponder_extend($para);
+ next; # and skip
+ } elsif($para_type eq '=encoding') {
+ $self->scream(
+ $self->{'line_count'},
+ "This document probably"
+ ." does not appear as it should, because it contains an"
+ ." \"=encoding $$para[2]\" command. The \"=encoding\" command"
+ ." is not yet implemented in this Pod::Simple"
+ ." version (v$Pod::Simple::VERSION)."
+ );
+
next; # and skip
} elsif($para_type eq '~Verbatim') {
$para->[0] = 'Verbatim';
@@ -1076,23 +1087,25 @@ sub _verbatim_format {
# #:^^^^^^^^^^^^^^^^^ /////////////
- DEBUG > 4 and print "_verbatim_format considers:\n$p->[$i-1]\n$p->[$i]\n";
+ DEBUG > 4 and print "_verbatim_format considers:\n<$p->[$i-1]>\n<$p->[$i]>\n";
$formatting = ' ' . $1;
$formatting =~ s/\s+$//s; # nix trailing whitespace
- unless(length $formatting and length $p->[$i-1]) {
+ unless(length $formatting and $p->[$i-1] =~ m/\S/) { # no-op
splice @$p,$i,1; # remove this line
$i--; # don't consider next line
next;
}
- # Otherwise:
- DEBUG > 4 and print "Formatting <$formatting> on ", $p->[$i-1], "\n";
- if( length($formatting) > length($p->[$i-1]) ) {
- $formatting = substr($formatting, 0, length($p->[$i-1]));
- } elsif( length($formatting) < length($p->[$i-1]) ) {
+ if( length($formatting) >= length($p->[$i-1]) ) {
+ $formatting = substr($formatting, 0, length($p->[$i-1]) - 1) . ' ';
+ } else {
$formatting .= ' ' x (length($p->[$i-1]) - length($formatting));
}
+ # Make $formatting and the previous line be exactly the same length,
+ # with $formatting having a " " as the last character.
+
+ DEBUG > 4 and print "Formatting <$formatting> on <", $p->[$i-1], ">\n";
my @new_line;
@@ -1116,11 +1129,15 @@ sub _verbatim_format {
#print "Formatting <$new_line[-1][-1]> as $new_line[-1][0]\n";
}
}
- splice @$p, $i-1, 2, @new_line; # replace myself and the next line
- DEBUG > 6 and print "New tokens: ", map( ref($_)?"<@$_> ":"<$_>", @new_line ), "\n";
- $i -= @new_line - 2
- # Skip however many things we've just added,
- # minus the two tokens we just nixed.
+ my @nixed =
+ splice @$p, $i-1, 2, @new_line; # replace myself and the next line
+ DEBUG > 10 and print "Nixed count: ", scalar(@nixed), "\n";
+
+ DEBUG > 6 and print "New version of the above line is these tokens (",
+ scalar(@new_line), "):",
+ map( ref($_)?"<@$_> ":"<$_>", @new_line ), "\n";
+ $i--; # So the next line we scrutinize is the line before the one
+ # that we just went and formatted
}
$p->[0] = 'VerbatimFormatted';
@@ -1138,8 +1155,12 @@ sub _verbatim_format {
for( my $i = $#$p; $i >= 2; $i-- ) {
# work backwards over the tokens, even the first
if( !ref($p->[$i]) ) {
- $p->[$i] =~ s/\n$//s;
- DEBUG > 5 and print "_verbatim_format killed the terminal newline on #$i: {$p->[$i]}, after {$p->[$i-1]}\n";
+ if($p->[$i] =~ s/\n$//s) {
+ DEBUG > 5 and print "_verbatim_format killed the terminal newline on #$i: {$p->[$i]}, after {$p->[$i-1]}\n";
+ } else {
+ DEBUG > 5 and print
+ "No terminal newline on #$i: {$p->[$i]}, after {$p->[$i-1]} !?\n";
+ }
last; # we only want the next one
}
}
@@ -1392,11 +1413,13 @@ sub pretty { # adopted from Class::Classless
} else {
if( chr(65) eq 'A' ) {
s<([^\x20\x21\x23\x27-\x3F\x41-\x5B\x5D-\x7E])>
- <$pretty_form{$1} || '\\x'.(unpack("H2",$1))>eg;
+ #<$pretty_form{$1} || '\\x'.(unpack("H2",$1))>eg;
+ <$pretty_form{$1} || '\\x{'.sprintf("%x", ord($1)).'}'>eg;
} else {
# We're in some crazy non-ASCII world!
s<([^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])>
- <$pretty_form{$1} || '\\x'.(unpack("H2",$1))>eg;
+ #<$pretty_form{$1} || '\\x'.(unpack("H2",$1))>eg;
+ <$pretty_form{$1} || '\\x{'.sprintf("%x", ord($1)).'}'>eg;
}
qq{"$_"};
}
@@ -1,7 +1,7 @@
require 5;
package Pod::Simple::DumpAsXML;
-$VERSION = '1.01';
+$VERSION = '1.03';
use Pod::Simple ();
BEGIN {@ISA = ('Pod::Simple')}
View
@@ -5,7 +5,7 @@ use strict;
use Pod::Simple::PullParser ();
use vars qw(@ISA %Tagmap $Computerese $Lame $Linearization_Limit $VERSION);
@ISA = ('Pod::Simple::PullParser');
-$VERSION = '1.03';
+$VERSION = '1.04';
use UNIVERSAL ();
sub DEBUG () {0}
@@ -24,6 +24,16 @@ my @_to_accept;
%Tagmap = (
'Verbatim' => "\n<pre$Computerese>",
'/Verbatim' => "</pre>\n",
+ 'VerbatimFormatted' => "\n<pre$Computerese>",
+ '/VerbatimFormatted' => "</pre>\n",
+ 'VerbatimB' => "<b>",
+ '/VerbatimB' => "</b>",
+ 'VerbatimI' => "<i>",
+ '/VerbatimI' => "</i>",
+ 'VerbatimBI' => "<b><i>",
+ '/VerbatimBI' => "</i></b>",
+
+
'Data' => "\n",
'/Data' => "\n",
@@ -101,7 +111,7 @@ sub new {
#$new->nix_X_codes(1);
$new->nbsp_for_S(1);
$new->accept_targets( 'html', 'HTML' );
-
+ $new->accept_codes('VerbatimFormatted');
$new->accept_codes(@_to_accept);
DEBUG > 2 and print "To accept: ", join(' ',@_to_accept), "\n";
@@ -144,13 +154,17 @@ sub do_pod_link {
$section = '_' unless length $section;
}
+
+
foreach my $it ($to, $section) {
- $it =~ s/([^\._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/sprintf('%%%02X',ord($1))/eg
- if defined $it;
- # Yes, stipulate the list without a range, so that this can work right on
- # all charsets that this module happens to run under.
- # Altho, hmm, what about that ord? Presumably that won't work right
- # under non-ASCII charsets. Something should be done about that.
+ if( defined $it ) {
+ $it =~ s/([^\x00-\xFF])/join '', map sprintf('%%%02X',$_), unpack 'C*', $1/eg;
+ $it =~ s/([^\._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/sprintf('%%%02X',ord($1))/eg;
+ # Yes, stipulate the list without a range, so that this can work right on
+ # all charsets that this module happens to run under.
+ # Altho, hmm, what about that ord? Presumably that won't work right
+ # under non-ASCII charsets. Something should be done about that.
+ }
}
my $out = $to if defined $to and length $to;
@@ -249,7 +263,8 @@ sub do_middle { # the main work
$tagname = 'Para_item' if @stack and $stack[-1] eq 'text';
}
print $fh $self->{'Tagmap'}{$tagname} || next;
- ++$dont_wrap if $tagname eq 'Verbatim' or $tagname eq 'X';
+ ++$dont_wrap if $tagname eq 'Verbatim' or $tagname eq "VerbatimFormatted"
+ or $tagname eq 'X';
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Oops, something went wrong.

0 comments on commit 79695b4

Please sign in to comment.