Fetching contributors…
Cannot retrieve contributors at this time
184 lines (161 sloc) 3.45 KB
# Copyright (c) 2013-2015 Christian Jaeger,
# This is free software, offered under either the same terms as perl 5
# or the terms of the Artistic License version 2 or the terms of the
# MIT License (Expat version). See the file that came
# bundled with this file.
=head1 NAME
package PXML::XHTML;
@ISA="Exporter"; require Exporter;
use strict; use warnings; use warnings FATAL => 'uninitialized';
use PXML::Element;
our $nbsp= "\xa0";
our $tags=
our $funcs=
map {
my $tag=$_;
uc $tag,
sub {
my $atts= ref($_[0]) eq "HASH" ? shift : undef;
PXML::PXHTML->new($tag, $atts, [@_]);
} @$tags
for (@$funcs) {
my ($name, $fn)=@$_;
no strict 'refs';
*{"PXML::XHTML::$name"}= $fn
our @EXPORT_OK= ('$nbsp', map { $$_[0] } @$funcs);
our %EXPORT_TAGS=(all=>\@EXPORT_OK);
package PXML::PXHTML;
our @ISA= "PXML::Element";
# serialize to HTML5 compatible representation:
sub require_printing_nonvoid_elements_nonselfreferential {
use PXML::HTML5 '$html5_void_element_h';
sub void_element_h {
use FP::Show ();
# This "should" be moved to PXML::Element except that we only know
# in the HTML case how to map back tag names to constructors (XX
# is it actually safe here?). (Would have to store what mapping
# functions were created under which function names for which tag
# names, and which packages they were exported to.) XXX at least
# move to common base class of XHTML and HTML5.
sub FP_Show_show {
my ($s,$show)=@_;
my $a= $s->maybe_attributes;
my $b= $s->body;
join(", ",
defined $a ? &$show($a) : (),
ref($b) eq "ARRAY" ? join(", ",map { &$show($_) } @$b)
: &$show($b)).