| 1 | package Kwiki::Formatter; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use Spoon::Formatter -Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use mixin 'Kwiki::Installer'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 6 | const config_class => 'Kwiki::Config'; | |||||||||||||||||||||||||||
| 6 | 6 | const class_id => 'formatter'; | |||||||||||||||||||||||||||
| 7 | 6 | const class_title => 'Kwiki Formatter'; | |||||||||||||||||||||||||||
| 8 | 6 | const top_class => 'Kwiki::Formatter::Top'; | |||||||||||||||||||||||||||
| 9 | 6 | const class_prefix => 'Kwiki::Formatter::'; | |||||||||||||||||||||||||||
| 10 | 6 | const all_blocks => [qw(comment wafl_block hr heading ul ol pre table p)]; | |||||||||||||||||||||||||||
| 11 | 6 | const all_phrases => [qw( | |||||||||||||||||||||||||||
| 12 | asis wafl_phrase forced | ||||||||||||||||||||||||||||
| 13 | titlehyper titlewiki titlemailto | ||||||||||||||||||||||||||||
| 14 | hyper wiki mailto | ||||||||||||||||||||||||||||
| 15 | ndash mdash strong em u tt del | ||||||||||||||||||||||||||||
| 16 | )]; | ||||||||||||||||||||||||||||
| 17 | 6 | const css_file => 'formatter.css'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 6 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 6 | $self->hub->css->add_file($self->css_file); | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 5 | ▶ | sub formatter_classes { | ||||||||||||||||||||||||||
|
Subroutine
formatter_classes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 5 | qw( | |||||||||||||||||||||||||||
| 25 | Spoon::Formatter::WaflPhrase | ||||||||||||||||||||||||||||
| 26 | Spoon::Formatter::WaflBlock | ||||||||||||||||||||||||||||
| 27 | Line Heading Paragraph Preformatted Comment | ||||||||||||||||||||||||||||
| 28 | Ulist Olist Item Table TableRow TableCell | ||||||||||||||||||||||||||||
| 29 | Strong Emphasize Underline Delete Inline MDash NDash Asis | ||||||||||||||||||||||||||||
| 30 | ForcedLink HyperLink TitledHyperLink TitledMailLink MailLink | ||||||||||||||||||||||||||||
| 31 | TitledWikiLink WikiLink | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | ################################################################################ | ||||||||||||||||||||||||||||
| 36 | # Blocks | ||||||||||||||||||||||||||||
| 37 | ################################################################################ | ||||||||||||||||||||||||||||
| 38 | package Kwiki::Formatter::Top; | ||||||||||||||||||||||||||||
| 39 | 6 | ▶ | use base 'Spoon::Formatter::Container'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 6 | const formatter_id => 'top'; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | ################################################################################ | ||||||||||||||||||||||||||||
| 43 | package Kwiki::Formatter::Comment; | ||||||||||||||||||||||||||||
| 44 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 6 | const formatter_id => 'comment'; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 6 | const html_start => "<!-- \n"; | |||||||||||||||||||||||||||
| 48 | 6 | const html_end => " -->\n"; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 19 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 51 | 19 | ▶ | return unless $self->text =~ /^((?:#[\ \t].*\n)+)/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $self->set_match; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub text_filter { | ||||||||||||||||||||||||||
|
Subroutine
text_filter: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 56 | 0 | my $comment = shift; | |||||||||||||||||||||||||||
| 57 | 0 | $comment =~ s/^# //gm; | |||||||||||||||||||||||||||
| 58 | 0 | $comment =~ s/-/-/g; | |||||||||||||||||||||||||||
| 59 | 0 | return $comment; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | ################################################################################ | ||||||||||||||||||||||||||||
| 63 | package Kwiki::Formatter::Line; | ||||||||||||||||||||||||||||
| 64 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 6 | const formatter_id => 'hr'; | |||||||||||||||||||||||||||
| 66 | 6 | const pattern_block => qr/^----+\s*\n/m; | |||||||||||||||||||||||||||
| 67 | 6 | const html => "<hr />\n"; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | ################################################################################ | ||||||||||||||||||||||||||||
| 70 | package Kwiki::Formatter::Heading; | ||||||||||||||||||||||||||||
| 71 | 6 | ▶ | use base 'Spoon::Formatter::Block'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 72 | 6 | const formatter_id => 'heading'; | |||||||||||||||||||||||||||
| 73 | 6 | field 'level'; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 3 | ▶ | sub html_start { '<h' . $self->level . '>' } | ||||||||||||||||||||||||||
|
Subroutine
html_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | 3 | ▶ | sub html_end { '</h' . $self->level . ">\n" } | ||||||||||||||||||||||||||
|
Subroutine
html_end: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 20 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 79 | 20 | ▶ | return unless $self->text =~ /^(={1,6})\s+(.*?)(\s+=+)?\s*\n+/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 4 | $self->level(length($1)); | |||||||||||||||||||||||||||
| 81 | 4 | $self->set_match($2); | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | ################################################################################ | ||||||||||||||||||||||||||||
| 85 | package Kwiki::Formatter::Paragraph; | ||||||||||||||||||||||||||||
| 86 | 6 | ▶ | use base 'Spoon::Formatter::Block'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | 6 | const formatter_id => 'p'; | |||||||||||||||||||||||||||
| 88 | 6 | const pattern_block => | |||||||||||||||||||||||||||
| 89 | qr/((?:^(?!(?:[\=\*\0]+ |[\#\|\s]|\.\w+\s*\n|-{4,}\s*\n)).*\S.*\n)+(^\s*\n)*)/m; | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 6 | const html_start => "<p>\n"; | |||||||||||||||||||||||||||
| 92 | 6 | const html_end => "</p>\n"; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | ################################################################################ | ||||||||||||||||||||||||||||
| 95 | package Kwiki::Formatter::List; | ||||||||||||||||||||||||||||
| 96 | 6 | ▶ | use base 'Spoon::Formatter::Container'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 97 | 6 | const contains_blocks => [qw(li)]; | |||||||||||||||||||||||||||
| 98 | 6 | field 'level'; | |||||||||||||||||||||||||||
| 99 | 6 | field 'start_level'; | |||||||||||||||||||||||||||
| 100 | 6 | field 'tag_stack' => []; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 29 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 103 | 29 | my $bullet = $self->bullet; | |||||||||||||||||||||||||||
| 104 | return unless | ||||||||||||||||||||||||||||
| 105 | 29 | ▶ | $self->text =~ /((?:^($bullet).*\n)(?:^\2(?!$bullet).*\n)*)/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 6 | $self->set_match; | |||||||||||||||||||||||||||
| 107 | 6 | ($bullet = $2) =~ s/\s//g; | |||||||||||||||||||||||||||
| 108 | 6 | $self->level(length($bullet)); | |||||||||||||||||||||||||||
| 109 | 6 | return 1; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 6 | ▶ | sub html_start { | ||||||||||||||||||||||||||
|
Subroutine
html_start: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 113 | 6 | my $next = $self->next_unit; | |||||||||||||||||||||||||||
| 114 | 6 | my $tag_stack = $self->tag_stack; | |||||||||||||||||||||||||||
| 115 | 6 | ▶ | $next->tag_stack($tag_stack) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $next and $next->isa("Kwiki::Formatter::List")
MC/DC50%1/2
ref $next and $next->isa("Kwiki::Formatter::List")
ref $next
$next->isa("Kwiki::Formatter::List")
Truth table66%2/3
A and B
A= ref $nextB= $next->isa("Kwiki::Formatter::List")
| |||||||||||||||||||||||||||||
| 116 | if ref($next) and $next->isa('Kwiki::Formatter::List'); | ||||||||||||||||||||||||||||
| 117 | 6 | ▶ | my $level = defined $self->start_level | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | ? $self->start_level : $self->level; | ||||||||||||||||||||||||||||
| 119 | 6 | push @$tag_stack, ($self->html_end_tag) x $level; | |||||||||||||||||||||||||||
| 120 | 6 | return ($self->html_start_tag x $level) . "\n"; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 6 | ▶ | sub html_end { | ||||||||||||||||||||||||||
|
Subroutine
html_end: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||
| 124 | 6 | my $level = $self->level; | |||||||||||||||||||||||||||
| 125 | 6 | my $tag_stack = $self->tag_stack; | |||||||||||||||||||||||||||
| 126 | 6 | my $next = $self->next_unit; | |||||||||||||||||||||||||||
| 127 | 6 | my $newline = "\n"; | |||||||||||||||||||||||||||
| 128 | 6 | ▶ | if (ref($next) and $next->isa('Kwiki::Formatter::List')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $next and $next->isa("Kwiki::Formatter::List")
MC/DC50%1/2
ref $next and $next->isa("Kwiki::Formatter::List")
ref $next
$next->isa("Kwiki::Formatter::List")
Truth table66%2/3
A and B
A= ref $nextB= $next->isa("Kwiki::Formatter::List")
| |||||||||||||||||||||||||||||
| 129 | 1 | my $next_level = $next->level; | |||||||||||||||||||||||||||
| 130 | 1 | ▶ | if ($level < $next_level) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | $next->start_level($next_level - $level); | |||||||||||||||||||||||||||
| 132 | 0 | $level = 0; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||
| 135 | 1 | $next->start_level(0); | |||||||||||||||||||||||||||
| 136 | 1 | $level = $level - $next_level; | |||||||||||||||||||||||||||
| 137 | 1 | $newline = ''; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | 1 | ▶ | if ($self->level - $level == $next->level and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->level - $level == $next->level and $self->formatter_id ne $next->formatter_id
MC/DC0%0/2
$self->level - $level == $next->level and $self->formatter_id ne $next->formatter_id
$self->level - $level == $next->level
$self->formatter_id ne $next->formatter_id
Truth table33%1/3
A and B
A= $self->level - $level == $next->levelB= $self->formatter_id ne $next->formatter_id
| |||||||||||||||||||||||||||||
| 140 | $self->formatter_id ne $next->formatter_id | ||||||||||||||||||||||||||||
| 141 | ) { | ||||||||||||||||||||||||||||
| 142 | 0 | $level++; | |||||||||||||||||||||||||||
| 143 | 0 | $next->start_level($next->start_level + 1); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | 6 | return join('', reverse splice(@$tag_stack, 0 - $level, $level)) | |||||||||||||||||||||||||||
| 147 | . $newline; | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | ################################################################################ | ||||||||||||||||||||||||||||
| 151 | package Kwiki::Formatter::Ulist; | ||||||||||||||||||||||||||||
| 152 | 6 | ▶ | use base 'Kwiki::Formatter::List'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 153 | 6 | const formatter_id => 'ul'; | |||||||||||||||||||||||||||
| 154 | 6 | const html_start_tag => '<ul>'; | |||||||||||||||||||||||||||
| 155 | 6 | const html_end_tag => '</ul>'; | |||||||||||||||||||||||||||
| 156 | 6 | const bullet => '\*+\ +'; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | ################################################################################ | ||||||||||||||||||||||||||||
| 159 | package Kwiki::Formatter::Olist; | ||||||||||||||||||||||||||||
| 160 | 6 | ▶ | use base 'Kwiki::Formatter::List'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 161 | 6 | const formatter_id => 'ol'; | |||||||||||||||||||||||||||
| 162 | 6 | const html_start_tag => '<ol>'; | |||||||||||||||||||||||||||
| 163 | 6 | const html_end_tag => '</ol>'; | |||||||||||||||||||||||||||
| 164 | 6 | const bullet => '0+\ +'; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | ################################################################################ | ||||||||||||||||||||||||||||
| 167 | package Kwiki::Formatter::Item; | ||||||||||||||||||||||||||||
| 168 | 6 | ▶ | use base 'Spoon::Formatter::Block'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 169 | 6 | const formatter_id => 'li'; | |||||||||||||||||||||||||||
| 170 | 6 | const html_start => "<li>"; | |||||||||||||||||||||||||||
| 171 | 6 | const html_end => "</li>\n"; | |||||||||||||||||||||||||||
| 172 | 6 | const bullet => '[0\*]+\ +'; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 10 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 175 | 10 | my $bullet = $self->bullet; | |||||||||||||||||||||||||||
| 176 | return unless | ||||||||||||||||||||||||||||
| 177 | 10 | ▶ | $self->text =~ /^$bullet(.*)\n/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 10 | $self->set_match; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | ################################################################################ | ||||||||||||||||||||||||||||
| 182 | package Kwiki::Formatter::Preformatted; | ||||||||||||||||||||||||||||
| 183 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 184 | 6 | const formatter_id => 'pre'; | |||||||||||||||||||||||||||
| 185 | 6 | const html_start => qq{<pre class="formatter_pre">}; | |||||||||||||||||||||||||||
| 186 | 6 | const html_end => "</pre>\n"; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 12 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 189 | 12 | ▶ | return unless $self->text =~ /((?:^ +\S.*?\n|^ *\n)+)/m; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 8 | my $text = $1; | |||||||||||||||||||||||||||
| 191 | 8 | $self->set_match; | |||||||||||||||||||||||||||
| 192 | 8 | ▶ | return unless $text =~ /\S/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 2 | return 1; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 2 | ▶ | sub text_filter { | ||||||||||||||||||||||||||
|
Subroutine
text_filter: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 197 | 2 | my $text = shift; | |||||||||||||||||||||||||||
| 198 | 2 | $text =~ s/(?<=\n)\s*$//mg; | |||||||||||||||||||||||||||
| 199 | 2 | my $indent; | |||||||||||||||||||||||||||
| 200 | 2 | for ($text =~ /^( +)/gm) { | |||||||||||||||||||||||||||
| 201 | 6 | ▶ | $indent = length() | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $indent or length $_ < $indent
MC/DC50%1/2
not defined $indent or length $_ < $indent
not defined $indent
length $_ < $indent
Truth table66%2/3
not(A) or B
A= not defined $indentB= length $_ < $indent
| |||||||||||||||||||||||||||||
| 202 | if not defined $indent or | ||||||||||||||||||||||||||||
| 203 | length() < $indent; | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | 2 | $text =~ s/^ {$indent}//gm; | |||||||||||||||||||||||||||
| 206 | 2 | $text; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | ################################################################################ | ||||||||||||||||||||||||||||
| 210 | # XXX Support colspan | ||||||||||||||||||||||||||||
| 211 | package Kwiki::Formatter::Table; | ||||||||||||||||||||||||||||
| 212 | 6 | ▶ | use base 'Spoon::Formatter::Container'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 213 | 6 | const formatter_id => 'table'; | |||||||||||||||||||||||||||
| 214 | 6 | const contains_blocks => [qw(tr)]; | |||||||||||||||||||||||||||
| 215 | 6 | const pattern_block => qr/((^\|.*?\|\n)+)/sm; | |||||||||||||||||||||||||||
| 216 | 6 | const html_start => qq{<table class="formatter_table">\n}; | |||||||||||||||||||||||||||
| 217 | 6 | const html_end => "</table>\n"; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | ################################################################################ | ||||||||||||||||||||||||||||
| 220 | package Kwiki::Formatter::TableRow; | ||||||||||||||||||||||||||||
| 221 | 6 | ▶ | use base 'Spoon::Formatter::Container'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 222 | 6 | const formatter_id => 'tr'; | |||||||||||||||||||||||||||
| 223 | 6 | const contains_blocks => [qw(td)]; | |||||||||||||||||||||||||||
| 224 | 6 | const pattern_block => qr/(^\|.*?\|\n)/sm; | |||||||||||||||||||||||||||
| 225 | 6 | const html_start => "<tr>\n"; | |||||||||||||||||||||||||||
| 226 | 6 | const html_end => "</tr>\n"; | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | ################################################################################ | ||||||||||||||||||||||||||||
| 229 | package Kwiki::Formatter::TableCell; | ||||||||||||||||||||||||||||
| 230 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 231 | 6 | const formatter_id => 'td'; | |||||||||||||||||||||||||||
| 232 | 6 | field contains_blocks => []; | |||||||||||||||||||||||||||
| 233 | 6 | field contains_phrases => []; | |||||||||||||||||||||||||||
| 234 | 6 | const table_blocks => [qw(wafl_block hr heading ul ol pre p)]; | |||||||||||||||||||||||||||
| 235 | 11 | ▶ | sub table_phrases { $self->hub->formatter->all_phrases } | ||||||||||||||||||||||||||
|
Subroutine
table_phrases: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 236 | 6 | const html_start => "<td>"; | |||||||||||||||||||||||||||
| 237 | 6 | const html_end => "</td>\n"; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 14 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 240 | 14 | ▶ | return unless $self->text =~ /(\|(\s*.*?\s*)\|)(.*)/sm; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 14 | $self->start_offset($-[1]); | |||||||||||||||||||||||||||
| 242 | 14 | ▶ | $self->end_offset($3 eq "\n" ? $+[3] : $+[2]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 14 | my $text = $2; | |||||||||||||||||||||||||||
| 244 | 14 | $text =~ s/^[ \t]*\n?(.*?)[ \t]*$/$1/; | |||||||||||||||||||||||||||
| 245 | 14 | $self->text($text); | |||||||||||||||||||||||||||
| 246 | 14 | ▶ | if ($text =~ /\n/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 3 | $self->contains_blocks($self->table_blocks); | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | else { | ||||||||||||||||||||||||||||
| 250 | 11 | $self->contains_phrases($self->table_phrases); | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | 14 | return 1; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | ################################################################################ | ||||||||||||||||||||||||||||
| 256 | # Phrase Classes | ||||||||||||||||||||||||||||
| 257 | ################################################################################ | ||||||||||||||||||||||||||||
| 258 | package Kwiki::Formatter::Strong; | ||||||||||||||||||||||||||||
| 259 | 6 | ▶ | use base 'Spoon::Formatter::Phrase'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 260 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 261 | 6 | const formatter_id => 'strong'; | |||||||||||||||||||||||||||
| 262 | 6 | const pattern_start => qr/(^|(?<=[^$ALPHANUM]))\*(?=\S)/; | |||||||||||||||||||||||||||
| 263 | 6 | const pattern_end => qr/\*(?=[^$ALPHANUM]|\z)/; | |||||||||||||||||||||||||||
| 264 | 6 | const html_start => "<strong>"; | |||||||||||||||||||||||||||
| 265 | 6 | const html_end => "</strong>"; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | ################################################################################ | ||||||||||||||||||||||||||||
| 268 | package Kwiki::Formatter::Emphasize; | ||||||||||||||||||||||||||||
| 269 | 6 | ▶ | use base 'Spoon::Formatter::Phrase'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 270 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 271 | 6 | const formatter_id => 'em'; | |||||||||||||||||||||||||||
| 272 | 6 | const pattern_start => qr/(^|(?<=[^$ALPHANUM]))\/(?=\S[^\/]*\/(?=\W|\z))/; | |||||||||||||||||||||||||||
| 273 | 6 | const pattern_end => qr/\/(?=[^$ALPHANUM]|\z)/; | |||||||||||||||||||||||||||
| 274 | 6 | const html_start => "<em>"; | |||||||||||||||||||||||||||
| 275 | 6 | const html_end => "</em>"; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | ################################################################################ | ||||||||||||||||||||||||||||
| 278 | package Kwiki::Formatter::Underline; | ||||||||||||||||||||||||||||
| 279 | 6 | ▶ | use base 'Spoon::Formatter::Phrase'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 280 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 281 | 6 | const formatter_id => 'u'; | |||||||||||||||||||||||||||
| 282 | 6 | const pattern_start => qr/(^|(?<=[^$ALPHANUM]))_(?=\S)/; | |||||||||||||||||||||||||||
| 283 | 6 | const pattern_end => qr/_(?=[^$ALPHANUM]|\z)/; | |||||||||||||||||||||||||||
| 284 | 6 | const html_start => "<u>"; | |||||||||||||||||||||||||||
| 285 | 6 | const html_end => "</u>"; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | ################################################################################ | ||||||||||||||||||||||||||||
| 288 | package Kwiki::Formatter::Inline; | ||||||||||||||||||||||||||||
| 289 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 290 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 291 | 6 | const formatter_id => 'tt'; | |||||||||||||||||||||||||||
| 292 | 6 | const pattern_start => qr/(^|(?<=[^$ALPHANUM]))\[\=/; | |||||||||||||||||||||||||||
| 293 | 6 | const pattern_end => qr/\](?=[^$ALPHANUM]|\z)/; | |||||||||||||||||||||||||||
| 294 | 6 | const html_start => "<tt>"; | |||||||||||||||||||||||||||
| 295 | 6 | const html_end => "</tt>"; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | ################################################################################ | ||||||||||||||||||||||||||||
| 298 | package Kwiki::Formatter::Delete; | ||||||||||||||||||||||||||||
| 299 | 6 | ▶ | use base 'Spoon::Formatter::Phrase'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 300 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 301 | 6 | const formatter_id => 'del'; | |||||||||||||||||||||||||||
| 302 | 6 | const pattern_start => qr/(^|(?<=[^$ALPHANUM]))-(?=[^\-\s])/; | |||||||||||||||||||||||||||
| 303 | 6 | const pattern_end => qr/-(?=[^$ALPHANUM]|\z)/; | |||||||||||||||||||||||||||
| 304 | 6 | const html_start => '<del>'; | |||||||||||||||||||||||||||
| 305 | 6 | const html_end => '</del>'; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | ################################################################################ | ||||||||||||||||||||||||||||
| 308 | # Empty Phrases (search & replace) | ||||||||||||||||||||||||||||
| 309 | ################################################################################ | ||||||||||||||||||||||||||||
| 310 | package Kwiki::Formatter::MDash; | ||||||||||||||||||||||||||||
| 311 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 312 | 6 | const formatter_id => 'mdash'; | |||||||||||||||||||||||||||
| 313 | 6 | const pattern_start => qr/\-{3}(?=[^-])/; | |||||||||||||||||||||||||||
| 314 | 6 | const html => '—'; | |||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | ################################################################################ | ||||||||||||||||||||||||||||
| 317 | package Kwiki::Formatter::NDash; | ||||||||||||||||||||||||||||
| 318 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 319 | 6 | const formatter_id => 'ndash'; | |||||||||||||||||||||||||||
| 320 | 6 | const pattern_start => qr/\-{2}(?=[^-])/; | |||||||||||||||||||||||||||
| 321 | 6 | const html => '–'; | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | ################################################################################ | ||||||||||||||||||||||||||||
| 324 | # Much Ado about Linking | ||||||||||||||||||||||||||||
| 325 | ################################################################################ | ||||||||||||||||||||||||||||
| 326 | package Kwiki::Formatter::ForcedLink; | ||||||||||||||||||||||||||||
| 327 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 328 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 329 | 6 | const formatter_id => 'forced'; | |||||||||||||||||||||||||||
| 330 | 6 | const pattern_start => qr/\[([$WORD]+)\]/; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 333 | 0 | $self->matched =~ $self->pattern_start; | |||||||||||||||||||||||||||
| 334 | 0 | my $target = $1; | |||||||||||||||||||||||||||
| 335 | 0 | my $script = $self->hub->config->script_name; | |||||||||||||||||||||||||||
| 336 | 0 | my $text = $self->escape_html( $target ); | |||||||||||||||||||||||||||
| 337 | 0 | my $page = $self->hub->pages->new_from_name($target); | |||||||||||||||||||||||||||
| 338 | 0 | ▶ | return $target unless $page; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | ▶ | my $class = $page->exists | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | ? '' : ' class="empty"'; | ||||||||||||||||||||||||||||
| 341 | 0 | return qq(<a href="$script?$target"$class>$target</a>); | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | ################################################################################ | ||||||||||||||||||||||||||||
| 345 | package Kwiki::Formatter::HyperLink; | ||||||||||||||||||||||||||||
| 346 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 347 | 6 | const formatter_id => 'hyper'; | |||||||||||||||||||||||||||
| 348 | 6 | our $pattern = qr{\w+:(?://|\?)\S+?(?=[),.:;]?\s|$)}; | |||||||||||||||||||||||||||
| 349 | 6 | const pattern_start => qr/$pattern|!$pattern/; | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 1 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 352 | 1 | my $text = $self->escape_html($self->matched); | |||||||||||||||||||||||||||
| 353 | 1 | ▶ | return $text if $text =~ s/^!//; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | 1 | ▶ | return qq(<img src="$text" />) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | if $text =~ /(?:jpe?g|gif|png)$/i; | ||||||||||||||||||||||||||||
| 356 | 1 | return qq(<a href="$text">$text</a>); | |||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | ################################################################################ | ||||||||||||||||||||||||||||
| 360 | package Kwiki::Formatter::TitledHyperLink; | ||||||||||||||||||||||||||||
| 361 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 362 | 6 | const formatter_id => 'titlehyper'; | |||||||||||||||||||||||||||
| 363 | 6 | const pattern_start => | |||||||||||||||||||||||||||
| 364 | qr{\[(?:\s*([^\]]+)\s+)?(\w+:(?://|\?)[^\]\s]+)(?:\s+([^\]]+)\s*)?\]}; | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 1 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 367 | 1 | my $text = $self->escape_html($self->matched); | |||||||||||||||||||||||||||
| 368 | 1 | my ($title1, $target, $title2) = ($text =~ $self->pattern_start); | |||||||||||||||||||||||||||
| 369 | 1 | ▶ | $title1 = '' unless defined $title1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 370 | 1 | ▶ | $title2 = '' unless defined $title2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | 1 | $target =~ s{^\w+:(?!//)}{}; | |||||||||||||||||||||||||||
| 372 | 1 | my $title = $title1 . ' ' . $title2; | |||||||||||||||||||||||||||
| 373 | 1 | $title =~ s/^\s*(.*?)\s*$/$1/; | |||||||||||||||||||||||||||
| 374 | 1 | ▶ | $title = $target | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | unless $title =~ /\S/; | ||||||||||||||||||||||||||||
| 376 | 1 | return qq(<a href="$target">$title</a>); | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | ################################################################################ | ||||||||||||||||||||||||||||
| 380 | package Kwiki::Formatter::WikiLink; | ||||||||||||||||||||||||||||
| 381 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 382 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 383 | 6 | const formatter_id => 'wiki'; | |||||||||||||||||||||||||||
| 384 | 6 | our $pattern = qr/[$UPPER](?=[$WORD]*[$UPPER])(?=[$WORD]*[$LOWER])[$WORD]+/; | |||||||||||||||||||||||||||
| 385 | 6 | const pattern_start => qr/$pattern|!$pattern/; | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 1 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 388 | 1 | my $page_name = $self->escape_html($self->matched); | |||||||||||||||||||||||||||
| 389 | 1 | ▶ | return $page_name | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | if $page_name =~ s/^!//; | ||||||||||||||||||||||||||||
| 391 | 1 | my $page = $self->hub->pages->new_from_name($page_name); | |||||||||||||||||||||||||||
| 392 | 0 | ▶ | return $page_name unless $page; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 0 | return $page->kwiki_link; | |||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | ################################################################################ | ||||||||||||||||||||||||||||
| 397 | package Kwiki::Formatter::TitledWikiLink; | ||||||||||||||||||||||||||||
| 398 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 399 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 400 | 6 | const formatter_id => 'titlewiki'; | |||||||||||||||||||||||||||
| 401 | 6 | const pattern_start => | |||||||||||||||||||||||||||
| 402 | qr/\[([^\]]*)\s+([$UPPER](?=[$WORD]*[$UPPER])(?=[$WORD]*[$LOWER])[$WORD]+)\]/; | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 405 | 0 | my $text = $self->escape_html($self->matched); | |||||||||||||||||||||||||||
| 406 | 0 | my ($label, $page_name) = ($text =~ $self->pattern_start); | |||||||||||||||||||||||||||
| 407 | 0 | my $page = $self->hub->pages->new_from_name($page_name); | |||||||||||||||||||||||||||
| 408 | 0 | ▶ | return $label unless $page; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | 0 | return $page->kwiki_link($label); | |||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | ################################################################################ | ||||||||||||||||||||||||||||
| 413 | package Kwiki::Formatter::MailLink; | ||||||||||||||||||||||||||||
| 414 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 415 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 416 | 6 | const formatter_id => 'mailto'; | |||||||||||||||||||||||||||
| 417 | 6 | our $pattern = qr/[$ALPHANUM][$WORD\+\-\.]*@[$WORD][$WORD\-\.]+/; | |||||||||||||||||||||||||||
| 418 | 6 | const pattern_start => qr/$pattern|!$pattern/; | |||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 421 | 0 | my $text = $self->escape_html( $self->matched ); | |||||||||||||||||||||||||||
| 422 | 0 | ▶ | return $text if $text =~ s/^!//; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | my $dot = ($text =~ s/(\.+)$//) ? $1 : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 0 | return qq(<a href="mailto:$text">$text</a>$dot); | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | ################################################################################ | ||||||||||||||||||||||||||||
| 428 | package Kwiki::Formatter::TitledMailLink; | ||||||||||||||||||||||||||||
| 429 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 430 | 6 | ▶ | use Kwiki ':char_classes'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 431 | 6 | const formatter_id => 'titlemailto'; | |||||||||||||||||||||||||||
| 432 | 6 | const pattern_start => | |||||||||||||||||||||||||||
| 433 | qr/\[([^\]]+)\s+([$ALPHANUM][$WORD\+\-\.]*@[$WORD][$WORD\-\.]+)\]/; | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 0 | ▶ | sub html { | ||||||||||||||||||||||||||
|
Subroutine
html: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 436 | 0 | my $text = $self->escape_html($self->matched); | |||||||||||||||||||||||||||
| 437 | 0 | my ($title, $addr) = ($text =~ $self->pattern_start); | |||||||||||||||||||||||||||
| 438 | 0 | ▶ | my $dot = ($addr =~ s/(\.+)$//) ? $1 : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 439 | 0 | return qq(<a href="mailto:$addr">$title</a>$dot); | |||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | ################################################################################ | ||||||||||||||||||||||||||||
| 443 | package Kwiki::Formatter::Asis; | ||||||||||||||||||||||||||||
| 444 | 6 | ▶ | use base 'Spoon::Formatter::Unit'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 445 | 6 | const formatter_id => 'asis'; | |||||||||||||||||||||||||||
| 446 | 6 | const pattern_start => qr/\{\{/; | |||||||||||||||||||||||||||
| 447 | 6 | const pattern_end => qr/\}\}/; | |||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | package Kwiki::Formatter; | ||||||||||||||||||||||||||||
| 450 | 6 | __DATA__ | |||||||||||||||||||||||||||