line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Handler::MinimalTree; |
2
|
|
|
|
|
|
|
|
3
|
31
|
|
|
31
|
|
37777
|
use strict; |
|
31
|
|
|
|
|
85
|
|
|
31
|
|
|
|
|
1015
|
|
4
|
31
|
|
|
31
|
|
166
|
use warnings; |
|
31
|
|
|
|
|
65
|
|
|
31
|
|
|
|
|
1038
|
|
5
|
31
|
|
|
31
|
|
642
|
use namespace::autoclean; |
|
31
|
|
|
|
|
18474
|
|
|
31
|
|
|
|
|
266
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.39'; |
8
|
|
|
|
|
|
|
|
9
|
31
|
|
|
31
|
|
3446
|
use Markdent::Types; |
|
31
|
|
|
|
|
68
|
|
|
31
|
|
|
|
|
254
|
|
10
|
31
|
|
|
31
|
|
742352
|
use Params::ValidationCompiler qw( validation_for ); |
|
31
|
|
|
|
|
36825
|
|
|
31
|
|
|
|
|
2355
|
|
11
|
31
|
|
|
31
|
|
267
|
use Specio::Declare; |
|
31
|
|
|
|
|
94
|
|
|
31
|
|
|
|
|
377
|
|
12
|
31
|
|
|
31
|
|
28762
|
use Tree::Simple; |
|
31
|
|
|
|
|
106052
|
|
|
31
|
|
|
|
|
176
|
|
13
|
|
|
|
|
|
|
|
14
|
31
|
|
|
31
|
|
1742
|
use Moose; |
|
31
|
|
|
|
|
476691
|
|
|
31
|
|
|
|
|
331
|
|
15
|
31
|
|
|
31
|
|
217833
|
use MooseX::SemiAffordanceAccessor; |
|
31
|
|
|
|
|
44010
|
|
|
31
|
|
|
|
|
292
|
|
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
|
175
|
|
|
175
|
0
|
370
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
175
|
|
|
|
|
5130
|
$self->_set_current_node( $self->tree ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub end_document { |
42
|
175
|
|
|
175
|
0
|
371
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
175
|
|
|
|
|
6051
|
$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
|
166
|
my $self = shift; |
55
|
67
|
|
|
|
|
1348
|
my ($level) = $validator->(@_); |
56
|
|
|
|
|
|
|
|
57
|
67
|
|
|
|
|
2034
|
my $header |
58
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'header', level => $level } ); |
59
|
67
|
|
|
|
|
4394
|
$self->_current_node->addChild($header); |
60
|
|
|
|
|
|
|
|
61
|
67
|
|
|
|
|
7799
|
$self->_set_current_node($header); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub end_header { |
66
|
67
|
|
|
67
|
0
|
150
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
67
|
|
|
|
|
227
|
$self->_set_current_up_one_level; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub start_blockquote { |
72
|
21
|
|
|
21
|
0
|
45
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
21
|
|
|
|
|
123
|
my $bq = Tree::Simple->new( { type => 'blockquote' } ); |
75
|
21
|
|
|
|
|
1478
|
$self->_current_node->addChild($bq); |
76
|
|
|
|
|
|
|
|
77
|
21
|
|
|
|
|
2785
|
$self->_set_current_node($bq); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub end_blockquote { |
81
|
21
|
|
|
21
|
0
|
41
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
21
|
|
|
|
|
64
|
$self->_set_current_up_one_level; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub start_unordered_list { |
87
|
29
|
|
|
29
|
0
|
51
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
29
|
|
|
|
|
153
|
my $bq = Tree::Simple->new( { type => 'unordered_list' } ); |
90
|
29
|
|
|
|
|
1695
|
$self->_current_node->addChild($bq); |
91
|
|
|
|
|
|
|
|
92
|
29
|
|
|
|
|
3383
|
$self->_set_current_node($bq); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub end_unordered_list { |
96
|
29
|
|
|
29
|
0
|
54
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
29
|
|
|
|
|
62
|
$self->_set_current_up_one_level; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub start_ordered_list { |
102
|
7
|
|
|
7
|
0
|
13
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
7
|
|
|
|
|
30
|
my $bq = Tree::Simple->new( { type => 'ordered_list' } ); |
105
|
7
|
|
|
|
|
433
|
$self->_current_node->addChild($bq); |
106
|
|
|
|
|
|
|
|
107
|
7
|
|
|
|
|
853
|
$self->_set_current_node($bq); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub end_ordered_list { |
111
|
7
|
|
|
7
|
0
|
13
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
7
|
|
|
|
|
13
|
$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
|
114
|
my $self = shift; |
124
|
69
|
|
|
|
|
1050
|
my ($bullet) = $validator->(@_); |
125
|
|
|
|
|
|
|
|
126
|
69
|
|
|
|
|
1622
|
my $list_item |
127
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'list_item', bullet => $bullet } ); |
128
|
69
|
|
|
|
|
3716
|
$self->_current_node->addChild($list_item); |
129
|
|
|
|
|
|
|
|
130
|
69
|
|
|
|
|
8217
|
$self->_set_current_node($list_item); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub end_list_item { |
135
|
69
|
|
|
69
|
0
|
107
|
my $self = shift; |
136
|
|
|
|
|
|
|
|
137
|
69
|
|
|
|
|
155
|
$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
|
381
|
my $self = shift; |
148
|
169
|
|
|
|
|
3238
|
my ($text) = $validator->(@_); |
149
|
|
|
|
|
|
|
|
150
|
169
|
|
|
|
|
5410
|
my $pre_node |
151
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'preformatted', text => $text } ); |
152
|
169
|
|
|
|
|
11046
|
$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
|
16
|
my $self = shift; |
170
|
7
|
|
|
|
|
121
|
my ( $code, $language ) = $validator->(@_); |
171
|
|
|
|
|
|
|
|
172
|
7
|
|
|
|
|
287
|
my $code_block_node = Tree::Simple->new( |
173
|
|
|
|
|
|
|
{ |
174
|
|
|
|
|
|
|
type => 'code_block', |
175
|
|
|
|
|
|
|
code => $code, |
176
|
|
|
|
|
|
|
language => $language, |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
7
|
|
|
|
|
434
|
$self->_current_node->addChild($code_block_node); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub start_paragraph { |
185
|
384
|
|
|
384
|
0
|
797
|
my $self = shift; |
186
|
|
|
|
|
|
|
|
187
|
384
|
|
|
|
|
2128
|
my $para = Tree::Simple->new( { type => 'paragraph' } ); |
188
|
384
|
|
|
|
|
25423
|
$self->_current_node->addChild($para); |
189
|
|
|
|
|
|
|
|
190
|
384
|
|
|
|
|
45655
|
$self->_set_current_node($para); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub end_paragraph { |
194
|
384
|
|
|
384
|
0
|
781
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
384
|
|
|
|
|
1254
|
$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
|
56
|
my $self = shift; |
211
|
21
|
|
|
|
|
419
|
my %p = $validator->(@_); |
212
|
|
|
|
|
|
|
|
213
|
21
|
|
|
|
|
600
|
my $para = Tree::Simple->new( { type => 'table', %p } ); |
214
|
21
|
|
|
|
|
1471
|
$self->_current_node->addChild($para); |
215
|
|
|
|
|
|
|
|
216
|
21
|
|
|
|
|
2833
|
$self->_set_current_node($para); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub end_table { |
221
|
21
|
|
|
21
|
0
|
44
|
my $self = shift; |
222
|
|
|
|
|
|
|
|
223
|
21
|
|
|
|
|
59
|
$self->_set_current_up_one_level; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub start_table_header { |
227
|
17
|
|
|
17
|
0
|
40
|
my $self = shift; |
228
|
|
|
|
|
|
|
|
229
|
17
|
|
|
|
|
91
|
my $para = Tree::Simple->new( { type => 'table_header' } ); |
230
|
17
|
|
|
|
|
1151
|
$self->_current_node->addChild($para); |
231
|
|
|
|
|
|
|
|
232
|
17
|
|
|
|
|
2342
|
$self->_set_current_node($para); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub end_table_header { |
236
|
17
|
|
|
17
|
0
|
49
|
my $self = shift; |
237
|
|
|
|
|
|
|
|
238
|
17
|
|
|
|
|
55
|
$self->_set_current_up_one_level; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub start_table_body { |
242
|
23
|
|
|
23
|
0
|
46
|
my $self = shift; |
243
|
|
|
|
|
|
|
|
244
|
23
|
|
|
|
|
121
|
my $para = Tree::Simple->new( { type => 'table_body' } ); |
245
|
23
|
|
|
|
|
1628
|
$self->_current_node->addChild($para); |
246
|
|
|
|
|
|
|
|
247
|
23
|
|
|
|
|
2845
|
$self->_set_current_node($para); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub end_table_body { |
251
|
23
|
|
|
23
|
0
|
50
|
my $self = shift; |
252
|
|
|
|
|
|
|
|
253
|
23
|
|
|
|
|
63
|
$self->_set_current_up_one_level; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub start_table_row { |
257
|
159
|
|
|
159
|
0
|
294
|
my $self = shift; |
258
|
|
|
|
|
|
|
|
259
|
159
|
|
|
|
|
636
|
my $para = Tree::Simple->new( { type => 'table_row' } ); |
260
|
159
|
|
|
|
|
9251
|
$self->_current_node->addChild($para); |
261
|
|
|
|
|
|
|
|
262
|
159
|
|
|
|
|
19199
|
$self->_set_current_node($para); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub end_table_row { |
266
|
159
|
|
|
159
|
0
|
275
|
my $self = shift; |
267
|
|
|
|
|
|
|
|
268
|
159
|
|
|
|
|
298
|
$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
|
1053
|
my $self = shift; |
285
|
628
|
|
|
|
|
9809
|
my %p = $validator->(@_); |
286
|
|
|
|
|
|
|
|
287
|
628
|
|
|
|
|
24831
|
my $para = Tree::Simple->new( { type => 'table_cell', %p } ); |
288
|
628
|
|
|
|
|
35326
|
$self->_current_node->addChild($para); |
289
|
|
|
|
|
|
|
|
290
|
628
|
|
|
|
|
77212
|
$self->_set_current_node($para); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub end_table_cell { |
295
|
628
|
|
|
628
|
0
|
1010
|
my $self = shift; |
296
|
|
|
|
|
|
|
|
297
|
628
|
|
|
|
|
1317
|
$self->_set_current_up_one_level; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub start_emphasis { |
301
|
48
|
|
|
48
|
0
|
116
|
my $self = shift; |
302
|
|
|
|
|
|
|
|
303
|
48
|
|
|
|
|
189
|
$self->_start_markup_node('emphasis'); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub end_emphasis { |
307
|
48
|
|
|
48
|
0
|
110
|
my $self = shift; |
308
|
|
|
|
|
|
|
|
309
|
48
|
|
|
|
|
156
|
$self->_set_current_up_one_level; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub start_strong { |
313
|
10
|
|
|
10
|
0
|
31
|
my $self = shift; |
314
|
|
|
|
|
|
|
|
315
|
10
|
|
|
|
|
47
|
$self->_start_markup_node('strong'); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub end_strong { |
319
|
10
|
|
|
10
|
0
|
30
|
my $self = shift; |
320
|
|
|
|
|
|
|
|
321
|
10
|
|
|
|
|
42
|
$self->_set_current_up_one_level; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub start_strikethrough { |
325
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
326
|
|
|
|
|
|
|
|
327
|
1
|
|
|
|
|
5
|
$self->_start_markup_node('strikethrough'); |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub end_strikethrough { |
331
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
332
|
|
|
|
|
|
|
|
333
|
1
|
|
|
|
|
4
|
$self->_set_current_up_one_level; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub start_code { |
337
|
106
|
|
|
106
|
0
|
239
|
my $self = shift; |
338
|
|
|
|
|
|
|
|
339
|
106
|
|
|
|
|
320
|
$self->_start_markup_node('code'); |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
sub end_code { |
343
|
106
|
|
|
106
|
0
|
242
|
my $self = shift; |
344
|
|
|
|
|
|
|
|
345
|
106
|
|
|
|
|
296
|
$self->_set_current_up_one_level; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
{ |
349
|
|
|
|
|
|
|
my $validator = validation_for( |
350
|
|
|
|
|
|
|
params => { |
351
|
|
|
|
|
|
|
uri => { |
352
|
|
|
|
|
|
|
type => t('Str'), |
353
|
|
|
|
|
|
|
optional => 1, |
354
|
|
|
|
|
|
|
}, |
355
|
|
|
|
|
|
|
}, |
356
|
|
|
|
|
|
|
); |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub auto_link { |
359
|
6
|
|
|
6
|
0
|
16
|
my $self = shift; |
360
|
6
|
|
|
|
|
119
|
my %p = $validator->(@_); |
361
|
|
|
|
|
|
|
|
362
|
6
|
|
|
|
|
210
|
my $link_node = Tree::Simple->new( { type => 'auto_link', %p } ); |
363
|
6
|
|
|
|
|
431
|
$self->_current_node->addChild($link_node); |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
{ |
368
|
|
|
|
|
|
|
my $validator = validation_for( |
369
|
|
|
|
|
|
|
params => { |
370
|
|
|
|
|
|
|
uri => { type => t('Str') }, |
371
|
|
|
|
|
|
|
title => { |
372
|
|
|
|
|
|
|
type => t('Str'), |
373
|
|
|
|
|
|
|
optional => 1, |
374
|
|
|
|
|
|
|
}, |
375
|
|
|
|
|
|
|
id => { |
376
|
|
|
|
|
|
|
type => t('Str'), |
377
|
|
|
|
|
|
|
optional => 1, |
378
|
|
|
|
|
|
|
}, |
379
|
|
|
|
|
|
|
is_implicit_id => { type => t('Bool') }, |
380
|
|
|
|
|
|
|
}, |
381
|
|
|
|
|
|
|
); |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
sub start_link { |
384
|
35
|
|
|
35
|
0
|
87
|
my $self = shift; |
385
|
35
|
|
|
|
|
611
|
my %p = $validator->(@_); |
386
|
|
|
|
|
|
|
|
387
|
35
|
|
|
|
|
1588
|
delete @p{ grep { !defined $p{$_} } keys %p }; |
|
111
|
|
|
|
|
217
|
|
388
|
|
|
|
|
|
|
|
389
|
35
|
|
|
|
|
145
|
$self->_start_markup_node( 'link', %p ); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub end_link { |
394
|
35
|
|
|
35
|
0
|
70
|
my $self = shift; |
395
|
|
|
|
|
|
|
|
396
|
35
|
|
|
|
|
110
|
$self->_set_current_up_one_level; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub line_break { |
400
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
401
|
|
|
|
|
|
|
|
402
|
3
|
|
|
|
|
15
|
my $break_node = Tree::Simple->new( { type => 'line_break' } ); |
403
|
|
|
|
|
|
|
|
404
|
3
|
|
|
|
|
193
|
$self->_current_node->addChild($break_node); |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
{ |
408
|
|
|
|
|
|
|
my $validator = validation_for( |
409
|
|
|
|
|
|
|
params => [ |
410
|
|
|
|
|
|
|
text => { type => t('Str') }, |
411
|
|
|
|
|
|
|
], |
412
|
|
|
|
|
|
|
named_to_list => 1, |
413
|
|
|
|
|
|
|
); |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
sub text { |
416
|
1540
|
|
|
1540
|
0
|
2710
|
my $self = shift; |
417
|
1540
|
|
|
|
|
25263
|
my ($text) = $validator->(@_); |
418
|
|
|
|
|
|
|
|
419
|
1540
|
|
|
|
|
39541
|
my $text_node |
420
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'text', text => $text } ); |
421
|
1540
|
|
|
|
|
94582
|
$self->_current_node->addChild($text_node); |
422
|
|
|
|
|
|
|
} |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
{ |
426
|
|
|
|
|
|
|
my $validator = validation_for( |
427
|
|
|
|
|
|
|
params => [ |
428
|
|
|
|
|
|
|
tag => { type => t('Str') }, |
429
|
|
|
|
|
|
|
attributes => { type => t('HashRef') }, |
430
|
|
|
|
|
|
|
], |
431
|
|
|
|
|
|
|
named_to_list => 1, |
432
|
|
|
|
|
|
|
); |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
sub start_html_tag { |
435
|
6
|
|
|
6
|
0
|
16
|
my $self = shift; |
436
|
6
|
|
|
|
|
117
|
my ( $tag, $attributes ) = $validator->(@_); |
437
|
|
|
|
|
|
|
|
438
|
6
|
|
|
|
|
251
|
my $tag_node = Tree::Simple->new( |
439
|
|
|
|
|
|
|
{ |
440
|
|
|
|
|
|
|
type => 'start_html_tag', |
441
|
|
|
|
|
|
|
tag => $tag, |
442
|
|
|
|
|
|
|
attributes => $attributes, |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
); |
445
|
|
|
|
|
|
|
|
446
|
6
|
|
|
|
|
413
|
$self->_current_node->addChild($tag_node); |
447
|
|
|
|
|
|
|
|
448
|
6
|
|
|
|
|
749
|
$self->_set_current_node($tag_node); |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
sub end_html_tag { |
453
|
6
|
|
|
6
|
0
|
15
|
my $self = shift; |
454
|
|
|
|
|
|
|
|
455
|
6
|
|
|
|
|
24
|
$self->_set_current_up_one_level; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
{ |
459
|
|
|
|
|
|
|
my $validator = validation_for( |
460
|
|
|
|
|
|
|
params => [ |
461
|
|
|
|
|
|
|
text => { type => t('Str') }, |
462
|
|
|
|
|
|
|
], |
463
|
|
|
|
|
|
|
named_to_list => 1, |
464
|
|
|
|
|
|
|
); |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
sub html_comment_block { |
467
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
468
|
2
|
|
|
|
|
41
|
my ($text) = $validator->(@_); |
469
|
|
|
|
|
|
|
|
470
|
2
|
|
|
|
|
77
|
my $html_node = Tree::Simple->new( |
471
|
|
|
|
|
|
|
{ type => 'html_comment_block', text => $text } ); |
472
|
2
|
|
|
|
|
137
|
$self->_current_node->addChild($html_node); |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
{ |
477
|
|
|
|
|
|
|
my $validator = validation_for( |
478
|
|
|
|
|
|
|
params => [ |
479
|
|
|
|
|
|
|
text => { type => t('Str') }, |
480
|
|
|
|
|
|
|
], |
481
|
|
|
|
|
|
|
named_to_list => 1, |
482
|
|
|
|
|
|
|
); |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
sub html_comment { |
485
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
486
|
1
|
|
|
|
|
21
|
my ($text) = $validator->(@_); |
487
|
|
|
|
|
|
|
|
488
|
1
|
|
|
|
|
37
|
my $html_node |
489
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'html_comment', text => $text } ); |
490
|
1
|
|
|
|
|
64
|
$self->_current_node->addChild($html_node); |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
{ |
495
|
|
|
|
|
|
|
my $validator = validation_for( |
496
|
|
|
|
|
|
|
params => [ |
497
|
|
|
|
|
|
|
tag => { type => t('Str') }, |
498
|
|
|
|
|
|
|
attributes => { type => t('HashRef') }, |
499
|
|
|
|
|
|
|
], |
500
|
|
|
|
|
|
|
named_to_list => 1, |
501
|
|
|
|
|
|
|
); |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
sub html_tag { |
504
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
505
|
3
|
|
|
|
|
58
|
my ( $tag, $attributes ) = $validator->(@_); |
506
|
|
|
|
|
|
|
|
507
|
3
|
|
|
|
|
113
|
my $tag_node = Tree::Simple->new( |
508
|
|
|
|
|
|
|
{ |
509
|
|
|
|
|
|
|
type => 'html_tag', |
510
|
|
|
|
|
|
|
tag => $tag, |
511
|
|
|
|
|
|
|
attributes => $attributes, |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
); |
514
|
|
|
|
|
|
|
|
515
|
3
|
|
|
|
|
173
|
$self->_current_node->addChild($tag_node); |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
{ |
520
|
|
|
|
|
|
|
my $validator = validation_for( |
521
|
|
|
|
|
|
|
params => [ |
522
|
|
|
|
|
|
|
entity => { type => t('Str') }, |
523
|
|
|
|
|
|
|
], |
524
|
|
|
|
|
|
|
named_to_list => 1, |
525
|
|
|
|
|
|
|
); |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
sub html_entity { |
528
|
7
|
|
|
7
|
0
|
14
|
my $self = shift; |
529
|
7
|
|
|
|
|
119
|
my ($entity) = $validator->(@_); |
530
|
|
|
|
|
|
|
|
531
|
7
|
|
|
|
|
169
|
my $html_node |
532
|
|
|
|
|
|
|
= Tree::Simple->new( |
533
|
|
|
|
|
|
|
{ type => 'html_entity', entity => $entity } ); |
534
|
7
|
|
|
|
|
405
|
$self->_current_node->addChild($html_node); |
535
|
|
|
|
|
|
|
} |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
{ |
539
|
|
|
|
|
|
|
my $validator = validation_for( |
540
|
|
|
|
|
|
|
params => [ |
541
|
|
|
|
|
|
|
html => { type => t('Str') }, |
542
|
|
|
|
|
|
|
], |
543
|
|
|
|
|
|
|
named_to_list => 1, |
544
|
|
|
|
|
|
|
); |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
sub html_block { |
547
|
14
|
|
|
14
|
0
|
29
|
my $self = shift; |
548
|
14
|
|
|
|
|
312
|
my ($html) = $validator->(@_); |
549
|
|
|
|
|
|
|
|
550
|
14
|
|
|
|
|
457
|
my $html_node |
551
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'html_block', html => $html } ); |
552
|
14
|
|
|
|
|
941
|
$self->_current_node->addChild($html_node); |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
{ |
557
|
|
|
|
|
|
|
my $validator = validation_for( |
558
|
|
|
|
|
|
|
params => { |
559
|
|
|
|
|
|
|
alt_text => { type => t('Str') }, |
560
|
|
|
|
|
|
|
uri => { type => t('Str') }, |
561
|
|
|
|
|
|
|
title => { |
562
|
|
|
|
|
|
|
type => t('Str'), |
563
|
|
|
|
|
|
|
optional => 1, |
564
|
|
|
|
|
|
|
}, |
565
|
|
|
|
|
|
|
id => { |
566
|
|
|
|
|
|
|
type => t('Str'), |
567
|
|
|
|
|
|
|
optional => 1, |
568
|
|
|
|
|
|
|
}, |
569
|
|
|
|
|
|
|
is_implicit_id => { |
570
|
|
|
|
|
|
|
type => t('Bool'), |
571
|
|
|
|
|
|
|
optional => 1, |
572
|
|
|
|
|
|
|
}, |
573
|
|
|
|
|
|
|
}, |
574
|
|
|
|
|
|
|
); |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
sub image { |
577
|
8
|
|
|
8
|
0
|
13
|
my $self = shift; |
578
|
8
|
|
|
|
|
129
|
my %p = $validator->(@_); |
579
|
|
|
|
|
|
|
|
580
|
8
|
|
|
|
|
391
|
my $image_node = Tree::Simple->new( { type => 'image', %p } ); |
581
|
8
|
|
|
|
|
475
|
$self->_current_node->addChild($image_node); |
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
sub horizontal_rule { |
586
|
6
|
|
|
6
|
0
|
15
|
my $self = shift; |
587
|
|
|
|
|
|
|
|
588
|
6
|
|
|
|
|
34
|
my $hr_node = Tree::Simple->new( { type => 'horizontal_rule' } ); |
589
|
6
|
|
|
|
|
407
|
$self->_current_node->addChild($hr_node); |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
sub _start_markup_node { |
593
|
200
|
|
|
200
|
|
363
|
my $self = shift; |
594
|
200
|
|
|
|
|
363
|
my $type = shift; |
595
|
|
|
|
|
|
|
|
596
|
200
|
|
|
|
|
990
|
my $markup = Tree::Simple->new( { type => $type, @_ } ); |
597
|
200
|
|
|
|
|
12291
|
$self->_current_node->addChild($markup); |
598
|
|
|
|
|
|
|
|
599
|
200
|
|
|
|
|
23273
|
$self->_set_current_node($markup); |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
sub _set_current_up_one_level { |
603
|
1631
|
|
|
1631
|
|
2405
|
my $self = shift; |
604
|
|
|
|
|
|
|
|
605
|
1631
|
|
|
|
|
43784
|
$self->_set_current_node( $self->_current_node->getParent() ); |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
1; |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
# ABSTRACT: A Markdent handler which builds a tree |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
__END__ |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
=pod |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=encoding UTF-8 |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=head1 NAME |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
Markdent::Handler::MinimalTree - A Markdent handler which builds a tree |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
=head1 VERSION |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
version 0.39 |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=head1 DESCRIPTION |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
This class implements an event receiver which in turn builds a tree using |
631
|
|
|
|
|
|
|
L<Tree::Simple>. |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
It is primarily intended for use in testing. |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
=head1 METHODS |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
This class provides the following methods: |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=head2 Markdent::Handler::MinimalTree->new(...) |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
This method creates a new handler. |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head2 $mhmt->tree |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Returns the root tree for the document. |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
=head1 ROLES |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
This class does the L<Markdent::Role::EventsAsMethods> and |
650
|
|
|
|
|
|
|
L<Markdent::Role::Handler> roles. |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=head1 BUGS |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=head1 SOURCE |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=head1 AUTHOR |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Dave Rolsky. |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
673
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
The full text of the license can be found in the |
676
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=cut |