line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::InHTML; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36909
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
1474
|
use version;our $VERSION = qv('0.0.4'); |
|
1
|
|
|
|
|
2523
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
10
|
|
|
|
|
|
|
encode_plain encode_whitespace encode_perl encode_diff encode_html encode_css |
11
|
|
|
|
|
|
|
encode_sql encode_mysql encode_xml encode_dtd encode_xslt encode_xmlschema |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('common' => \@EXPORT_OK); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
1
|
|
|
1
|
|
9
|
my ($me, @gimme) = @_; |
17
|
1
|
|
|
|
|
2
|
my %seen; |
18
|
1
|
|
|
|
|
12
|
@seen{ @EXPORT_OK } = (); |
19
|
1
|
|
|
|
|
15
|
for my $func (@gimme) { |
20
|
0
|
0
|
|
|
|
0
|
next if exists $seen{ $func }; |
21
|
0
|
0
|
|
|
|
0
|
push @EXPORT_OK, $func if $func =~ m{^encode_\w+$}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub encode_whitespace { |
26
|
5
|
|
|
5
|
1
|
903
|
my ($string, $tabs) = @_; |
27
|
|
|
|
|
|
|
|
28
|
5
|
50
|
33
|
|
|
32
|
$tabs = 4 if !defined $tabs || $tabs !~ m/^\d+$/; |
29
|
5
|
|
|
|
|
20
|
my $spaces = ' ' x $tabs; |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
41
|
$string =~ s{\n}{ \n}g; |
32
|
5
|
|
|
|
|
26
|
$string =~ s{\t}{$spaces}g; |
33
|
5
|
|
|
|
|
33
|
$string =~ s{[ ]{5}}{ }g; |
34
|
5
|
|
|
|
|
35
|
$string =~ s{[ ]{3}}{ }g; |
35
|
5
|
|
|
|
|
25
|
$string =~ s{[ ]{2}}{ }g; |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
30
|
return $string; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub encode_plain { |
41
|
4
|
|
|
4
|
1
|
11
|
my ($string, $tabs) = @_; |
42
|
4
|
|
|
|
|
1129
|
require HTML::Entities; |
43
|
4
|
|
|
|
|
703638
|
return Text::InHTML::encode_whitespace( |
44
|
|
|
|
|
|
|
HTML::Entities::encode($string, '<>&"'), $tabs |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub AUTOLOAD { |
49
|
4
|
|
|
4
|
|
13304
|
my($string, $syntax, $tabs) = @_; |
50
|
|
|
|
|
|
|
|
51
|
4
|
50
|
33
|
|
|
24
|
$syntax = {} if !defined $syntax || ref $syntax ne 'HASH'; |
52
|
4
|
|
|
|
|
27
|
my ($format) = our $AUTOLOAD =~ m{encode_(\w+(-\w+)*)}; |
53
|
|
|
|
|
|
|
|
54
|
4
|
100
|
|
|
|
22
|
die "Could not autoload $AUTOLOAD" if !$format; # only dies when they don't follow the rules |
55
|
3
|
|
|
|
|
8
|
$format =~ s{_}{-}g; |
56
|
|
|
|
|
|
|
|
57
|
3
|
50
|
|
|
|
6
|
if(eval { require Syntax::Highlight::Universal; }) { |
|
3
|
|
|
|
|
22226
|
|
58
|
0
|
|
|
|
|
0
|
my $hl = Syntax::Highlight::Universal->new(); |
59
|
0
|
0
|
|
|
|
0
|
$syntax->{'pre_proc'}->($hl) if ref $syntax->{'callbacks'} eq 'CODE'; |
60
|
0
|
|
|
|
|
0
|
return Text::InHTML::encode_whitespace( |
61
|
|
|
|
|
|
|
$hl->highlight($format, $string, $syntax->{'callbacks'}), $tabs |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
593
|
return Text::InHTML::encode_plain( $string ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |