line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Handler::MinimalTree; |
2
|
|
|
|
|
|
|
|
3
|
30
|
|
|
30
|
|
34992
|
use strict; |
|
30
|
|
|
|
|
90
|
|
|
30
|
|
|
|
|
1045
|
|
4
|
30
|
|
|
30
|
|
183
|
use warnings; |
|
30
|
|
|
|
|
72
|
|
|
30
|
|
|
|
|
904
|
|
5
|
30
|
|
|
30
|
|
613
|
use namespace::autoclean; |
|
30
|
|
|
|
|
17867
|
|
|
30
|
|
|
|
|
222
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.38'; |
8
|
|
|
|
|
|
|
|
9
|
30
|
|
|
30
|
|
2994
|
use Markdent::Types; |
|
30
|
|
|
|
|
72
|
|
|
30
|
|
|
|
|
347
|
|
10
|
30
|
|
|
30
|
|
766382
|
use Params::ValidationCompiler qw( validation_for ); |
|
30
|
|
|
|
|
35438
|
|
|
30
|
|
|
|
|
2328
|
|
11
|
30
|
|
|
30
|
|
254
|
use Specio::Declare; |
|
30
|
|
|
|
|
107
|
|
|
30
|
|
|
|
|
323
|
|
12
|
30
|
|
|
30
|
|
26743
|
use Tree::Simple; |
|
30
|
|
|
|
|
108981
|
|
|
30
|
|
|
|
|
165
|
|
13
|
|
|
|
|
|
|
|
14
|
30
|
|
|
30
|
|
1623
|
use Moose; |
|
30
|
|
|
|
|
464314
|
|
|
30
|
|
|
|
|
296
|
|
15
|
30
|
|
|
30
|
|
217866
|
use MooseX::SemiAffordanceAccessor; |
|
30
|
|
|
|
|
42069
|
|
|
30
|
|
|
|
|
256
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
with 'Markdent::Role::EventsAsMethods'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $tree_simple_type = object_isa_type('Tree::Simple'); |
20
|
|
|
|
|
|
|
has tree => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => $tree_simple_type, |
23
|
|
|
|
|
|
|
default => sub { |
24
|
|
|
|
|
|
|
Tree::Simple->new( { type => 'document' }, Tree::Simple->ROOT() ); |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
init_arg => undef, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has _current_node => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => t( 'Maybe', of => $tree_simple_type ), |
32
|
|
|
|
|
|
|
init_arg => undef, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub start_document { |
36
|
172
|
|
|
172
|
0
|
396
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
172
|
|
|
|
|
5226
|
$self->_set_current_node( $self->tree() ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub end_document { |
42
|
172
|
|
|
172
|
0
|
370
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
172
|
|
|
|
|
5974
|
$self->_set_current_node(undef); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
my $validator = validation_for( |
49
|
|
|
|
|
|
|
params => [ level => { type => t('HeaderLevel') } ], |
50
|
|
|
|
|
|
|
named_to_list => 1, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub start_header { |
54
|
67
|
|
|
67
|
0
|
134
|
my $self = shift; |
55
|
67
|
|
|
|
|
1221
|
my ($level) = $validator->(@_); |
56
|
|
|
|
|
|
|
|
57
|
67
|
|
|
|
|
1795
|
my $header |
58
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'header', level => $level } ); |
59
|
67
|
|
|
|
|
4257
|
$self->_current_node()->addChild($header); |
60
|
|
|
|
|
|
|
|
61
|
67
|
|
|
|
|
7988
|
$self->_set_current_node($header); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub end_header { |
66
|
67
|
|
|
67
|
0
|
138
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
67
|
|
|
|
|
200
|
$self->_set_current_up_one_level(); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub start_blockquote { |
72
|
21
|
|
|
21
|
0
|
42
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
21
|
|
|
|
|
145
|
my $bq = Tree::Simple->new( { type => 'blockquote' } ); |
75
|
21
|
|
|
|
|
1457
|
$self->_current_node()->addChild($bq); |
76
|
|
|
|
|
|
|
|
77
|
21
|
|
|
|
|
2821
|
$self->_set_current_node($bq); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub end_blockquote { |
81
|
21
|
|
|
21
|
0
|
50
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
21
|
|
|
|
|
61
|
$self->_set_current_up_one_level(); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub start_unordered_list { |
87
|
29
|
|
|
29
|
0
|
52
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
29
|
|
|
|
|
127
|
my $bq = Tree::Simple->new( { type => 'unordered_list' } ); |
90
|
29
|
|
|
|
|
1699
|
$self->_current_node()->addChild($bq); |
91
|
|
|
|
|
|
|
|
92
|
29
|
|
|
|
|
3373
|
$self->_set_current_node($bq); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub end_unordered_list { |
96
|
29
|
|
|
29
|
0
|
51
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
29
|
|
|
|
|
71
|
$self->_set_current_up_one_level(); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub start_ordered_list { |
102
|
7
|
|
|
7
|
0
|
12
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
7
|
|
|
|
|
35
|
my $bq = Tree::Simple->new( { type => 'ordered_list' } ); |
105
|
7
|
|
|
|
|
387
|
$self->_current_node()->addChild($bq); |
106
|
|
|
|
|
|
|
|
107
|
7
|
|
|
|
|
715
|
$self->_set_current_node($bq); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub end_ordered_list { |
111
|
7
|
|
|
7
|
0
|
13
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
7
|
|
|
|
|
15
|
$self->_set_current_up_one_level(); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
{ |
117
|
|
|
|
|
|
|
my $validator = validation_for( |
118
|
|
|
|
|
|
|
params => [ bullet => { type => t('Str') } ], |
119
|
|
|
|
|
|
|
named_to_list => 1, |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub start_list_item { |
123
|
69
|
|
|
69
|
0
|
134
|
my $self = shift; |
124
|
69
|
|
|
|
|
1139
|
my ($bullet) = $validator->(@_); |
125
|
|
|
|
|
|
|
|
126
|
69
|
|
|
|
|
1636
|
my $list_item |
127
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'list_item', bullet => $bullet } ); |
128
|
69
|
|
|
|
|
3699
|
$self->_current_node()->addChild($list_item); |
129
|
|
|
|
|
|
|
|
130
|
69
|
|
|
|
|
8264
|
$self->_set_current_node($list_item); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub end_list_item { |
135
|
69
|
|
|
69
|
0
|
123
|
my $self = shift; |
136
|
|
|
|
|
|
|
|
137
|
69
|
|
|
|
|
149
|
$self->_set_current_up_one_level(); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
my $validator = validation_for( |
142
|
|
|
|
|
|
|
params => [ text => { type => t('Str') } ], |
143
|
|
|
|
|
|
|
named_to_list => 1, |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub preformatted { |
147
|
169
|
|
|
169
|
0
|
612
|
my $self = shift; |
148
|
169
|
|
|
|
|
2915
|
my ($text) = $validator->(@_); |
149
|
|
|
|
|
|
|
|
150
|
169
|
|
|
|
|
4091
|
my $pre_node |
151
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'preformatted', text => $text } ); |
152
|
169
|
|
|
|
|
10169
|
$self->_current_node()->addChild($pre_node); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
{ |
157
|
|
|
|
|
|
|
my $validator = validation_for( |
158
|
|
|
|
|
|
|
params => [ |
159
|
|
|
|
|
|
|
code => { type => t('Str') }, |
160
|
|
|
|
|
|
|
language => { |
161
|
|
|
|
|
|
|
type => t('Str'), |
162
|
|
|
|
|
|
|
optional => 1, |
163
|
|
|
|
|
|
|
}, |
164
|
|
|
|
|
|
|
], |
165
|
|
|
|
|
|
|
named_to_list => 1, |
166
|
|
|
|
|
|
|
); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub code_block { |
169
|
7
|
|
|
7
|
0
|
15
|
my $self = shift; |
170
|
7
|
|
|
|
|
131
|
my ( $code, $language ) = $validator->(@_); |
171
|
|
|
|
|
|
|
|
172
|
7
|
|
|
|
|
300
|
my $code_block_node = Tree::Simple->new( |
173
|
|
|
|
|
|
|
{ |
174
|
|
|
|
|
|
|
type => 'code_block', |
175
|
|
|
|
|
|
|
code => $code, |
176
|
|
|
|
|
|
|
language => $language, |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
7
|
|
|
|
|
516
|
$self->_current_node()->addChild($code_block_node); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub start_paragraph { |
185
|
381
|
|
|
381
|
0
|
978
|
my $self = shift; |
186
|
|
|
|
|
|
|
|
187
|
381
|
|
|
|
|
1823
|
my $para = Tree::Simple->new( { type => 'paragraph' } ); |
188
|
381
|
|
|
|
|
24637
|
$self->_current_node()->addChild($para); |
189
|
|
|
|
|
|
|
|
190
|
381
|
|
|
|
|
44643
|
$self->_set_current_node($para); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub end_paragraph { |
194
|
381
|
|
|
381
|
0
|
733
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
381
|
|
|
|
|
943
|
$self->_set_current_up_one_level(); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
{ |
200
|
|
|
|
|
|
|
my $validator = validation_for( |
201
|
|
|
|
|
|
|
params => { |
202
|
|
|
|
|
|
|
caption => { |
203
|
|
|
|
|
|
|
type => t('Str'), |
204
|
|
|
|
|
|
|
optional => 1, |
205
|
|
|
|
|
|
|
}, |
206
|
|
|
|
|
|
|
}, |
207
|
|
|
|
|
|
|
); |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub start_table { |
210
|
21
|
|
|
21
|
0
|
54
|
my $self = shift; |
211
|
21
|
|
|
|
|
459
|
my %p = $validator->(@_); |
212
|
|
|
|
|
|
|
|
213
|
21
|
|
|
|
|
639
|
my $para = Tree::Simple->new( { type => 'table', %p } ); |
214
|
21
|
|
|
|
|
1602
|
$self->_current_node()->addChild($para); |
215
|
|
|
|
|
|
|
|
216
|
21
|
|
|
|
|
3281
|
$self->_set_current_node($para); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub end_table { |
221
|
21
|
|
|
21
|
0
|
48
|
my $self = shift; |
222
|
|
|
|
|
|
|
|
223
|
21
|
|
|
|
|
55
|
$self->_set_current_up_one_level(); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub start_table_header { |
227
|
17
|
|
|
17
|
0
|
37
|
my $self = shift; |
228
|
|
|
|
|
|
|
|
229
|
17
|
|
|
|
|
96
|
my $para = Tree::Simple->new( { type => 'table_header' } ); |
230
|
17
|
|
|
|
|
1145
|
$self->_current_node()->addChild($para); |
231
|
|
|
|
|
|
|
|
232
|
17
|
|
|
|
|
2457
|
$self->_set_current_node($para); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub end_table_header { |
236
|
17
|
|
|
17
|
0
|
41
|
my $self = shift; |
237
|
|
|
|
|
|
|
|
238
|
17
|
|
|
|
|
48
|
$self->_set_current_up_one_level(); |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub start_table_body { |
242
|
23
|
|
|
23
|
0
|
46
|
my $self = shift; |
243
|
|
|
|
|
|
|
|
244
|
23
|
|
|
|
|
112
|
my $para = Tree::Simple->new( { type => 'table_body' } ); |
245
|
23
|
|
|
|
|
1638
|
$self->_current_node()->addChild($para); |
246
|
|
|
|
|
|
|
|
247
|
23
|
|
|
|
|
2980
|
$self->_set_current_node($para); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub end_table_body { |
251
|
23
|
|
|
23
|
0
|
51
|
my $self = shift; |
252
|
|
|
|
|
|
|
|
253
|
23
|
|
|
|
|
80
|
$self->_set_current_up_one_level(); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub start_table_row { |
257
|
159
|
|
|
159
|
0
|
312
|
my $self = shift; |
258
|
|
|
|
|
|
|
|
259
|
159
|
|
|
|
|
700
|
my $para = Tree::Simple->new( { type => 'table_row' } ); |
260
|
159
|
|
|
|
|
10522
|
$self->_current_node()->addChild($para); |
261
|
|
|
|
|
|
|
|
262
|
159
|
|
|
|
|
22118
|
$self->_set_current_node($para); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub end_table_row { |
266
|
159
|
|
|
159
|
0
|
329
|
my $self = shift; |
267
|
|
|
|
|
|
|
|
268
|
159
|
|
|
|
|
370
|
$self->_set_current_up_one_level(); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
{ |
272
|
|
|
|
|
|
|
my $validator = validation_for( |
273
|
|
|
|
|
|
|
params => { |
274
|
|
|
|
|
|
|
alignment => { |
275
|
|
|
|
|
|
|
type => t('TableCellAlignment'), |
276
|
|
|
|
|
|
|
optional => 1, |
277
|
|
|
|
|
|
|
}, |
278
|
|
|
|
|
|
|
colspan => { type => t('PositiveInt') }, |
279
|
|
|
|
|
|
|
is_header_cell => { type => t('Bool') }, |
280
|
|
|
|
|
|
|
}, |
281
|
|
|
|
|
|
|
); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub start_table_cell { |
284
|
628
|
|
|
628
|
0
|
1095
|
my $self = shift; |
285
|
628
|
|
|
|
|
10958
|
my %p = $validator->(@_); |
286
|
|
|
|
|
|
|
|
287
|
628
|
|
|
|
|
28907
|
my $para = Tree::Simple->new( { type => 'table_cell', %p } ); |
288
|
628
|
|
|
|
|
41808
|
$self->_current_node()->addChild($para); |
289
|
|
|
|
|
|
|
|
290
|
628
|
|
|
|
|
90713
|
$self->_set_current_node($para); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub end_table_cell { |
295
|
628
|
|
|
628
|
0
|
1112
|
my $self = shift; |
296
|
|
|
|
|
|
|
|
297
|
628
|
|
|
|
|
1438
|
$self->_set_current_up_one_level(); |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub start_emphasis { |
301
|
48
|
|
|
48
|
0
|
106
|
my $self = shift; |
302
|
|
|
|
|
|
|
|
303
|
48
|
|
|
|
|
155
|
$self->_start_markup_node('emphasis'); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub end_emphasis { |
307
|
48
|
|
|
48
|
0
|
105
|
my $self = shift; |
308
|
|
|
|
|
|
|
|
309
|
48
|
|
|
|
|
129
|
$self->_set_current_up_one_level(); |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub start_strong { |
313
|
10
|
|
|
10
|
0
|
26
|
my $self = shift; |
314
|
|
|
|
|
|
|
|
315
|
10
|
|
|
|
|
62
|
$self->_start_markup_node('strong'); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub end_strong { |
319
|
10
|
|
|
10
|
0
|
28
|
my $self = shift; |
320
|
|
|
|
|
|
|
|
321
|
10
|
|
|
|
|
35
|
$self->_set_current_up_one_level(); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub start_code { |
325
|
106
|
|
|
106
|
0
|
203
|
my $self = shift; |
326
|
|
|
|
|
|
|
|
327
|
106
|
|
|
|
|
275
|
$self->_start_markup_node('code'); |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub end_code { |
331
|
106
|
|
|
106
|
0
|
215
|
my $self = shift; |
332
|
|
|
|
|
|
|
|
333
|
106
|
|
|
|
|
258
|
$self->_set_current_up_one_level(); |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
{ |
337
|
|
|
|
|
|
|
my $validator = validation_for( |
338
|
|
|
|
|
|
|
params => { |
339
|
|
|
|
|
|
|
uri => { |
340
|
|
|
|
|
|
|
type => t('Str'), |
341
|
|
|
|
|
|
|
optional => 1, |
342
|
|
|
|
|
|
|
}, |
343
|
|
|
|
|
|
|
}, |
344
|
|
|
|
|
|
|
); |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub auto_link { |
347
|
6
|
|
|
6
|
0
|
12
|
my $self = shift; |
348
|
6
|
|
|
|
|
97
|
my %p = $validator->(@_); |
349
|
|
|
|
|
|
|
|
350
|
6
|
|
|
|
|
169
|
my $link_node = Tree::Simple->new( { type => 'auto_link', %p } ); |
351
|
6
|
|
|
|
|
379
|
$self->_current_node()->addChild($link_node); |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
{ |
356
|
|
|
|
|
|
|
my $validator = validation_for( |
357
|
|
|
|
|
|
|
params => { |
358
|
|
|
|
|
|
|
uri => { type => t('Str') }, |
359
|
|
|
|
|
|
|
title => { |
360
|
|
|
|
|
|
|
type => t('Str'), |
361
|
|
|
|
|
|
|
optional => 1, |
362
|
|
|
|
|
|
|
}, |
363
|
|
|
|
|
|
|
id => { |
364
|
|
|
|
|
|
|
type => t('Str'), |
365
|
|
|
|
|
|
|
optional => 1, |
366
|
|
|
|
|
|
|
}, |
367
|
|
|
|
|
|
|
is_implicit_id => { type => t('Bool') }, |
368
|
|
|
|
|
|
|
}, |
369
|
|
|
|
|
|
|
); |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
sub start_link { |
372
|
35
|
|
|
35
|
0
|
77
|
my $self = shift; |
373
|
35
|
|
|
|
|
606
|
my %p = $validator->(@_); |
374
|
|
|
|
|
|
|
|
375
|
35
|
|
|
|
|
1751
|
delete @p{ grep { !defined $p{$_} } keys %p }; |
|
111
|
|
|
|
|
214
|
|
376
|
|
|
|
|
|
|
|
377
|
35
|
|
|
|
|
169
|
$self->_start_markup_node( 'link', %p ); |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub end_link { |
382
|
35
|
|
|
35
|
0
|
93
|
my $self = shift; |
383
|
|
|
|
|
|
|
|
384
|
35
|
|
|
|
|
112
|
$self->_set_current_up_one_level(); |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
sub line_break { |
388
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
389
|
|
|
|
|
|
|
|
390
|
3
|
|
|
|
|
14
|
my $break_node = Tree::Simple->new( { type => 'line_break' } ); |
391
|
|
|
|
|
|
|
|
392
|
3
|
|
|
|
|
191
|
$self->_current_node()->addChild($break_node); |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
{ |
396
|
|
|
|
|
|
|
my $validator = validation_for( |
397
|
|
|
|
|
|
|
params => [ |
398
|
|
|
|
|
|
|
text => { type => t('Str') }, |
399
|
|
|
|
|
|
|
], |
400
|
|
|
|
|
|
|
named_to_list => 1, |
401
|
|
|
|
|
|
|
); |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
sub text { |
404
|
1535
|
|
|
1535
|
0
|
2773
|
my $self = shift; |
405
|
1535
|
|
|
|
|
26318
|
my ($text) = $validator->(@_); |
406
|
|
|
|
|
|
|
|
407
|
1535
|
|
|
|
|
39429
|
my $text_node |
408
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'text', text => $text } ); |
409
|
1535
|
|
|
|
|
97405
|
$self->_current_node()->addChild($text_node); |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
{ |
414
|
|
|
|
|
|
|
my $validator = validation_for( |
415
|
|
|
|
|
|
|
params => [ |
416
|
|
|
|
|
|
|
tag => { type => t('Str') }, |
417
|
|
|
|
|
|
|
attributes => { type => t('HashRef') }, |
418
|
|
|
|
|
|
|
], |
419
|
|
|
|
|
|
|
named_to_list => 1, |
420
|
|
|
|
|
|
|
); |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub start_html_tag { |
423
|
6
|
|
|
6
|
0
|
14
|
my $self = shift; |
424
|
6
|
|
|
|
|
111
|
my ( $tag, $attributes ) = $validator->(@_); |
425
|
|
|
|
|
|
|
|
426
|
6
|
|
|
|
|
247
|
my $tag_node = Tree::Simple->new( |
427
|
|
|
|
|
|
|
{ |
428
|
|
|
|
|
|
|
type => 'start_html_tag', |
429
|
|
|
|
|
|
|
tag => $tag, |
430
|
|
|
|
|
|
|
attributes => $attributes, |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
); |
433
|
|
|
|
|
|
|
|
434
|
6
|
|
|
|
|
436
|
$self->_current_node()->addChild($tag_node); |
435
|
|
|
|
|
|
|
|
436
|
6
|
|
|
|
|
742
|
$self->_set_current_node($tag_node); |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
sub end_html_tag { |
441
|
6
|
|
|
6
|
0
|
27
|
my $self = shift; |
442
|
|
|
|
|
|
|
|
443
|
6
|
|
|
|
|
24
|
$self->_set_current_up_one_level(); |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
{ |
447
|
|
|
|
|
|
|
my $validator = validation_for( |
448
|
|
|
|
|
|
|
params => [ |
449
|
|
|
|
|
|
|
text => { type => t('Str') }, |
450
|
|
|
|
|
|
|
], |
451
|
|
|
|
|
|
|
named_to_list => 1, |
452
|
|
|
|
|
|
|
); |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
sub html_comment_block { |
455
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
456
|
2
|
|
|
|
|
40
|
my ($text) = $validator->(@_); |
457
|
|
|
|
|
|
|
|
458
|
2
|
|
|
|
|
61
|
my $html_node = Tree::Simple->new( |
459
|
|
|
|
|
|
|
{ type => 'html_comment_block', text => $text } ); |
460
|
2
|
|
|
|
|
130
|
$self->_current_node()->addChild($html_node); |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
{ |
465
|
|
|
|
|
|
|
my $validator = validation_for( |
466
|
|
|
|
|
|
|
params => [ |
467
|
|
|
|
|
|
|
text => { type => t('Str') }, |
468
|
|
|
|
|
|
|
], |
469
|
|
|
|
|
|
|
named_to_list => 1, |
470
|
|
|
|
|
|
|
); |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
sub html_comment { |
473
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
474
|
1
|
|
|
|
|
21
|
my ($text) = $validator->(@_); |
475
|
|
|
|
|
|
|
|
476
|
1
|
|
|
|
|
36
|
my $html_node |
477
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'html_comment', text => $text } ); |
478
|
1
|
|
|
|
|
64
|
$self->_current_node()->addChild($html_node); |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
{ |
483
|
|
|
|
|
|
|
my $validator = validation_for( |
484
|
|
|
|
|
|
|
params => [ |
485
|
|
|
|
|
|
|
tag => { type => t('Str') }, |
486
|
|
|
|
|
|
|
attributes => { type => t('HashRef') }, |
487
|
|
|
|
|
|
|
], |
488
|
|
|
|
|
|
|
named_to_list => 1, |
489
|
|
|
|
|
|
|
); |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
sub html_tag { |
492
|
3
|
|
|
3
|
0
|
8
|
my $self = shift; |
493
|
3
|
|
|
|
|
56
|
my ( $tag, $attributes ) = $validator->(@_); |
494
|
|
|
|
|
|
|
|
495
|
3
|
|
|
|
|
122
|
my $tag_node = Tree::Simple->new( |
496
|
|
|
|
|
|
|
{ |
497
|
|
|
|
|
|
|
type => 'html_tag', |
498
|
|
|
|
|
|
|
tag => $tag, |
499
|
|
|
|
|
|
|
attributes => $attributes, |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
); |
502
|
|
|
|
|
|
|
|
503
|
3
|
|
|
|
|
218
|
$self->_current_node()->addChild($tag_node); |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
{ |
508
|
|
|
|
|
|
|
my $validator = validation_for( |
509
|
|
|
|
|
|
|
params => [ |
510
|
|
|
|
|
|
|
entity => { type => t('Str') }, |
511
|
|
|
|
|
|
|
], |
512
|
|
|
|
|
|
|
named_to_list => 1, |
513
|
|
|
|
|
|
|
); |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
sub html_entity { |
516
|
7
|
|
|
7
|
0
|
14
|
my $self = shift; |
517
|
7
|
|
|
|
|
128
|
my ($entity) = $validator->(@_); |
518
|
|
|
|
|
|
|
|
519
|
7
|
|
|
|
|
215
|
my $html_node |
520
|
|
|
|
|
|
|
= Tree::Simple->new( |
521
|
|
|
|
|
|
|
{ type => 'html_entity', entity => $entity } ); |
522
|
7
|
|
|
|
|
460
|
$self->_current_node()->addChild($html_node); |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
{ |
527
|
|
|
|
|
|
|
my $validator = validation_for( |
528
|
|
|
|
|
|
|
params => [ |
529
|
|
|
|
|
|
|
html => { type => t('Str') }, |
530
|
|
|
|
|
|
|
], |
531
|
|
|
|
|
|
|
named_to_list => 1, |
532
|
|
|
|
|
|
|
); |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
sub html_block { |
535
|
14
|
|
|
14
|
0
|
33
|
my $self = shift; |
536
|
14
|
|
|
|
|
270
|
my ($html) = $validator->(@_); |
537
|
|
|
|
|
|
|
|
538
|
14
|
|
|
|
|
430
|
my $html_node |
539
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'html_block', html => $html } ); |
540
|
14
|
|
|
|
|
959
|
$self->_current_node()->addChild($html_node); |
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
} |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
{ |
545
|
|
|
|
|
|
|
my $validator = validation_for( |
546
|
|
|
|
|
|
|
params => { |
547
|
|
|
|
|
|
|
alt_text => { type => t('Str') }, |
548
|
|
|
|
|
|
|
uri => { type => t('Str') }, |
549
|
|
|
|
|
|
|
title => { |
550
|
|
|
|
|
|
|
type => t('Str'), |
551
|
|
|
|
|
|
|
optional => 1, |
552
|
|
|
|
|
|
|
}, |
553
|
|
|
|
|
|
|
id => { |
554
|
|
|
|
|
|
|
type => t('Str'), |
555
|
|
|
|
|
|
|
optional => 1, |
556
|
|
|
|
|
|
|
}, |
557
|
|
|
|
|
|
|
is_implicit_id => { |
558
|
|
|
|
|
|
|
type => t('Bool'), |
559
|
|
|
|
|
|
|
optional => 1, |
560
|
|
|
|
|
|
|
}, |
561
|
|
|
|
|
|
|
}, |
562
|
|
|
|
|
|
|
); |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
sub image { |
565
|
8
|
|
|
8
|
0
|
19
|
my $self = shift; |
566
|
8
|
|
|
|
|
152
|
my %p = $validator->(@_); |
567
|
|
|
|
|
|
|
|
568
|
8
|
|
|
|
|
448
|
my $image_node = Tree::Simple->new( { type => 'image', %p } ); |
569
|
8
|
|
|
|
|
523
|
$self->_current_node()->addChild($image_node); |
570
|
|
|
|
|
|
|
} |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
sub horizontal_rule { |
574
|
6
|
|
|
6
|
0
|
12
|
my $self = shift; |
575
|
|
|
|
|
|
|
|
576
|
6
|
|
|
|
|
40
|
my $hr_node = Tree::Simple->new( { type => 'horizontal_rule' } ); |
577
|
6
|
|
|
|
|
447
|
$self->_current_node()->addChild($hr_node); |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
sub _start_markup_node { |
581
|
199
|
|
|
199
|
|
331
|
my $self = shift; |
582
|
199
|
|
|
|
|
303
|
my $type = shift; |
583
|
|
|
|
|
|
|
|
584
|
199
|
|
|
|
|
884
|
my $markup = Tree::Simple->new( { type => $type, @_ } ); |
585
|
199
|
|
|
|
|
11813
|
$self->_current_node()->addChild($markup); |
586
|
|
|
|
|
|
|
|
587
|
199
|
|
|
|
|
22625
|
$self->_set_current_node($markup); |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
sub _set_current_up_one_level { |
591
|
1627
|
|
|
1627
|
|
2377
|
my $self = shift; |
592
|
|
|
|
|
|
|
|
593
|
1627
|
|
|
|
|
47207
|
$self->_set_current_node( $self->_current_node()->getParent() ); |
594
|
|
|
|
|
|
|
} |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
1; |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# ABSTRACT: A Markdent handler which builds a tree |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
__END__ |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=pod |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
=encoding UTF-8 |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=head1 NAME |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
Markdent::Handler::MinimalTree - A Markdent handler which builds a tree |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head1 VERSION |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
version 0.38 |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
=head1 DESCRIPTION |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
This class implements an event receiver which in turn builds a tree using |
619
|
|
|
|
|
|
|
L<Tree::Simple>. |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
It is primarily intended for use in testing. |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=head1 METHODS |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
This class provides the following methods: |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=head2 Markdent::Handler::MinimalTree->new(...) |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
This method creates a new handler. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
=head2 $mhmt->tree() |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
Returns the root tree for the document. |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
=head1 ROLES |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
This class does the L<Markdent::Role::EventsAsMethods> and |
638
|
|
|
|
|
|
|
L<Markdent::Role::Handler> roles. |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
=head1 BUGS |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=head1 SOURCE |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=head1 AUTHOR |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Dave Rolsky. |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
661
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
The full text of the license can be found in the |
664
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=cut |