line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwim::Markup; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
15
|
use Pegex::Base; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
20
|
|
4
|
2
|
|
|
2
|
|
8899
|
use base 'Kwim::Tree'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1914
|
|
5
|
|
|
|
|
|
|
# use XXX -with => 'YAML::XS'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has option => {}; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
24
|
use constant top_block_separator => ''; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11357
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub BUILD { |
12
|
91
|
|
50
|
91
|
0
|
11671
|
$_[0]->{option} ||= {}; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub final { |
16
|
91
|
|
|
91
|
1
|
211
|
my ($self, $tree) = @_; |
17
|
91
|
|
|
|
|
562
|
$self->{stack} = []; |
18
|
91
|
|
|
|
|
304
|
$self->{bullet} = []; |
19
|
91
|
|
|
|
|
756
|
my $out = $self->render($tree); |
20
|
91
|
50
|
|
|
|
500
|
if ($self->option->{'complete'}) { |
21
|
0
|
0
|
|
|
|
0
|
if ($self->can('render_complete')) { |
22
|
0
|
|
|
|
|
0
|
$out = $self->render_complete($out); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
91
|
|
|
|
|
956
|
$out; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub render { |
29
|
770
|
|
|
770
|
0
|
1675
|
my ($self, $node, $separator) = @_; |
30
|
770
|
|
|
|
|
921
|
my $out; |
31
|
770
|
100
|
|
|
|
2396
|
if (not ref $node) { |
|
|
100
|
|
|
|
|
|
32
|
216
|
|
|
|
|
736
|
$out = $self->render_text($node); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif (ref($node) eq 'HASH') { |
35
|
277
|
|
|
|
|
798
|
$out = $self->render_node($node); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
277
|
100
|
100
|
|
|
1736
|
$separator ||= |
39
|
|
|
|
|
|
|
$self->at_top_level ? $self->top_block_separator : ''; |
40
|
277
|
|
|
|
|
681
|
$out = join $separator, grep $_, map { $self->render($_) } @$node; |
|
449
|
|
|
|
|
1126
|
|
41
|
|
|
|
|
|
|
} |
42
|
770
|
|
|
|
|
2756
|
return $out; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub render_node { |
46
|
221
|
|
|
221
|
0
|
398
|
my ($self, $hash) = @_; |
47
|
221
|
|
|
|
|
769
|
my ($name, $node) = each %$hash; |
48
|
221
|
100
|
|
|
|
1122
|
my $number = $name =~ s/(\d)$// ? $1 : 0; |
49
|
221
|
|
|
|
|
483
|
my $method = "render_$name"; |
50
|
221
|
|
|
|
|
324
|
push @{$self->{stack}}, $name; |
|
221
|
|
|
|
|
678
|
|
51
|
221
|
|
|
|
|
1180
|
my $out = $self->$method($node, $number); |
52
|
221
|
|
|
|
|
342
|
pop @{$self->{stack}}; |
|
221
|
|
|
|
|
529
|
|
53
|
221
|
|
|
|
|
621
|
$out; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub render_func { |
57
|
0
|
|
|
0
|
0
|
0
|
my ($self, $node) = @_; |
58
|
0
|
0
|
|
|
|
0
|
if ($node =~ /^([\-\w]+)(?:[\ \:]|\z)((?s:.*)?)$/) { |
59
|
0
|
|
|
|
|
0
|
my ($name, $args) = ($1, $2); |
60
|
0
|
|
|
|
|
0
|
(my $method = "phrase_func_$name") =~ s/-/_/g; |
61
|
0
|
|
|
|
|
0
|
(my $plugin = "Kwim::Plugin::$name") =~ s/-/::/g; |
62
|
0
|
|
|
|
|
0
|
while (1) { |
63
|
0
|
0
|
|
|
|
0
|
if ($self->can($method)) { |
64
|
0
|
|
|
|
|
0
|
my $out = $self->$method($args); |
65
|
0
|
0
|
|
|
|
0
|
return $out if defined $out; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
0
|
|
|
|
0
|
last if $plugin eq "Kwim::Plugin"; |
68
|
0
|
|
|
|
|
0
|
eval "require $plugin"; |
69
|
0
|
|
|
|
|
0
|
$plugin =~ s/(.*)::.*/$1/; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
0
|
"<$node>"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub at_top_level { |
76
|
272
|
|
|
272
|
0
|
358
|
@{$_[0]->{stack}} == 0 |
|
272
|
|
|
|
|
2871
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |