line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Decorator::Filter::Quoted; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
58
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
21
|
use base 'Text::Decorator::Filter'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1077
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
923
|
use Text::Decorator::Group; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
23
|
|
8
|
2
|
|
|
2
|
|
1428
|
use Text::Quoted; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Text::Decorator::Filter::Quoted - Mark up paragraphs of quoted text |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$decorator->add_filter("Quoted", begin => ' ', |
17
|
|
|
|
|
|
|
end => ''); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 filter_node |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This filter uses the L module to add quoting-level style |
24
|
|
|
|
|
|
|
tags on a HTML representation of piece of text. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub filter_node { |
29
|
|
|
|
|
|
|
my ($class, $args, $node) = @_; |
30
|
|
|
|
|
|
|
$args = { @{ $args || [] } }; |
31
|
|
|
|
|
|
|
$args->{begin} ||= ""; |
32
|
|
|
|
|
|
|
$args->{end} ||= ""; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# There's a slight bug here; this filter will obliterate all HTML |
35
|
|
|
|
|
|
|
# markup made so far, which is something this module was designed to |
36
|
|
|
|
|
|
|
# avoid! It shouldn't be that much of a deal, since most markup should |
37
|
|
|
|
|
|
|
# be in the group pre- and post- stuff, but this really needs |
38
|
|
|
|
|
|
|
# redesigned to preserve properties of existing nodes. |
39
|
|
|
|
|
|
|
my $structure = extract($node->format_as("text")); |
40
|
|
|
|
|
|
|
my @output; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Let's have a level one group |
43
|
|
|
|
|
|
|
my $group = $class->_new_group($args, 1); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$group->{nodes} = [ $class->_traverse($args, $structure, 1) ]; |
46
|
|
|
|
|
|
|
return $group, Text::Decorator::Node->new("\n") # Swallowed somewhere |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _traverse { |
50
|
|
|
|
|
|
|
my ($class, $args, $stuff, $level) = @_; |
51
|
|
|
|
|
|
|
my @output; |
52
|
|
|
|
|
|
|
for (@$stuff) { |
53
|
|
|
|
|
|
|
if (ref $_ eq "ARRAY") { |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# New group |
56
|
|
|
|
|
|
|
my $group = $class->_new_group($args, $level + 1); |
57
|
|
|
|
|
|
|
$group->{nodes} = [ $class->_traverse($args, $_, $level + 1) ]; |
58
|
|
|
|
|
|
|
push @output, $group; |
59
|
|
|
|
|
|
|
} elsif (ref $_ eq "HASH") { |
60
|
|
|
|
|
|
|
push @output, Text::Decorator::Node->new($_->{raw} . "\n"); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
return @output; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _new_group { |
67
|
|
|
|
|
|
|
my ($class, $args, $level) = @_; |
68
|
|
|
|
|
|
|
my $group = Text::Decorator::Group->new(); |
69
|
|
|
|
|
|
|
$group->{notes}->{level} = $level; |
70
|
|
|
|
|
|
|
$group->{representations}{html}{pre} = sprintf($args->{begin}, $level); |
71
|
|
|
|
|
|
|
$group->{representations}{html}{post} = sprintf($args->{end}, $level); |
72
|
|
|
|
|
|
|
return $group; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |