| 1 | ## -*- perl -*- | ||||||||||||||||||||||||||||||||
| 2 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 3 | ## Markdown Parser Only - ~/lib/Markdown/Parser/Link.pm | ||||||||||||||||||||||||||||||||
| 4 | ## Version v0.3.0 | ||||||||||||||||||||||||||||||||
| 5 | ## Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||
| 6 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||
| 7 | ## Created 2021/08/23 | ||||||||||||||||||||||||||||||||
| 8 | ## Modified 2024/08/30 | ||||||||||||||||||||||||||||||||
| 9 | ## All rights reserved | ||||||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 14 | package Markdown::Parser::Link; | ||||||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use parent qw( Markdown::Parser::Element ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 2 | our $VERSION = 'v0.3.0'; | |||||||||||||||||||||||||||||||
| 22 | }; | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | sub init | ||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 29 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 30 | 1 | $self->{encrypt} = ''; | |||||||||||||||||||||||||||||||
| 31 | 1 | $self->{id} = []; | |||||||||||||||||||||||||||||||
| 32 | 1 | $self->{link_id} = ''; | |||||||||||||||||||||||||||||||
| 33 | 1 | $self->{name} = ''; | |||||||||||||||||||||||||||||||
| 34 | 1 | $self->{original} = ''; | |||||||||||||||||||||||||||||||
| 35 | 1 | $self->{tag_name} = 'link'; | |||||||||||||||||||||||||||||||
| 36 | 1 | $self->{title} = ''; | |||||||||||||||||||||||||||||||
| 37 | 1 | $self->{url} = ''; | |||||||||||||||||||||||||||||||
| 38 | 1 | return( $self->SUPER::init( @_ ) ); | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | sub as_markdown | ||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
as_markdown: called CC=10 SCAR=29.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 43 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 44 | 1 | my $arr = $self->new_array; | |||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | my $name = $self->children->map(sub{ $_->as_markdown })->join( '' ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 46 | 1 | $arr->push( sprintf( '[%s]', $name ) ); | |||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if( $self->link_id ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||
| 49 | 0 | $arr->push( sprintf( '[%s]', $self->link_id ) ); | |||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | ▶ | elsif( $self->url || $self->title ) | |||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->url or $self->title
MC/DC0%0/2
$self->url or $self->title
$self->url
$self->title
Truth table33%1/3
A or B
A= $self->urlB= $self->title
| |||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||
| 53 | 1 | $arr->push( '(' ); | |||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | $arr->push( sprintf( '%s', $self->url ) ) if( $self->url ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 55 | 1 | ▶ | $arr->push( ' ' ) if( $self->url && $self->title ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->url and $self->title
MC/DC0%0/2
$self->url and $self->title
$self->url
$self->title
Truth table33%1/3
A and B
A= $self->urlB= $self->title
| |||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | $arr->push( sprintf( '"%s"', $self->title ) ) if( $self->title ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 57 | 1 | $arr->push( ')' ); | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | if( $self->class->length || $self->id->length ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->class->length or $self->id->length
MC/DC0%0/2
$self->class->length or $self->id->length
$self->class->length
$self->id->length
Truth table33%1/3
A or B
A= $self->class->lengthB= $self->id->length
| |||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||
| 61 | 0 | my $def = $self->new_array; | |||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $def->push( $self->id->map(sub{ "\#${_}" })->list ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $def->push( $self->class->map(sub{ ".$_" })->list ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 64 | 0 | $arr->push( '{' . $def->join( ' ' )->scalar . '}' ); | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | 1 | return( $arr->join( '' )->scalar ); | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | sub as_pod | ||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
as_pod: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 72 | 0 | my $arr = $self->new_array; | |||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $name = $self->children->map(sub{ $_->as_pod })->join( '' ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if( $self->url && $name ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->url and $name
MC/DC0%0/2
$self->url and $name
$self->url
$name
Truth table0%0/3
A and B
A= $self->urlB= $name
| |||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||
| 76 | 0 | $arr->push( sprintf( 'L<%s|%s>', $name, $self->url ) ); | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | elsif( $self->url ) | ||||||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||||||
| 80 | 0 | $arr->push( sprintf( 'L<%s>', $self->url ) ); | |||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | 0 | return( $arr->join( '' )->scalar ); | |||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | sub as_string | ||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 87 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 88 | 0 | my $arr = $self->new_array; | |||||||||||||||||||||||||||||||
| 89 | 0 | my $tag = 'a'; | |||||||||||||||||||||||||||||||
| 90 | 0 | my $tag_open = $tag; | |||||||||||||||||||||||||||||||
| 91 | 0 | my $url = $self->url; | |||||||||||||||||||||||||||||||
| 92 | 0 | my $orig = $self->original->scalar; | |||||||||||||||||||||||||||||||
| 93 | 0 | my $url_str = "$url"; | |||||||||||||||||||||||||||||||
| 94 | 0 | my $encrypt = $self->encrypt; | |||||||||||||||||||||||||||||||
| 95 | 0 | my $scheme = ''; | |||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $scheme = $url->scheme if( ref( $url ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | 0 | $arr->push( "<${tag_open}" ); | |||||||||||||||||||||||||||||||
| 98 | 0 | my $attr = $self->new_array; | |||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $attr->push( $self->format_id ) if( $self->id->length ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $attr->push( $self->format_class ) if( $self->class->length ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | 0 | my $attributes = $self->format_attributes; | |||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $attr->push( $attributes->join( ' ' )->scalar ) if( $attributes->length ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $arr->push( ' ' . $attr->join( ' ' )->scalar ) if( $attr->length ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if( $scheme eq 'mailto' ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if( $encrypt eq 'obfuscate' ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||
| 108 | 0 | $self->document->setup_email_obfuscation; | |||||||||||||||||||||||||||||||
| 109 | # We use the original e-mail address as it as provided in the text, because URI alters it by url-encoding it | ||||||||||||||||||||||||||||||||
| 110 | 0 | my $email = $orig; | |||||||||||||||||||||||||||||||
| 111 | 0 | my $user = substr( $email, 0, rindex( $email, '@' ) ); | |||||||||||||||||||||||||||||||
| 112 | 0 | my $host = substr( $email, rindex( $email, '@' ) + 1 ); | |||||||||||||||||||||||||||||||
| 113 | # Use of a decoy email address | ||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if( $self->document->default_email->length > 0 ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||
| 116 | 0 | $arr->push( sprintf( ' href="%s"', $self->document->default_email->scalar ) ); | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | else | ||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||
| 120 | 0 | $arr->push( " href=\"mailto:dave.null\@${host}\"" ); | |||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $data_user = $self->document->email_obfuscate_data_user->scalar || 'user'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->document->email_obfuscate_data_user->scalar || 'user'
MC/DC0%0/1
$self->document->email_obfuscate_data_user->scalar || 'user'
$self->document->email_obfuscate_data_user->scalar
Truth table0%0/2
A
A= $self->document->email_obfuscate_data_user->scalar
| |||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my $data_host = $self->document->email_obfuscate_data_host->scalar || 'host'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->document->email_obfuscate_data_host->scalar || 'host'
MC/DC0%0/1
$self->document->email_obfuscate_data_host->scalar || 'host'
$self->document->email_obfuscate_data_host->scalar
Truth table0%0/2
A
A= $self->document->email_obfuscate_data_host->scalar
| |||||||||||||||||||||||||||||||||
| 124 | 0 | $arr->push( sprintf( ' data-%s="%s"', $data_user, $self->encode_html( ['"', '&', '?', '#'], join( '', reverse( split( //, $user ) ) ) ) ) ); | |||||||||||||||||||||||||||||||
| 125 | 0 | $arr->push( sprintf( ' data-%s="%s"', $data_host, $self->encode_html( ['"', '&', '?', '#'], join( '', reverse( split( //, $host ) ) ) ) ) ); | |||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $self->class->push( $self->document->email_obfuscate_class ) if( !$self->class->has( $self->document->email_obfuscate_class->scalar ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 127 | 0 | $arr->push( sprintf( ' class="%s"', $self->class->join( ', ' )->scalar ) ); | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | ▶ | elsif( $encrypt eq 'encode' || $encrypt ) | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$encrypt eq "encode" or $encrypt
MC/DC0%0/2
$encrypt eq "encode" or $encrypt
$encrypt eq "encode"
$encrypt
Truth table0%0/3
A or B
A= $encrypt eq "encode"B= $encrypt
| |||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||
| 131 | 0 | $url_str = $self->encode_email_address( $orig ); | |||||||||||||||||||||||||||||||
| 132 | 0 | $arr->push( " href=\"$url_str\"" ); | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | else | ||||||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||||||
| 136 | 0 | $arr->push( " href=\"$url_str\"" ); | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | else | ||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||
| 141 | 0 | $arr->push( " href=\"$url_str\"" ); | |||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if( $self->title->length ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||
| 145 | 0 | $arr->push( sprintf( ' title="%s"', $self->encode_html( 'all', $self->title ) ) ); | |||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | 0 | $arr->push( ">" ); | |||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if( $scheme eq 'mailto' && $encrypt eq 'obfuscate' ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$scheme eq "mailto" and $encrypt eq "obfuscate"
MC/DC0%0/2
$scheme eq "mailto" and $encrypt eq "obfuscate"
$scheme eq "mailto"
$encrypt eq "obfuscate"
Truth table0%0/3
A and B
A= $scheme eq "mailto"B= $encrypt eq "obfuscate"
| |||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||
| 150 | ## We do nothing | ||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | elsif( $self->children->length ) | ||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $arr->push( $self->children->map(sub{ $_->as_string })->list ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||
| 156 | else | ||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $link_text = $scheme eq 'mailto' ? $self->encode_email_address( $orig ) : $orig; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 159 | 0 | $arr->push( $link_text ); | |||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||
| 161 | 0 | $arr->push( "</${tag}>" ); | |||||||||||||||||||||||||||||||
| 162 | 0 | return( $arr->join( '' )->scalar ); | |||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | sub copy_from | ||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
copy_from: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 167 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $def = shift( @_ ) || return( $self->error( "No link definition object was provided." ) ); | ||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || (return $self->error('No link definition object was provided.'))
MC/DC0%0/1
shift @_ || (return $self->error('No link definition object was provided.'))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | return( $self->error( "Link definition object provided to copy information from \"", overload::StrVal( $def ), "\" is not a Markdown::Parser::LinkDefinition object." ) ) if( !$self->_is_a( $def, 'Markdown::Parser::LinkDefinition' ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 170 | 0 | return( $def->copy_to( $self ) ); | |||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | sub encrypt { return( shift->_set_get_scalar_as_object( 'encrypt', @_ ) ); } | ||||||||||||||||||||||||||||||
|
Subroutine
encrypt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | sub encode_email_address | ||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
encode_email_address: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 177 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 178 | 0 | my $addr = shift( @_ ); | |||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | return( '' ) if( !length( $addr ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | ## Borrowed from Markdown original author John Gruber | ||||||||||||||||||||||||||||||||
| 181 | 0 | srand(); | |||||||||||||||||||||||||||||||
| 182 | ## Use either decimal, hexadecimal or no encoding | ||||||||||||||||||||||||||||||||
| 183 | ## https://stackoverflow.com/questions/20357800/html-entities-when-to-use-decimal-vs-hex | ||||||||||||||||||||||||||||||||
| 184 | my @encode = | ||||||||||||||||||||||||||||||||
| 185 | ( | ||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub{ '&#' . ord( shift ) . ';' }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub{ '&#x' . sprintf( "%X", ord( shift ) ) . ';' }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub{ shift }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 189 | 0 | ); | |||||||||||||||||||||||||||||||
| 190 | 0 | my @chars = split( //, $addr ); | |||||||||||||||||||||||||||||||
| 191 | 0 | for my $i ( 0..$#chars ) | |||||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if( $chars[$i] eq '@' ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||
| 195 | ## Markdown's original author John Gruber says: "this *must* be encoded. I insist." | ||||||||||||||||||||||||||||||||
| 196 | 0 | $chars[$i] = $encode[ int( rand( 1 ) ) ]->( $chars[$i] ); | |||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | elsif( $chars[$i] ne ':' ) | ||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||
| 200 | ## leave ':' alone (to spot mailto: later) | ||||||||||||||||||||||||||||||||
| 201 | 0 | my $r = rand(); | |||||||||||||||||||||||||||||||
| 202 | # roughly 10% raw, 45% hex, 45% dec | ||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | $chars[$i] = ( | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 204 | $r > .9 ? $encode[2]->( $chars[$i] ) : | ||||||||||||||||||||||||||||||||
| 205 | $r < .45 ? $encode[1]->( $chars[$i] ) : | ||||||||||||||||||||||||||||||||
| 206 | $encode[0]->( $chars[$i] ) | ||||||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | 0 | return( join( '', @chars ) ); | |||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | sub link_id { return( shift->_set_get_scalar_as_object( 'link_id', @_ ) ); } | ||||||||||||||||||||||||||||||
|
Subroutine
link_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | sub name | ||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 217 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||
| 220 | 0 | my $text = shift( @_ ); | |||||||||||||||||||||||||||||||
| 221 | 0 | return( $self->add_element( $self->create_text({ text => $text }) ) ); | |||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||
| 223 | else | ||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | return( $self->children->map(sub{ $_->as_string })->join( '' ) ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub original { return( shift->_set_get_scalar_as_object( 'original', @_ ) ); } | ||||||||||||||||||||||||||||||
|
Subroutine
original: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | sub title { return( shift->_set_get_scalar_as_object( 'title', @_ ) ); } | ||||||||||||||||||||||||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||
| 233 | 5 | ▶ | sub url { return( shift->_set_get_uri( 'url', @_ ) ); } | ||||||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | 2 | 1; | |||||||||||||||||||||||||||||||
| 236 | # NOTE: POD | ||||||||||||||||||||||||||||||||
| 237 | __END__ | ||||||||||||||||||||||||||||||||