Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect (X)HTML generated by Pod::Html #8017

Closed
p5pRT opened this issue Jul 13, 2005 · 10 comments
Closed

Incorrect (X)HTML generated by Pod::Html #8017

p5pRT opened this issue Jul 13, 2005 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 13, 2005

Migrated from rt.perl.org#36526 (status was 'resolved')

Searchable as RT36526$

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From earl@earlhood.com

Created by earl@earlhood.com

Pod​::Html generated invalid markup for lists. For example,
a numbered listed turns out as​:

<ol>
<li></li>
...text here...
<p></p>
...

Causing lists to be rendered like​:

  1.
  ... text here ...

  2.
  ... text here ...

Or for unordered lists​:

  *
  ... text here ...

  *
  ... text here ...

Notice the annoying line break after each bullet.

What follows is a patch for Pod​::Html based upon the version provided
in Perl 5.8.6 that appears to fix the problem and generate more
proper XHTML. Looking at the Pod​::Html for 5.8.7, the patch should
be applicable to both.

SPECIAL NOTE​: This patch also includes a functional enhancement to
enable xrefs to scripts that include POD in the source file. I.e.
Pod​::Html does not support linking to scripts that do not have a
known extension (pod or pm). This patch includes code to include
files in the cache that appear to have POD content along with markup
generation fixes.

Patch​:

Inline Patch
--- Html.pm.5.8.6	Wed Jul 13 01:28:13 2005
+++ Html.pm	Wed Jul 13 01:20:05 2005
@@ -524,7 +524,7 @@
 		} elsif (/^=over\s*(.*)/) {		# =over N
 		    process_over();
 		} elsif (/^=back/) {		# =back
-		    process_back();
+		    process_back($need_dd);
 		} elsif (/^=for\s+(\S+)\s*(.*)/si) {# =for
 		    process_for($1,$2);
 		} else {
@@ -571,11 +571,10 @@
 		## end of experimental
 
 		if( $after_item ){
-		    print HTML "$text\n";
+		    #print HTML "$text\n";
 		    $After_Lpar = 1;
-		} else {
-		    print HTML "<p>$text</p>\n";
 		}
+		print HTML "<p>$text</p>\n";
 	    }
 	    print HTML "</dd>\n" if $need_dd;
 	    $after_item = 0;
@@ -959,6 +958,19 @@
 	    $Pages{$_}  = "" unless defined $Pages{$_};
 	    $Pages{$_} .= "$dir/$_.pm:";
 	    push(@pods, "$dir/$_.pm");
+	} elsif (-T "$dir/$_") {			    # script(?)
+	    local *F;
+	    if (open(F, "$dir/$_")) {
+		my $line;
+		while (defined($line = <F>)) {
+		    if ($line =~ /^=(?:pod|head1)/) {
+			$Pages{$_}  = "" unless defined $Pages{$_};
+			$Pages{$_} .= "$dir/$_.pod:";
+			last;
+		    }
+		}
+		close(F);
+	    }
 	}
     }
     closedir(DIR);
@@ -1107,7 +1119,8 @@
         $name = anchorify($name);
 	print HTML qq{<a name="$name">}, process_text( \$otext ), '</a>';
     }
-    print HTML "</strong><br />\n";
+    #print HTML "</strong><br />\n";
+    print HTML "</strong>\n";
     undef( $EmittedItem );
 }
 
@@ -1139,7 +1152,8 @@
 
     # formatting: insert a paragraph if preceding item has >1 paragraph
     if( $After_Lpar ){
-	print HTML "<p></p>\n";
+	#print HTML "<p></p>\n";
+	print HTML $need_dd ? "</dd>\n" : "</li>\n" if $After_Lpar;
 	$After_Lpar = 0;
     }
 
@@ -1172,7 +1186,7 @@
         }
         $need_dd = 1;
     }
-    print HTML "</$emitted>" if $emitted;
+    #print HTML "</$emitted>" if $emitted;
     print HTML "\n";
     return $need_dd;
 }
@@ -1191,6 +1205,7 @@
 # process_back - process a pod back tag and convert it to HTML format.
 #
 sub process_back {
+    my $need_dd = shift;
     if( $Listlevel == 0 ){
 	warn "$0: $Podfile: unexpected =back directive in paragraph $Paragraph.  ignoring.\n";
 	return;
@@ -1201,7 +1216,8 @@
     # $Listend[$Listlevel] may have never been initialized.
     $Listlevel--;
     if( defined $Listend[$Listlevel] ){
-	print HTML '<p></p>' if $After_Lpar;
+	#print HTML '<p></p>' if $After_Lpar;
+	print HTML $need_dd ? "</dd>\n" : "</li>\n" if $After_Lpar;
 	print HTML $Listend[$Listlevel];
         print HTML "\n";
         pop( @Listend );
Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.6:

Configured by ehood at Sat Jun 11 12:42:58 CDT 2005.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
  Platform:
    osname=linux, osvers=2.4.20-43.7.legacy, archname=i686-linux-thread-multi
    uname='linux mcguire.earlhood.com 2.4.20-43.7.legacy #1 sat apr 30 01:48:03 edt 2005 i686 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.3 2.96-113)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.6:
    /usr/local/lib/perl5/5.8.6/i686-linux-thread-multi
    /usr/local/lib/perl5/5.8.6
    /usr/local/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.8.6
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.8.6:
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=en_US
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/X11/bin:/sbin:/usr/sbin:/usr/bin:/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From @schwern

On Tue, Jul 12, 2005 at 11​:55​:28PM -0700, Earl Hood wrote​:

- print HTML "$text\n";
+ #print HTML "$text\n";

As a note for future patches, just delete old code. Commented out old code
just piles up and gets in the way. Finding old code is what we have version
control for.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
Don't try the paranormal until you know what's normal.
  -- "Lords and Ladies" by Terry Prachett

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From @steve-m-hay

Earl Hood (via RT) wrote​:

Pod​::Html generated invalid markup for lists. For example,
a numbered listed turns out as​:

<ol>
<li></li>
...text here...
<p></p>
...

Causing lists to be rendered like​:

1.
... text here ...

2.
... text here ...

Or for unordered lists​:

*
... text here ...

*
... text here ...

Notice the annoying line break after each bullet.

Removing those line breaks is definitely an improvement, but the patch
also inserts extra space into <dl> style lists - e.g. see the old and
new examples (from the Benchmark manpage) attached.

Looks fine to me, but before I commit it is anyone particularly wedded
to the more compact old look?


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From @steve-m-hay

old.png

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From @steve-m-hay

new.png

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2005

From @rgs

Steve Hay wrote​:

Removing those line breaks is definitely an improvement, but the patch
also inserts extra space into <dl> style lists - e.g. see the old and
new examples (from the Benchmark manpage) attached.

Looks fine to me, but before I commit it is anyone particularly wedded
to the more compact old look?

I think it's ok, fixing generated HTML is more important than being
rendering-compatible.

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

From @steve-m-hay

Earl Hood (via RT) wrote​:

What follows is a patch for Pod​::Html based upon the version provided
in Perl 5.8.6 that appears to fix the problem and generate more
proper XHTML. Looking at the Pod​::Html for 5.8.7, the patch should
be applicable to both.

Thanks, applied to bleadperl as change 25181.

I've deleted, rather than commented out, the old code, as Michael
Schwern suggested.

A further note to bear in mind for any future patches is that the patch
is easier to apply if the paths are more complete than

Inline Patch
--- Html.pm.5.8.6    Wed Jul 13 01:28:13 2005
+++ Html.pm    Wed Jul 13 01:20:05 2005

A path of at least "lib/Pod/Html.pm" would have been more convenient.

Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

From @steve-m-hay

Now fixed in bleadperl. Should be in 5.8.8, otherwise in 5.10.

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2005

@steve-m-hay - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant