| 1 | package HTML::WikiConverter::MultiMarkdown; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | our $VERSION = '0.02'; | |||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use base 'HTML::WikiConverter::Markdown'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Params::Validate qw( ARRAYREF ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | sub rules | ||||||||||
| 14 | 3 | ▶ | { | ||||||||
|
Subroutine
rules: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 15 | 3 | my $self = shift; | |||||||||
| 16 | |||||||||||
| 17 | 3 | my $rules = $self->SUPER::rules(@_); | |||||||||
| 18 | |||||||||||
| 19 | return | ||||||||||
| 20 | 3 | { %{$rules}, | |||||||||
| 21 | table => { block => 1, | ||||||||||
| 22 | end => \&_table_end, | ||||||||||
| 23 | }, | ||||||||||
| 24 | tr => { start => \&_tr_start, | ||||||||||
| 25 | end => qq{ |\n}, | ||||||||||
| 26 | line_format => 'single' | ||||||||||
| 27 | }, | ||||||||||
| 28 | td => { start => \&_td_start, | ||||||||||
| 29 | end => q{ } }, | ||||||||||
| 30 | th => { alias => 'td', }, | ||||||||||
| 31 | title => { replace => \&_title }, | ||||||||||
| 32 | }; | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub attributes | ||||||||||
| 36 | 1 | ▶ | { | ||||||||
|
Subroutine
attributes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 37 | 1 | my $self = shift; | |||||||||
| 38 | |||||||||||
| 39 | return | ||||||||||
| 40 | 1 | { %{ $self->SUPER::attributes() }, | |||||||||
| 41 | strip_tags => { type => ARRAYREF, default => [ qw( ~comment script style / ) ] }, | ||||||||||
| 42 | }; | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | sub _title | ||||||||||
| 46 | 2 | ▶ | { | ||||||||
|
Subroutine
_title: called CC=1 SCAR=0.0
| |||||||||||
| 47 | 2 | my $self = shift; | |||||||||
| 48 | 2 | my $node = shift; | |||||||||
| 49 | |||||||||||
| 50 | 2 | my $text = $self->get_elem_contents($node); | |||||||||
| 51 | |||||||||||
| 52 | 2 | return 'Title: ' . $text; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub _table_end | ||||||||||
| 56 | 1 | ▶ | { | ||||||||
|
Subroutine
_table_end: called CC=1 SCAR=0.0
| |||||||||||
| 57 | 1 | my $self = shift; | |||||||||
| 58 | |||||||||||
| 59 | 1 | delete $self->{__row_count__}; | |||||||||
| 60 | 1 | delete $self->{__th_count__}; | |||||||||
| 61 | |||||||||||
| 62 | 1 | return q{}; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | # This method is first called on the _second_ row, go figure | ||||||||||
| 67 | sub _tr_start | ||||||||||
| 68 | 3 | ▶ | { | ||||||||
|
Subroutine
_tr_start: called CC=2 SCAR=6.9
| |||||||||||
| 69 | 3 | my $self = shift; | |||||||||
| 70 | |||||||||||
| 71 | 3 | my $start = q{}; | |||||||||
| 72 | 3 | ▶ | if ( $self->{__row_count__} == 2 ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | { | ||||||||||
| 74 | 1 | $start = '|---' x $self->{__th_count__}; | |||||||||
| 75 | 1 | $start .= qq{|\n}; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 3 | $self->{__row_count__}++; | |||||||||
| 79 | |||||||||||
| 80 | 3 | return $start; | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | # This method is called for the first cell in a table, and before the | ||||||||||
| 84 | # first call to table or tr start! | ||||||||||
| 85 | sub _td_start | ||||||||||
| 86 | 6 | ▶ | { | ||||||||
|
Subroutine
_td_start: called CC=4 SCAR=13.9
| |||||||||||
| 87 | 6 | my $self = shift; | |||||||||
| 88 | |||||||||||
| 89 | $self->{__row_count__} = 1 | ||||||||||
| 90 | 6 | ▶ | unless exists $self->{__row_count__}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | |||||||||||
| 92 | 6 | ▶ | if ( $self->{__row_count__} == 1 ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | { | ||||||||||
| 94 | 2 | ▶ | if ( exists $self->{__th_count__} ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | { | ||||||||||
| 96 | 1 | $self->{__th_count__}++; | |||||||||
| 97 | } | ||||||||||
| 98 | else | ||||||||||
| 99 | { | ||||||||||
| 100 | 1 | $self->{__th_count__} = 1; | |||||||||
| 101 | } | ||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 6 | return '| '; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 1 | 1; | |||||||||
| 108 | |||||||||||
| 109 | __END__ | ||||||||||