~ubuntu-branches/ubuntu/saucy/libhtml-stripscripts-perl/saucy

« back to all changes in this revision

Viewing changes to examples/tags/MyStripScripts.pm

  • Committer: Bazaar Package Importer
  • Author(s): Tim Retout
  • Date: 2008-08-07 17:21:30 UTC
  • Revision ID: james.westby@ubuntu.com-20080807172130-3l9o4bwl9ftodfqh
Tags: upstream-1.04
ImportĀ upstreamĀ versionĀ 1.04

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package MyStripScripts;
 
2
 
 
3
use strict;
 
4
use warnings FATAL => 'all';
 
5
 
 
6
use HTML::StripScripts::Parser();
 
7
our @ISA = qw(HTML::StripScripts::Parser);
 
8
 
 
9
 
 
10
### NOTE - When changing the values of any of these hashes, first copy the hash
 
11
###        and THEN change the values. For instance: 
 
12
###
 
13
###           my %head = %{$Context{Head}};
 
14
###           $head{meta} = 'EMPTY';
 
15
###           $Context{Head} = \%head
 
16
###
 
17
###        This will ensure that the original
 
18
###        HTML::StripScripts will still work as expected.
 
19
 
 
20
our (%Context,%Attrib);
 
21
 
 
22
### Add <meta> and <link> tags to <head>
 
23
sub init_context_whitelist {
 
24
    my ($self) = @_;
 
25
    unless (%Context) {
 
26
        %Context       = %{$self->SUPER::init_context_whitelist};
 
27
        my %head       = %{$Context{Head}};
 
28
        $head{meta}    = 'EMPTY';
 
29
        $head{link}    = 'EMPTY';
 
30
        $Context{Head} = \%head;
 
31
    }
 
32
    return \%Context;
 
33
}
 
34
 
 
35
### Add attributes for the <meta> and <link> tags
 
36
sub init_attrib_whitelist  {
 
37
    my ($self) = @_;
 
38
    unless (%Attrib) {
 
39
        %Attrib     = %{$self->SUPER::init_attrib_whitelist};
 
40
        $Attrib{meta} = {
 
41
            'name'          => 'word',
 
42
            'http-equiv'    => 'word',
 
43
            'content'       => 'text',
 
44
            'lang'          => 'word',
 
45
        };
 
46
        $Attrib{link} = {
 
47
            'href'          => 'href',
 
48
            'type'          => 'text',
 
49
            'rel'           => 'word',
 
50
        };
 
51
    }
 
52
    return \%Attrib;
 
53
}
 
54
 
 
55
 
 
56
1;