| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Parse::BBCode::Markdown; |
|
2
|
|
|
|
|
|
|
$Parse::BBCode::Markdown::VERSION = '0.15'; |
|
3
|
1
|
|
|
1
|
|
896
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak carp); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
66
|
|
|
6
|
1
|
|
|
1
|
|
796
|
use URI::Escape; |
|
|
1
|
|
|
|
|
1717
|
|
|
|
1
|
|
|
|
|
52
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw/ Parse::BBCode /; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
853
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %default_tags = ( |
|
10
|
|
|
|
|
|
|
'b' => '*%s*', |
|
11
|
|
|
|
|
|
|
'i' => '__%s__', |
|
12
|
|
|
|
|
|
|
'u' => '_%s_', |
|
13
|
|
|
|
|
|
|
#  |
|
14
|
|
|
|
|
|
|
'img' => '', |
|
15
|
|
|
|
|
|
|
'url' => 'url:[%s](%{link}A)', |
|
16
|
|
|
|
|
|
|
'email' => 'url:[%s](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
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
quote => { |
|
27
|
|
|
|
|
|
|
parse => 1, |
|
28
|
|
|
|
|
|
|
class => 'block', |
|
29
|
|
|
|
|
|
|
code => sub { |
|
30
|
|
|
|
|
|
|
my ($parser, $attr, $content, $attribute_fallback) = @_; |
|
31
|
|
|
|
|
|
|
$$content =~ s/^/> /gm; |
|
32
|
|
|
|
|
|
|
$$content =~ s/^> >/>>/gm; |
|
33
|
|
|
|
|
|
|
"$attribute_fallback:\n$$content\n"; |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
'code' => { |
|
37
|
|
|
|
|
|
|
code => sub { |
|
38
|
|
|
|
|
|
|
my ($parser, $attr, $content, $attribute_fallback) = @_; |
|
39
|
|
|
|
|
|
|
$$content =~ s/^/| /gm; |
|
40
|
|
|
|
|
|
|
return "Code $attribute_fallback:\n" . ('-' x 20) . "\n$$content\n" . ('-' x 20); |
|
41
|
|
|
|
|
|
|
}, |
|
42
|
|
|
|
|
|
|
class => 'block', |
|
43
|
|
|
|
|
|
|
}, |
|
44
|
|
|
|
|
|
|
'' => sub { |
|
45
|
|
|
|
|
|
|
my $text = $_[2]; |
|
46
|
|
|
|
|
|
|
$text; |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my %optional_tags = ( |
|
51
|
|
|
|
|
|
|
# Parse::BBCode::HTML->optional(), |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my %default_escapes = ( |
|
55
|
|
|
|
|
|
|
Parse::BBCode::HTML->default_escapes |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub defaults { |
|
60
|
1
|
|
|
1
|
1
|
3
|
my ($class, @keys) = @_; |
|
61
|
|
|
|
|
|
|
return @keys |
|
62
|
1
|
50
|
|
|
|
13
|
? (map { $_ => $default_tags{$_} } grep { defined $default_tags{$_} } @keys) |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
63
|
|
|
|
|
|
|
: %default_tags; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub default_escapes { |
|
67
|
1
|
|
|
1
|
1
|
2
|
my ($class, @keys) = @_; |
|
68
|
|
|
|
|
|
|
return @keys |
|
69
|
1
|
50
|
|
|
|
9
|
? (map { $_ => $default_escapes{$_} } grep { defined $default_escapes{$_} } @keys) |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
: %default_escapes; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub optional { |
|
74
|
0
|
|
|
0
|
1
|
|
my ($class, @keys) = @_; |
|
75
|
0
|
0
|
|
|
|
|
return @keys ? (grep defined, @optional_tags{@keys}) : %optional_tags; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |