line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Perl Markdown Compiler |
2
|
|
|
|
|
|
|
package Markdown::Compiler; |
3
|
17
|
|
|
17
|
|
9997
|
use Moo; |
|
17
|
|
|
|
|
166328
|
|
|
17
|
|
|
|
|
92
|
|
4
|
17
|
|
|
17
|
|
34991
|
use Markdown::Compiler::Lexer; |
|
17
|
|
|
|
|
57
|
|
|
17
|
|
|
|
|
611
|
|
5
|
17
|
|
|
17
|
|
11142
|
use Markdown::Compiler::Parser; |
|
17
|
|
|
|
|
53
|
|
|
17
|
|
|
|
|
562
|
|
6
|
17
|
|
|
17
|
|
8877
|
use Markdown::Compiler::Target::HTML; |
|
17
|
|
|
|
|
52
|
|
|
17
|
|
|
|
|
742
|
|
7
|
17
|
|
|
17
|
|
132
|
use Module::Runtime qw( use_module ); |
|
17
|
|
|
|
|
37
|
|
|
17
|
|
|
|
|
139
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has source => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has lexer => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
builder => sub { |
18
|
66
|
|
|
66
|
|
1507
|
Markdown::Compiler::Lexer->new( source => shift->source ); |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has parser => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
|
|
|
|
|
|
builder => sub { |
26
|
65
|
|
|
65
|
|
1505
|
Markdown::Compiler::Parser->new( stream => shift->stream ); |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has stream => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
lazy => 1, |
33
|
|
|
|
|
|
|
builder => sub { |
34
|
65
|
|
|
65
|
|
1395
|
shift->lexer->tokens; |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has tree => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
lazy => 1, |
41
|
|
|
|
|
|
|
builder => sub { |
42
|
64
|
|
|
64
|
|
1438
|
shift->parser->tree; |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has compiler => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
lazy => 1, |
49
|
|
|
|
|
|
|
builder => sub { |
50
|
64
|
|
|
64
|
|
1443
|
Markdown::Compiler::Target::HTML->new( tree => shift->tree ); |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub compiler_for { |
55
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $target ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
0
|
$target = substr($target,0,1) eq '+' |
58
|
|
|
|
|
|
|
? substr($target,1) |
59
|
|
|
|
|
|
|
: 'Markdown::Compiler::Target::' . $target; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
return use_module("$target")->new( tree => $self->tree ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has result => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
lazy => 1, |
67
|
|
|
|
|
|
|
builder => sub { |
68
|
64
|
|
|
64
|
|
1532
|
shift->compiler->result; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has metadata => ( |
73
|
|
|
|
|
|
|
is => 'ro', |
74
|
|
|
|
|
|
|
lazy => 1, |
75
|
|
|
|
|
|
|
builder => sub { |
76
|
0
|
|
|
0
|
|
|
shift->compiler->metadata; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |