File Coverage

blib/lib/App/sdview/Parser.pm
Criterion Covered Total %
statement 86 90 95.5
branch n/a
condition n/a
subroutine 36 38 94.7
pod n/a
total 122 128 95.3


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2022-2023 -- leonerd@leonerd.org.uk
5              
6 8     8   619 use v5.26;
  8         28  
7 8     8   44 use warnings;
  8         19  
  8         237  
8 8     8   45 use utf8;
  8         14  
  8         56  
9              
10 8     8   928 use Object::Pad 0.800 ':experimental(adjust_params)';
  8         10941  
  8         369  
11 8     8   5355 use Object::Pad::FieldAttr::Checked;
  8         5225  
  8         49  
12              
13             package App::sdview::Parser 0.13;
14             role App::sdview::Parser;
15              
16 8     8   8179 use String::Tagged;
  8         65539  
  8         322  
17 8     8   4844 use Types::Standard;
  8         650867  
  8         85  
18              
19             my $ListType;
20             BEGIN {
21 8     8   5506 $ListType = Types::Standard::Enum[qw( bullet number text )];
22             }
23              
24             # This package is empty but provides a bunch of helper classes
25              
26             class App::sdview::Para::Heading :strict(params) {
27 8     8   21939 use Types::Standard qw( InstanceOf Num );
  8         28  
  8         53  
28              
29 0     0   0 field $level :param :reader :Checked(Num);
  0         0  
30 32     32   1426 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  32         168  
31              
32 36     36   2424 method type { "head" . $level }
  36         302  
33             }
34              
35             class App::sdview::Para::Plain :strict(params) {
36 8     8   31405 use Types::Standard qw( InstanceOf Num );
  8         23  
  8         88  
37              
38 159     159   6427 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  159         647  
39 2     2   9 field $indent :param :reader :Checked(Num) = 0;
40              
41 2     106   10 method type { "plain" }
  106         1022  
  106         466  
42             }
43              
44             class App::sdview::Para::Verbatim :strict(params) {
45 8     8   3423 use Types::Standard qw( Maybe Str InstanceOf Num );
  8         20  
  8         38  
46              
47             field $language :param :reader :Checked(Maybe[Str]) = undef;
48 2     2   7 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  2     30   15  
  30         88  
  30         193  
49 0     0   0 field $indent :param :reader :Checked(Num) = 0;
50              
51 0     8   0 method type { "verbatim" }
  8         20  
  8         48  
52             }
53              
54             class App::sdview::Para::List :strict(params) {
55 8     8   3262 use Types::Standard qw( Num );
  8         18  
  8         68  
56              
57 36     36   63 field $listtype :param :reader :Checked($ListType);
  36         152  
58 24     24   105 field $indent :param :reader :Checked(Num);
  24         113  
59 9     9   20 field $initial :param :reader :Checked(Num) = 1; # for number lists
60              
61 9     19   33 field @items :reader;
  19         50  
  19         68  
62              
63 61     61   445 method push_item ( $item ) { push @items, $item; }
  61         90  
  61         89  
  61         76  
  61         222  
64              
65 41     41   3495 method type { "list-$listtype" }
  41         279  
66             }
67              
68             class App::sdview::Para::ListItem :strict(params) {
69 8     8   4974 use Types::Standard qw( InstanceOf Maybe );
  8         21  
  8         63  
70              
71 50     50   94 field $listtype :param :reader :Checked($ListType);
  50         260  
72             field $term :param :reader :Checked(Maybe[InstanceOf['String::Tagged']]) = undef;
73 42     42   91 field $text :param :reader :Checked(InstanceOf['String::Tagged']);
  42     94   154  
  94         204  
  94         358  
74              
75 130     130   2881 method type { "item" }
  130         582  
76             }
77              
78             class App::sdview::Para::Table :strict(params) {
79 5     5   425 method type { "table" }
  5         41  
80              
81 6     6   17 field @rows :reader;
  6         25  
82              
83             ADJUST :params ( :$rows ) {
84             @rows = $rows->@*;
85             }
86             }
87              
88             class App::sdview::Para::TableCell :isa(App::sdview::Para::Plain) :strict(params) {
89 8     8   8386 use Types::Standard qw( Enum );
  8         20  
  8         207  
90              
91 31     31   58 field $align :param :reader :Checked(Enum[qw( left centre right )]);
  31         148  
92              
93 4     4   396 method type { "table-cell" }
  4         18  
94             }
95              
96             0x55AA;