From: Rafael Garcia-Suarez Date: Tue, 19 Sep 2006 14:05:48 +0000 (+0000) Subject: Upgrade to podlators 2.0.5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42ae9e1d404cbbd1e5d91e9bff7a3d9d9721f747;p=p5sagit%2Fp5-mst-13.2.git Upgrade to podlators 2.0.5 p4raw-id: //depot/perl@28871 --- diff --git a/MANIFEST b/MANIFEST index 7463370..e950504 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2298,6 +2298,7 @@ lib/Pod/t/htmlview.t pod2html render test lib/Pod/t/InputObjects.t See if Pod::InputObjects works lib/Pod/t/man.t podlators test lib/Pod/t/parselink.t podlators test +lib/Pod/t/pod-parser.t podlators test lib/Pod/t/pod2html-lib.pl pod2html testing library lib/Pod/t/pod2latex.t See if Pod::LaTeX works lib/Pod/t/Select.t See if Pod::Select works diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm index dd81035..077bd7b 100644 --- a/lib/Pod/Man.pm +++ b/lib/Pod/Man.pm @@ -1,5 +1,5 @@ # Pod::Man -- Convert POD data to formatted *roff input. -# $Id: Man.pm,v 2.9 2006-02-19 23:02:35 eagle Exp $ +# $Id: Man.pm,v 2.12 2006-09-16 20:55:41 eagle Exp $ # # Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 # Russ Allbery @@ -40,7 +40,7 @@ use POSIX qw(strftime); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 2.09; +$VERSION = '2.12'; # Set the debugging level. If someone has inserted a debug function into this # class already, use that. Otherwise, use any Pod::Simple debug function @@ -422,17 +422,17 @@ sub guesswork { DEBUG > 5 and print " Guesswork called on [$_]\n"; # By the time we reach this point, all hypens will be escaped by adding a - # backslash. We want to do that escaping if they're part of regular words - # and there's only a single dash, since that's a real hyphen that *roff - # gets to consider a possible break point. Make sure that a dash after - # the first character of a word stays non-breaking, however. + # backslash. We want to undo that escaping if they're part of regular + # words and there's only a single dash, since that's a real hyphen that + # *roff gets to consider a possible break point. Make sure that a dash + # after the first character of a word stays non-breaking, however. # # Note that this is not user-controllable; we pretty much have to do this # transformation or *roff will mangle the output in unacceptable ways. s{ - ( (?:\G|^|\s) [a-zA-Z] ) ( \\- )? - ( (?: [a-zA-Z]+ \\-)+ ) - ( [a-zA-Z]+ ) (?=\s|\Z|\\\ ) + ( (?:\G|^|\s) [\(\"]* [a-zA-Z] ) ( \\- )? + ( (?: [a-zA-Z\']+ \\-)+ ) + ( [a-zA-Z\']+ ) (?= [\)\".?!,;:]* (?:\s|\Z|\\\ ) ) \b } { my ($prefix, $hyphen, $main, $suffix) = ($1, $2, $3, $4); @@ -882,6 +882,10 @@ $preamble .\\" .IX Title "$index" .TH $name $section "$date" "$$self{release}" "$$self{center}" +.\\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\\" way too many mistakes in technical documents. +.if n .ad l +.nh ----END OF HEADER---- $self->output (".\\\" [End of preamble]\n") if DEBUG; } @@ -1216,7 +1220,23 @@ sub cmd_item_block { my $self = shift; $self->item_common ('block', @_) } sub parse_from_file { my $self = shift; $self->reinit; + + # Fake the old cutting option to Pod::Parser. This fiddings with internal + # Pod::Simple state and is quite ugly; we need a better approach. + if (ref ($_[0]) eq 'HASH') { + my $opts = shift @_; + if (defined ($$opts{-cutting}) && !$$opts{-cutting}) { + $$self{in_pod} = 1; + $$self{last_was_blank} = 1; + } + } + + # Do the work. my $retval = $self->SUPER::parse_from_file (@_); + + # Flush output, since Pod::Simple doesn't do this. Ideally we should also + # close the file descriptor if we had to open one, but we can't easily + # figure this out. my $fh = $self->output_fh (); my $oldfh = select $fh; my $oldflush = $|; @@ -1303,11 +1323,11 @@ sub preamble_template { .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. | will give a -.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to -.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' -.\" expand to `' in nroff, nothing in troff, for use with C<>. -.tr \(*W-|\(bv\*(Tr +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- @@ -1338,11 +1358,6 @@ sub preamble_template { . rr F .\} .\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 -.if n .na -.\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm index a23f70a..03a62bf 100644 --- a/lib/Pod/Text.pm +++ b/lib/Pod/Text.pm @@ -1,5 +1,5 @@ # Pod::Text -- Convert POD data to formatted ASCII text. -# $Id: Text.pm,v 3.7 2006-02-19 23:02:35 eagle Exp $ +# $Id: Text.pm,v 3.8 2006-09-16 20:55:41 eagle Exp $ # # Copyright 1999, 2000, 2001, 2002, 2004, 2006 # by Russ Allbery @@ -41,7 +41,7 @@ use Pod::Simple (); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 3.07; +$VERSION = 3.08; ############################################################################## # Initialization @@ -589,7 +589,23 @@ sub pod2text { sub parse_from_file { my $self = shift; $self->reinit; + + # Fake the old cutting option to Pod::Parser. This fiddings with internal + # Pod::Simple state and is quite ugly; we need a better approach. + if (ref ($_[0]) eq 'HASH') { + my $opts = shift @_; + if (defined ($$opts{-cutting}) && !$$opts{-cutting}) { + $$self{in_pod} = 1; + $$self{last_was_blank} = 1; + } + } + + # Do the work. my $retval = $self->Pod::Simple::parse_from_file (@_); + + # Flush output, since Pod::Simple doesn't do this. Ideally we should also + # close the file descriptor if we had to open one, but we can't easily + # figure this out. my $fh = $self->output_fh (); my $oldfh = select $fh; my $oldflush = $|; diff --git a/lib/Pod/t/basic.man b/lib/Pod/t/basic.man index 499e06f..a60a0aa 100644 --- a/lib/Pod/t/basic.man +++ b/lib/Pod/t/basic.man @@ -177,7 +177,7 @@ This paragraph should be doubly indented. .Sp This paragraph should only be singly indented. .IP "\(bu" 4 -This is an item in the middle of a block\-quote, which should be allowed. +This is an item in the middle of a block-quote, which should be allowed. .IP "\(bu" 4 We're also testing tagless item commands. .RE @@ -254,7 +254,7 @@ A forward slash. Try to get this bit of text over towards the edge so |that\ all\ of\ this\ text\ inside\ S<>\ won't| be wrapped. Also test the |same\ thing\ with\ non-breaking\ spaces.| .PP -There is a soft hy\%phen in hyphen at hy\-phen. +There is a soft hy\%phen in hyphen at hy-phen. .PP This is a test of an index entry. .IX Xref "index entry" diff --git a/lib/Pod/t/basic.t b/lib/Pod/t/basic.t index b05b914..6d4b842 100644 --- a/lib/Pod/t/basic.t +++ b/lib/Pod/t/basic.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: basic.t,v 1.10 2006-01-28 22:31:50 eagle Exp $ +# $Id: basic.t,v 1.11 2006-09-16 20:25:25 eagle Exp $ # # basic.t -- Basic tests for podlators. # @@ -90,7 +90,7 @@ for (sort keys %translators) { open (OUTPUT, "> out.$translators{$_}") or die "Cannot create out.$translators{$_}: $!\n"; local $_; - while () { last if /^\.TH/ } + while () { last if /^\.nh/ } print OUTPUT while ; close OUTPUT; close TMP; diff --git a/lib/Pod/t/filehandle.t b/lib/Pod/t/filehandle.t index bcad199..1b9b8d9 100644 --- a/lib/Pod/t/filehandle.t +++ b/lib/Pod/t/filehandle.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: filehandle.t,v 1.1 2006-02-19 23:02:37 eagle Exp $ +# $Id: filehandle.t,v 1.2 2006-09-16 20:25:25 eagle Exp $ # # filehandle.t -- Test the parse_from_filehandle interface. # @@ -47,7 +47,7 @@ while () { close IN; close OUT; open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; - while () { last if /^\.TH/ } + while () { last if /^\.nh/ } my $output; { local $/; diff --git a/lib/Pod/t/man.t b/lib/Pod/t/man.t index 77f485d..b293eb4 100644 --- a/lib/Pod/t/man.t +++ b/lib/Pod/t/man.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: man.t,v 1.9 2006-01-28 22:31:50 eagle Exp $ +# $Id: man.t,v 1.10 2006-09-16 20:25:25 eagle Exp $ # # man.t -- Additional specialized tests for Pod::Man. # @@ -49,7 +49,7 @@ while () { $parser->parse_from_file ('tmp.pod', \*OUT); close OUT; open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; - while () { last if /^\.TH/ } + while () { last if /^\.nh/ } my $output; { local $/; @@ -413,9 +413,11 @@ Blorpy \fBprok\fR wugga chachacha. ### =head1 Hyphen in SEE -Don't S. +Don't S. This "one's-fine!", as well. However, +$-0.13 should have a real hyphen. ### .SH "Hyphen in S<>" .IX Header "Hyphen in S<>" -Don't transform\ even-this\ hyphen. +Don't transform\ even-this\ hyphen. This \*(L"one's-fine!\*(R", as well. However, +$\-0.13 should have a real hyphen. ### diff --git a/lib/Pod/t/pod-parser.t b/lib/Pod/t/pod-parser.t new file mode 100644 index 0000000..7b0f8c1 --- /dev/null +++ b/lib/Pod/t/pod-parser.t @@ -0,0 +1,75 @@ +#!/usr/bin/perl -w +# $Id: pod-parser.t,v 1.2 2006-09-16 21:09:57 eagle Exp $ +# +# pod-parser.t -- Tests for backward compatibility with Pod::Parser. +# +# Copyright 2006 by Russ Allbery +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } else { + unshift (@INC, '../blib/lib'); + } + unshift (@INC, '../blib/lib'); + $| = 1; + print "1..3\n"; +} + +END { + print "not ok 1\n" unless $loaded; +} + +use Pod::Man; +use Pod::Text; + +$loaded = 1; +print "ok 1\n"; + +my $parser = Pod::Man->new or die "Cannot create parser\n"; +open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; +print TMP "Some random B.\n"; +close TMP; +open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; +$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT); +close OUT; +open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; +while () { last if /^\.nh/ } +my $output; +{ + local $/; + $output = ; +} +close OUT; +if ($output eq "Some random \\fBtext\\fR.\n") { + print "ok 2\n"; +} else { + print "not ok 2\n"; + print "Expected\n========\nSome random \\fBtext\\fR.\n\n"; + print "Output\n======\n$output\n"; +} + +$parser = Pod::Text->new or die "Cannot create parser\n"; +open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; +$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT); +close OUT; +open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n"; +{ + local $/; + $output = ; +} +close OUT; +if ($output eq " Some random text.\n\n") { + print "ok 3\n"; +} else { + print "not ok 3\n"; + print "Expected\n========\n Some random text.\n\n\n"; + print "Output\n======\n$output\n"; +} + +unlink ('tmp.pod', 'out.tmp'); +exit 0;