| 1 | package Markdent::Handler::MinimalTree; | ||
| 2 | |||
| 3 | 31 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 31 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 31 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 31 | our $VERSION = '0.39'; | |
| 8 | |||
| 9 | 31 | ▶ | use Markdent::Types; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 31 | ▶ | use Params::ValidationCompiler qw( validation_for ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 31 | ▶ | use Specio::Declare; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 31 | ▶ | use Tree::Simple; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 31 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 31 | ▶ | use MooseX::SemiAffordanceAccessor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | 31 | with 'Markdent::Role::EventsAsMethods'; | |
| 18 | |||
| 19 | 31 | my $tree_simple_type = object_isa_type('Tree::Simple'); | |
| 20 | has tree => ( | ||
| 21 | is => 'ro', | ||
| 22 | isa => $tree_simple_type, | ||
| 23 | default => sub { | ||
| 24 | 176 | ▶ | Tree::Simple->new( { type => 'document' }, Tree::Simple->ROOT() ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 25 | }, | ||
| 26 | 31 | init_arg => undef, | |
| 27 | ); | ||
| 28 | |||
| 29 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
start_document: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 37 | |||
| 38 | 175 | $self->_set_current_node( $self->tree ); | |
| 39 | } | ||
| 40 | |||
| 41 | sub end_document { | ||
| 42 | 175 | ▶ | my $self = shift; |
|
Subroutine
end_document: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 43 | |||
| 44 | 175 | $self->_set_current_node(undef); | |
| 45 | } | ||
| 46 | |||
| 47 | { | ||
| 48 | 31 | my $validator = validation_for( | |
| 49 | params => [ level => { type => t('HeaderLevel') } ], | ||
| 50 | named_to_list => 1, | ||
| 51 | ); | ||
| 52 | |||
| 53 | sub start_header { | ||
| 54 | 67 | ▶ | my $self = shift; |
|
Subroutine
start_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 55 | 67 | my ($level) = $validator->(@_); | |
| 56 | |||
| 57 | 67 | my $header | |
| 58 | = Tree::Simple->new( { type => 'header', level => $level } ); | ||
| 59 | 67 | $self->_current_node->addChild($header); | |
| 60 | |||
| 61 | 67 | $self->_set_current_node($header); | |
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | 31 | sub end_header { | |
| 66 | 67 | ▶ | my $self = shift; |
|
Subroutine
end_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 67 | |||
| 68 | 67 | $self->_set_current_up_one_level; | |
| 69 | } | ||
| 70 | |||
| 71 | sub start_blockquote { | ||
| 72 | 21 | ▶ | my $self = shift; |
|
Subroutine
start_blockquote: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 73 | |||
| 74 | 21 | my $bq = Tree::Simple->new( { type => 'blockquote' } ); | |
| 75 | 21 | $self->_current_node->addChild($bq); | |
| 76 | |||
| 77 | 21 | $self->_set_current_node($bq); | |
| 78 | } | ||
| 79 | |||
| 80 | sub end_blockquote { | ||
| 81 | 21 | ▶ | my $self = shift; |
|
Subroutine
end_blockquote: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 82 | |||
| 83 | 21 | $self->_set_current_up_one_level; | |
| 84 | } | ||
| 85 | |||
| 86 | sub start_unordered_list { | ||
| 87 | 29 | ▶ | my $self = shift; |
|
Subroutine
start_unordered_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 88 | |||
| 89 | 29 | my $bq = Tree::Simple->new( { type => 'unordered_list' } ); | |
| 90 | 29 | $self->_current_node->addChild($bq); | |
| 91 | |||
| 92 | 29 | $self->_set_current_node($bq); | |
| 93 | } | ||
| 94 | |||
| 95 | sub end_unordered_list { | ||
| 96 | 29 | ▶ | my $self = shift; |
|
Subroutine
end_unordered_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 97 | |||
| 98 | 29 | $self->_set_current_up_one_level; | |
| 99 | } | ||
| 100 | |||
| 101 | sub start_ordered_list { | ||
| 102 | 7 | ▶ | my $self = shift; |
|
Subroutine
start_ordered_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 103 | |||
| 104 | 7 | my $bq = Tree::Simple->new( { type => 'ordered_list' } ); | |
| 105 | 7 | $self->_current_node->addChild($bq); | |
| 106 | |||
| 107 | 7 | $self->_set_current_node($bq); | |
| 108 | } | ||
| 109 | |||
| 110 | sub end_ordered_list { | ||
| 111 | 7 | ▶ | my $self = shift; |
|
Subroutine
end_ordered_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 112 | |||
| 113 | 7 | $self->_set_current_up_one_level; | |
| 114 | } | ||
| 115 | |||
| 116 | { | ||
| 117 | 31 | my $validator = validation_for( | |
| 118 | params => [ bullet => { type => t('Str') } ], | ||
| 119 | named_to_list => 1, | ||
| 120 | ); | ||
| 121 | |||
| 122 | sub start_list_item { | ||
| 123 | 69 | ▶ | my $self = shift; |
|
Subroutine
start_list_item: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 124 | 69 | my ($bullet) = $validator->(@_); | |
| 125 | |||
| 126 | 69 | my $list_item | |
| 127 | = Tree::Simple->new( { type => 'list_item', bullet => $bullet } ); | ||
| 128 | 69 | $self->_current_node->addChild($list_item); | |
| 129 | |||
| 130 | 69 | $self->_set_current_node($list_item); | |
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | 31 | sub end_list_item { | |
| 135 | 69 | ▶ | my $self = shift; |
|
Subroutine
end_list_item: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 136 | |||
| 137 | 69 | $self->_set_current_up_one_level; | |
| 138 | } | ||
| 139 | |||
| 140 | { | ||
| 141 | 31 | my $validator = validation_for( | |
| 142 | params => [ text => { type => t('Str') } ], | ||
| 143 | named_to_list => 1, | ||
| 144 | ); | ||
| 145 | |||
| 146 | sub preformatted { | ||
| 147 | 169 | ▶ | my $self = shift; |
|
Subroutine
preformatted: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 148 | 169 | my ($text) = $validator->(@_); | |
| 149 | |||
| 150 | 169 | my $pre_node | |
| 151 | = Tree::Simple->new( { type => 'preformatted', text => $text } ); | ||
| 152 | 169 | $self->_current_node->addChild($pre_node); | |
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | { | ||
| 157 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
code_block: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 170 | 7 | my ( $code, $language ) = $validator->(@_); | |
| 171 | |||
| 172 | 7 | my $code_block_node = Tree::Simple->new( | |
| 173 | { | ||
| 174 | type => 'code_block', | ||
| 175 | code => $code, | ||
| 176 | language => $language, | ||
| 177 | } | ||
| 178 | ); | ||
| 179 | |||
| 180 | 7 | $self->_current_node->addChild($code_block_node); | |
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | 31 | sub start_paragraph { | |
| 185 | 384 | ▶ | my $self = shift; |
|
Subroutine
start_paragraph: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 186 | |||
| 187 | 384 | my $para = Tree::Simple->new( { type => 'paragraph' } ); | |
| 188 | 384 | $self->_current_node->addChild($para); | |
| 189 | |||
| 190 | 384 | $self->_set_current_node($para); | |
| 191 | } | ||
| 192 | |||
| 193 | sub end_paragraph { | ||
| 194 | 384 | ▶ | my $self = shift; |
|
Subroutine
end_paragraph: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 195 | |||
| 196 | 384 | $self->_set_current_up_one_level; | |
| 197 | } | ||
| 198 | |||
| 199 | { | ||
| 200 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
start_table: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 211 | 21 | my %p = $validator->(@_); | |
| 212 | |||
| 213 | 21 | my $para = Tree::Simple->new( { type => 'table', %p } ); | |
| 214 | 21 | $self->_current_node->addChild($para); | |
| 215 | |||
| 216 | 21 | $self->_set_current_node($para); | |
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | 31 | sub end_table { | |
| 221 | 21 | ▶ | my $self = shift; |
|
Subroutine
end_table: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 222 | |||
| 223 | 21 | $self->_set_current_up_one_level; | |
| 224 | } | ||
| 225 | |||
| 226 | sub start_table_header { | ||
| 227 | 17 | ▶ | my $self = shift; |
|
Subroutine
start_table_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 228 | |||
| 229 | 17 | my $para = Tree::Simple->new( { type => 'table_header' } ); | |
| 230 | 17 | $self->_current_node->addChild($para); | |
| 231 | |||
| 232 | 17 | $self->_set_current_node($para); | |
| 233 | } | ||
| 234 | |||
| 235 | sub end_table_header { | ||
| 236 | 17 | ▶ | my $self = shift; |
|
Subroutine
end_table_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 237 | |||
| 238 | 17 | $self->_set_current_up_one_level; | |
| 239 | } | ||
| 240 | |||
| 241 | sub start_table_body { | ||
| 242 | 23 | ▶ | my $self = shift; |
|
Subroutine
start_table_body: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 243 | |||
| 244 | 23 | my $para = Tree::Simple->new( { type => 'table_body' } ); | |
| 245 | 23 | $self->_current_node->addChild($para); | |
| 246 | |||
| 247 | 23 | $self->_set_current_node($para); | |
| 248 | } | ||
| 249 | |||
| 250 | sub end_table_body { | ||
| 251 | 23 | ▶ | my $self = shift; |
|
Subroutine
end_table_body: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 252 | |||
| 253 | 23 | $self->_set_current_up_one_level; | |
| 254 | } | ||
| 255 | |||
| 256 | sub start_table_row { | ||
| 257 | 159 | ▶ | my $self = shift; |
|
Subroutine
start_table_row: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 258 | |||
| 259 | 159 | my $para = Tree::Simple->new( { type => 'table_row' } ); | |
| 260 | 159 | $self->_current_node->addChild($para); | |
| 261 | |||
| 262 | 159 | $self->_set_current_node($para); | |
| 263 | } | ||
| 264 | |||
| 265 | sub end_table_row { | ||
| 266 | 159 | ▶ | my $self = shift; |
|
Subroutine
end_table_row: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 267 | |||
| 268 | 159 | $self->_set_current_up_one_level; | |
| 269 | } | ||
| 270 | |||
| 271 | { | ||
| 272 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
start_table_cell: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 285 | 628 | my %p = $validator->(@_); | |
| 286 | |||
| 287 | 628 | my $para = Tree::Simple->new( { type => 'table_cell', %p } ); | |
| 288 | 628 | $self->_current_node->addChild($para); | |
| 289 | |||
| 290 | 628 | $self->_set_current_node($para); | |
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 | 31 | sub end_table_cell { | |
| 295 | 628 | ▶ | my $self = shift; |
|
Subroutine
end_table_cell: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 296 | |||
| 297 | 628 | $self->_set_current_up_one_level; | |
| 298 | } | ||
| 299 | |||
| 300 | sub start_emphasis { | ||
| 301 | 48 | ▶ | my $self = shift; |
|
Subroutine
start_emphasis: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 302 | |||
| 303 | 48 | $self->_start_markup_node('emphasis'); | |
| 304 | } | ||
| 305 | |||
| 306 | sub end_emphasis { | ||
| 307 | 48 | ▶ | my $self = shift; |
|
Subroutine
end_emphasis: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 308 | |||
| 309 | 48 | $self->_set_current_up_one_level; | |
| 310 | } | ||
| 311 | |||
| 312 | sub start_strong { | ||
| 313 | 10 | ▶ | my $self = shift; |
|
Subroutine
start_strong: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 314 | |||
| 315 | 10 | $self->_start_markup_node('strong'); | |
| 316 | } | ||
| 317 | |||
| 318 | sub end_strong { | ||
| 319 | 10 | ▶ | my $self = shift; |
|
Subroutine
end_strong: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 320 | |||
| 321 | 10 | $self->_set_current_up_one_level; | |
| 322 | } | ||
| 323 | |||
| 324 | sub start_strikethrough { | ||
| 325 | 1 | ▶ | my $self = shift; |
|
Subroutine
start_strikethrough: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 326 | |||
| 327 | 1 | $self->_start_markup_node('strikethrough'); | |
| 328 | } | ||
| 329 | |||
| 330 | sub end_strikethrough { | ||
| 331 | 1 | ▶ | my $self = shift; |
|
Subroutine
end_strikethrough: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 332 | |||
| 333 | 1 | $self->_set_current_up_one_level; | |
| 334 | } | ||
| 335 | |||
| 336 | sub start_code { | ||
| 337 | 106 | ▶ | my $self = shift; |
|
Subroutine
start_code: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 338 | |||
| 339 | 106 | $self->_start_markup_node('code'); | |
| 340 | } | ||
| 341 | |||
| 342 | sub end_code { | ||
| 343 | 106 | ▶ | my $self = shift; |
|
Subroutine
end_code: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 344 | |||
| 345 | 106 | $self->_set_current_up_one_level; | |
| 346 | } | ||
| 347 | |||
| 348 | { | ||
| 349 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
auto_link: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 360 | 6 | my %p = $validator->(@_); | |
| 361 | |||
| 362 | 6 | my $link_node = Tree::Simple->new( { type => 'auto_link', %p } ); | |
| 363 | 6 | $self->_current_node->addChild($link_node); | |
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 367 | { | ||
| 368 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
start_link: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 385 | 35 | my %p = $validator->(@_); | |
| 386 | |||
| 387 | 35 | delete @p{ grep { !defined $p{$_} } keys %p }; | |
| 388 | |||
| 389 | 35 | $self->_start_markup_node( 'link', %p ); | |
| 390 | } | ||
| 391 | } | ||
| 392 | |||
| 393 | 31 | sub end_link { | |
| 394 | 35 | ▶ | my $self = shift; |
|
Subroutine
end_link: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 395 | |||
| 396 | 35 | $self->_set_current_up_one_level; | |
| 397 | } | ||
| 398 | |||
| 399 | sub line_break { | ||
| 400 | 3 | ▶ | my $self = shift; |
|
Subroutine
line_break: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 401 | |||
| 402 | 3 | my $break_node = Tree::Simple->new( { type => 'line_break' } ); | |
| 403 | |||
| 404 | 3 | $self->_current_node->addChild($break_node); | |
| 405 | } | ||
| 406 | |||
| 407 | { | ||
| 408 | 31 | my $validator = validation_for( | |
| 409 | params => [ | ||
| 410 | text => { type => t('Str') }, | ||
| 411 | ], | ||
| 412 | named_to_list => 1, | ||
| 413 | ); | ||
| 414 | |||
| 415 | sub text { | ||
| 416 | 1540 | ▶ | my $self = shift; |
|
Subroutine
text: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 417 | 1540 | my ($text) = $validator->(@_); | |
| 418 | |||
| 419 | 1540 | my $text_node | |
| 420 | = Tree::Simple->new( { type => 'text', text => $text } ); | ||
| 421 | 1540 | $self->_current_node->addChild($text_node); | |
| 422 | } | ||
| 423 | } | ||
| 424 | |||
| 425 | { | ||
| 426 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
start_html_tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 436 | 6 | my ( $tag, $attributes ) = $validator->(@_); | |
| 437 | |||
| 438 | 6 | my $tag_node = Tree::Simple->new( | |
| 439 | { | ||
| 440 | type => 'start_html_tag', | ||
| 441 | tag => $tag, | ||
| 442 | attributes => $attributes, | ||
| 443 | } | ||
| 444 | ); | ||
| 445 | |||
| 446 | 6 | $self->_current_node->addChild($tag_node); | |
| 447 | |||
| 448 | 6 | $self->_set_current_node($tag_node); | |
| 449 | } | ||
| 450 | } | ||
| 451 | |||
| 452 | 31 | sub end_html_tag { | |
| 453 | 6 | ▶ | my $self = shift; |
|
Subroutine
end_html_tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 454 | |||
| 455 | 6 | $self->_set_current_up_one_level; | |
| 456 | } | ||
| 457 | |||
| 458 | { | ||
| 459 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
html_comment_block: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 468 | 2 | my ($text) = $validator->(@_); | |
| 469 | |||
| 470 | 2 | my $html_node = Tree::Simple->new( | |
| 471 | { type => 'html_comment_block', text => $text } ); | ||
| 472 | 2 | $self->_current_node->addChild($html_node); | |
| 473 | } | ||
| 474 | } | ||
| 475 | |||
| 476 | { | ||
| 477 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
html_comment: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 486 | 1 | my ($text) = $validator->(@_); | |
| 487 | |||
| 488 | 1 | my $html_node | |
| 489 | = Tree::Simple->new( { type => 'html_comment', text => $text } ); | ||
| 490 | 1 | $self->_current_node->addChild($html_node); | |
| 491 | } | ||
| 492 | } | ||
| 493 | |||
| 494 | { | ||
| 495 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
html_tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 505 | 3 | my ( $tag, $attributes ) = $validator->(@_); | |
| 506 | |||
| 507 | 3 | my $tag_node = Tree::Simple->new( | |
| 508 | { | ||
| 509 | type => 'html_tag', | ||
| 510 | tag => $tag, | ||
| 511 | attributes => $attributes, | ||
| 512 | } | ||
| 513 | ); | ||
| 514 | |||
| 515 | 3 | $self->_current_node->addChild($tag_node); | |
| 516 | } | ||
| 517 | } | ||
| 518 | |||
| 519 | { | ||
| 520 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
html_entity: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 529 | 7 | my ($entity) = $validator->(@_); | |
| 530 | |||
| 531 | 7 | my $html_node | |
| 532 | = Tree::Simple->new( | ||
| 533 | { type => 'html_entity', entity => $entity } ); | ||
| 534 | 7 | $self->_current_node->addChild($html_node); | |
| 535 | } | ||
| 536 | } | ||
| 537 | |||
| 538 | { | ||
| 539 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
html_block: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 548 | 14 | my ($html) = $validator->(@_); | |
| 549 | |||
| 550 | 14 | my $html_node | |
| 551 | = Tree::Simple->new( { type => 'html_block', html => $html } ); | ||
| 552 | 14 | $self->_current_node->addChild($html_node); | |
| 553 | } | ||
| 554 | } | ||
| 555 | |||
| 556 | { | ||
| 557 | 31 | 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 | ▶ | my $self = shift; |
|
Subroutine
image: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 578 | 8 | my %p = $validator->(@_); | |
| 579 | |||
| 580 | 8 | my $image_node = Tree::Simple->new( { type => 'image', %p } ); | |
| 581 | 8 | $self->_current_node->addChild($image_node); | |
| 582 | } | ||
| 583 | } | ||
| 584 | |||
| 585 | 31 | sub horizontal_rule { | |
| 586 | 6 | ▶ | my $self = shift; |
|
Subroutine
horizontal_rule: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 587 | |||
| 588 | 6 | my $hr_node = Tree::Simple->new( { type => 'horizontal_rule' } ); | |
| 589 | 6 | $self->_current_node->addChild($hr_node); | |
| 590 | } | ||
| 591 | |||
| 592 | sub _start_markup_node { | ||
| 593 | 200 | ▶ | my $self = shift; |
|
Subroutine
_start_markup_node: called CC=1 SCAR=0.0
| |||
| 594 | 200 | my $type = shift; | |
| 595 | |||
| 596 | 200 | my $markup = Tree::Simple->new( { type => $type, @_ } ); | |
| 597 | 200 | $self->_current_node->addChild($markup); | |
| 598 | |||
| 599 | 200 | $self->_set_current_node($markup); | |
| 600 | } | ||
| 601 | |||
| 602 | sub _set_current_up_one_level { | ||
| 603 | 1631 | ▶ | my $self = shift; |
|
Subroutine
_set_current_up_one_level: called CC=1 SCAR=0.0
| |||
| 604 | |||
| 605 | 1631 | $self->_set_current_node( $self->_current_node->getParent() ); | |
| 606 | } | ||
| 607 | |||
| 608 | 31 | __PACKAGE__->meta->make_immutable; | |
| 609 | |||
| 610 | 31 | 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 | ||