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, 2021-2022 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
474671
|
use v5.26; |
|
4
|
|
|
|
|
33
|
|
7
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
132
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1218
|
use Object::Pad 0.800; |
|
4
|
|
|
|
|
18341
|
|
|
4
|
|
|
|
|
255
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package App::sdview::Parser::Markdown 0.12; |
12
|
|
|
|
|
|
|
class App::sdview::Parser::Markdown |
13
|
|
|
|
|
|
|
:does(App::sdview::Parser) |
14
|
2
|
|
|
2
|
|
1183
|
:strict(params); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
93
|
|
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
3027
|
use File::Slurper 'read_text'; |
|
4
|
|
|
|
|
12534
|
|
|
4
|
|
|
|
|
310
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
2377
|
use String::Tagged::Markdown; |
|
4
|
|
|
|
|
11521
|
|
|
4
|
|
|
|
|
178
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
29
|
use constant format => "Markdown"; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
275
|
|
21
|
4
|
|
|
4
|
|
27
|
use constant sort_order => 20; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
13412
|
|
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
0
|
0
|
sub find_file ( $class, $name ) { return undef } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
3
|
sub can_parse_file ( $class, $file ) |
26
|
1
|
|
|
1
|
0
|
6686
|
{ |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
27
|
1
|
|
|
|
|
12
|
return $file =~ m/\.(?:md|markdown)$/; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
method parse_file ( $fh ) |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
31
|
0
|
|
|
0
|
0
|
0
|
{ |
32
|
0
|
|
|
|
|
0
|
return $self->parse_string( read_text $fh ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
field @_paragraphs; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _split_table_row ( $str ) |
38
|
16
|
|
|
16
|
|
128
|
{ |
|
16
|
|
|
|
|
26
|
|
|
16
|
|
|
|
|
22
|
|
39
|
16
|
50
|
|
|
|
79
|
$str =~ m/^\s*\|/ or return undef; |
40
|
16
|
50
|
|
|
|
70
|
$str =~ m/\|\s*$/ or return undef; |
41
|
|
|
|
|
|
|
|
42
|
16
|
|
|
|
|
86
|
my @cols = split m/\|/, $str, -1; |
43
|
16
|
|
|
|
|
32
|
shift @cols; pop @cols; |
|
16
|
|
|
|
|
25
|
|
44
|
|
|
|
|
|
|
|
45
|
16
|
|
|
|
|
126
|
s/^\s+//, s/\s+$// for @cols; |
46
|
|
|
|
|
|
|
|
47
|
16
|
|
|
|
|
90
|
return \@cols; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
15
|
|
|
|
|
24
|
method parse_string ( $str ) |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
20
|
|
51
|
15
|
|
|
15
|
0
|
37
|
{ |
52
|
15
|
|
|
|
|
29
|
my $in_verb; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my @lines; |
55
|
|
|
|
|
|
|
|
56
|
15
|
|
|
|
|
67
|
foreach ( split( m/\n/, $str ), "" ) { |
57
|
97
|
|
|
|
|
160
|
my $line = $_; # So we have a copy, because foreach my ... will alias the readonly "" |
58
|
|
|
|
|
|
|
|
59
|
97
|
100
|
|
|
|
176
|
if( $in_verb ) { |
60
|
4
|
|
|
|
|
5
|
my $para = $_paragraphs[-1]; |
61
|
|
|
|
|
|
|
|
62
|
4
|
100
|
|
|
|
14
|
if( $line =~ m/^\`\`\`/ ) { |
63
|
1
|
|
|
|
|
2
|
undef $in_verb; |
64
|
|
|
|
|
|
|
next |
65
|
1
|
|
|
|
|
2
|
} |
66
|
|
|
|
|
|
|
|
67
|
3
|
100
|
|
|
|
8
|
length $para->text and |
68
|
|
|
|
|
|
|
$para->text->append( "\n" ); |
69
|
|
|
|
|
|
|
|
70
|
3
|
|
|
|
|
43
|
$para->text->append( $line ); |
71
|
3
|
|
|
|
|
51
|
next; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
93
|
100
|
|
|
|
207
|
if( $line =~ s/^\`\`\`// ) { |
75
|
|
|
|
|
|
|
# Ignore the type specifier for now |
76
|
1
|
|
|
|
|
6
|
push @_paragraphs, App::sdview::Para::Verbatim->new( |
77
|
|
|
|
|
|
|
text => String::Tagged->new, |
78
|
|
|
|
|
|
|
); |
79
|
1
|
|
|
|
|
14
|
$in_verb++; |
80
|
1
|
|
|
|
|
3
|
next; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
92
|
100
|
|
|
|
181
|
if( length $line ) { |
84
|
56
|
|
|
|
|
85
|
push @lines, $line; |
85
|
56
|
|
|
|
|
103
|
next; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
36
|
|
|
|
|
73
|
while( @lines ) { |
89
|
42
|
50
|
100
|
|
|
473
|
if( $lines[0] =~ m/^ |