line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Perl Markdown Compiler |
2
|
|
|
|
|
|
|
package Markdown::Compiler; |
3
|
18
|
|
|
18
|
|
9452
|
use Moo; |
|
18
|
|
|
|
|
150525
|
|
|
18
|
|
|
|
|
88
|
|
4
|
18
|
|
|
18
|
|
31398
|
use Markdown::Compiler::Source; |
|
18
|
|
|
|
|
57
|
|
|
18
|
|
|
|
|
630
|
|
5
|
18
|
|
|
18
|
|
10146
|
use Markdown::Compiler::Lexer; |
|
18
|
|
|
|
|
65
|
|
|
18
|
|
|
|
|
591
|
|
6
|
18
|
|
|
18
|
|
11119
|
use Markdown::Compiler::Parser; |
|
18
|
|
|
|
|
60
|
|
|
18
|
|
|
|
|
628
|
|
7
|
18
|
|
|
18
|
|
8786
|
use Markdown::Compiler::Target::HTML; |
|
18
|
|
|
|
|
56
|
|
|
18
|
|
|
|
|
657
|
|
8
|
18
|
|
|
18
|
|
168
|
use Module::Runtime qw( use_module ); |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
149
|
|
9
|
18
|
|
|
18
|
|
9137
|
use YAML::XS; |
|
18
|
|
|
|
|
47321
|
|
|
18
|
|
|
|
|
7793
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has source => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has _source => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
builder => sub { |
20
|
67
|
|
|
67
|
|
1310
|
Markdown::Compiler::Source->new( source => shift->source ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has lexer => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
builder => sub { |
28
|
65
|
|
|
65
|
|
1332
|
Markdown::Compiler::Lexer->new( source => shift->_source->body ); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has parser => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
builder => sub { |
36
|
64
|
|
|
64
|
|
1233
|
Markdown::Compiler::Parser->new( stream => shift->stream ); |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has stream => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
lazy => 1, |
43
|
|
|
|
|
|
|
builder => sub { |
44
|
64
|
|
|
64
|
|
1302
|
shift->lexer->tokens; |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has tree => ( |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
builder => sub { |
52
|
64
|
|
|
64
|
|
1203
|
shift->parser->tree; |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has compiler => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
lazy => 1, |
59
|
|
|
|
|
|
|
builder => sub { |
60
|
64
|
|
|
64
|
|
1230
|
Markdown::Compiler::Target::HTML->new( tree => shift->tree ); |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub compiler_for { |
65
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $target ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
0
|
$target = substr($target,0,1) eq '+' |
68
|
|
|
|
|
|
|
? substr($target,1) |
69
|
|
|
|
|
|
|
: 'Markdown::Compiler::Target::' . $target; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
return use_module("$target")->new( tree => $self->tree ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has result => ( |
75
|
|
|
|
|
|
|
is => 'ro', |
76
|
|
|
|
|
|
|
lazy => 1, |
77
|
|
|
|
|
|
|
builder => sub { |
78
|
64
|
|
|
64
|
|
1471
|
shift->compiler->result; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has metadata => ( |
83
|
|
|
|
|
|
|
is => 'ro', |
84
|
|
|
|
|
|
|
lazy => 1, |
85
|
|
|
|
|
|
|
builder => sub { |
86
|
2
|
|
|
2
|
|
22
|
my ( $self ) = @_; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Process YAML files with YAML::XS. |
89
|
2
|
50
|
|
|
|
31
|
if ( $self->_source->metatype eq 'YAML' ) { |
90
|
2
|
|
|
|
|
34
|
return Load( $self->_source->metadata ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return $self->_source->metadata; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |