line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Decorator::Node; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
930
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
250
|
|
4
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
701
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Text::Decorator::Node - A blob of text in a Text::Decorator decoration |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $node = Text::Decorator::Node->new($text); |
13
|
|
|
|
|
|
|
$node->format_as("html"); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This represents a piece of text which is going to undergo formatting |
18
|
|
|
|
|
|
|
and decoration. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 new |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $node = Text::Decorator::Node->new($text); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Creates a new Text::Decorator::Node instance with the specified text. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
31
|
13
|
|
|
13
|
1
|
394
|
my ($class, $text) = @_; |
32
|
13
|
|
|
|
|
156
|
return bless { |
33
|
|
|
|
|
|
|
representations => { text => $text }, |
34
|
|
|
|
|
|
|
notes => {} # So filters can pass messages to each other |
35
|
|
|
|
|
|
|
} => $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 format_as |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$node->format_as($representation) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns this node in the specified representation, or plain text. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub format_as { |
47
|
22
|
|
|
22
|
1
|
1259
|
my ($self, $format) = @_; |
48
|
22
|
|
100
|
|
|
229
|
return $self->{representations}{$format} |
49
|
|
|
|
|
|
|
|| $self->{representations}{text}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|