From: Jarkko Hietaniemi Date: Thu, 4 Apr 2002 05:54:20 +0000 (+0000) Subject: pod2html: try to be EOL agnostic. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bbed45f69afd2733a47fb6f98dde2d952fd14e1e;p=p5sagit%2Fp5-mst-13.2.git pod2html: try to be EOL agnostic. (Needs testing on CRLF and CR platforms.) p4raw-id: //depot/perl@15727 --- diff --git a/MANIFEST b/MANIFEST index add706f..2ff8167 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1280,6 +1280,7 @@ lib/Pod/t/basic.ovr podlators test lib/Pod/t/basic.pod podlators test lib/Pod/t/basic.t podlators test lib/Pod/t/basic.txt podlators test +lib/Pod/t/eol.t end of line agnosticism lib/Pod/t/Functions.t See if Pod::Functions works lib/Pod/t/htmlescp.pod pod2html escape test input data lib/Pod/t/htmlescp.t pod2html escape test diff --git a/lib/Pod/Html.pm b/lib/Pod/Html.pm index c912319..515ca4e 100644 --- a/lib/Pod/Html.pm +++ b/lib/Pod/Html.pm @@ -369,6 +369,25 @@ sub pod2html { $/ = ""; my @poddata = ; close(POD); + + # be eol agnostic + for (@poddata) { + if (/\x0D/) { + if (/\x0D\x0A/) { + @poddata = map { s/\x0D\x0A/\n/g; + /\n\n/ ? + map { "$_\n\n" } split /\n\n/ : + $_ } @poddata; + } else { + @poddata = map { s/\x0D/\n/g; + /\n\n/ ? + map { "$_\n\n" } split /\n\n/ : + $_ } @poddata; + } + last; + } + } + clean_data( \@poddata ); # scan the pod for =head[1-6] directives and build an index diff --git a/lib/Pod/t/eol.t b/lib/Pod/t/eol.t new file mode 100644 index 0000000..82e349b --- /dev/null +++ b/lib/Pod/t/eol.t @@ -0,0 +1,93 @@ +#!./perl -w + +use Test::More tests => 3; + +open(POD, ">$$.pod") or die "$$.pod: $!"; +print POD <<__EOF__; +=pod + +=head1 NAME + +crlf + +=head1 DESCRIPTION + +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf + + clrf clrf clrf clrf + clrf clrf clrf clrf + clrf clrf clrf clrf + +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf +clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf clrf + +=cut +__EOF__ +close(POD); + +use Pod::Html; + +# --- CR --- + +open(POD, "<$$.pod") or die "$$.pod: $!"; +open(IN, ">$$.in") or die "$$.in: $!"; +while () { + tr/\x0D\x0A//d; + print IN $_, "\x0D"; +} +close(POD); +close(IN); + +pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o1"); + +# --- LF --- + +open(POD, "<$$.pod") or die "$$.pod: $!"; +open(IN, ">$$.in") or die "$$.in: $!"; +while () { + tr/\x0D\x0A//d; + print IN $_, "\x0A"; +} +close(POD); +close(IN); + +pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o2"); + +# --- CRLF --- + +open(POD, "<$$.pod") or die "$$.pod: $!"; +open(IN, ">$$.in") or die "$$.in: $!"; +while () { + tr/\x0D\x0A//d; + print IN $_, "\x0D\x0A"; +} +close(POD); +close(IN); + +pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o3"); + +# --- now test --- + +local $/; + +open(IN, "<$$.o1") or die "$$.o1: $!"; +my $cksum1 = unpack("%32C*", ); + +open(IN, "<$$.o2") or die "$$.o2: $!"; +my $cksum2 = unpack("%32C*", ); + +open(IN, "<$$.o3") or die "$$.o3: $!"; +my $cksum3 = unpack("%32C*", ); + +ok($cksum1 == $cksum2, "CR vs LF"); +ok($cksum1 == $cksum3, "CR vs CRLF"); +ok($cksum2 == $cksum3, "LF vs CRLF"); + +END { + 1 while unlink("$$.pod", "$$.in", "$$.o1", "$$.o2", "$$.o3"); +} diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 0ee13e1..08e70a8 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -1260,6 +1260,15 @@ C now allows specifying a cache directory. =item * +C now produces XHTML 1.0. + +=item * + +C now understands POD written using different line endings\ +(PC-like CRLF versus UNIX-like LF versus MacClassic-like CR). + +=item * + C has been completely rewritten in Perl. (It is in fact a full implementation of sed in Perl: you can use the sed functionality by using the C utility.)