1HTML::RewriteAttributesU(s3e)r Contributed Perl DocumentaHtTiMoLn::RewriteAttributes(3)
2
3
4

NAME

6       HTML::RewriteAttributes - concise attribute rewriting
7

SYNOPSIS

9           $html = HTML::RewriteAttributes->rewrite($html, sub {
10               my ($tag, $attr, $value) = @_;
11
12               # delete any attribute that mentions..
13               return if $value =~ /COBOL/i;
14
15               $value =~ s/\brocks\b/rules/g;
16               return $value;
17           });
18
19
20           # writing some HTML email I see..
21           $html = HTML::RewriteAttributes::Resources->rewrite($html, sub {
22               my $uri = shift;
23               my $content = render_template($uri);
24               my $cid = generate_cid_from($content);
25               $mime->attach($cid => content);
26               return "cid:$cid";
27           });
28
29
30           # up for some HTML::ResolveLink?
31           $html = HTML::RewriteAttributes::Links->rewrite($html, "http://search.cpan.org");
32
33           # or perhaps HTML::LinkExtor?
34           HTML::RewriteAttributes::Links->rewrite($html, sub {
35               my ($tag, $attr, $value) = @_;
36               push @links, $value;
37               $value;
38           });
39

DESCRIPTION

41       "HTML::RewriteAttributes" is designed for simple yet powerful HTML
42       attribute rewriting.
43
44       You simply specify a callback to run for each attribute and we do the
45       rest for you.
46
47       This module is designed to be subclassable to make handling special
48       cases eaiser. See the source for methods you can override.
49

METHODS

51   "new"
52       You don't need to call "new" explicitly - it's done in "rewrite". It
53       takes no arguments.
54
55   "rewrite" HTML, callback -> HTML
56       This is the main interface of the module. You pass in some HTML and a
57       callback, the callback is invoked potentially many times, and you get
58       back some similar HTML.
59
60       The callback receives as arguments the tag name, the attribute name,
61       and the attribute value (though subclasses may override this --
62       HTML::RewriteAttributes::Resources does). Return "undef" to remove the
63       attribute, or any other value to set the value of the attribute.
64

SEE ALSO

66       HTML::Parser, HTML::ResolveLink, Email::MIME::CreateHTML,
67       HTML::LinkExtor
68

THANKS

70       Some code was inspired by, and tests borrowed from, Miyagawa's
71       HTML::ResolveLink.
72

AUTHOR

74       Shawn M Moore, "<sartak@bestpractical.com>"
75

LICENSE

77       Copyright 2008-2010 Best Practical Solutions, LLC.
78       HTML::RewriteAttributes is distributed under the same terms as Perl
79       itself.
80
81
82
83perl v5.34.0                      2021-07-22        HTML::RewriteAttributes(3)
Impressum