| 1 | package Pod::Simple::Wiki::Mediawiki; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Pod::Simple::Wiki::Mediawiki - A class for creating Pod to MediaWiki filters. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Copyright 2003-2012, John McNamara, jmcnamara@cpan.org | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # Documentation after __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | # perltidy with the following options: -mbl=2 -pt=0 -nola | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use Pod::Simple::Wiki; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 9 | ▶ | use vars qw(@ISA $VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | @ISA = qw(Pod::Simple::Wiki); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | $VERSION = '0.20'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # The tag to wiki mappings. | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 9 | my $tags = { | |||||||||||||||||||||||||||||||||||||||||
| 29 | '<b>' => "'''", | ||||||||||||||||||||||||||||||||||||||||||
| 30 | '</b>' => "'''", | ||||||||||||||||||||||||||||||||||||||||||
| 31 | '<i>' => "''", | ||||||||||||||||||||||||||||||||||||||||||
| 32 | '</i>' => "''", | ||||||||||||||||||||||||||||||||||||||||||
| 33 | '<tt>' => '<tt>', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | '</tt>' => '</tt>', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | '<pre>' => "<code>\n", | ||||||||||||||||||||||||||||||||||||||||||
| 36 | '</pre>' => "\n</code>\n", | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | '<h1>' => '==', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | '</h1>' => "==\n", | ||||||||||||||||||||||||||||||||||||||||||
| 40 | '<h2>' => '===', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | '</h2>' => "===\n", | ||||||||||||||||||||||||||||||||||||||||||
| 42 | '<h3>' => '====', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | '</h3>' => "====\n", | ||||||||||||||||||||||||||||||||||||||||||
| 44 | '<h4>' => '=====', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | '</h4>' => "=====\n", | ||||||||||||||||||||||||||||||||||||||||||
| 46 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # The default module options | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 9 | my $default_opts = { | |||||||||||||||||||||||||||||||||||||||||
| 54 | transformer_lists => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | link_prefix => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | sentence_case_headers => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | remove_name_section => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 62 | # | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # new() | ||||||||||||||||||||||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # Simple constructor inheriting from Pod::Simple::Wiki. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | # | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 38 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 38 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 38 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 38 | ▶ | if ( ref $_[-1] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 7 | $opts = pop @_; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | # Merge custom tags with the default tags, if passed. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | $opts->{tags} = { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | %$tags, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | %{ | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | exists $opts->{custom_tags} | |||||||||||||||||||||||||||||||||||||||||
| 80 | ? delete $opts->{custom_tags} | ||||||||||||||||||||||||||||||||||||||||||
| 81 | : {} | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 7 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 31 | $opts->{tags} = $tags; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 38 | $opts = { %$default_opts, %$opts }; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 38 | my $self = Pod::Simple::Wiki->new( 'wiki', @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | 38 | $self->{_tags} = $opts->{tags}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 38 | $self->{_transformer_lists} = $opts->{transformer_lists}; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 38 | $self->{_link_prefix} = $opts->{link_prefix}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 38 | $self->{_sentence_case_headers} = $opts->{sentence_case_headers}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 38 | $self->{_remove_name_section} = $opts->{remove_name_section}; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 38 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 38 | $self->accept_targets( 'mediawiki' ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 38 | $self->nbsp_for_S( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 38 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # _append() | ||||||||||||||||||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||||||||||||||||||
| 111 | # Appends some text to the buffered Wiki text. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 190 | ▶ | sub _append { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_append: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 190 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 190 | ▶ | if ( $self->{_indent_text} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 17 | $self->{_wiki_text} .= $self->{_indent_text}; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 17 | $self->{_indent_text} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 190 | $self->{_wiki_text} .= $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # _indent_item() | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||||||||||||||||
| 130 | # Indents an "over-item" to the correct level. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 51 | ▶ | sub _indent_item { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indent_item: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 51 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 51 | my $item_type = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 51 | my $item_param = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 51 | my $indent_level = $self->{_item_indent}; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 51 | ▶ | if ( $item_type eq 'bullet' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | $self->_append( '*' x $indent_level . ' ' ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | elsif ( $item_type eq 'number' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 16 | $self->_append( '#' x $indent_level . ' ' ); | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | elsif ( $item_type eq 'text' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 19 | $self->_append( ':' x ( $indent_level - 1 ) . '; ' ); | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # Functions to deal with links. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 8 | ▶ | sub _start_L { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_L: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 8 | my ( $self, $attr ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 8 | ▶ | if ( !$self->_skip_headings ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | $self->_append( '' ); # In case we have _indent_text pending | |||||||||||||||||||||||||||||||||||||||||
| 161 | # Flush the text buffer, so it will contain only the link text | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 8 | $self->_output; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 8 | $self->{_link_attr} = $attr; # Save for later | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 8 | ▶ | sub _end_L { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_end_L: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 8 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | my $attr = delete $self->{_link_attr}; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | ▶ | if ( $attr and my $method = $self->can( '_format_link' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$attr and my $method = $self->can("_format_link")
MC/DC0%0/2
$attr and my $method = $self->can("_format_link")
$attr
my $method = $self->can("_format_link")
Truth table33%1/3
A and B
A= $attrB= my $method = $self->can("_format_link")
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | $self->{_wiki_text} = $method->( $self, $self->{_wiki_text}, $attr ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # _format_link | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 8 | ▶ | sub _format_link { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_link: called CC=11 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 8 | my ( $self, $text, $attr ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | ▶ | if ( $attr->{type} eq 'url' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | my $link = $attr->{to}; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | ▶ | return $link if $attr->{'content-implicit'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | return "[$link $text]"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # Manpage: | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | ▶ | if ( $attr->{type} eq 'man' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # FIXME link to http://www.linuxmanpages.com? | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return "<tt>$text</tt>" if $attr->{'content-implicit'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return "$text (<tt>$attr->{to}</tt>)"; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | ▶ | die "Unknown link type $attr->{type}" unless $attr->{type} eq 'pod'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | # Handle a link within this page: | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | ▶ | return "[[#$attr->{section}|$text]]" unless defined $attr->{to}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # Handle a link to a specific section in another page: | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | if ( defined $attr->{section} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | return $self->{_link_prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | ? "[$self->{_link_prefix}$attr->{to}#$attr->{section} $text]" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | : "[[$attr->{to}#$attr->{section}|$text]]"; | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | if ( $attr->{'content-implicit'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | return $self->{_link_prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | ? "[$self->{_link_prefix}$attr->{to} $attr->{to}]" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | : "[[$attr->{to}]]"; | ||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return "[[$attr->{to}|$text]]"; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # _handle_text() | ||||||||||||||||||||||||||||||||||||||||||
| 227 | # | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # Perform any necessary transforms on the text. This is mainly used to escape | ||||||||||||||||||||||||||||||||||||||||||
| 229 | # inadvertent CamelCase words. | ||||||||||||||||||||||||||||||||||||||||||
| 230 | # | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 97 | ▶ | sub _handle_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_text: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 97 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 97 | my $text = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 97 | ▶ | if ( $self->{_sentence_case_headers} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | if ( $self->{_in_head1} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | $text = ucfirst( lc( $text ) ); | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 97 | ▶ | if ( !$self->{_in_Data} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | # Escape colons in definition lists: | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 97 | ▶ | if ( $self->{_in_item_text} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 19 | $text =~ s/:/:/g; # A colon would end the item | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | # Escape empty lines in verbatim sections: | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 97 | ▶ | if ( $self->{_in_Verbatim} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | $text =~ s/^$/ /mg; # An empty line would split the section | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 97 | $text =~ s/\xA0/ /g; # Convert non-breaking spaces to entities | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 97 | $text =~ s/''/''/g; # It's not a formatting code | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 97 | $text =~ s/\xA9/©/g; # Convert copyright symbols to entities | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 97 | $self->_append( $text ); | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # | ||||||||||||||||||||||||||||||||||||||||||
| 267 | # Functions to deal with =over ... =back regions for | ||||||||||||||||||||||||||||||||||||||||||
| 268 | # | ||||||||||||||||||||||||||||||||||||||||||
| 269 | # Bulleted lists | ||||||||||||||||||||||||||||||||||||||||||
| 270 | # Numbered lists | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # Text lists | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # Block lists | ||||||||||||||||||||||||||||||||||||||||||
| 273 | # | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 19 | ▶ | sub _end_item_text { } # _start_Para will insert the : | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_end_item_text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 278 | # | ||||||||||||||||||||||||||||||||||||||||||
| 279 | # _start_Para() | ||||||||||||||||||||||||||||||||||||||||||
| 280 | # | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # Special handling for paragraphs that are part of an "over" block. | ||||||||||||||||||||||||||||||||||||||||||
| 282 | # | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 34 | ▶ | sub _start_Para { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_Para: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 34 | my $indent_level = $self->{_item_indent}; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 34 | ▶ | if ( $self->{_in_over_block} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | $self->{_indent_text} = ( ':' x $indent_level ); | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 34 | ▶ | if ( $self->{_in_over_text} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 16 | $self->{_indent_text} = "\n" . ( ':' x $indent_level ); | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 34 | ▶ | if ( $self->{_transformer_lists} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | if ( $self->{_in_over_bullet} || $self->{_in_over_number} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_in_over_bullet"} or $self->{"_in_over_number"}
MC/DC0%0/2
$self->{"_in_over_bullet"} or $self->{"_in_over_number"}
$self->{"_in_over_bullet"}
$self->{"_in_over_number"}
Truth table33%1/3
A or B
A= $self->{"_in_over_bullet"}B= $self->{"_in_over_number"}
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | ▶ | if ( $self->{output_string} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | chomp( ${ $self->{output_string} } ); | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 2 | $self->{_indent_text} = "<p>"; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 308 | # | ||||||||||||||||||||||||||||||||||||||||||
| 309 | # _end_Para() | ||||||||||||||||||||||||||||||||||||||||||
| 310 | # | ||||||||||||||||||||||||||||||||||||||||||
| 311 | # Special handling for paragraphs that are part of an "over_text" block. | ||||||||||||||||||||||||||||||||||||||||||
| 312 | # | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 34 | ▶ | sub _end_Para { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_end_Para: called CC=8 SCAR=25.4
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | # Only add a newline if the paragraph isn't part of a text | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 34 | ▶ | if ( $self->{_in_over_text} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | # Do nothing in this format. | ||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | ▶ | elsif ( $self->{_transformer_lists} | |||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$self->{"_transformer_lists"} and $self->{"_in_over_bullet"} || $self->{"_in_over_number"}
$self->{"_in_over_bullet"} or $self->{"_in_over_number"}
MC/DC0%0/3
$self->{"_transformer_lists"} and $self->{"_in_over_bullet"} || $self->{"_in_over_number"}
$self->{"_transformer_lists"}
$self->{"_in_over_bullet"}
$self->{"_in_over_number"}
Truth table25%1/4
A and B or C
A= $self->{"_transformer_lists"}B= $self->{"_in_over_bullet"}C= $self->{"_in_over_number"}
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | && ( $self->{_in_over_bullet} || $self->{_in_over_number} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->_output( "</p>\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 18 | $self->_output( "\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 34 | ▶ | if ( !$self->{_transformer_lists} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->{'_transformer_lists'} && ($self->{'_in_over_bullet'} || $self->{'_in_over_number'})
$self->{"_in_over_bullet"} or $self->{"_in_over_number"}
MC/DC33%1/3
$self->{'_transformer_lists'} && ($self->{'_in_over_bullet'} || $self->{'_in_over_number'})
$self->{'_transformer_lists'}
$self->{"_in_over_bullet"}
$self->{"_in_over_number"}
Truth table50%2/4
A && B or C
A= $self->{'_transformer_lists'}B= $self->{"_in_over_bullet"}C= $self->{"_in_over_number"}
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | || ( !$self->{_in_over_bullet} && !$self->{_in_over_number} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 32 | $self->_output( "\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 342 | # | ||||||||||||||||||||||||||||||||||||||||||
| 343 | # _end_Data | ||||||||||||||||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||||||||||||||||
| 345 | # Special handling for data paragraphs | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub _end_Data { $_[0]->_output( "\n\n" ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_end_Data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # | ||||||||||||||||||||||||||||||||||||||||||
| 352 | # parse_string_document() | ||||||||||||||||||||||||||||||||||||||||||
| 353 | # | ||||||||||||||||||||||||||||||||||||||||||
| 354 | # Optional overriding of Pod::Simple method to remove the "NAME" section | ||||||||||||||||||||||||||||||||||||||||||
| 355 | # | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 38 | ▶ | sub parse_string_document { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_string_document: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 38 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 38 | $self = $self->SUPER::parse_string_document( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 38 | ▶ | if ( $self->{_remove_name_section} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 9 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | ${ $self->{output_string} } =~ | |||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | s/^==\s*NAME\s*==\n(?:[\w:]+)(?: - (.*))*/$1||''/iesg; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 38 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | __END__ | ||||||||||||||||||||||||||||||||||||||||||