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