line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Handler::MinimalTree; |
2
|
|
|
|
|
|
|
|
3
|
31
|
|
|
31
|
|
39664
|
use strict; |
|
31
|
|
|
|
|
96
|
|
|
31
|
|
|
|
|
1140
|
|
4
|
31
|
|
|
31
|
|
186
|
use warnings; |
|
31
|
|
|
|
|
72
|
|
|
31
|
|
|
|
|
1094
|
|
5
|
31
|
|
|
31
|
|
683
|
use namespace::autoclean; |
|
31
|
|
|
|
|
18540
|
|
|
31
|
|
|
|
|
281
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
8
|
|
|
|
|
|
|
|
9
|
31
|
|
|
31
|
|
3462
|
use Markdent::Types; |
|
31
|
|
|
|
|
79
|
|
|
31
|
|
|
|
|
280
|
|
10
|
31
|
|
|
31
|
|
803968
|
use Params::ValidationCompiler qw( validation_for ); |
|
31
|
|
|
|
|
38160
|
|
|
31
|
|
|
|
|
2571
|
|
11
|
31
|
|
|
31
|
|
281
|
use Specio::Declare; |
|
31
|
|
|
|
|
82
|
|
|
31
|
|
|
|
|
417
|
|
12
|
31
|
|
|
31
|
|
31459
|
use Tree::Simple; |
|
31
|
|
|
|
|
116836
|
|
|
31
|
|
|
|
|
212
|
|
13
|
|
|
|
|
|
|
|
14
|
31
|
|
|
31
|
|
1900
|
use Moose; |
|
31
|
|
|
|
|
477143
|
|
|
31
|
|
|
|
|
356
|
|
15
|
31
|
|
|
31
|
|
231060
|
use MooseX::SemiAffordanceAccessor; |
|
31
|
|
|
|
|
45072
|
|
|
31
|
|
|
|
|
277
|
|
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
|
177
|
|
|
177
|
0
|
397
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
177
|
|
|
|
|
5760
|
$self->_set_current_node( $self->tree ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub end_document { |
42
|
177
|
|
|
177
|
0
|
386
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
177
|
|
|
|
|
6521
|
$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
|
148
|
my $self = shift; |
55
|
67
|
|
|
|
|
1234
|
my ($level) = $validator->(@_); |
56
|
|
|
|
|
|
|
|
57
|
67
|
|
|
|
|
1769
|
my $header |
58
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'header', level => $level } ); |
59
|
67
|
|
|
|
|
4194
|
$self->_current_node->addChild($header); |
60
|
|
|
|
|
|
|
|
61
|
67
|
|
|
|
|
7635
|
$self->_set_current_node($header); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub end_header { |
66
|
67
|
|
|
67
|
0
|
145
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
67
|
|
|
|
|
190
|
$self->_set_current_up_one_level; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub start_blockquote { |
72
|
21
|
|
|
21
|
0
|
43
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
21
|
|
|
|
|
101
|
my $bq = Tree::Simple->new( { type => 'blockquote' } ); |
75
|
21
|
|
|
|
|
1434
|
$self->_current_node->addChild($bq); |
76
|
|
|
|
|
|
|
|
77
|
21
|
|
|
|
|
3183
|
$self->_set_current_node($bq); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub end_blockquote { |
81
|
21
|
|
|
21
|
0
|
44
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
21
|
|
|
|
|
48
|
$self->_set_current_up_one_level; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub start_unordered_list { |
87
|
29
|
|
|
29
|
0
|
64
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
29
|
|
|
|
|
179
|
my $bq = Tree::Simple->new( { type => 'unordered_list' } ); |
90
|
29
|
|
|
|
|
2031
|
$self->_current_node->addChild($bq); |
91
|
|
|
|
|
|
|
|
92
|
29
|
|
|
|
|
3960
|
$self->_set_current_node($bq); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub end_unordered_list { |
96
|
29
|
|
|
29
|
0
|
69
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
29
|
|
|
|
|
87
|
$self->_set_current_up_one_level; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub start_ordered_list { |
102
|
7
|
|
|
7
|
0
|
14
|
my $self = shift; |
103
|
|
|
|
|
|
|
|
104
|
7
|
|
|
|
|
45
|
my $bq = Tree::Simple->new( { type => 'ordered_list' } ); |
105
|
7
|
|
|
|
|
484
|
$self->_current_node->addChild($bq); |
106
|
|
|
|
|
|
|
|
107
|
7
|
|
|
|
|
909
|
$self->_set_current_node($bq); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub end_ordered_list { |
111
|
7
|
|
|
7
|
0
|
19
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
7
|
|
|
|
|
21
|
$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
|
171
|
my $self = shift; |
124
|
69
|
|
|
|
|
1227
|
my ($bullet) = $validator->(@_); |
125
|
|
|
|
|
|
|
|
126
|
69
|
|
|
|
|
2005
|
my $list_item |
127
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'list_item', bullet => $bullet } ); |
128
|
69
|
|
|
|
|
4417
|
$self->_current_node->addChild($list_item); |
129
|
|
|
|
|
|
|
|
130
|
69
|
|
|
|
|
9740
|
$self->_set_current_node($list_item); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub end_list_item { |
135
|
69
|
|
|
69
|
0
|
129
|
my $self = shift; |
136
|
|
|
|
|
|
|
|
137
|
69
|
|
|
|
|
207
|
$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
|
|
|
|
|
3099
|
my ($text) = $validator->(@_); |
149
|
|
|
|
|
|
|
|
150
|
169
|
|
|
|
|
4407
|
my $pre_node |
151
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'preformatted', text => $text } ); |
152
|
169
|
|
|
|
|
11038
|
$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
|
14
|
my $self = shift; |
170
|
7
|
|
|
|
|
144
|
my ( $code, $language ) = $validator->(@_); |
171
|
|
|
|
|
|
|
|
172
|
7
|
|
|
|
|
254
|
my $code_block_node = Tree::Simple->new( |
173
|
|
|
|
|
|
|
{ |
174
|
|
|
|
|
|
|
type => 'code_block', |
175
|
|
|
|
|
|
|
code => $code, |
176
|
|
|
|
|
|
|
language => $language, |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
7
|
|
|
|
|
824
|
$self->_current_node->addChild($code_block_node); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub start_paragraph { |
185
|
386
|
|
|
386
|
0
|
761
|
my $self = shift; |
186
|
|
|
|
|
|
|
|
187
|
386
|
|
|
|
|
2052
|
my $para = Tree::Simple->new( { type => 'paragraph' } ); |
188
|
386
|
|
|
|
|
26692
|
$self->_current_node->addChild($para); |
189
|
|
|
|
|
|
|
|
190
|
386
|
|
|
|
|
48396
|
$self->_set_current_node($para); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub end_paragraph { |
194
|
386
|
|
|
386
|
0
|
719
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
386
|
|
|
|
|
1090
|
$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
|
49
|
my $self = shift; |
211
|
21
|
|
|
|
|
421
|
my %p = $validator->(@_); |
212
|
|
|
|
|
|
|
|
213
|
21
|
|
|
|
|
517
|
my $para = Tree::Simple->new( { type => 'table', %p } ); |
214
|
21
|
|
|
|
|
1525
|
$self->_current_node->addChild($para); |
215
|
|
|
|
|
|
|
|
216
|
21
|
|
|
|
|
2946
|
$self->_set_current_node($para); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub end_table { |
221
|
21
|
|
|
21
|
0
|
51
|
my $self = shift; |
222
|
|
|
|
|
|
|
|
223
|
21
|
|
|
|
|
56
|
$self->_set_current_up_one_level; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub start_table_header { |
227
|
17
|
|
|
17
|
0
|
35
|
my $self = shift; |
228
|
|
|
|
|
|
|
|
229
|
17
|
|
|
|
|
85
|
my $para = Tree::Simple->new( { type => 'table_header' } ); |
230
|
17
|
|
|
|
|
1137
|
$self->_current_node->addChild($para); |
231
|
|
|
|
|
|
|
|
232
|
17
|
|
|
|
|
2374
|
$self->_set_current_node($para); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub end_table_header { |
236
|
17
|
|
|
17
|
0
|
41
|
my $self = shift; |
237
|
|
|
|
|
|
|
|
238
|
17
|
|
|
|
|
42
|
$self->_set_current_up_one_level; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub start_table_body { |
242
|
23
|
|
|
23
|
0
|
51
|
my $self = shift; |
243
|
|
|
|
|
|
|
|
244
|
23
|
|
|
|
|
110
|
my $para = Tree::Simple->new( { type => 'table_body' } ); |
245
|
23
|
|
|
|
|
1615
|
$self->_current_node->addChild($para); |
246
|
|
|
|
|
|
|
|
247
|
23
|
|
|
|
|
2903
|
$self->_set_current_node($para); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub end_table_body { |
251
|
23
|
|
|
23
|
0
|
46
|
my $self = shift; |
252
|
|
|
|
|
|
|
|
253
|
23
|
|
|
|
|
54
|
$self->_set_current_up_one_level; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub start_table_row { |
257
|
159
|
|
|
159
|
0
|
253
|
my $self = shift; |
258
|
|
|
|
|
|
|
|
259
|
159
|
|
|
|
|
678
|
my $para = Tree::Simple->new( { type => 'table_row' } ); |
260
|
159
|
|
|
|
|
10485
|
$self->_current_node->addChild($para); |
261
|
|
|
|
|
|
|
|
262
|
159
|
|
|
|
|
21417
|
$self->_set_current_node($para); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub end_table_row { |
266
|
159
|
|
|
159
|
0
|
286
|
my $self = shift; |
267
|
|
|
|
|
|
|
|
268
|
159
|
|
|
|
|
338
|
$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
|
1221
|
my $self = shift; |
285
|
628
|
|
|
|
|
11436
|
my %p = $validator->(@_); |
286
|
|
|
|
|
|
|
|
287
|
628
|
|
|
|
|
29250
|
my $para = Tree::Simple->new( { type => 'table_cell', %p } ); |
288
|
628
|
|
|
|
|
41511
|
$self->_current_node->addChild($para); |
289
|
|
|
|
|
|
|
|
290
|
628
|
|
|
|
|
90011
|
$self->_set_current_node($para); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub end_table_cell { |
295
|
628
|
|
|
628
|
0
|
1217
|
my $self = shift; |
296
|
|
|
|
|
|
|
|
297
|
628
|
|
|
|
|
1517
|
$self->_set_current_up_one_level; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub start_emphasis { |
301
|
48
|
|
|
48
|
0
|
120
|
my $self = shift; |
302
|
|
|
|
|
|
|
|
303
|
48
|
|
|
|
|
164
|
$self->_start_markup_node('emphasis'); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub end_emphasis { |
307
|
48
|
|
|
48
|
0
|
121
|
my $self = shift; |
308
|
|
|
|
|
|
|
|
309
|
48
|
|
|
|
|
166
|
$self->_set_current_up_one_level; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub start_strong { |
313
|
10
|
|
|
10
|
0
|
35
|
my $self = shift; |
314
|
|
|
|
|
|
|
|
315
|
10
|
|
|
|
|
41
|
$self->_start_markup_node('strong'); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub end_strong { |
319
|
10
|
|
|
10
|
0
|
27
|
my $self = shift; |
320
|
|
|
|
|
|
|
|
321
|
10
|
|
|
|
|
36
|
$self->_set_current_up_one_level; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub start_strikethrough { |
325
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
326
|
|
|
|
|
|
|
|
327
|
1
|
|
|
|
|
6
|
$self->_start_markup_node('strikethrough'); |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub end_strikethrough { |
331
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
332
|
|
|
|
|
|
|
|
333
|
1
|
|
|
|
|
5
|
$self->_set_current_up_one_level; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub start_code { |
337
|
106
|
|
|
106
|
0
|
246
|
my $self = shift; |
338
|
|
|
|
|
|
|
|
339
|
106
|
|
|
|
|
392
|
$self->_start_markup_node('code'); |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
sub end_code { |
343
|
106
|
|
|
106
|
0
|
241
|
my $self = shift; |
344
|
|
|
|
|
|
|
|
345
|
106
|
|
|
|
|
272
|
$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
|
8
|
|
|
8
|
0
|
19
|
my $self = shift; |
360
|
8
|
|
|
|
|
170
|
my %p = $validator->(@_); |
361
|
|
|
|
|
|
|
|
362
|
8
|
|
|
|
|
282
|
my $link_node = Tree::Simple->new( { type => 'auto_link', %p } ); |
363
|
8
|
|
|
|
|
570
|
$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
|
83
|
my $self = shift; |
385
|
35
|
|
|
|
|
659
|
my %p = $validator->(@_); |
386
|
|
|
|
|
|
|
|
387
|
35
|
|
|
|
|
1734
|
delete @p{ grep { !defined $p{$_} } keys %p }; |
|
111
|
|
|
|
|
246
|
|
388
|
|
|
|
|
|
|
|
389
|
35
|
|
|
|
|
144
|
$self->_start_markup_node( 'link', %p ); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub end_link { |
394
|
35
|
|
|
35
|
0
|
74
|
my $self = shift; |
395
|
|
|
|
|
|
|
|
396
|
35
|
|
|
|
|
99
|
$self->_set_current_up_one_level; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub line_break { |
400
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
401
|
|
|
|
|
|
|
|
402
|
3
|
|
|
|
|
14
|
my $break_node = Tree::Simple->new( { type => 'line_break' } ); |
403
|
|
|
|
|
|
|
|
404
|
3
|
|
|
|
|
194
|
$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
|
1544
|
|
|
1544
|
0
|
2925
|
my $self = shift; |
417
|
1544
|
|
|
|
|
27994
|
my ($text) = $validator->(@_); |
418
|
|
|
|
|
|
|
|
419
|
1544
|
|
|
|
|
41125
|
my $text_node |
420
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'text', text => $text } ); |
421
|
1544
|
|
|
|
|
102713
|
$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
|
20
|
my $self = shift; |
436
|
6
|
|
|
|
|
124
|
my ( $tag, $attributes ) = $validator->(@_); |
437
|
|
|
|
|
|
|
|
438
|
6
|
|
|
|
|
287
|
my $tag_node = Tree::Simple->new( |
439
|
|
|
|
|
|
|
{ |
440
|
|
|
|
|
|
|
type => 'start_html_tag', |
441
|
|
|
|
|
|
|
tag => $tag, |
442
|
|
|
|
|
|
|
attributes => $attributes, |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
); |
445
|
|
|
|
|
|
|
|
446
|
6
|
|
|
|
|
433
|
$self->_current_node->addChild($tag_node); |
447
|
|
|
|
|
|
|
|
448
|
6
|
|
|
|
|
862
|
$self->_set_current_node($tag_node); |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
sub end_html_tag { |
453
|
6
|
|
|
6
|
0
|
16
|
my $self = shift; |
454
|
|
|
|
|
|
|
|
455
|
6
|
|
|
|
|
45
|
$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
|
|
|
|
|
39
|
my ($text) = $validator->(@_); |
469
|
|
|
|
|
|
|
|
470
|
2
|
|
|
|
|
58
|
my $html_node = Tree::Simple->new( |
471
|
|
|
|
|
|
|
{ type => 'html_comment_block', text => $text } ); |
472
|
2
|
|
|
|
|
128
|
$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
|
|
|
|
|
20
|
my ($text) = $validator->(@_); |
487
|
|
|
|
|
|
|
|
488
|
1
|
|
|
|
|
35
|
my $html_node |
489
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'html_comment', text => $text } ); |
490
|
1
|
|
|
|
|
85
|
$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
|
9
|
my $self = shift; |
505
|
3
|
|
|
|
|
61
|
my ( $tag, $attributes ) = $validator->(@_); |
506
|
|
|
|
|
|
|
|
507
|
3
|
|
|
|
|
126
|
my $tag_node = Tree::Simple->new( |
508
|
|
|
|
|
|
|
{ |
509
|
|
|
|
|
|
|
type => 'html_tag', |
510
|
|
|
|
|
|
|
tag => $tag, |
511
|
|
|
|
|
|
|
attributes => $attributes, |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
); |
514
|
|
|
|
|
|
|
|
515
|
3
|
|
|
|
|
190
|
$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
|
|
|
|
|
128
|
my ($entity) = $validator->(@_); |
530
|
|
|
|
|
|
|
|
531
|
7
|
|
|
|
|
196
|
my $html_node |
532
|
|
|
|
|
|
|
= Tree::Simple->new( |
533
|
|
|
|
|
|
|
{ type => 'html_entity', entity => $entity } ); |
534
|
7
|
|
|
|
|
482
|
$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
|
44
|
my $self = shift; |
548
|
14
|
|
|
|
|
303
|
my ($html) = $validator->(@_); |
549
|
|
|
|
|
|
|
|
550
|
14
|
|
|
|
|
482
|
my $html_node |
551
|
|
|
|
|
|
|
= Tree::Simple->new( { type => 'html_block', html => $html } ); |
552
|
14
|
|
|
|
|
1038
|
$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
|
17
|
my $self = shift; |
578
|
8
|
|
|
|
|
147
|
my %p = $validator->(@_); |
579
|
|
|
|
|
|
|
|
580
|
8
|
|
|
|
|
438
|
my $image_node = Tree::Simple->new( { type => 'image', %p } ); |
581
|
8
|
|
|
|
|
529
|
$self->_current_node->addChild($image_node); |
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
sub horizontal_rule { |
586
|
6
|
|
|
6
|
0
|
13
|
my $self = shift; |
587
|
|
|
|
|
|
|
|
588
|
6
|
|
|
|
|
31
|
my $hr_node = Tree::Simple->new( { type => 'horizontal_rule' } ); |
589
|
6
|
|
|
|
|
403
|
$self->_current_node->addChild($hr_node); |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
sub _start_markup_node { |
593
|
200
|
|
|
200
|
|
484
|
my $self = shift; |
594
|
200
|
|
|
|
|
327
|
my $type = shift; |
595
|
|
|
|
|
|
|
|
596
|
200
|
|
|
|
|
975
|
my $markup = Tree::Simple->new( { type => $type, @_ } ); |
597
|
200
|
|
|
|
|
13276
|
$self->_current_node->addChild($markup); |
598
|
|
|
|
|
|
|
|
599
|
200
|
|
|
|
|
24611
|
$self->_set_current_node($markup); |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
sub _set_current_up_one_level { |
603
|
1633
|
|
|
1633
|
|
2496
|
my $self = shift; |
604
|
|
|
|
|
|
|
|
605
|
1633
|
|
|
|
|
49687
|
$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.40 |
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 |