| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Book::Bilingual; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Data structure for a bilingual book |
|
3
|
4
|
|
|
4
|
|
119814
|
use Mojo::Base -base; |
|
|
4
|
|
|
|
|
328031
|
|
|
|
4
|
|
|
|
|
33
|
|
|
4
|
4
|
|
|
4
|
|
771
|
use Carp; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
243
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
1979
|
use version; our $VERSION = version->declare('0.003'); |
|
|
4
|
|
|
|
|
6424
|
|
|
|
4
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'chapters'; # ArrayRef of Book::Bilingual::Chapter |
|
9
|
|
|
|
|
|
|
|
|
10
|
28
|
|
|
28
|
1
|
3639
|
sub new { $_[0]->SUPER::new({ chapters => [] }) } |
|
11
|
|
|
|
|
|
|
sub chapter_count { ## () :> Int |
|
12
|
12
|
|
|
12
|
0
|
70
|
my ($self) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
12
|
|
|
|
|
19
|
return scalar @{$self->{chapters}}; |
|
|
12
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
sub push { ## ($chapter:>Book::Bilingual::Chapter) :> Self |
|
17
|
46
|
|
|
46
|
0
|
357
|
my ($self, $chapter) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
46
|
100
|
|
|
|
284
|
croak 'Not a Book::Bilingual::Chapter' |
|
20
|
|
|
|
|
|
|
unless ref($chapter) eq 'Book::Bilingual::Chapter'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
45
|
|
|
|
|
55
|
push @{$self->{chapters}}, $chapter; |
|
|
45
|
|
|
|
|
103
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
45
|
|
|
|
|
105
|
return $self; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub chapter_at { ## ($ch_idx :>Int) :> Int |
|
28
|
5
|
|
|
5
|
0
|
27
|
my ($self, $ch_idx) = @_; |
|
29
|
5
|
|
|
|
|
19
|
return $self->{chapters}[$ch_idx]; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub chapter_dlineset_count { ## ($ch_idx) :> Int |
|
33
|
7
|
|
|
7
|
1
|
54
|
my ($self,$ch_idx) = @_; |
|
34
|
7
|
|
|
|
|
17
|
return $self->chapters->[$ch_idx]->dlineset_count; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
sub chapter_dlineset_dline_len { ## ($ch_idx, $dset_idx) :> Int |
|
37
|
8
|
|
|
8
|
0
|
47
|
my ($self, $ch_idx, $dset_idx) = @_; |
|
38
|
8
|
|
|
|
|
18
|
return $self->chapters->[$ch_idx]->dlineset_at($dset_idx)->dline_count; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding utf-8 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Book::Bilingual - A crappy model for bilingual books |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
use Book::Bilingual::Reader; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $file = 't/ff01.mdown'; |
|
56
|
|
|
|
|
|
|
my $reader = Book::Bilingual::Reader->new($file); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
print $reader->html(); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L is a model for bilingual books written in Markdown |
|
63
|
|
|
|
|
|
|
format. The L module reads the file and |
|
64
|
|
|
|
|
|
|
generates HTML. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 chapter_dlineset_count($chapter_idx:>Int) :> Int |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns the number of dlinesets in the given Chapter. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 num_dline_in_dlineset($chapter_idx:Int, $dlineset_idx:Int) :> Int |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns the number of dlines in the given Chapter and Dlineset. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Hoe Kit CHEW Ehoekit at gmail.comE |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Copyright (C) 2021 Hoe Kit CHEW |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 LICENSE |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
|
89
|
|
|
|
|
|
|
|