line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Xatena::Node::DefinitionList; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
88
|
use strict; |
|
17
|
|
|
|
|
37
|
|
|
17
|
|
|
|
|
531
|
|
4
|
17
|
|
|
17
|
|
85
|
use warnings; |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
380
|
|
5
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
79
|
use strict; |
|
17
|
|
|
|
|
34
|
|
|
17
|
|
|
|
|
385
|
|
7
|
17
|
|
|
17
|
|
77
|
use warnings; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
479
|
|
8
|
17
|
|
|
17
|
|
86
|
use base qw(Text::Xatena::Node); |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
304
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
17
|
|
|
|
|
13391
|
DL => qr/^:([^:]*):(.*)/, |
11
|
17
|
|
|
17
|
|
95
|
}; |
|
17
|
|
|
|
|
45
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub parse { |
14
|
307
|
|
|
307
|
0
|
494
|
my ($class, $s, $parent, $stack) = @_; |
15
|
307
|
100
|
|
|
|
720
|
if ($s->scan(DL)) { |
16
|
8
|
|
|
|
|
36
|
my $node = $class->new([ $s->matched->[0] ]); |
17
|
8
|
|
100
|
|
|
23
|
until ($s->eos || !$s->scan(DL)) { |
18
|
11
|
|
|
|
|
530
|
push @$node, $s->matched->[0]; |
19
|
|
|
|
|
|
|
} |
20
|
8
|
|
|
|
|
303
|
push @$parent, $node; |
21
|
8
|
|
|
|
|
122
|
return 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## NOT COMPATIBLE WITH Hatena Syntax |
26
|
|
|
|
|
|
|
sub as_struct { |
27
|
8
|
|
|
8
|
0
|
10
|
my ($self, $context) = @_; |
28
|
8
|
|
|
|
|
15
|
my $ret = []; |
29
|
|
|
|
|
|
|
|
30
|
8
|
|
|
|
|
32
|
my $children = $self->children; |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
18
|
for my $line (@$children) { |
33
|
19
|
100
|
|
|
|
55
|
if (my ($description) = ($line =~ /^::(.+)/)) { |
34
|
3
|
|
|
|
|
9
|
push @$ret, +{ |
35
|
|
|
|
|
|
|
name => 'dd', |
36
|
|
|
|
|
|
|
content => $context->inline->format($description), |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} else { |
39
|
16
|
|
|
|
|
76
|
my ($title, $description) = ($line =~ /^:([^:]+)(?::(.*))?$/); |
40
|
16
|
|
|
|
|
54
|
push @$ret, +{ |
41
|
|
|
|
|
|
|
name => 'dt', |
42
|
|
|
|
|
|
|
content => $context->inline->format($title), |
43
|
|
|
|
|
|
|
}; |
44
|
16
|
100
|
|
|
|
68
|
push @$ret, +{ |
45
|
|
|
|
|
|
|
name => 'dd', |
46
|
|
|
|
|
|
|
content => $context->inline->format($description), |
47
|
|
|
|
|
|
|
} if $description; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
8
|
|
|
|
|
40
|
$ret; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_html { |
55
|
8
|
|
|
8
|
0
|
24
|
my ($self, $context, %opts) = @_; |
56
|
|
|
|
|
|
|
|
57
|
8
|
|
|
|
|
26
|
$context->_tmpl(__PACKAGE__, q[ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
? for (@$items) { |
60
|
|
|
|
|
|
|
<{{= $_->{name} }}>{{= $_->{content} }}{{= $_->{name} }}> |
61
|
|
|
|
|
|
|
? } |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
], { |
64
|
|
|
|
|
|
|
items => $self->as_struct($context), |
65
|
|
|
|
|
|
|
}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |