Skip Menu |

This queue is for tickets about the Perl6-Perldoc CPAN distribution.

Report information
The Basics
Id: 26382
Status: open
Priority: 0/
Queue: Perl6-Perldoc

People
Owner: Nobody in particular
Requestors: perl [...] perceptualsolutions.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: XHTML output is not a full XHTML document
perldoc2xhtml (Perl6-Perldoc-v0.0.3) doesn't produce a full XHTML document. It does not include the XML declaration (this is optional, but required for specifying charset for non-utf8 files) nor the root <html> element. As such, when the file has an .xhtml extension, Gecko-based browsers refuse to render it in standards mode as it isn't well-formed. Opera also refuses to render it for the same reason. Sample output from perldoc2xhtml attached.
Subject: s26.xhtml
Download s26.xhtml
application/xhtml+xml 84.5k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #26382] XHTML output is not a full XHTML document
Date: Fri, 20 Apr 2007 11:23:19 +1000
To: bug-Perl6-Perldoc [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Nick Johnston via RT wrote: Show quoted text
> perldoc2xhtml (Perl6-Perldoc-v0.0.3) doesn't produce a full XHTML > document.
I've added a 'full_doc' option to to_xhtml() to support this. It's not the default, so that multiple pod6 sources can be converted and concatenated into a single body. Damian
Subject: Re: [rt.cpan.org #26382] XHTML output is not a full XHTML document
Date: Thu, 26 Apr 2007 20:56:28 +0100
To: bug-Perl6-Perldoc [...] rt.cpan.org
From: Nick Johnston <nick [...] perceptualsolutions.com>
perldoc2xhtml_enhanced's output has improved Perl6::Perldoc::To::Xhtml's output but unfortunately the XML is still not well-formed. I have attached a simple patch that fixes the problem (I'd be honoured if you consider applying it). Explanation below. The DOCTYPE declaration, if 'PUBLIC' is used, must contain a URI to the DTD after the Formal Public Identifier. Perl6::Perldoc::To::Xhtml outputs XML with a DOCTYPE declaration like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> This fails xmllint: s26test.xhtml:1: parser error : Space required after the Public Identifier Also, neither Mozilla-based browsers nor Opera consider the file well-formed. In Opera, adding even an empty URI "" in the DOCTYPE declaration is enough to consider it well-formed. However, Mozilla-based browsers are more fussy - they do not consider the file well-formed unless it *also* contains an xmlns declaration in the root element, e.g. <html xmlns="http://www.w3.org/1999/xhtml"> Looking at the XHTML spec (http://www.w3.org/TR/xhtml1/#docconf) the Mozilla guys seem to have it right: "A Strictly Conforming XHTML Document is an XML document that requires only the facilities described as mandatory in this specification. Such a document must meet all of the following criteria: [...] The root element of the document must contain an xmlns declaration for the XHTML namespace [XMLNS]. The namespace for XHTML is defined to be http://www.w3.org/1999/xhtml" Also, perldoc2xhtml_enhanced doesn't seem to get installed as a script, so I've supplied a trivial patch for Makefile.PL. It will probably be quicker just adding the script by hand than applying the patch though. Thanks Nick damian@conway.org via RT wrote: Show quoted text
>I've added a 'full_doc' option to to_xhtml() to support this. > >It's not the default, so that multiple pod6 sources can be converted and >concatenated into a single body. > > >
--- /tmp/Perl6-Perldoc-v0.0.5/lib/Perl6/Perldoc/To/Xhtml.pm Wed Apr 25 07:31:02 2007 +++ Xhtml.pm Thu Apr 26 20:45:08 2007 @@ -19,6 +19,11 @@ 1 => '-//W3C//DTD XHTML 1.0 Transitional//EN', ); +my %DTD_URLS = ( + strict => 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd', + transitional => 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' +); + sub _full_doc { my ($tree, $opt_ref, $body) = @_; @@ -48,10 +53,16 @@ : $requested ; + # Determine the DTD's URL + my $url = !defined $requested ? $DTD_URLS{transitional} + : exists $DTD_URLS{$requested} ? $DTD_URLS{$requested} + : $requested + ; + # Encapsulate body in appropriate frou-frou... return <<END_STRICT_DOC; -<!DOCTYPE html PUBLIC "$type"> -<html> +<!DOCTYPE html PUBLIC "$type" "$url"> +<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>$title</title> $style
--- Makefile.PL.orig Sun Apr 15 01:22:30 2007 +++ Makefile.PL Thu Apr 26 20:43:32 2007 @@ -7,7 +7,8 @@ AUTHOR => 'Damian Conway <DCONWAY@CPAN.org>', VERSION_FROM => 'lib/Perl6/Perldoc.pm', ABSTRACT_FROM => 'lib/Perl6/Perldoc.pm', - EXE_FILES => ['bin/perldoc2text','bin/perldoc2xhtml'], + EXE_FILES => ['bin/perldoc2text','bin/perldoc2xhtml', + 'bin/perldoc2xhtml_enhanced'], PL_FILES => {}, PREREQ_PM => { 'Filter::Simple' => 0,