-
Notifications
You must be signed in to change notification settings - Fork 3
/
SVG.pm
83 lines (61 loc) · 1.5 KB
/
SVG.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
# Copyright (c) 2014-2015 Christian Jaeger, copying@christianjaeger.ch
#
# 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 COPYING.md that came
# bundled with this file.
#
=head1 NAME
PXML::SVG
=head1 SYNOPSIS
=head1 DESCRIPTION
=cut
package PXML::SVG;
@ISA="Exporter"; require Exporter;
use strict; use warnings; use warnings FATAL => 'uninitialized';
use PXML::Element;
our $tags=
[
'svg',
'path',
'a',
# XXX unfinished! Many more of course.
];
sub svg {
my $attrs= ref $_[0] eq "HASH" ? shift : {};
my $attrs2= +{%$attrs};
$$attrs2{xmlns}= "http://www.w3.org/2000/svg";
$$attrs2{"xmlns:xlink"}= "http://www.w3.org/1999/xlink";
PXML::SVG::SVG($attrs2, @_)
}
# XX mostly copy paste from PXHTML. Abstract away, please.
our $nbsp= "\xa0";
our $funcs=
[
map {
my $tag=$_;
[
uc $tag,
sub {
my $atts= ref($_[0]) eq "HASH" ? shift : undef;
PXML::PSVG->new($tag, $atts, [@_]);
}
]
} @$tags
];
for (@$funcs) {
my ($name, $fn)=@$_;
no strict 'refs';
*{"PXML::SVG::$name"}= $fn
}
our @EXPORT_OK= ('svg', '$nbsp', map { $$_[0] } @$funcs);
our %EXPORT_TAGS=(all=>\@EXPORT_OK);
{
package PXML::PSVG;
our @ISA= "PXML::Element";
# serialize to HTML5 compatible representation: -- nope, not
# necessary for SVG, ok? Assuming XHTML always? And different tags
# anyway, ok?
}
1