Perl / perl5

đŸȘ The Perl programming language
https://dev.perl.org/perl5/
Other
1.91k stars 542 forks source link

Pod::HTML problem: =begin html and =end html fail to respect empty lines #5476

Closed p5pRT closed 10 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#9385 (status was 'rejected')

Searchable as RT9385$

p5pRT commented 22 years ago

From hughmyers@micron.com

Created by hughmyers@mail-srv1.micron.com

In Pod​::HTML 1.04\, =begin html/=end html eats lines that consist of single newlines\, i.e. "\n". This happens because the sub clean_data is applied to the body of text before parsing. This converts the text into 'paragraphs'\, text delimited by blank lines\, which discards the delimiter. As an example\, the fragment​:

=begin html

\ \

#include <stdio.h>

int main(int argc\,char *argv[]) {

  printf("Hellow World\n");   return 0;

} \

\

=end html

should display as​:

#include \<stdio.h>

int main(int argc\,char *argv[]) {

  printf("Hellow World\n");   return 0;

}

not as​:

#include \<stdio.h>int main(int argc\,char *argv[]) { printf("Hellow World\n");   return 0;}

There is an obvious work-around of 'no blank lines--use  '

--hsm

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.6.1: Configured by tscheresky at Sat Jul 7 16:59:10 2001. Summary of my perl5 (revision 5 version 6 subversion 1) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86 uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_MSVCRT_READFIX', optimize='-O1 -MD -DNDEBUG', cppflags='-DWIN32' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='', ldflags ='-nologo -nodefaultlib -release -libpath:"c:\mtapps\tsg\sps\perl\prod\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio\Common\MSDev98\lib" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl.lib Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"c:\mtapps\tsg\sps\perl\prod\lib\CORE" -machine:x86' Locally applied patches: @INC for perl v5.6.1: C:\OpenAuto\perllib C:\mtapps\tsg\sps\perl\prod\lib C:\mtapps\tsg\sps\perl\prod\site\lib C:\Perl\lib C:\Perl\site\lib C:/MTAPPS/TSG/sps/perl/prod/lib C:/MTAPPS/TSG/sps/perl/prod/site/lib . Environment for perl v5.6.1: HOME=C:\users LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH=C:\WINNT\System32 LOGDIR (unset) PATH=C:\winnt;C:\texmf\miktex\bin;C:\Program Files\CWEB\bin;PATH=C:\OpenAuto\v2.1\lib;C:\OpenAuto\v2.1\bin;C:\mtapps\tsg\ sps\perl\prod\bin;C:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\bin;C:\PROGRA~1\RAT IONAL\RATION~1\NUTCROOT\bin\x11;C:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\mksnt ;C:\PROGRA~1\pvcs\VM\win32\bin;C:\PROGRA~1\DOCUME~1\DFCRE40\bin;C:\WINNT\sys tem32;C:\WINNT;C:\WINNT\System32\WBEM;C:\WINNT\System32\WBEM\SNMP;C:\Sybase; C:\Sybase\Bin;C:\Sybase\DLL;C:\Program Files\Documentum\Shared;C:\Program Files\Documentum\DFCRE40\BIN;C:\Program Files\Rational\common;C:\Program Files\Rational\ClearCase\bin;C:\Program Files\Rational\ProcessWorkbench;C:\Program Files\Rational\Rose\TopLink\;C:\Program Files\Rational\Rational Test;C:\Program Files\Rational\ClearQuest;C:\Program Files\Rational\Coverage;C:\Program Files\Rational\Coverage\cache;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\Bin;C:\Program Files\doxygen\bin;C:\Perl\bin PERLLIB=C:\OpenAuto\perllib;C:\mtapps\tsg\sps\perl\prod\lib;C:\mtapps\tsg\sp s\perl\prod\site\lib;C:\Perl\lib;C:\Perl\site\lib PERL_BADLANG (unset) SHELL (unset) Complete configuration data for perl v5.6.1: Author='' CONFIGDOTSH='true' Date='$Date' Header='' Id='$Id' Locker='' Log='$Log' PERL_API_REVISION='5' PERL_API_SUBVERSION='0' PERL_API_VERSION='5' PERL_REVISION='5' PERL_SUBVERSION='1' PERL_VERSION='6' RCSfile='$RCSfile' Revision='$Revision' Source='' State='' _a='.lib' _exe='.exe' _o='.obj' afs='false' alignbytes='8' ansi2knr='' aphostname='' api_revision='5' api_subversion='0' api_version='5' api_versionstring='5.5.0' ar='lib' archlib='c:\mtapps\tsg\sps\perl\prod\lib' archlibexp='c:\mtapps\tsg\sps\perl\prod\lib' archname='MSWin32-x86' archname64='' archobjs='' awk='awk' baserev='5' bash='' bin='c:\mtapps\tsg\sps\perl\prod\bin' bincompat5005='' binexp='c:\mtapps\tsg\sps\perl\prod\bin' bison='' byacc='byacc' byteorder='1234' c='' castflags='0' cat='type' cc='cl' cccdlflags=' ' ccdlflags=' ' ccflags='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_MSVCRT_READFIX' ccflags_uselargefiles='' ccname='' ccsymbols='' ccversion='' cf_by='tscheresky' cf_email='dtlperl@micron.com' cf_time='Sat Jul 7 16:59:10 2001' charsize='1' chgrp='' chmod='' chown='' clocktype='clock_t' comm='' compress='' contains='grep' cp='copy' cpio='' cpp='cl -nologo -E' cpp_stuff='42' cppccsymbols='' cppflags='-DWIN32' cpplast='' cppminus='' cpprun='cl -nologo -E' cppstdin='cl -nologo -E' cppsymbols='' crosscompile='' cryptlib='' csh='' d_Gconvert='sprintf((b),"%.*g",(n),(x))' d_PRIEUldbl='' d_PRIFUldbl='' d_PRIGUldbl='' d_PRIXU64='' d_PRId64='' d_PRIeldbl='' d_PRIfldbl='' d_PRIgldbl='' d_PRIi64='' d_PRIo64='' d_PRIu64='' d_PRIx64='' d_SCNfldbl='' d__fwalk='' d_access='define' d_accessx='' d_alarm='' d_archlib='define' d_atolf='' d_atoll='' d_attribut='' d_bcmp='' d_bcopy='' d_bincompat5005='' d_bsd='define' d_bsdgetpgrp='' d_bsdsetpgrp='' d_bzero='' d_casti32='' d_castneg='define' d_charvspr='' d_chown='' d_chroot='' d_chsize='define' d_closedir='define' d_const='define' d_crypt='define' d_csh='' d_cuserid='' d_dbl_dig='define' d_difftime='define' d_dirnamlen='define' d_dlerror='define' d_dlopen='define' d_dlsymun='' d_dosuid='' d_drand48proto='' d_dup2='define' d_eaccess='' d_endgrent='' d_endhent='' d_endnent='' d_endpent='' d_endpwent='' d_endsent='' d_eofnblk='define' d_eunice='' d_fchmod='' d_fchown='' d_fcntl='' d_fcntl_can_lock='' d_fd_macros='define' d_fd_set='define' d_fds_bits='define' d_fgetpos='define' d_flexfnam='define' d_flock='define' d_fork='' d_fpathconf='' d_fpos64_t='' d_frexpl='' d_fs_data_s='' d_fseeko='' d_fsetpos='define' d_fstatfs='' d_fstatvfs='' d_fsync='' d_ftello='' d_ftime='define' d_getcwd='' d_getespwnam='' d_getfsstat='' d_getgrent='' d_getgrps='' d_gethbyaddr='define' d_gethbyname='define' d_gethent='' d_gethname='define' d_gethostprotos='define' d_getlogin='define' d_getmnt='' d_getmntent='' d_getnbyaddr='' d_getnbyname='' d_getnent='' d_getnetprotos='' d_getpagsz='' d_getpbyname='define' d_getpbynumber='define' d_getpent='' d_getpgid='' d_getpgrp='' d_getpgrp2='' d_getppid='' d_getprior='' d_getprotoprotos='define' d_getprpwnam='' d_getpwent='' d_getsbyname='define' d_getsbyport='define' d_getsent='' d_getservprotos='define' d_getspnam='' d_gettimeod='' d_gnulibc='' d_grpasswd='' d_hasmntopt='' d_htonl='define' d_iconv='' d_index='' d_inetaton='' d_int64_t='' d_isascii='define' d_isnan='define' d_isnanl='' d_killpg='' d_lchown='' d_ldbl_dig='define' d_link='define' d_locconv='define' d_lockf='' d_longdbl='define' d_longlong='' d_lseekproto='define' d_lstat='' d_madvise='' d_mblen='define' d_mbstowcs='define' d_mbtowc='define' d_memchr='define' d_memcmp='define' d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' d_mkdtemp='' d_mkfifo='' d_mkstemp='' d_mkstemps='' d_mktime='define' d_mmap='' d_modfl='' d_mprotect='' d_msg='' d_msg_ctrunc='' d_msg_dontroute='' d_msg_oob='' d_msg_peek='' d_msg_proxy='' d_msgctl='' d_msgget='' d_msgrcv='' d_msgsnd='' d_msync='' d_munmap='' d_mymalloc='' d_nice='' d_nv_preserves_uv='define' d_nv_preserves_uv_bits='32' d_off64_t='' d_old_pthread_create_joinable='' d_oldpthreads='' d_oldsock='' d_open3='' d_pathconf='' d_pause='define' d_perl_otherlibdirs='' d_phostname='' d_pipe='define' d_poll='' d_portable='define' d_pthread_yield='' d_pwage='' d_pwchange='' d_pwclass='' d_pwcomment='' d_pwexpire='' d_pwgecos='' d_pwpasswd='' d_pwquota='' d_qgcvt='' d_quad='' d_readdir='define' d_readlink='' d_rename='define' d_rewinddir='define' d_rmdir='define' d_safebcpy='' d_safemcpy='' d_sanemcmp='define' d_sbrkproto='' d_sched_yield='' d_scm_rights='' d_seekdir='define' d_select='define' d_sem='' d_semctl='' d_semctl_semid_ds='' d_semctl_semun='' d_semget='' d_semop='' d_setegid='' d_seteuid='' d_setgrent='' d_setgrps='' d_sethent='' d_setlinebuf='' d_setlocale='define' d_setnent='' d_setpent='' d_setpgid='' d_setpgrp='' d_setpgrp2='' d_setprior='' d_setproctitle='' d_setpwent='' d_setregid='' d_setresgid='' d_setresuid='' d_setreuid='' d_setrgid='' d_setruid='' d_setsent='' d_setsid='' d_setvbuf='define' d_sfio='' d_shm='' d_shmat='' d_shmatprototype='' d_shmctl='' d_shmdt='' d_shmget='' d_sigaction='' d_sigsetjmp='' d_socket='define' d_socklen_t='' d_sockpair='' d_socks5_init='' d_sqrtl='' d_statblks='' d_statfs_f_flags='' d_statfs_s='' d_statvfs='' d_stdio_cnt_lval='define' d_stdio_ptr_lval='define' d_stdio_ptr_lval_nochange_cnt='' d_stdio_ptr_lval_sets_cnt='' d_stdio_stream_array='' d_stdiobase='define' d_stdstdio='define' d_strchr='define' d_strcoll='define' d_strctcpy='define' d_strerrm='strerror(e)' d_strerror='define' d_strtod='define' d_strtol='define' d_strtold='' d_strtoll='' d_strtoul='define' d_strtoull='' d_strtouq='' d_strxfrm='define' d_suidsafe='' d_symlink='' d_syscall='' d_sysconf='' d_sysernlst='' d_syserrlst='define' d_system='define' d_tcgetpgrp='' d_tcsetpgrp='' d_telldir='define' d_telldirproto='define' d_time='define' d_times='define' d_truncate='' d_tzname='define' d_umask='define' d_uname='define' d_union_semun='define' d_ustat='' d_vendorarch='' d_vendorbin='' d_vendorlib='' d_vfork='' d_void_closedir='' d_voidsig='define' d_voidtty='' d_volatile='define' d_vprintf='define' d_wait4='' d_waitpid='define' d_wcstombs='define' d_wctomb='define' d_xenix='' date='date' db_hashtype='int' db_prefixtype='int' defvoidused='15' direntrytype='struct direct' dlext='dll' dlsrc='dl_win32.xs' doublesize='8' drand01='(rand()/(double)((unsigned)1<
p5pRT commented 16 years ago

From renee.baecker@smart-websolutions.de

Attached is a small patch for Pod​::Html (against Pod​::Html 1.09_04).

-- RenĂ©e BĂ€cker renee.baecker@​smart-websolutions.de

XING​: http​://www.xing.com/profile/Renee_Baecker Foo-Magazin​: http​://foo-magazin.de

p5pRT commented 16 years ago

From renee.baecker@smart-websolutions.de

Html.pm.patch ```diff --- Html.pm.orig 2008-06-30 12:03:43.000000000 +0200 +++ Html.pm 2008-06-30 12:02:32.000000000 +0200 @@ -308,6 +308,7 @@ # now convert this file my $after_item; # set to true after an =item warn "Converting input file $Podfile\n" if $Verbose; + my $is_pre = 0; foreach my $i (0..$#poddata){ $_ = $poddata[$i]; $Paragraph = $i+1; @@ -348,7 +349,18 @@ else { next if $Ignore; next if @Begin_Stack && $Begin_Stack[-1] ne 'html'; - print HTML and next if @Begin_Stack && $Begin_Stack[-1] eq 'html'; + + if( @Begin_Stack && $Begin_Stack[-1] eq 'html' and /<\/pre>/ ){ + $is_pre = 0; + } + + if( @Begin_Stack && $Begin_Stack[-1] eq 'html' and /
.*?(?)/ ){
+                $is_pre = 1;
+            }
+
+            my $nl = $is_pre ? "\n\n" : "\n";
+            print HTML ($_,$nl) and next if @Begin_Stack && $Begin_Stack[-1] eq 'html';
+
             my $text = $_;

             # Open tag for definition list as we have something to put in it

```
p5pRT commented 16 years ago

From renee.baecker@smart-websolutions.de

Here it is...

Bram wrote​:

Citeren RenĂ©e BĂ€cker \renee\.baecker@&#8203;smart\-websolutions\.de​:

Attached is a small patch for Pod​::Html (against Pod​::Html 1.09_04).

Can you also add a test for it?

Kind regards\,

Bram

-- RenĂ©e BĂ€cker renee.baecker@​smart-websolutions.de

XING​: http​://www.xing.com/profile/Renee_Baecker Foo-Magazin​: http​://foo-magazin.de

p5pRT commented 16 years ago

From renee.baecker@smart-websolutions.de

use strict; use warnings; use lib qw(/home/rbaecker/cpan/lib/perl5/5.8.8/); use Pod​::Html; use Config; use Test​::More tests => 1;

my $out = $$ . '.html'; pod2html("--infile=$0"\, "--outfile=$out");

my $admin = $Config{'perladmin'};

my $expected = \<\<"EXPECTED"; \<?xml version="1.0" ?> \<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http​://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> \ \ \9385.pl - A testscript for bug #9385\ \<meta http-equiv="content-type" content="text/html; charset=utf-8" /> \ \

\

\<!-- INDEX BEGIN --> \

\

\\\

\

\


\
\<!-- INDEX END -->

\

\

\

\NAME\\

\

9385.pl - A testscript for bug #9385\

\

\

\

\TESTCASE\\

\

The following testcase shows the bug\

\

in Pod​::Html\

\ \
#include <stdio.h>

int main(int argc\,char *argv[]) {

  printf("Hellow World\\n");   return 0; } \

\
this is a test line in an HTML section of this Pod.

\

\ EXPECTED

my $check;

{   local $/;   open my $fh\, '\<'\, $out or die "Cannot open $out​: $!";   $check = \<$fh>;   close $fh; }

$check =~ s/\r?\n/\n/g; $expected =~ s/\r?\n/\n/g;

is( $check\, $expected );

1 while unlink $out; 1 while unlink "pod2htmd.tmp"; 1 while unlink "pod2htmi.tmp";

=head1 NAME

9385.pl - A testscript for bug #9385

=head2 TESTCASE

The following testcase shows the bug

in Pod​::Html

=begin html

\ \

#include <stdio.h>

int main(int argc\,char *argv[]) {

  printf("Hellow World\n");   return 0; } \

\

this is a test line in

an HTML section of this Pod.

=end html

p5pRT commented 16 years ago

From david@landgren.net

Renée BÀcker a écrit :

Attached is a small patch for Pod​::Html (against Pod​::Html 1.09_04).

I've just discovered this message\, as I summarise a fortnight's worth of   traffic (I needed a break).

Anyway\, 1.09_04 is on CPAN\, but not in blead\, since the first step of detabbing the source and pushing the POD to the end of the source file (which is what I would need to do in order to stay sane) was greeted with shrieks of horror that someone would dare reformat TomC's hallowed code.

So\, at the moment\, development is stalled until I hear otherwise.

David

p5pRT commented 12 years ago

From @jkeenan

I am attaching what I believe is a very slightly cleaned-up version of the test file supplied by Renee_Baecker four years ago. The bug appears to persist when tested with Perl 5.14.2.

p5pRT commented 12 years ago

From @jkeenan

use strict; use warnings; use Pod​::Html; use Config; use Test​::More tests => 1;

my $out = $$ . '.html'; pod2html("--infile=$0"\, "--outfile=$out");

my $admin = $Config{'perladmin'};

my $expected = \<\<"EXPECTED"; \<?xml version="1.0" ?> \<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http​://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> \ \ \9385.pl - A testscript for bug #9385\ \<meta http-equiv="content-type" content="text/html; charset=utf-8" /> \ \

\

\<!-- INDEX BEGIN --> \

\

\\\

\

\


\
\<!-- INDEX END -->

\

\

\

\NAME\\

\

9385.pl - A testscript for bug #9385\

\

\

\

\TESTCASE\\

\

The following testcase shows the bug\

\

in Pod​::Html\

\ \
#include <stdio.h>

int main(int argc\,char *argv[]) {

  printf("Hellow World\\n");   return 0; } \

\
this is a test line in an HTML section of this Pod.

\

\ EXPECTED

my $check;

{   local $/;   open my $fh\, '\<'\, $out or die "Cannot open $out​: $!";   $check = \<$fh>;   close $fh; }

$check =~ s/\r?\n/\n/g; $expected =~ s/\r?\n/\n/g;

is( $check\, $expected );

1 while unlink $out; 1 while unlink "pod2htmd.tmp"; 1 while unlink "pod2htmi.tmp";

=head1 NAME

9385.pl - A testscript for bug #9385

=head2 TESTCASE

The following testcase shows the bug

in Pod​::Html

=begin html

\ \

#include <stdio.h>

int main(int argc\,char *argv[]) {

  printf("Hellow World\n");   return 0; } \

\

this is a test line in

an HTML section of this Pod.

=end html

p5pRT commented 12 years ago

From @jkeenan

On Mon Mar 26 18​:10​:25 2012\, jkeenan wrote​:

I am attaching what I believe is a very slightly cleaned-up version of the test file supplied by Renee_Baecker four years ago. The bug appears to persist when tested with Perl 5.14.2.

The original bug report -- back in 2002! -- summarized the problem like this​:

##### In Pod​::HTML 1.04\, =begin html/=end html eats lines that consist of single newlines\, i.e. "\n". This happens because the sub clean_data is applied to the body of text before parsing. This converts the text into 'paragraphs'\, text delimited by blank lines\, which discards the delimiter. #####

There no longer appears to be a subroutine called clean_data() in Pod​::Html. But\, as the test file attached in my previous post demonstrates\, the bug is still there.

Thank you very much. Jim Keenan

p5pRT commented 11 years ago

From matt.follett@gmail.com

It looks like this ticket should probably be moved over to Pod​::Simple. I think this issue may be somewhere in Pod​::Simple​::BlackBox\, but the comments started to get a little too Lovecraftian for me.

On Mon Mar 26 18​:28​:49 2012\, jkeenan wrote​:

On Mon Mar 26 18​:10​:25 2012\, jkeenan wrote​:

I am attaching what I believe is a very slightly cleaned-up version of the test file supplied by Renee_Baecker four years ago. The bug appears to persist when tested with Perl 5.14.2.

The original bug report -- back in 2002! -- summarized the problem like this​:

##### In Pod​::HTML 1.04\, =begin html/=end html eats lines that consist of single newlines\, i.e. "\n". This happens because the sub clean_data is applied to the body of text before parsing. This converts the text into 'paragraphs'\, text delimited by blank lines\, which discards the delimiter. #####

There no longer appears to be a subroutine called clean_data() in Pod​::Html. But\, as the test file attached in my previous post demonstrates\, the bug is still there.

Thank you very much. Jim Keenan

p5pRT commented 10 years ago

From @jkeenan

On Sat Nov 17 15​:58​:57 2012\, mfollett wrote​:

It looks like this ticket should probably be moved over to Pod​::Simple. I think this issue may be somewhere in Pod​::Simple​::BlackBox\, but the comments started to get a little too Lovecraftian for me.

I agree. I have filed a ticket in Pod-Simple's own bug tracker at​: https://rt.cpan.org/Ticket/Display.html?id=91851

Closing this ticket.

Thank you very much. Jim Keenan

p5pRT commented 10 years ago

@jkeenan - Status changed from 'open' to 'rejected'

p5pRT commented 9 years ago

From dwheeler@cpan.org

I believe this issue is fixed as of http​://github.com/theory/pod-simple/commits/bb23b85. Additional testing would be much appreciated!