File Coverage

blib/lib/Perl6/Pod/FormattingCode/L.pm
Criterion Covered Total %
statement 18 46 39.1
branch 0 20 0.0
condition 0 26 0.0
subroutine 6 9 66.6
pod 0 3 0.0
total 24 104 23.0


line stmt bran cond sub pod time code
1             package Perl6::Pod::FormattingCode::L;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Perl6::Pod::FormattingCode::L - handle "L" formatting code
8              
9             =head1 SYNOPSIS
10              
11             A standard web URL. For example:
12              
13             This module needs the LAME library
14             (available from L)
15              
16              
17             =head1 DESCRIPTION
18              
19             The L<> code is used to specify all kinds of links, filenames, citations, and cross-references (both internal and external).
20              
21             A link specification consists of a scheme specifier terminated by a colon, followed by an external address (in the scheme's preferred syntax), followed by an internal address (again, in the scheme's syntax). All three components are optional, though at least one must be present in any link specification.
22              
23             Usually, in schemes where an internal address makes sense, it will be separated from the preceding external address by a #, unless the particular addressing scheme requires some other syntax. When new addressing schemes are created specifically for Perldoc it is strongly recommended that # be used to mark the start of internal addresses.
24              
25             =cut
26              
27 3     3   15 use warnings;
  3         6  
  3         83  
28 3     3   14 use strict;
  3         3  
  3         57  
29 3     3   15 use Data::Dumper;
  3         28  
  3         136  
30 3     3   13 use Perl6::Pod::FormattingCode;
  3         6  
  3         67  
31 3     3   14 use base 'Perl6::Pod::FormattingCode';
  3         8  
  3         196  
32 3     3   15 use Perl6::Pod::Utl;
  3         5  
  3         2163  
33             our $VERSION = '0.01';
34              
35             sub new {
36 0     0 0   my $class = shift;
37 0           my $self = $class->SUPER::new(@_);
38             #parse conntent
39 0           if (0) {
40             my $txt = $self->{'content'};
41             ( $self->{alt_text}, $txt ) = split( /\s*\|\s*/, $txt ) if $txt =~/\|/;
42             #cut scheme
43             if ( $txt =~s/^\s*(\w+):// ) {
44             $self->{scheme} = $1;
45             }
46             #is_external
47             if ( $txt =~ s%^//%%) {
48             $self->{is_external}='//'
49             }
50             #cut address
51             if ($txt =~ /([^\#]*)(?:\#(.*))?/) {
52             $self->{address} = $1 ||'';
53             $self->{section} = $2 || '';
54             }
55             }
56 0           return $self;
57             }
58              
59             sub to_xhtml {
60 0     0 0   my ( $self, $to ) = @_;
61 0           my $w = $to->w;
62 0   0       my $scheme = $self->{scheme}|| '';
63 0 0 0       if ( ( $scheme =~ /^https?|.*$/ ) or $self->{section} ) {
64 0   0       my $url = $self->{address} || '';
65 0 0         $url .= "#" . $self->{section} if $self->{section};
66 0 0 0       $url = $self->{scheme} . ($scheme =~ /^https?/ ? '//' : '') . $url if $self->{is_external} || ($self->{scheme} && $self->{scheme} eq 'mailto:');
    0 0        
67 0           $w->raw('');
68 0 0         unless ( $self->{alt_text}) {
69 0           $w->print($url)
70             } else {
71 0           $to->visit(Perl6::Pod::Utl::parse_para($self->{alt_text}))
72             }
73 0           $w->raw('');
74             }
75             }
76              
77             sub to_docbook {
78 0     0 0   my ( $self, $to ) = @_;
79 0           my $w = $to->w;
80 0   0       my $scheme = $self->{scheme}|| '';
81 0 0 0       if ( ( $scheme =~ /^https?|.*$/ ) or $self->{section} ) {
82 0   0       my $url = $self->{address} || '';
83 0 0         $url .= "#" . $self->{section} if $self->{section};
84 0 0 0       $url = $self->{scheme} . ($scheme =~ /^https?/ ? '//' : '') . $url if $self->{is_external} || ($self->{scheme} && $self->{scheme} eq 'mailto:');
    0 0        
85 0           $w->raw('');
86 0 0         unless ( $self->{alt_text}) {
87 0           $w->print($url)
88             } else {
89 0           $to->visit(Perl6::Pod::Utl::parse_para($self->{alt_text}))
90             }
91 0           $w->raw('');
92             }
93             }
94             1;
95             __END__