line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::MojoSlides::MoreTagHelpers; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
9024
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
37
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# list stolen from HTML::Tags (Web::Simple) |
6
|
|
|
|
|
|
|
my @HTML_TAGS = qw( |
7
|
|
|
|
|
|
|
a |
8
|
|
|
|
|
|
|
aside |
9
|
|
|
|
|
|
|
audio |
10
|
|
|
|
|
|
|
blockquote |
11
|
|
|
|
|
|
|
body |
12
|
|
|
|
|
|
|
br |
13
|
|
|
|
|
|
|
button |
14
|
|
|
|
|
|
|
canvas |
15
|
|
|
|
|
|
|
caption |
16
|
|
|
|
|
|
|
cite |
17
|
|
|
|
|
|
|
code |
18
|
|
|
|
|
|
|
col |
19
|
|
|
|
|
|
|
colgroup |
20
|
|
|
|
|
|
|
div |
21
|
|
|
|
|
|
|
dd |
22
|
|
|
|
|
|
|
del |
23
|
|
|
|
|
|
|
dl |
24
|
|
|
|
|
|
|
dt |
25
|
|
|
|
|
|
|
em |
26
|
|
|
|
|
|
|
embed |
27
|
|
|
|
|
|
|
fieldset |
28
|
|
|
|
|
|
|
figcaption |
29
|
|
|
|
|
|
|
figure |
30
|
|
|
|
|
|
|
footer |
31
|
|
|
|
|
|
|
h1 |
32
|
|
|
|
|
|
|
h2 |
33
|
|
|
|
|
|
|
h3 |
34
|
|
|
|
|
|
|
h4 |
35
|
|
|
|
|
|
|
h5 |
36
|
|
|
|
|
|
|
h6 |
37
|
|
|
|
|
|
|
head |
38
|
|
|
|
|
|
|
header |
39
|
|
|
|
|
|
|
hr |
40
|
|
|
|
|
|
|
html |
41
|
|
|
|
|
|
|
i |
42
|
|
|
|
|
|
|
iframe |
43
|
|
|
|
|
|
|
img |
44
|
|
|
|
|
|
|
label |
45
|
|
|
|
|
|
|
legend |
46
|
|
|
|
|
|
|
li |
47
|
|
|
|
|
|
|
noscript |
48
|
|
|
|
|
|
|
object |
49
|
|
|
|
|
|
|
ol |
50
|
|
|
|
|
|
|
optgroup |
51
|
|
|
|
|
|
|
option |
52
|
|
|
|
|
|
|
output |
53
|
|
|
|
|
|
|
p |
54
|
|
|
|
|
|
|
pre |
55
|
|
|
|
|
|
|
rp |
56
|
|
|
|
|
|
|
rt |
57
|
|
|
|
|
|
|
ruby |
58
|
|
|
|
|
|
|
script |
59
|
|
|
|
|
|
|
span |
60
|
|
|
|
|
|
|
strong |
61
|
|
|
|
|
|
|
style |
62
|
|
|
|
|
|
|
table |
63
|
|
|
|
|
|
|
tbody |
64
|
|
|
|
|
|
|
td |
65
|
|
|
|
|
|
|
textarea |
66
|
|
|
|
|
|
|
tfoot |
67
|
|
|
|
|
|
|
th |
68
|
|
|
|
|
|
|
thead |
69
|
|
|
|
|
|
|
tr |
70
|
|
|
|
|
|
|
ul |
71
|
|
|
|
|
|
|
video |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub register { |
75
|
4
|
|
|
4
|
1
|
180
|
my ($plugin, $app) = @_; |
76
|
4
|
|
|
|
|
10
|
foreach my $tag (@HTML_TAGS) { |
77
|
260
|
|
|
|
|
20467
|
$app->helper( $tag => _tag($tag) ); |
78
|
|
|
|
|
|
|
} |
79
|
4
|
|
|
|
|
340
|
$app->helper( incremental => \&_incremental ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _tag { |
83
|
260
|
|
|
260
|
|
400
|
my $tag = shift; |
84
|
|
|
|
|
|
|
return sub { |
85
|
16
|
|
|
16
|
|
155119
|
my $self = shift; |
86
|
16
|
|
|
|
|
30
|
my $id; |
87
|
|
|
|
|
|
|
my @class; |
88
|
16
|
100
|
|
|
|
73
|
if ($_[0] =~ /^[#.]/) { |
89
|
4
|
|
|
|
|
10
|
my $sel = shift; |
90
|
4
|
|
|
|
|
21
|
($id) = $sel =~ /\#([^#. ]+)/; |
91
|
4
|
|
|
|
|
20
|
@class = $sel =~ /\.([^#. ]+)/g; |
92
|
|
|
|
|
|
|
} |
93
|
16
|
100
|
|
|
|
175
|
return $self->tag( |
|
|
100
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$tag, |
95
|
|
|
|
|
|
|
$id ? ( id => $id ) : (), |
96
|
|
|
|
|
|
|
@class ? ( class => join(' ', @class) ) : (), |
97
|
|
|
|
|
|
|
@_ |
98
|
|
|
|
|
|
|
); |
99
|
260
|
|
|
|
|
1494
|
}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _gen_pod_list { |
103
|
0
|
|
|
0
|
|
0
|
my @list = map { "=item $_" } @HTML_TAGS; |
|
0
|
|
|
|
|
0
|
|
104
|
0
|
|
|
|
|
0
|
return '=over', @list, '=back'; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _incremental { |
108
|
2
|
|
|
2
|
|
253
|
my $c = shift; |
109
|
2
|
|
|
|
|
4
|
my $text = pop; |
110
|
2
|
|
50
|
|
|
13
|
my $i = shift || 1; |
111
|
|
|
|
|
|
|
|
112
|
2
|
100
|
|
|
|
3
|
$text = $text->() if eval { ref $text eq 'CODE' }; |
|
2
|
|
|
|
|
13
|
|
113
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
142
|
require Mojo::DOM; |
115
|
2
|
|
|
|
|
17
|
my $dom = Mojo::DOM->new($text); |
116
|
2
|
|
|
|
|
1019
|
my $children = $dom->children; |
117
|
2
|
100
|
|
|
|
369
|
if ($children->size == 1) { |
118
|
1
|
|
|
|
|
40
|
$children = $children->[0]->children; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
$children->each(sub{ |
121
|
4
|
|
|
4
|
|
94
|
$_->{ms_overlay} = $i++ . '-'; |
122
|
2
|
|
|
|
|
199
|
}); |
123
|
|
|
|
|
|
|
|
124
|
2
|
|
|
|
|
73
|
require Mojo::ByteStream; |
125
|
2
|
|
|
|
|
7
|
return Mojo::ByteStream->new($dom->to_string); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |