line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::BBCode::Text; |
2
|
|
|
|
|
|
|
$Parse::BBCode::Text::VERSION = '0.15'; |
3
|
1
|
|
|
1
|
|
1008
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw/ Parse::BBCode /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
920
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %default_tags = ( |
10
|
|
|
|
|
|
|
'b' => '%s', |
11
|
|
|
|
|
|
|
'i' => '%s', |
12
|
|
|
|
|
|
|
'u' => '%s', |
13
|
|
|
|
|
|
|
'img' => '%s', |
14
|
|
|
|
|
|
|
'url' => '%s', |
15
|
|
|
|
|
|
|
'email' => 'mailto:%{email}A', |
16
|
|
|
|
|
|
|
'size' => '%s', |
17
|
|
|
|
|
|
|
'color' => '%s', |
18
|
|
|
|
|
|
|
'list' => 'block:%{parse}s', |
19
|
|
|
|
|
|
|
'*' => { |
20
|
|
|
|
|
|
|
parse => 1, |
21
|
|
|
|
|
|
|
output => '* %s', |
22
|
|
|
|
|
|
|
close => 0, |
23
|
|
|
|
|
|
|
class => 'block', |
24
|
|
|
|
|
|
|
code => sub { |
25
|
|
|
|
|
|
|
my ($parser, $attr, $content, $attribute_fallback) = @_; |
26
|
|
|
|
|
|
|
$$content =~ s/\n+\Z//; |
27
|
|
|
|
|
|
|
$$content =~ s/^\s+//; |
28
|
|
|
|
|
|
|
return "* $$content\n"; |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
quote => { |
32
|
|
|
|
|
|
|
parse => 1, |
33
|
|
|
|
|
|
|
class => 'block', |
34
|
|
|
|
|
|
|
code => sub { |
35
|
|
|
|
|
|
|
my ($parser, $attr, $content, $attribute_fallback) = @_; |
36
|
|
|
|
|
|
|
$$content =~ s/^/> /gm; |
37
|
|
|
|
|
|
|
$$content =~ s/^> >/>>/gm; |
38
|
|
|
|
|
|
|
"$attribute_fallback:\n$$content\n"; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
'' => sub { |
42
|
|
|
|
|
|
|
my $text = $_[2]; |
43
|
|
|
|
|
|
|
$text; |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %optional_tags = ( |
48
|
|
|
|
|
|
|
# Parse::BBCode::HTML->optional(), |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my %default_escapes = ( |
52
|
|
|
|
|
|
|
Parse::BBCode::HTML->default_escapes |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub defaults { |
57
|
1
|
|
|
1
|
1
|
2
|
my ($class, @keys) = @_; |
58
|
|
|
|
|
|
|
return @keys |
59
|
1
|
50
|
|
|
|
16
|
? (map { $_ => $default_tags{$_} } grep { defined $default_tags{$_} } @keys) |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
: %default_tags; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub default_escapes { |
64
|
1
|
|
|
1
|
1
|
2
|
my ($class, @keys) = @_; |
65
|
|
|
|
|
|
|
return @keys |
66
|
1
|
50
|
|
|
|
6
|
? (map { $_ => $default_escapes{$_} } grep { defined $default_escapes{$_} } @keys) |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
: %default_escapes; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub optional { |
71
|
0
|
|
|
0
|
1
|
|
my ($class, @keys) = @_; |
72
|
0
|
0
|
|
|
|
|
return @keys ? (grep defined, @optional_tags{@keys}) : %optional_tags; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
=pod |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Parse::BBCode::Text - Provides plaintext defaults for Parse::BBCode |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use Parse::BBCode::Text; |
87
|
|
|
|
|
|
|
my $p = Parse::BBCode::Markdown->new(); |
88
|
|
|
|
|
|
|
my $code = 'some [b]b code[/b]'; |
89
|
|
|
|
|
|
|
my $plaintext = $p->render($code); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This module can be used to turn bbcode into minimal plaintext. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over 4 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item defaults |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns a hash with default tags. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
b, i, u, img, url, email, size, color, list, * |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item default_escapes |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns a hash with escaping functions. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
html, uri, link, email, htmlcolor, num |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item optional |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns a hash of optional tags. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
html |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|