Markdown/Perl/BlockParser.pm

filter: Statementstmt 99.6% 514 / 516 Branchbran 92.6% 241 / 260 Conditioncond 89.3% 177 / 198 MC/DCmcdc 62.1% 64 / 103 Subroutinesub 100% 51 / 51 Podpod 0.0% 0 / 7 totaltotal 92.2% 1047 / 1135 CC 199 SCAR 27.6
CC
199
Cov
96%
_parse_table_structure
46.2
_parse_blocks
22.0
_do_list_item
20.0
CRAP 15.8
« Markdown/Perl.pm ↑ Summary Markdown/Perl/InlineTree.pm »
1 package Markdown::Perl::BlockParser;
2  
3 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 31 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 31 ▶use feature ':5.24';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 31 ▶use feature 'refaliasing';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 31 ▶no warnings 'experimental::refaliasing';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 31 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 31 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 31 ▶use Hash::Util 'lock_keys_plus';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 31 ▶use List::MoreUtils 'first_index';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 31 ▶use List::Util 'pairs', 'min';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 31 ▶use Markdown::Perl::HTML 'html_escape', 'decode_entities', 'remove_disallowed_tags';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 31 ▶use Markdown::Perl::Util ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 31 ▶use YAML::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 31 our $VERSION = '0.02';
21  
22 =pod
23  
24 =encoding utf8
25  
26 =cut
27  
28 sub new {
29 # $md must be a reference
30 41135 ▶ my ($class, $pmarkdown, $md) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
31  
32 41135 my $this = bless {
33 pmarkdown => $pmarkdown,
34 blocks => [],
35 blocks_stack => [],
36 paragraph => [],
37 last_line_is_blank => 0,
38 last_line_was_blank => 0,
39 skip_next_block_matching => 0,
40 is_lazy_continuation => 0,
41 md => undef,
42 last_pos => 0,
43 line_ending => '',
44 continuation_re => qr//,
45 linkrefs => {},
46 matched_prefix_size => 0,
47 }, $class;
48 41135 lock_keys_plus(%{$this}, qw(forced_line));
49  
50 41135 \$this->{md} = $md; # aliasing to avoid copying the input, does this work? is it useful?
51  
52 41135 return $this;
53 }
54  
55 # This autoload method allows to call option accessors from the parent object
56 # transparently.
57 31 my $pkg = __PACKAGE__;
58  
59 sub AUTOLOAD { ## no critic (ProhibitAutoloading, RequireArgUnpacking)
60 685734 ▶ our $AUTOLOAD; # Automatically populated when the method is called.
Subroutine AUTOLOAD: called CC=3 SCAR=11.0
61 685734 $AUTOLOAD =~ s/${pkg}:://;
62 685734 ▶ return if $AUTOLOAD eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $Markdown::Perl::BlockParser::AUTOLOAD eq "DESTROY" 37090 648644 685734
63 648644 ▶ confess "Undefined method ${AUTOLOAD}" unless $AUTOLOAD =~ m/^get_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::AUTOLOAD =~ /^get_/u 0 648644 648644
64 648644 my $this = shift @_;
65 648644 return $this->{pmarkdown}->$AUTOLOAD(@_);
66 }
67  
68 31 my $eol_re = qr/ \r\n | \n | \r /x;
69  
70 sub next_line {
71 178659 ▶ my ($this) = @_;
Subroutine next_line: called CC=9 SCAR=22.0
Pod undocumented
72 # When we are forcing a line, we don’t recompute the line_ending, but it
73 # should already be correct because the forced one is a substring of the last
74 # line.
75 178659 ▶ return delete $this->{forced_line} if exists $this->{forced_line};
Branch: 1 branch
BranchTrueFalseTotal
if exists $this->{"forced_line"} 23498 155161 178659
76 155161 ▶ return if pos($this->{md}) == length($this->{md});
Branch: 1 branch
BranchTrueFalseTotal
if pos $this->{"md"} == length $this->{"md"} 26432 128729 155161
77 128729 $this->{last_pos} = pos($this->{md});
78 128729 ▶ $this->{md} =~ m/\G([^\n\r]*)(${eol_re})?/g or confess 'Should not happen';
Branch: 1 branch
BranchTrueFalseTotal
$this->{"md"} =~ /\G([^\n\r]*)($eol_re)?/gu or confess("Should not happen") 0 128729 128729
79 128729 my ($t, $e) = ($1, $2);
80 128729 ▶ if ($1 =~ /^[ \t]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 =~ /^[ \t]+$/u) { } 1381 127348 128729
81 1381 ▶ $this->{line_ending} = $t.($e // '') if $this->get_preserve_white_lines;
Branch: 1 branch
BranchTrueFalseTotal
if $this->get_preserve_white_lines 1060 321 1381
Condition100%2/2
$e // ""
l!l
100060
MC/DC100%1/1
$e // ""
$e
Truth table100%2/2
A
A= $e
Aresult
11
00
82 1381 return '';
83 } else {
84 127348 ▶ $this->{line_ending} = $e // ($this->get_force_final_new_line ? "\n" : '');
Branch: 1 branch
BranchTrueFalseTotal
$this->get_force_final_new_line ? : 3815 12997 16812
Condition100%3/3
$e // ($this->get_force_final_new_line ? "\n" : "")
l!l&&r!l&&!r
110536381512997
MC/DC100%2/2
$e // ($this->get_force_final_new_line ? "\n" : "")
$e ($this->get_force_final_new_line ? "\n" : "")
Truth table100%3/3
A // B
A= $eB= ($this->get_force_final_new_line ? "\n" : "")
ABresult
1X1
011
000
85 127348 return $t;
86 }
87 }
88  
89 sub line_ending {
90 29416 ▶ my ($this) = @_;
Subroutine line_ending: called CC=1 SCAR=0.0
Pod undocumented
91 29416 return $this->{line_ending};
92 }
93  
94 # last_pos should be passed whenever set_pos can be followed by a "return;" in
95 # one of the _do_..._block method (so, if the method fails), to reset the parser
96 # to its previous state, when the pos was manipulated.
97 # TODO: add a better abstraction to save and restore parser state.
98 sub set_pos {
99 21537 ▶ my ($this, $pos, $last_pos) = @_;
Subroutine set_pos: called CC=2 SCAR=6.9
Pod undocumented
100 21537 pos($this->{md}) = $pos;
101 21537 ▶ $this->{last_pos} = $last_pos if defined $last_pos;
Branch: 1 branch
BranchTrueFalseTotal
if defined $last_pos 7653 13884 21537
102 21537 return;
103 }
104  
105 sub get_pos {
106 20268 ▶ my ($this) = @_;
Subroutine get_pos: called CC=1 SCAR=0.0
Pod undocumented
107 20268 return pos($this->{md});
108 }
109  
110 sub redo_line {
111 9326 ▶ my ($this) = @_;
Subroutine redo_line: called CC=2 SCAR=7.0
Pod undocumented
112 9326 ▶ confess 'Cannot push back more than one line' unless exists $this->{last_pos};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $this->{"last_pos"} 0 9326 9326
113 9326 $this->set_pos(delete $this->{last_pos});
114 9326 return;
115 }
116  
117 # Takes a string and converts it to HTML. Can be called as a free function or as
118 # class method. In the latter case, provided options override those set in the
119 # class constructor.
120 # Both the input and output are unicode strings.
121 sub process {
122 17563 ▶ my ($this) = @_;
Subroutine process: called CC=4 SCAR=13.9
Pod undocumented
123 17563 pos($this->{md}) = 0;
124  
125 # https://spec.commonmark.org/0.30/#characters-and-lines
126 # TODO: The spec asks for this, however we can’t apply it, because md is a
127 # reference to the value passed by the user and we don’t want to modify it (it
128 # may even be a read-only value). I’m too lazy to find another place to
129 # implement this behavior.
130 # $this->{md} =~ s/\000/\xfffd/g;
131  
132 # https://spec.commonmark.org/0.30/#tabs
133 # TODO: nothing to do at this stage.
134  
135 # https://spec.commonmark.org/0.30/#backslash-escapes
136 # https://spec.commonmark.org/0.30/#entity-and-numeric-character-references
137 # Done at a later stage, as escaped characters don’t have their Markdown
138 # meaning, we need a way to represent that.
139  
140 17563 ▶ $this->_parse_yaml_metadata() if $this->get_parse_file_metadata eq 'yaml';
Branch: 1 branch
BranchTrueFalseTotal
if $this->get_parse_file_metadata eq "yaml" 4235 13328 17563
141  
142 17562 ▶ while (defined (my $l = $this->next_line())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $l = $this->next_line)) 123087 17562 140649
143 # This field might be set to true at the beginning of the processing, while
144 # we’re looking at the conditions of the currently open containers.
145 123087 $this->{is_lazy_continuation} = 0;
146 123087 $this->_parse_blocks($l);
147 }
148 17562 $this->_finalize_paragraph();
149 17562 ▶ while (@{$this->{blocks_stack}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"blocks_stack"};}) 6997 17562 24559
150 6997 $this->_restore_parent_block();
151 }
152 17562 return delete $this->{linkrefs}, delete $this->{blocks};
153 }
154  
155 # The $force_loose_test parameter is used when we are actually starting a new
156 # block. In that case, or if we are actually after a paragraph, then we possibly
157 # convert the enclosing list to a loose list.
158 # TODO: the logic to decide if a list is loose is extremely complex and split in
159 # many different place. It would be great to rewrite it in a simpler way.
160 sub _finalize_paragraph {
161 122367 ▶ my ($this, $force_loose_test) = @_;
Subroutine _finalize_paragraph: called CC=7 SCAR=19.5
162 122367 ▶ if (@{$this->{paragraph}} || $force_loose_test) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"paragraph"};} or $force_loose_test) 85459 36908 122367
Condition100%3/3
@{$this->{"paragraph"};} or $force_loose_test
l!l&&r!l&&!r
536763178336908
MC/DC100%2/2
@{$this->{"paragraph"};} or $force_loose_test
@{$this->{"paragraph"};} $force_loose_test
Truth table100%3/3
A or B
A= @{$this->{"paragraph"};}B= $force_loose_test
ABresult
1X1
011
000
163 85459 ▶ if ($this->{last_line_was_blank}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"last_line_was_blank"}) 5778 79681 85459
164 5778 ▶ if (@{$this->{blocks_stack}}
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"blocks_stack"};} and $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item") 151 5627 5778
Condition100%3/3
@{$this->{"blocks_stack"};} and $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
!ll&&!rl&&r
561314151
MC/DC100%2/2
@{$this->{"blocks_stack"};} and $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
@{$this->{"blocks_stack"};} $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
Truth table100%3/3
A and B
A= @{$this->{"blocks_stack"};}B= $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
ABresult
0X0
100
111
165 && $this->{blocks_stack}[-1]{block}{type} eq 'list_item') {
166 151 $this->{blocks_stack}[-1]{block}{loose} = 1;
167 }
168 }
169 }
170 122367 ▶ return unless @{$this->{paragraph}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$this->{"paragraph"};} 68691 53676 122367
171 53676 push @{$this->{blocks}}, {type => 'paragraph', content => $this->{paragraph}};
172 53676 $this->{paragraph} = [];
173 53676 return;
174 }
175  
176 # Whether the list_item match the most recent list (should we add to the same
177 # list or create a new one).
178 sub _list_match {
179 34838 ▶ my ($this, $item) = @_;
Subroutine _list_match: called CC=4 SCAR=13.9
180 34838 ▶ return 0 unless @{$this->{blocks}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$this->{"blocks"};} 9865 24973 34838
181 24973 my $list = $this->{blocks}[-1];
182 return
183 $list->{type} eq 'list'
184 && $list->{style} eq $item->{style}
185 24973 ▶ && $list->{marker} eq $item->{marker};
Condition100%6/6
$list->{'type'} eq 'list' && $list->{'style'} eq $item->{'style'} && $list->{'marker'} eq $item->{'marker'}
!ll&&!rl&&r
196681515154
$list->{"type"} eq "list" and $list->{"style"} eq $item->{"style"}
!ll&&!rl&&r
1437952895305
MC/DC100%3/3
$list->{'type'} eq 'list' && $list->{'style'} eq $item->{'style'} && $list->{'marker'} eq $item->{'marker'}
$list->{"type"} eq "list" $list->{"style"} eq $item->{"style"} $list->{'marker'} eq $item->{'marker'}
Truth table100%4/4
A and B && C
A= $list->{"type"} eq "list"B= $list->{"style"} eq $item->{"style"}C= $list->{'marker'} eq $item->{'marker'}
ABCresult
0XX0
10X0
1100
1111
186 }
187  
188 sub _add_block {
189 35860 ▶ my ($this, $block) = @_;
Subroutine _add_block: called CC=4 SCAR=13.9
190 35860 ▶ if ($block->{type} eq 'list_item') {
Branch: 1 branch
BranchTrueFalseTotal
if ($block->{'type'} eq 'list_item') { } 16433 19427 35860
191 16433 $this->_finalize_paragraph(0);
192 # https://spec.commonmark.org/0.30/#lists
193 16433 ▶ if ($this->_list_match($block)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->_list_match($block)) { } 2403 14030 16433
194 2403 push @{$this->{blocks}[-1]{items}}, $block;
195 2403 ▶ $this->{blocks}[-1]{loose} ||= $block->{loose};
Condition100%3/3
$this->{"blocks"}[-1]{"loose"} ||= $block->{"loose"}
l!l&&r!l&&!r
612162126
MC/DC100%2/2
$this->{"blocks"}[-1]{"loose"} ||= $block->{"loose"}
$this->{"blocks"}[-1]{"loose"} $block->{"loose"}
Truth table100%3/3
A ||= B
A= $this->{"blocks"}[-1]{"loose"}B= $block->{"loose"}
ABresult
1X1
011
000
196 } else {
197 my $list = {
198 type => 'list',
199 style => $block->{style},
200 marker => $block->{marker},
201 start_num => $block->{num},
202 items => [$block],
203 loose => $block->{loose}
204 14030 };
205 14030 push @{$this->{blocks}}, $list;
206 }
207 } else {
208 19427 $this->_finalize_paragraph(1);
209 19427 push @{$this->{blocks}}, $block;
210 }
211 35860 return;
212 }
213  
214 # Anything passed to $prefix_re must necessary accept an empty string unless the
215 # block cannot accept lazy continuations. This is a best effort simulation of
216 # the block condition, to be used for some complex multi-line constructs that
217 # are parsed through a single regex.
218 sub _enter_child_block {
219 29725 ▶ my ($this, $new_block, $cond, $prefix_re, $forced_next_line) = @_;
Subroutine _enter_child_block: called CC=2 SCAR=6.9
220 29725 $this->_finalize_paragraph(1);
221 29725 ▶ if (defined $forced_next_line) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $forced_next_line) 27299 2426 29725
222 27299 $this->{forced_line} = $forced_next_line;
223 }
224 29725 push @{$this->{blocks_stack}}, {
225 cond => $cond,
226 block => $new_block,
227 parent_blocks => $this->{blocks},
228 continuation_re => $this->{continuation_re}
229 29725 };
230 29725 $this->{continuation_re} = qr/$this->{continuation_re} $prefix_re/x;
231 29725 $this->{blocks} = [];
232 29725 return;
233 }
234  
235 sub _restore_parent_block {
236 25671 ▶ my ($this) = @_;
Subroutine _restore_parent_block: called CC=1 SCAR=0.0
237 # TODO: rename the variables here with something better.
238 25671 my $last_block = pop @{$this->{blocks_stack}};
239 25671 my $block = delete $last_block->{block};
240 # TODO: maybe rename content to blocks here.
241 25671 $block->{content} = $this->{blocks};
242 25671 $this->{blocks} = delete $last_block->{parent_blocks};
243 25671 $this->{continuation_re} = delete $last_block->{continuation_re};
244 25671 $this->_add_block($block);
245 25671 return;
246 }
247  
248 # Returns true if $l would be parsed as the continuation of a paragraph in the
249 # context of $this (which is not modified).
250 sub _test_lazy_continuation {
251 29816 ▶ my ($this, $l) = @_;
Subroutine _test_lazy_continuation: called CC=4 SCAR=13.9
252 29816 ▶ return unless @{$this->{paragraph}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$this->{"paragraph"};} 6244 23572 29816
253 23572 my $tester = new(ref($this), $this->{pmarkdown}, \'');
254 23572 pos($tester->{md}) = 0;
255 # What is a paragraph depends on whether we already have a paragraph or not.
256 23572 ▶ $tester->{paragraph} = [@{$this->{paragraph}} ? ('foo') : ()];
Branch: 1 branch
BranchTrueFalseTotal
@{$this->{'paragraph'};} ? : 23572 0 23572
257 # We use this field both in the tester and in the actual object when we
258 # matched a lazy continuation.
259 23572 $tester->{is_lazy_continuation} = 1;
260 # We’re ignoring the eol of the original line as it should not affect parsing.
261 23572 $tester->_parse_blocks($l);
262 # BUG: there is a bug here which is that a construct like a fenced code block
263 # or a link ref definition, whose validity depends on more than one line,
264 # might be misclassified. The probability of that is low.
265 23572 ▶ if (@{$tester->{paragraph}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$tester->{"paragraph"};}) 12823 10749 23572
266 12823 $this->{is_lazy_continuation} = 1;
267 12823 return 1;
268 }
269 10749 return 0;
270 }
271  
272 sub _count_matching_blocks {
273 152301 ▶ my ($this, $lr) = @_; # $lr is a scalar *reference* to the current line text.
Subroutine _count_matching_blocks: called CC=5 SCAR=16.1
274 152301 $this->{matched_prefix_size} = 0;
275 152301 for my $i (0 .. $#{$this->{blocks_stack}}) {
276 38560 local *::_ = $lr;
277 38560 my $r = $this->{blocks_stack}[$i]{cond}();
278 38560 ▶ $this->{matched_prefix_size} += $r if defined $r && $r > 0; # $r < 0 means match but no prefix.
Branch: 1 branch
BranchTrueFalseTotal
if defined $r and $r > 0 19107 19453 38560
Condition100%3/3
defined $r and $r > 0
!ll&&!rl&&r
16601779319107
MC/DC100%2/2
defined $r and $r > 0
defined $r $r > 0
Truth table100%3/3
A and B
A= defined $rB= $r > 0
ABresult
0X0
100
111
279 38560 ▶ return $i unless $r;
Branch: 1 branch
BranchTrueFalseTotal
unless $r 19199 19361 38560
280 }
281 133102 return @{$this->{blocks_stack}};
282 }
283  
284 sub _all_blocks_match {
285 29140 ▶ my ($this, $lr) = @_;
Subroutine _all_blocks_match: called CC=1 SCAR=0.0
286 29140 return @{$this->{blocks_stack}} == $this->_count_matching_blocks($lr);
287 }
288  
289 31 my $thematic_break_re = qr/^\ {0,3} (?: (?:-[ \t]*){3,} | (_[ \t]*){3,} | (\*[ \t]*){3,} ) $/x;
290 31 my $block_quotes_re = qr/^ {0,3}>/;
291 31 my $indented_code_re = qr/^(?: {0,3}\t| {4})/;
292 31 my $list_item_marker_re = qr/ [-+*] | (?<digits>\d{1,9}) (?<symbol>[.)])/x;
293 31 my $list_item_re =
294 qr/^ (?<indent>\ {0,3}) (?<marker>${list_item_marker_re}) (?<text>(?:[ \t].*)?) $/x;
295 31 my $supported_html_tags = join('|',
296 qw(address article aside base basefont blockquote body caption center col colgroup dd details dialog dir div dl dt fieldset figcaption figure footer form frame frameset h1 h2 h3 h4 h5 h6 head header hr html iframe legend li link main menu menuitem nav noframes ol optgroup option p param search section summary table tbody td tfoot th thead title tr track ul)
297 );
298  
299 31 my $directive_name_re = qr/(?<name> [-\w]+ )?/x;
300 31 my $directive_content_re = qr/(?: \s* \[ (?<content> [^\]]+ ) \] )?/x;
301 31 my $directive_attribute_re = qr/(?: \s* \{ (?<attributes> .* ) \} )?/x;
302 31 my $directive_data_re = qr/${directive_name_re} ${directive_content_re} ${directive_attribute_re}/x;
303 31 my $directive_block_re = qr/^\ {0,3} (?<marker> :{3,} ) \s* ${directive_data_re} \s* :* \s* $/x;
304  
305 # TODO: Share these regex with the Inlines.pm file that has a copy of them.
306 31 my $html_tag_name_re = qr/[a-zA-Z][-a-zA-Z0-9]*/;
307 31 my $html_attribute_name_re = qr/[a-zA-Z_:][-a-zA-Z0-9_.:]*/;
308 # We include new lines in these regex as the spec mentions them, but we can’t
309 # match them for now as the regex will see lines one at a time.
310 31 my $html_space_re = qr/\n[ \t]*|[ \t][ \t]*\n?[ \t]*/; # Spaces, tabs, and up to one line ending.
311 31 my $opt_html_space_re = qr/[ \t]*\n?[ \t]*/; # Optional spaces.
312 31 my $html_attribute_value_re = qr/ [^ \t\n"'=<>`]+ | '[^']*' | "[^"]*" /x;
313 31 my $html_attribute_re =
314 qr/ ${html_space_re} ${html_attribute_name_re} (?: ${opt_html_space_re} = ${opt_html_space_re} ${html_attribute_value_re} )? /x;
315 31 my $html_open_tag_re =
316 qr/ < ${html_tag_name_re} ${html_attribute_re}* ${opt_html_space_re} \/? > /x;
317 31 my $html_close_tag_re = qr/ <\/ ${html_tag_name_re} ${opt_html_space_re} > /x;
318  
319 # Parse at least one line of text to build a new block; and possibly several
320 # lines, depending on the block type.
321 # https://spec.commonmark.org/0.30/#blocks-and-inlines
322 31 our $l; # global variable, localized during the call to _parse_blocks.
323  
324 sub _parse_blocks { ## no critic (RequireArgUnpacking)
325 146659 ▶ my $this = shift @_;
Subroutine _parse_blocks: called CC=22 SCAR=30.9
326 # TODO do the localization in process to avoid the copy (but this will need
327 # change in the continuation tester).
328 146659 local $l = shift @_; ## no critic (ProhibitLocalVars)
329  
330 146659 ▶ if (!$this->{skip_next_block_matching}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $this->{'skip_next_block_matching'}) { } 123161 23498 146659
331 123161 my $matched_block = $this->_count_matching_blocks(\$l);
332 123161 ▶ if (@{$this->{blocks_stack}} > $matched_block) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"blocks_stack"};} > $matched_block) 17583 105578 123161
333 17583 $this->_finalize_paragraph();
334 17583 ▶ while (@{$this->{blocks_stack}} > $matched_block) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"blocks_stack"};} > $matched_block) 18674 17583 36257
335 18674 $this->_restore_parent_block();
336 }
337 }
338 } else {
339 23498 $this->{skip_next_block_matching} = 0;
340 }
341  
342 # There are two different cases. The first one, handled here, is when we have
343 # multiple blocks inside a list item separated by a blank line. The second
344 # case (when the list items themselves are separated by a blank line) is
345 # handled when parsing the list item itself (based on the last_line_was_blank
346 # setting).
347 146659 ▶ if ($this->{last_line_is_blank}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"last_line_is_blank"}) 14874 131785 146659
348 14874 ▶ if (@{$this->{blocks_stack}}
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"blocks_stack"};} and $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item") 557 14317 14874
Condition100%3/3
@{$this->{"blocks_stack"};} and $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
!ll&&!rl&&r
1428433557
MC/DC100%2/2
@{$this->{"blocks_stack"};} and $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
@{$this->{"blocks_stack"};} $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
Truth table100%3/3
A and B
A= @{$this->{"blocks_stack"};}B= $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
ABresult
0X0
100
111
349 && $this->{blocks_stack}[-1]{block}{type} eq 'list_item') {
350 # $this->{blocks_stack}[-1]{block}{loose} = 1;
351 }
352 }
353 146659 $this->{last_line_was_blank} = $this->{last_line_is_blank};
354 146659 $this->{last_line_is_blank} = 0;
355  
356 146659 ▶ _do_atx_heading($this)
Branch: 1 branch
BranchTrueFalseTotal
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this) or _do_directive_block($this) or _do_link_reference_definition($this) or $this->get_use_table_blocks and _do_table_block($this) or _do_paragraph($this) or croak("Current line could not be parsed as anything: $Markdown::Perl::BlockParser::l") 0 146659 146659
Condition97%41/42
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this) or _do_directive_block($this) or _do_link_reference_definition($this) or $this->get_use_table_blocks and _do_table_block($this) or _do_paragraph($this)
l!l&&r!l&&!r
401071065520
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this) or _do_directive_block($this) or _do_link_reference_definition($this) or $this->get_use_table_blocks and _do_table_block($this)
l!l&&r!l&&!r
401007106552
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this) or _do_directive_block($this) or _do_link_reference_definition($this)
l!l&&r!l&&!r
39908192106559
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this) or _do_directive_block($this)
l!l&&r!l&&!r
3982682106751
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this)
l!l&&r!l&&!r
2142118405106833
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this)
l!l&&r!l&&!r
1018311238125238
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this)
l!l&&r!l&&!r
74822676136501
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this)
l!l&&r!l&&!r
24105042139207
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this)
l!l&&r!l&&!r
14001010144249
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this)
l!l&&r!l&&!r
1132268145259
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this)
l!l&&r!l&&!r
618514145527
$this->get_use_setext_headings and _do_setext_heading($this)
!ll&&!rl&&r
44416101111514
$this->get_use_fenced_code_blocks and _do_fenced_code_block($this)
!ll&&!rl&&r
364191027885042
$this->get_use_table_blocks and _do_table_block($this)
!ll&&!rl&&r
52880536727
MC/DC0%0/15
_do_atx_heading($this) or $this->get_use_setext_headings and _do_setext_heading($this) or _do_thematic_break($this) or _do_indented_code_block($this) or $this->get_use_fenced_code_blocks and _do_fenced_code_block($this) or _do_html_block($this) or _do_block_quotes($this) or _do_list_item($this) or _do_directive_block($this) or _do_link_reference_definition($this) or $this->get_use_table_blocks and _do_table_block($this) or _do_paragraph($this)
_do_atx_heading($this) $this->get_use_setext_headings _do_setext_heading($this) _do_thematic_break($this) _do_indented_code_block($this) $this->get_use_fenced_code_blocks _do_fenced_code_block($this) _do_html_block($this) _do_block_quotes($this) _do_list_item($this) _do_directive_block($this) _do_link_reference_definition($this) $this->get_use_table_blocks _do_table_block($this) _do_paragraph($this)
Truth table56%27/48
A or B and C or D or E or F and G or H or I or J or K or L or M and N or O
A= _do_atx_heading($this)B= $this->get_use_setext_headingsC= _do_setext_heading($this)D= _do_thematic_break($this)E= _do_indented_code_block($this)F= $this->get_use_fenced_code_blocksG= _do_fenced_code_block($this)H= _do_html_block($this)I= _do_block_quotes($this)J= _do_list_item($this)K= _do_directive_block($this)L= _do_link_reference_definition($this)M= $this->get_use_table_blocksN= _do_table_block($this)O= _do_paragraph($this)
ABCDEFGHIJKLMNOresult
1XXXXXXXXXXXXXX1
011XXXXXXXXXXXX1
00X1XXXXXXXXXXX1
0101XXXXXXXXXXX1
00X01XXXXXXXXXX1
01001XXXXXXXXXX1
00X0011XXXXXXXX1
0100011XXXXXXXX1
00X000X1XXXXXXX1
00X00101XXXXXXX1
010000X1XXXXXXX1
01000101XXXXXXX1
00X000X01XXXXXX1
00X001001XXXXXX1
010000X01XXXXXX1
010001001XXXXXX1
00X000X001XXXXX1
00X0010001XXXXX1
010000X001XXXXX1
0100010001XXXXX1
00X000X0001XXXX1
00X00100001XXXX1
010000X0001XXXX1
01000100001XXXX1
00X000X00001XXX1
00X001000001XXX1
010000X00001XXX1
010001000001XXX1
00X000X0000011X1
00X00100000011X1
010000X0000011X1
01000100000011X1
00X000X000000X11
00X000X000001011
00X0010000000X11
00X0010000001011
010000X000000X11
010000X000001011
0100010000000X11
0100010000001011
00X000X000000X00
00X000X000001000
00X0010000000X00
00X0010000001000
010000X000000X00
010000X000001000
0100010000000X00
0100010000001000
357 || ($this->get_use_setext_headings && _do_setext_heading($this))
358 # Thematic breaks are described first in the spec, but the setext headings has
359 # precedence in case of conflict, so we test for the break after the heading.
360 || _do_thematic_break($this)
361 || _do_indented_code_block($this)
362 || ($this->get_use_fenced_code_blocks && _do_fenced_code_block($this))
363 || _do_html_block($this)
364 || _do_block_quotes($this)
365 || _do_list_item($this)
366 || _do_directive_block($this)
367 || _do_link_reference_definition($this)
368 || ($this->get_use_table_blocks && _do_table_block($this))
369 || _do_paragraph($this)
370 || croak "Current line could not be parsed as anything: $l";
371 146659 return;
372 }
373  
374 sub _load_yaml_module {
375 1 ▶ my ($module_name) = @_;
Subroutine _load_yaml_module: called CC=2 SCAR=7.6
376 1 ▶ if (!eval "require $module_name; 1") { ## no critic (BuiltinFunctions::ProhibitStringyEval)
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $module_name; 1") 0 1 1
377 0 croak "Cannot load module $module_name: ${EVAL_ERROR}";
378 }
379 1 return;
380 }
381  
382 sub _call_yaml_parser {
383 9 ▶ my ($this, $yaml) = @_;
Subroutine _call_yaml_parser: called CC=4 SCAR=14.4
384 9 my $parser = $this->get_yaml_parser;
385 9 my $metadata;
386 9 ▶ if ($parser eq 'YAML::Tiny') {
Branch: 2 branches
BranchTrueFalseTotal
if ($parser eq 'YAML::Tiny') { } 8 1 9
elsif ($parser eq 'YAML::PP' or $parser eq 'YAML::PP::LibYAML') { } 1 0 1
387 8 return eval { YAML::Tiny->read_string($yaml)->[0] };
388 ▶ } elsif ($parser eq 'YAML::PP' || $parser eq 'YAML::PP::LibYAML') {
Condition33%1/3
$parser eq "YAML::PP" or $parser eq "YAML::PP::LibYAML"
l!l&&r!l&&!r
100
MC/DC0%0/2
$parser eq "YAML::PP" or $parser eq "YAML::PP::LibYAML"
$parser eq "YAML::PP" $parser eq "YAML::PP::LibYAML"
Truth table33%1/3
A or B
A= $parser eq "YAML::PP"B= $parser eq "YAML::PP::LibYAML"
ABresult
1X1
011
000
389 1 _load_yaml_module($parser);
390 1 return eval { ($parser->new()->load_string($yaml))[0] };
391 }
392 0 croak "Unsupported YAML parser: $parser";
393 }
394  
395 sub _parse_yaml_metadata {
396 4235 ▶ my ($this) = @_;
Subroutine _parse_yaml_metadata: called CC=6 SCAR=17.9
397  
398 # At this point, pos(md) is guaranteed to be 0.
399 4235 ▶ my $line_re = $this->get_yaml_file_metadata_allows_empty_lines ? qr/.*\n/ : qr/.+\n/;
Branch: 1 branch
BranchTrueFalseTotal
$this->get_yaml_file_metadata_allows_empty_lines ? : 2 4233 4235
400 4235 ▶ if ($this->{md} =~ m/ ^ ---\n (?<YAML> (?: $line_re )+? ) (?: --- | \.\.\. ) \n /gxc) { ## no critic (ProhibitUnusedCapture)
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"md"} =~ / ^ ---\n (?<YAML> (?: $line_re )+? ) (?: --- | \.\.\. ) \n /cgux) 9 4226 4235
401 9 my $metadata = $this->_call_yaml_parser($+{YAML});
402 9 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Markdown::Perl::BlockParser::EVAL_ERROR) 2 7 9
403 2 pos($this->{md}) = 0;
404 2 ▶ carp 'YAML Metadata (Markdown frontmatter) is invalid' if $this->get_warn_for_unused_input();
Branch: 1 branch
BranchTrueFalseTotal
if $this->get_warn_for_unused_input 2 0 2
405 2 return;
406 }
407 7 ▶ if (exists($this->{pmarkdown}{hooks}{yaml_metadata})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $this->{"pmarkdown"}{"hooks"}{"yaml_metadata"}) 5 2 7
408 5 $this->{pmarkdown}{hooks}{yaml_metadata}->($metadata);
409 }
410 }
411 4232 return;
412 }
413  
414 # https://spec.commonmark.org/0.30/#atx-headings
415 sub _do_atx_heading {
416 146659 ▶ my ($this) = @_;
Subroutine _do_atx_heading: called CC=3 SCAR=11.0
417 146659 ▶ if ($l =~ /^ \ {0,3} (\#{1,6}) (?:[ \t]+(.+?))?? (?:[ \t]+\#+)? [ \t]* $/x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Markdown::Perl::BlockParser::l =~ /^ \ {0,3} (\#{1,6}) (?:[ \t]+(.+?))?? (?:[ \t]+\#+)? [ \t]* $/ux) 618 146041 146659
418 # Note: heading breaks can interrupt a paragraph or a list
419 # TODO: the content of the header needs to be interpreted for inline content.
420 618 ▶ $this->_add_block({
Condition100%2/2
$2 // ""
l!l
51999
MC/DC100%1/1
$2 // ""
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
421 type => 'heading',
422 level => length($1),
423 content => $2 // '',
424 debug => 'atx'
425 });
426 618 return 1;
427 }
428 146041 return;
429 }
430  
431 # https://spec.commonmark.org/0.30/#setext-headings
432 sub _do_setext_heading {
433 101625 ▶ my ($this) = @_;
Subroutine _do_setext_heading: called CC=11 SCAR=24.0
434 101625 ▶ return unless $l =~ /^ {0,3}(-+|=+)[ \t]*$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ /^ {0,3}(-+|=+)[ \t]*$/u 100110 1515 101625
435 1515 ▶ if ( !@{$this->{paragraph}}
Branch: 1 branch
BranchTrueFalseTotal
if (not @{$this->{"paragraph"};} or indent_size($this->{"paragraph"}[0]) >= 4 or $this->{"is_lazy_continuation"}) 307 514 821
Condition83%5/6
not @{$this->{"paragraph"};} or indent_size($this->{"paragraph"}[0]) >= 4 or $this->{"is_lazy_continuation"}
l!l&&r!l&&!r
694307514
not @{$this->{"paragraph"};} or indent_size($this->{"paragraph"}[0]) >= 4
l!l&&r!l&&!r
6940821
MC/DC66%2/3
not @{$this->{"paragraph"};} or indent_size($this->{"paragraph"}[0]) >= 4 or $this->{"is_lazy_continuation"}
not @{$this->{"paragraph"};} indent_size($this->{"paragraph"}[0]) >= 4 $this->{"is_lazy_continuation"}
Truth table75%3/4
not(A) or B or C
A= not @{$this->{"paragraph"};}B= indent_size($this->{"paragraph"}[0]) >= 4C= $this->{"is_lazy_continuation"}
ABCresult
1XX1
01X1
0011
0000
436 || indent_size($this->{paragraph}[0]) >= 4
437 || $this->{is_lazy_continuation}) {
438 1001 return;
439 }
440 # TODO: this should not interrupt a list if the heading is just one -
441 514 my $c = substr $1, 0, 1;
442 514 my $p = $this->{paragraph};
443 514 my $m = $this->get_multi_lines_setext_headings;
444 514 ▶ if ($m eq 'single_line' && @{$p} > 1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($m eq 'single_line' and @{$p;} > 1) { } 1 513 514
elsif ($m eq 'break' and $Markdown::Perl::BlockParser::l =~ /$thematic_break_re/u) { } 1 512 513
elsif ($m eq 'ignore') { } 1 511 512
Condition66%2/3
$m eq "single_line" and @{$p;} > 1
!ll&&!rl&&r
51301
MC/DC50%1/2
$m eq "single_line" and @{$p;} > 1
$m eq "single_line" @{$p;} > 1
Truth table66%2/3
A and B
A= $m eq "single_line"B= @{$p;} > 1
ABresult
0X0
100
111
445 1 my $last_line = pop @{$p};
446 1 $this->_finalize_paragraph();
447 1 $p = [$last_line];
448 ▶ } elsif ($m eq 'break' && $l =~ m/${thematic_break_re}/) {
Condition66%2/3
$m eq "break" and $Markdown::Perl::BlockParser::l =~ /$thematic_break_re/u
!ll&&!rl&&r
51201
MC/DC50%1/2
$m eq "break" and $Markdown::Perl::BlockParser::l =~ /$thematic_break_re/u
$m eq "break" $Markdown::Perl::BlockParser::l =~ /$thematic_break_re/u
Truth table66%2/3
A and B
A= $m eq "break"B= $Markdown::Perl::BlockParser::l =~ /$thematic_break_re/u
ABresult
0X0
100
111
449 1 $this->_finalize_paragraph();
450 1 $this->_add_block({type => 'break', debug => 'setext_as_break'});
451 1 return 1;
452 } elsif ($m eq 'ignore') {
453 # TODO: maybe we should just do nothing and return 0 here.
454 1 push @{$this->{paragraph}}, $l;
455 1 return 1;
456 }
457 512 $this->{paragraph} = [];
458 512 ▶ $this->_add_block({
Branch: 1 branch
BranchTrueFalseTotal
$c eq '=' ? : 37 475 512
459 type => 'heading',
460 level => ($c eq '=' ? 1 : 2),
461 content => $p,
462 debug => 'setext'
463 });
464 512 return 1;
465 }
466  
467 # https://spec.commonmark.org/0.30/#thematic-breaks
468 sub _do_thematic_break {
469 145527 ▶ my ($this) = @_;
Subroutine _do_thematic_break: called CC=2 SCAR=6.9
470 145527 ▶ if ($l !~ /${thematic_break_re}/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Markdown::Perl::BlockParser::l =~ /$thematic_break_re/u) 145259 268 145527
471 145259 return;
472 }
473 268 $this->_add_block({type => 'break', debug => 'native_break'});
474 268 return 1;
475 }
476  
477 # https://spec.commonmark.org/0.30/#indented-code-blocks
478 sub _do_indented_code_block {
479 145259 ▶ my ($this) = @_;
Subroutine _do_indented_code_block: called CC=9 SCAR=22.0
480 # Indented code blocks cannot interrupt a paragraph.
481 145259 ▶ if (@{$this->{paragraph}} || $l !~ m/${indented_code_re}/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"paragraph"};} or not $Markdown::Perl::BlockParser::l =~ /$indented_code_re/u) 144249 1010 145259
Condition100%3/3
@{$this->{"paragraph"};} or not $Markdown::Perl::BlockParser::l =~ /$indented_code_re/u
l!l&&r!l&&!r
71937723121010
MC/DC100%2/2
@{$this->{"paragraph"};} or not $Markdown::Perl::BlockParser::l =~ /$indented_code_re/u
@{$this->{"paragraph"};} not $Markdown::Perl::BlockParser::l =~ /$indented_code_re/u
Truth table100%3/3
A or not(B)
A= @{$this->{"paragraph"};}B= not $Markdown::Perl::BlockParser::l =~ /$indented_code_re/u
ABresult
1X1
011
000
482 144249 return;
483 }
484 1010 my $convert_tabs = $this->get_code_blocks_convert_tabs_to_spaces;
485 1010 ▶ tabs_to_space($l, $this->{matched_prefix_size}) if $convert_tabs;
Branch: 1 branch
BranchTrueFalseTotal
if $convert_tabs 212 798 1010
486 1010 my @code_lines = scalar(remove_prefix_spaces(4, $l.$this->line_ending()));
487 1010 my $count = 1; # The number of lines we have read
488 1010 my $valid_count = 1; # The number of lines we know are in the code block.
489 1010 my $valid_pos = $this->get_pos();
490 1010 ▶ while (defined (my $nl = $this->next_line())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $nl = $this->next_line)) 1093 177 1270
491 1093 ▶ if ($this->_all_blocks_match(\$nl)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->_all_blocks_match(\$nl)) { } 884 209 1093
492 884 $count++;
493 884 ▶ if ($nl =~ m/${indented_code_re}/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nl =~ /$indented_code_re/u) { } 53 831 884
elsif ($nl eq '') { } 207 624 831
494 53 $valid_pos = $this->get_pos();
495 53 $valid_count = $count;
496 53 ▶ tabs_to_space($nl, $this->{matched_prefix_size}) if $convert_tabs;
Branch: 1 branch
BranchTrueFalseTotal
if $convert_tabs 2 51 53
497 53 push @code_lines, scalar(remove_prefix_spaces(4, $nl.$this->line_ending()));
498 } elsif ($nl eq '') {
499 207 push @code_lines, scalar(remove_prefix_spaces(4, $nl.$this->line_ending(), !$convert_tabs));
500 } else {
501 624 last;
502 }
503 } else {
504 209 last;
505 }
506 }
507 1010 splice @code_lines, $valid_count;
508 1010 $this->set_pos($valid_pos);
509 1010 my $code = join('', @code_lines);
510 1010 $this->_add_block({type => 'code', content => $code, debug => 'indented'});
511 1010 return 1;
512 }
513  
514 # https://spec.commonmark.org/0.30/#fenced-code-blocks
515 sub _do_fenced_code_block {
516 107830 ▶ my ($this) = @_;
Subroutine _do_fenced_code_block: called CC=10 SCAR=23.0
517 107830 ▶ return unless $l =~ /^ (?<indent>\ {0,3}) (?<fence>`{3,}|~{3,}) [ \t]* (?<info>.*?) [ \t]* $/x; ## no critic (ProhibitComplexRegexes)
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ /^ (?<indent>\ {0,3}) (?<fence>`{3,}|~{3,}) [ \t]* (?<info>.*?) [ \t]* $/ux 97682 10148 107830
518 10148 my $f = substr $+{fence}, 0, 1;
519 10148 ▶ if ($f eq '`' && index($+{info}, '`') != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f eq "`" and index($+{"info"}, "`") != -1) 1528 8620 10148
Condition100%3/3
$f eq "`" and index($+{"info"}, "`") != -1
!ll&&!rl&&r
1986011528
MC/DC100%2/2
$f eq "`" and index($+{"info"}, "`") != -1
$f eq "`" index($+{"info"}, "`") != -1
Truth table100%3/3
A and B
A= $f eq "`"B= index($+{"info"}, "`") != -1
ABresult
0X0
100
111
520 1528 return;
521 }
522 8620 my $fl = length($+{fence});
523 8620 my $info = $+{info};
524 8620 my $indent = length($+{indent});
525 # This is one of the few case where we need to process character escaping
526 # outside of the full inlines rendering process.
527 # TODO: Consider if it would be cleaner to do it inside the render_html method.
528 8620 $info =~ s/\\(\p{PosixPunct})/$1/g;
529 # The spec does not describe what we should do with fenced code blocks inside
530 # other containers if we don’t match them.
531 8620 my @code_lines; # The first line is not part of the block.
532 8620 my $end_fence_seen = 0;
533 8620 my $start_pos = $this->get_pos();
534 8620 ▶ while (defined (my $nl = $this->next_line())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $nl = $this->next_line)) 23130 7327 30457
535 23130 ▶ if ($this->_all_blocks_match(\$nl)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->_all_blocks_match(\$nl)) { } 22276 854 23130
536 22276 ▶ if ($nl =~ m/^ {0,3}${f}{$fl,}[ \t]*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nl =~ /^ {0,3}${f}{$fl,}[ \t]*$/u) { } 439 21837 22276
537 439 $end_fence_seen = 1;
538 439 last;
539 } else {
540 # We’re adding one line to the fenced code block
541 21837 push @code_lines, scalar(remove_prefix_spaces($indent, $nl.$this->line_ending()));
542 }
543 } else {
544 # We’re out of our enclosing block and we haven’t seen the end of the
545 # fence. If we accept enclosed fence, then that last line must be tried
546 # again (and, otherwise, we will start again from start_pos).
547 854 ▶ $this->redo_line() if !$this->get_fenced_code_blocks_must_be_closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->get_fenced_code_blocks_must_be_closed 165 689 854
548 854 last;
549 }
550 }
551  
552 8620 ▶ if (!$end_fence_seen && $this->get_fenced_code_blocks_must_be_closed) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $end_fence_seen and $this->get_fenced_code_blocks_must_be_closed) 3548 5072 8620
Condition100%3/3
not $end_fence_seen and $this->get_fenced_code_blocks_must_be_closed
!ll&&!rl&&r
43946333548
MC/DC100%2/2
not $end_fence_seen and $this->get_fenced_code_blocks_must_be_closed
not $end_fence_seen $this->get_fenced_code_blocks_must_be_closed
Truth table100%3/3
not(A) and B
A= not $end_fence_seenB= $this->get_fenced_code_blocks_must_be_closed
ABresult
0X0
100
111
553 3548 $this->set_pos($start_pos);
554 3548 return;
555 }
556 5072 my $code = join('', @code_lines);
557 5072 $this->_add_block({
558 type => 'code',
559 content => $code,
560 info => $info,
561 debug => 'fenced'
562 });
563 5072 return 1;
564 }
565  
566 # https://spec.commonmark.org/0.31.2/#html-blocks
567 sub _do_html_block {
568 139177 ▶ my ($this) = @_;
Subroutine _do_html_block: called CC=15 SCAR=27.1
569 # HTML blocks can interrupt a paragraph.
570 # TODO: add an option so that they don’t interrupt a paragraph (make it be
571 # the default?).
572 # TODO: PERF: test that $l =~ m/^ {0,3}</ to short circuit all these regex.
573 139177 my $html_end_condition;
574 139177 ▶ if ($l =~ m/ ^\ {0,3} < (?:pre|script|style|textarea) (?:\ |\t|>|$) /x) {
Branch: 7 branches
BranchTrueFalseTotal
if ($Markdown::Perl::BlockParser::l =~ / ^\ {0,3} < (?:pre|script|style|textarea) (?:\ |\t|>|$) /ux) { } 16 139161 139177
elsif ($Markdown::Perl::BlockParser::l =~ /^ {0,3}<!--/u) { } 10 139151 139161
elsif ($Markdown::Perl::BlockParser::l =~ /^ {0,3}<\?/u) { } 2 139149 139151
elsif ($Markdown::Perl::BlockParser::l =~ /^ {0,3}<![a-zA-Z]/u) { } 2 139147 139149
elsif ($Markdown::Perl::BlockParser::l =~ /^ {0,3}<!\[CDATA\[/u) { } 2 139145 139147
elsif ($Markdown::Perl::BlockParser::l =~ m[^\ {0,3} < /? (?:$supported_html_tags) (?:\ |\t|/?>|$) ]ux) { } 2643 136502 139145
elsif (not @{$this->{'paragraph'};} and $Markdown::Perl::BlockParser::l =~ /^\ {0,3} (?: $html_open_tag_re | $html_close_tag_re ) [ \t]* $ /ux) { } 26 204923 204949
575 16 $html_end_condition = qr/ <\/ (?:pre|script|style|textarea) > /x;
576 } elsif ($l =~ m/^ {0,3}<!--/) {
577 10 $html_end_condition = qr/-->/;
578 } elsif ($l =~ m/^ {0,3}<\?/) {
579 2 $html_end_condition = qr/\?>/;
580 } elsif ($l =~ m/^ {0,3}<![a-zA-Z]/) {
581 2 $html_end_condition = qr/=>/;
582 } elsif ($l =~ m/^ {0,3}<!\[CDATA\[/) {
583 2 $html_end_condition = qr/]]>/;
584 } elsif ($l =~ m/^\ {0,3} < \/? (?:${supported_html_tags}) (?:\ |\t|\/?>|$) /x) {
585 2643 $html_end_condition = qr/^$/; ## no critic (ProhibitFixedStringMatches)
586 136502 ▶ } elsif (!@{$this->{paragraph}}
Condition100%3/3
not @{$this->{"paragraph"};} and $Markdown::Perl::BlockParser::l =~ /^\ {0,3} (?: $html_open_tag_re | $html_close_tag_re ) [ \t]* $ /ux
!ll&&!rl&&r
684476802926
MC/DC100%2/2
not @{$this->{"paragraph"};} and $Markdown::Perl::BlockParser::l =~ /^\ {0,3} (?: $html_open_tag_re | $html_close_tag_re ) [ \t]* $ /ux
not @{$this->{"paragraph"};} $Markdown::Perl::BlockParser::l =~ /^\ {0,3} (?: $html_open_tag_re | $html_close_tag_re ) [ \t]* $ /ux
Truth table100%3/3
not(A) and B
A= not @{$this->{"paragraph"};}B= $Markdown::Perl::BlockParser::l =~ /^\ {0,3} (?: $html_open_tag_re | $html_close_tag_re ) [ \t]* $ /ux
ABresult
0X0
100
111
587 && $l =~ m/^\ {0,3} (?: ${html_open_tag_re} | ${html_close_tag_re} ) [ \t]* $ /x) {
588 # TODO: the spec seem to say that the tag can take more than one line, but
589 # this is not tested, so we don’t implement this for now.
590 26 $html_end_condition = qr/^$/; ## no critic (ProhibitFixedStringMatches)
591 }
592 # TODO: Implement rule 7 about any possible tag.
593 139177 ▶ if (!$html_end_condition) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($html_end_condition) 136476 2701 139177
594 136476 return;
595 }
596 # TODO: see if some code could be shared with the code blocks
597 2701 my @html_lines = $l.$this->line_ending();
598 # TODO: add an option to not parse a tag if it’s closing condition is never
599 # seen.
600 2701 ▶ if ($l !~ m/${html_end_condition}/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Markdown::Perl::BlockParser::l =~ /$html_end_condition/u) 2691 10 2701
601 # The end condition can occur on the opening line.
602 2691 ▶ while (defined (my $nl = $this->next_line())) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $nl = $this->next_line)) 4917 1366 6283
603 4917 ▶ if ($this->_all_blocks_match(\$nl)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->_all_blocks_match(\$nl)) { } 4364 553 4917
604 4364 ▶ if ($nl !~ m/${html_end_condition}/) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $nl =~ /$html_end_condition/u) { } 3592 772 4364
elsif ($nl eq '') { } 756 16 772
605 3592 push @html_lines, $nl.$this->line_ending();
606 } elsif ($nl eq '') {
607 # This can only happen for rules 6 and 7 where the end condition
608 # line is not part of the HTML block.
609 756 $this->redo_line();
610 756 last;
611 } else {
612 16 push @html_lines, $nl.$this->line_ending();
613 16 last;
614 }
615 } else {
616 553 $this->redo_line();
617 553 last;
618 }
619 }
620 }
621 2701 my $html = join('', @html_lines);
622 2701 remove_disallowed_tags($html, $this->get_disallowed_html_tags);
623 2701 $this->_add_block({type => 'html', content => $html});
624 2701 return 1;
625 }
626  
627 # https://spec.commonmark.org/0.30/#block-quotes
628 sub _do_block_quotes {
629 136476 ▶ my ($this) = @_;
Subroutine _do_block_quotes: called CC=2 SCAR=6.9
630 136476 ▶ return unless $l =~ /${block_quotes_re}/;
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ /$block_quotes_re/u 125238 11238 136476
631 # TODO: handle laziness (block quotes where the > prefix is missing)
632 my $cond = sub {
633 26491 ▶ if (s/(${block_quotes_re})/' ' x length($1)/e) {
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (s/($block_quotes_re)/" " x length($1);/eu) 13390 13101 26491
634 # We remove the '>' character that we replaced by a space, and the
635 # optional space after it. We’re using this approach to correctly handle
636 # the case of a line like '>\t\tfoo' where we need to retain the 6
637 # spaces of indentation, to produce a code block starting with two
638 # spaces.
639 13390 my $m;
640 13390 ($_, $m) = remove_prefix_spaces(length($1) + 1, $_);
641 # Returns the matched horizontal size.
642 13390 return $m;
643 }
644 13101 return $this->_test_lazy_continuation($_);
645 11238 };
646 {
647 11238 local *::_ = \$l;
648 11238 $this->{matched_prefix_size} += $cond->();
649 }
650 11238 $this->{skip_next_block_matching} = 1;
651 11238 $this->_enter_child_block({type => 'quotes'}, $cond, qr/ {0,3}(?:> ?)?/, $l);
652 11238 return 1;
653 }
654  
655 # https://spec.commonmark.org/0.30/#list-items
656 sub _do_list_item {
657 125238 ▶ my ($this) = @_;
Subroutine _do_list_item: called CC=20 SCAR=30.0
658 125238 ▶ return unless $l =~ m/${list_item_re}/;
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ /$list_item_re/u 101316 23922 125238
659 # There is a note in the spec on thematic breaks that are not list items,
660 # it’s not exactly clear what is intended, and there are no examples.
661 23922 my ($indent_outside, $marker, $text, $digits, $symbol) = @+{qw(indent marker text digits symbol)};
662 23922 my $indent_marker = length($indent_outside) + length($marker);
663 23922 ▶ my $type = $marker =~ m/[-+*]/ ? 'ul' : 'ol';
Branch: 1 branch
BranchTrueFalseTotal
$marker =~ /[-+*]/u ? : 12237 11685 23922
664 # The $indent_marker is passed in case the text starts with tabs, to properly
665 # compute the tab stops. This is better than nothing but won’t work inside
666 # other container blocks. In all cases, using tabs instead of space should not
667 # be encouraged.
668 23922 my $text_indent = indent_size($text, $indent_marker + $this->{matched_prefix_size});
669 # When interrupting a paragraph, the rules are stricter.
670 23922 my $mode = $this->get_lists_can_interrupt_paragraph;
671 23922 ▶ if (@{$this->{paragraph}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$this->{"paragraph"};}) 12856 11066 23922
672 12856 ▶ return if $mode eq 'never';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "never" 6 12850 12856
673 12850 ▶ if ($mode eq 'within_list'
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "within_list" and not @{$this->{"blocks_stack"};} && $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item") 5430 7420 12850
Condition100%6/6
$mode eq "within_list" and not @{$this->{"blocks_stack"};} && $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
!ll&&!rl&&r
741735430
@{$this->{'blocks_stack'};} && $this->{'blocks_stack'}[-1]{'block'}{'type'} eq 'list_item'
!ll&&!rl&&r
426011703
MC/DC100%3/3
$mode eq "within_list" and not @{$this->{"blocks_stack"};} && $this->{"blocks_stack"}[-1]{"block"}{"type"} eq "list_item"
$mode eq "within_list" @{$this->{'blocks_stack'};} $this->{'blocks_stack'}[-1]{'block'}{'type'} eq 'list_item'
Truth table100%4/4
A and not(B && C)
A= $mode eq "within_list"B= @{$this->{'blocks_stack'};}C= $this->{'blocks_stack'}[-1]{'block'}{'type'} eq 'list_item'
ABCresult
0XX0
1110
10X1
1101
674 5433 && !(@{$this->{blocks_stack}} && $this->{blocks_stack}[-1]{block}{type} eq 'list_item')) {
675 5430 return;
676 }
677 7420 ▶ if ($mode eq 'strict' && ($text eq '' || ($type eq 'ol' && $digits != 1))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "strict" and $text eq "" || $type eq "ol" && $digits != 1) 81 7339 7420
Condition100%9/9
$mode eq "strict" and $text eq "" || $type eq "ol" && $digits != 1
!ll&&!rl&&r
9738427
$text eq "" or $type eq "ol" and $digits != 1
l!l&&r!l&&!r
77237311
$type eq "ol" and $digits != 1
!ll&&!rl&&r
353237984
MC/DC50%2/4
$mode eq "strict" and $text eq "" || $type eq "ol" && $digits != 1
$mode eq "strict" $text eq "" $type eq "ol" $digits != 1
Truth table60%3/5
A and B or C and D
A= $mode eq "strict"B= $text eq ""C= $type eq "ol"D= $digits != 1
ABCDresult
0XXX0
100X0
10100
11XX1
10111
678 81 return;
679 }
680 }
681 18405 ▶ return if $text ne '' && $text_indent == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $text ne "" and $text_indent == 0 0 18405 18405
Condition66%2/3
$text ne "" and $text_indent == 0
!ll&&!rl&&r
289181160
MC/DC0%0/2
$text ne "" and $text_indent == 0
$text ne "" $text_indent == 0
Truth table66%2/3
A and B
A= $text ne ""B= $text_indent == 0
ABresult
0X0
100
111
682 # in the current implementation, $text_indent is enough to know if $text
683 # is matching $indented_code_re, but let’s not depend on that.
684 18405 my $first_line_blank = $text =~ m/^[ \t]*$/;
685 18405 ▶ my $discard_text_indent = $first_line_blank || indented(4 + 1, $text); # 4 + 1 is an indented code block, plus the required space after marker.
Condition100%3/3
$first_line_blank || indented(5, $text)
l!l&&r!l&&!r
234427015791
MC/DC100%2/2
$first_line_blank || indented(5, $text)
$first_line_blank indented(5, $text)
Truth table100%3/3
A || B
A= $first_line_blankB= indented(5, $text)
ABresult
1X1
011
000
686 18405 ▶ my $indent_inside = $discard_text_indent ? 1 : $text_indent;
Branch: 1 branch
BranchTrueFalseTotal
$discard_text_indent ? : 2614 15791 18405
687 18405 my $indent = $indent_inside + $indent_marker;
688 my $cond = sub {
689 23041 ▶ if ($first_line_blank && m/^[ \t]*$/) {
Subroutine __ANON__: called CC=6 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($first_line_blank and /^[ \t]*$/u) { } 301 22740 23041
Condition100%3/3
$first_line_blank and /^[ \t]*$/u
!ll&&!rl&&r
214141326301
MC/DC100%2/2
$first_line_blank and /^[ \t]*$/u
$first_line_blank /^[ \t]*$/u
Truth table100%3/3
A and B
A= $first_line_blankB= /^[ \t]*$/u
ABresult
0X0
100
111
690 # A list item can start with at most one blank line
691 301 return 0;
692 } else {
693 22740 $first_line_blank = 0;
694 }
695 22740 ▶ if (indent_size($_) >= $indent) {
Branch: 1 branch
BranchTrueFalseTotal
if (indent_size($_) >= $indent) 639 22101 22740
696 639 $_ = remove_prefix_spaces($indent, $_);
697 # Returns the matched horizontal size.
698 639 return $indent;
699 }
700 # TODO: we probably don’t need to test the list_item_re case here, just
701 # the lazy continuation and the emptiness is enough.
702 22101 ▶ return (!m/${list_item_re}/ && $this->_test_lazy_continuation($_))
Condition100%6/6
!/$list_item_re/u && $this->_test_lazy_continuation($_) || $_ eq ''
l!l&&r!l&&!r
6210349312398
not /$list_item_re/u and $this->_test_lazy_continuation($_)
!ll&&!rl&&r
5386105056210
MC/DC100%3/3
!/$list_item_re/u && $this->_test_lazy_continuation($_) || $_ eq ''
not /$list_item_re/u $this->_test_lazy_continuation($_) $_ eq ''
Truth table80%4/5
not(A) and B || C
A= not /$list_item_re/uB= $this->_test_lazy_continuation($_)C= $_ eq ''
ABCresult
11X1
0X11
1011
0X00
1000
703 || $_ eq '';
704 18405 };
705 18405 my $forced_next_line = undef;
706 18405 ▶ if (!$first_line_blank) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($first_line_blank) 16061 2344 18405
707 # We are doing a weird compensation for the fact that we are not
708 # processing the condition and to correctly handle the case where the
709 # list marker was followed by tabs.
710 16061 $forced_next_line = remove_prefix_spaces($indent, (' ' x $indent_marker).$text);
711 16061 $this->{matched_prefix_size} = $indent;
712 16061 $this->{skip_next_block_matching} = 1;
713 }
714 # Note that we are handling the creation of the lists themselves in the
715 # _add_block method. See https://spec.commonmark.org/0.30/#lists for
716 # reference.
717 # TODO: handle tight and loose lists.
718 18405 ▶ my $item = {
Condition80%4/5
$symbol // $marker
l!l&&r!l&&!r
889095150
$digits // 1
l!l
88909515
MC/DC0%0/2
$symbol // $marker
$symbol $marker
MC/DC100%1/1
$digits // 1
$digits
Truth table66%2/3
A // B
A= $symbolB= $marker
ABresult
1X1
011
000
Truth table100%2/2
A
A= $digits
Aresult
11
00
719 type => 'list_item',
720 style => $type,
721 marker => $symbol // $marker,
722 num => int($digits // 1),
723 };
724 $item->{loose} =
725 18405 ▶ $this->_list_match($item) && $this->{last_line_was_blank};
Condition100%3/3
$this->_list_match($item) && $this->{'last_line_was_blank'}
!ll&&!rl&&r
156542538213
MC/DC100%2/2
$this->_list_match($item) && $this->{'last_line_was_blank'}
$this->_list_match($item) $this->{'last_line_was_blank'}
Truth table100%3/3
A && B
A= $this->_list_match($item)B= $this->{'last_line_was_blank'}
ABresult
0X0
100
111
726 18405 $this->_enter_child_block($item, $cond, qr/ {0,${indent}}/, $forced_next_line);
727 18405 return 1;
728 }
729  
730 # https://talk.commonmark.org/t/generic-directives-plugins-syntax/444
731 # See also https://github.com/mkende/pmarkdown/issues/5
732 sub _do_directive_block {
733 106833 ▶ my ($this) = @_;
Subroutine _do_directive_block: called CC=3 SCAR=11.0
734 106833 ▶ return unless $this->get_use_directive_blocks();
Branch: 1 branch
BranchTrueFalseTotal
unless $this->get_use_directive_blocks 74408 32425 106833
735 # marker, name, content, attributes
736 32425 ▶ return unless $l =~ /${directive_block_re}/; # TODO: add an option to allow this block type.
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ /$directive_block_re/u 32343 82 32425
737 82 my $lm = length($+{marker});
738 my $cond = sub {
739 266 ▶ if (m/^\ {0,3} :{$lm,} \s* $/x) {
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (/^\ {0,3} :{$lm,} \s* $/ux) 12 254 266
740 12 $_ = '';
741 12 return 0;
742 }
743 254 return -1;
744 82 };
745 # At rendering time, a hook should be able to intercept the name and
746 # attributes of the directive to do fancy things with it.
747 $this->_enter_child_block({
748 type => 'directive',
749 name => $+{name},
750 inline => $+{content},
751 attributes => $+{attributes}
752 },
753 82 $cond,
754 qr/ {0,3}/); # Unclear if we need the continuation prefix here.
755 82 return 1;
756 }
757  
758 # https://spec.commonmark.org/0.31.2/#link-reference-definitions
759 sub _do_link_reference_definition {
760 106751 ▶ my ($this) = @_;
Subroutine _do_link_reference_definition: called CC=10 SCAR=23.0
761 # Link reference definitions cannot interrupt paragraphs
762 #
763 # This construct needs to be parsed across multiple lines, so we are directly
764 # using the {md} string rather than our parsed $l line
765 # TODO: another maybe much simpler approach would be to parse the block as a
766 # normal paragraph but immediately try to parse the content as a link
767 # reference definition (and otherwise to keep it as a normal paragraph).
768 # That would allow to use the higher lever InlineTree parsing constructs.
769 106751 ▶ return if @{$this->{paragraph}} || $l !~ m/^ {0,3}\[/;
Branch: 1 branch
BranchTrueFalseTotal
if @{$this->{"paragraph"};} or not $Markdown::Perl::BlockParser::l =~ /^ {0,3}\[/u 104018 2733 106751
Condition100%3/3
@{$this->{"paragraph"};} or not $Markdown::Perl::BlockParser::l =~ /^ {0,3}\[/u
l!l&&r!l&&!r
54632493862733
MC/DC100%2/2
@{$this->{"paragraph"};} or not $Markdown::Perl::BlockParser::l =~ /^ {0,3}\[/u
@{$this->{"paragraph"};} not $Markdown::Perl::BlockParser::l =~ /^ {0,3}\[/u
Truth table100%3/3
A or not(B)
A= @{$this->{"paragraph"};}B= not $Markdown::Perl::BlockParser::l =~ /^ {0,3}\[/u
ABresult
1X1
011
000
770 2733 my $last_pos = $this->{last_pos};
771 2733 my $init_pos = $this->get_pos();
772 2733 $this->redo_line();
773 2733 my $start_pos = $this->get_pos();
774  
775 # We consume the continuation prefix of enclosing blocks. Note that in the big
776 # regex we allow any number of space after the continuation because it’s what
777 # cmark does.
778 2733 my $cont = $this->{continuation_re};
779 2733 ▶ confess 'Unexpected regex match failure' unless $this->{md} =~ m/\G${cont}/g;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G$cont/gu 0 2733 2733
780  
781 # TODO:
782 # - Support for escaped or balanced parenthesis in naked destination
783 # - break this up in smaller pieces and test them independently.
784 # - The need to disable ProhibitUnusedCapture seems to be buggy...
785 # - most of the regex parses only \n and not other eol sequence. The regex
786 # should either be fixed or the entry be normalized.
787 ## no critic (ProhibitComplexRegexes, ProhibitUnusedCapture)
788 2733 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"md"} =~ /\G \ {0,3} \[ (?>(?<LABEL> # The link label (in square brackets), matched as an atomic group (?: [^\\\[\]]{0,100} (?:(?:\\\\)* \\ .)? # The label cannot contain unescaped ] # With 5.38 this could be (?(*{ ...}) (*FAIL)) which will be more efficient. (*COMMIT) (?(?{ pos $_ > $start_pos + 1004; }) (*FAIL) ) # As our block can be repeated, we prune the search when we are far enough. )+ )) \]: [ \t]* (?:\n $cont)? [ \t]* # optional spaces and tabs with up to one line ending (?>(?<TARGET> # the destination can be either: < (?: [^\n>]* (?<! \\) (?:\\\\)* )+ > # - enclosed in <> and containing no unescaped > | [^< [:cntrl:]] [^ [:cntrl:]]* # - not enclosed but cannot contains spaces, new lines, etc. and only balanced or escaped parenthesis )) (?: # Note that this is an atomic pattern so that we don\342\200\231t backtrack in it # (so the pattern must not erroneously accept one of its branch). (?> [ \t]* (?:\n $cont) [ \t]* | [ \t]+ ) # The spec says that spaces must be present here, but it seems that a new line is fine too. (?<TITLE> # The title can be between ", ' or (). The matching characters can\342\200\231t appear unescaped in the title " (:?[^\n"]* (?: (?<! \n) \n (?! \n) | (?<! \\) (?:\\\\)* \\ " )? )* " | ' (:?[^\n']* (?: (?<! \n) \n (?! \n) | (?<! \\) (?:\\\\)* \\ ' )? )* ' | \( (:?[^\n"()]* (?: (?<! \n) \n (?! \n) | (?<! \\) (?:\\\\)* \\ [()] )? )* \) ) )? [ \t]*(:?\r\n|\n|\r|$) # The spec says that no characters can occur after the title, but it seems that whitespace is tolerated. /gux) 211 2522 2733
789 $this->{md} =~ m/\G
790 \ {0,3} \[
791 (?>(?<LABEL> # The link label (in square brackets), matched as an atomic group
792 (?:
793 [^\\\[\]]{0,100} (?:(?:\\\\)* \\ .)? # The label cannot contain unescaped ]
794 # With 5.38 this could be (?(*{ ...}) (*FAIL)) which will be more efficient.
795 1758 (*COMMIT) (?(?{ pos() > $start_pos + 1004 }) (*FAIL) ) # As our block can be repeated, we prune the search when we are far enough.
796 )+
797 )) \]:
798 [ \t]* (?:\n ${cont})? [ \t]* # optional spaces and tabs with up to one line ending
799 (?>(?<TARGET> # the destination can be either:
800 < (?: [^\n>]* (?<! \\) (?:\\\\)* )+ > # - enclosed in <> and containing no unescaped >
801 | [^< [:cntrl:]] [^ [:cntrl:]]* # - not enclosed but cannot contains spaces, new lines, etc. and only balanced or escaped parenthesis
802 ))
803 (?:
804 # Note that this is an atomic pattern so that we don’t backtrack in it
805 # (so the pattern must not erroneously accept one of its branch).
806 (?> [ \t]* (?:\n ${cont}) [ \t]* | [ \t]+ ) # The spec says that spaces must be present here, but it seems that a new line is fine too.
807 (?<TITLE> # The title can be between ", ' or (). The matching characters can’t appear unescaped in the title
808 " (:?[^\n"]* (?: (?<! \n) \n (?! \n) | (?<! \\) (?:\\\\)* \\ " )? )* "
809 | ' (:?[^\n']* (?: (?<! \n) \n (?! \n) | (?<! \\) (?:\\\\)* \\ ' )? )* '
810 | \( (:?[^\n"()]* (?: (?<! \n) \n (?! \n) | (?<! \\) (?:\\\\)* \\ [()] )? )* \)
811 )
812 )?
813 [ \t]*(:?\r\n|\n|\r|$) # The spec says that no characters can occur after the title, but it seems that whitespace is tolerated.
814 /gx
815 ## use critic
816 ) {
817 211 my ($ref, $target, $title) = @LAST_PAREN_MATCH{qw(LABEL TARGET TITLE)};
818 211 $ref = normalize_label($ref);
819 211 ▶ if ($ref ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref ne "") 192 19 211
820 192 $this->_finalize_paragraph(1);
821 # TODO: option to keep the last appearance instead of the first one.
822 192 ▶ if (exists $this->{linkrefs}{$ref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $this->{"linkrefs"}{$ref}) 4 188 192
823 # We keep the first appearance of a label.
824 # TODO: mention the link label.
825 4 ▶ carp 'Only the first appearance of a link reference definition is kept'
Branch: 1 branch
BranchTrueFalseTotal
if $this->get_warn_for_unused_input 0 4 4
826 if $this->get_warn_for_unused_input();
827 4 return 1;
828 }
829 188 ▶ if (defined $title) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $title) 71 117 188
830 71 $title =~ s/^.(.*).$/$1/s;
831 71 _unescape_char($title);
832 }
833 188 $target =~ s/^<(.*)>$/$1/;
834 188 _unescape_char($target);
835 188 ▶ $this->{linkrefs}{$ref} = {
Branch: 1 branch
BranchTrueFalseTotal
defined $title ? : 71 117 188
836 target => $target,
837 (defined $title ? ('title' => $title) : ())
838 };
839 188 return 1;
840 }
841 #pass-through intended;
842 }
843 2541 $this->set_pos($init_pos, $last_pos);
844 2541 return;
845 }
846  
847 # https://github.github.com/gfm/#tables-extension-
848 sub _do_table_block {
849 53679 ▶ my ($this) = @_;
Subroutine _do_table_block: called CC=9 SCAR=22.0
850  
851 # TODO: add an option to prevent interrupting a paragraph with a table (and
852 # make it be true for pmarkdown, but not for github where tables can interrupt
853 # a paragraph).
854 # TODO: github supports omitting the first | even on the first line when we
855 # are not interrupting a paragraph and when subsequent the delimiter line has
856 # more than one dash per cell.
857 53679 my $i = !!@{$this->{paragraph}};
858 53679 ▶ return if $i && !$this->get_table_blocks_can_interrupt_paragraph;
Branch: 1 branch
BranchTrueFalseTotal
if $i and not $this->get_table_blocks_can_interrupt_paragraph 16768 36911 53679
Condition100%3/3
$i and not $this->get_table_blocks_can_interrupt_paragraph
!ll&&!rl&&r
27935897616768
MC/DC100%2/2
$i and not $this->get_table_blocks_can_interrupt_paragraph
$i not $this->get_table_blocks_can_interrupt_paragraph
Truth table100%3/3
A and not(B)
A= $iB= not $this->get_table_blocks_can_interrupt_paragraph
ABresult
0X0
100
111
859 36911 my $m = $this->get_table_blocks_pipes_requirements;
860 # The tests here are quite lenient and there are many ways in which parsing
861 # the table can fail even if these tests pass.
862 36911 ▶ if ($m eq 'strict' || ($m eq 'loose' && $i)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq 'strict' or $m eq 'loose' and $i) { } 24538 12373 36911
Condition83%5/6
$m eq "strict" or $m eq "loose" and $i
l!l&&r!l&&!r
15562897612373
$m eq "loose" and $i
!ll&&!rl&&r
0123738976
MC/DC66%2/3
$m eq "strict" or $m eq "loose" and $i
$m eq "strict" $m eq "loose" $i
Truth table75%3/4
A or B and C
A= $m eq "strict"B= $m eq "loose"C= $i
ABCresult
1XX1
0111
00X0
0100
863 24538 ▶ return unless $l =~ m/^ {0,3}\|/;
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ /^ {0,3}\|/u 23467 1071 24538
864 } else {
865 12373 ▶ return unless $l =~ m/ (?<! \\) (?:\\\\)* \| /x;
Branch: 1 branch
BranchTrueFalseTotal
unless $Markdown::Perl::BlockParser::l =~ / (?<! \\) (?:\\\\)* \| /ux 8325 4048 12373
866 }
867 5119 my $last_pos = $this->{last_pos};
868 5119 my $init_pos = $this->get_pos();
869 5119 $this->redo_line();
870 5119 my $table = $this->_parse_table_structure();
871 5119 ▶ if (!$table) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($table) 5112 7 5119
872 5112 $this->set_pos($init_pos, $last_pos);
873 5112 return;
874 }
875  
876 7 $this->_add_block({type => 'table', content => $table});
877  
878 7 return 1;
879 }
880  
881 sub _parse_table_structure { ## no critic (ProhibitExcessComplexity)
882 5119 ▶ my ($this) = @_;
Subroutine _parse_table_structure: called CC=42 SCAR=38.3
883  
884 5119 my $m = $this->get_table_blocks_pipes_requirements;
885 5119 my $i = !!@{$this->{paragraph}};
886  
887 # A regexp that matches no back-slashes or an even number of them, so that the
888 # next character cannot be escaped.
889 5119 my $e = qr/(?<! \\) (?:\\\\)*/x;
890  
891 # We consume the continuation prefix of enclosing blocks. Note that,
892 # as opposed to what happens for links, subsequent lines can have at most
893 # 3 more spaces than the initial one with the GitHub implementation (but not
894 # some other GFM implementations).
895 5119 my $cont = $this->{continuation_re};
896 5119 ▶ confess 'Unexpected regex match failure' unless $this->{md} =~ m/\G${cont}/g;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G$cont/gu 0 5119 5119
897 # We want to allow successive 0 length matches. For more details on this
898 # behavior, see:
899 # https://perldoc.perl.org/perlre#Repeated-Patterns-Matching-a-Zero-length-Substring
900 5119 pos($this->{md}) = pos($this->{md});
901  
902 # Now we consume the initial | marking the beginning of the table that we know
903 # is here because of the initial match against $l in _do_table_block.
904 5119 ▶ confess 'Unexpected missing table markers' unless $this->{md} =~ m/\G (\ {0,3}) (\|)?/gcx;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G (\ {0,3}) (\|)?/cgux 0 5119 5119
905  
906 5119 my $n = length($1) + 3; # Maximum amount of space allowed on subsequent line
907 5119 my $has_pipe = defined $2;
908  
909 # We parse the header row
910 5119 my @headers = $this->{md} =~ m/\G [ \t]* (.*? [ \t]* $e) \| /gcx;
911 5119 ▶ return unless @headers;
Branch: 1 branch
BranchTrueFalseTotal
unless @headers 769 4350 5119
912 # We parse the last header if it is not followed by a pipe, and the newline.
913 # The only failure case here is if we have reached the end of the file.
914 4350 ▶ return unless $this->{md} =~ m/\G [ \t]* (.+)? [ \t]* ${eol_re} /gcx;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G [ \t]* (.+)? [ \t]* $eol_re /cgux 607 3743 4350
915 3743 ▶ if (defined $1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1) 3350 393 3743
916 3350 push @headers, $1;
917 3350 $has_pipe = 0;
918 }
919  
920 3743 ▶ return if ($m eq 'strict' || ($m eq 'loose' && $i) || @headers == 1) && !$has_pipe;
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "strict" || $m eq "loose" && $i || @headers == 1 and not $has_pipe 651 3092 3743
Condition91%11/12
$m eq "strict" || $m eq "loose" && $i || @headers == 1 and not $has_pipe
!ll&&!rl&&r
305141651
$m eq "strict" or $m eq "loose" and $i or @headers == 1
l!l&&r!l&&!r
4672253051
$m eq "strict" or $m eq "loose" and $i
l!l&&r!l&&!r
401663276
$m eq "loose" and $i
!ll&&!rl&&r
0327666
MC/DC80%4/5
$m eq "strict" || $m eq "loose" && $i || @headers == 1 and not $has_pipe
$m eq "strict" $m eq "loose" $i @headers == 1 not $has_pipe
Truth table70%7/10
A or B and C or D and not(E)
A= $m eq "strict"B= $m eq "loose"C= $iD= @headers == 1E= not $has_pipe
ABCDEresult
00X0X0
0100X0
1XXX00
011X00
00X100
010100
1XXX11
011X11
00X111
010111
921  
922 # We consume the continuation marker at the beginning of the delimiter row.
923 3092 ▶ return unless $this->{md} =~ m/\G ${cont} \ {0,$n} (\|)? /gx;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G $cont \ {0,$n} (\|)? /gux 0 3092 3092
924  
925 3092 ▶ $has_pipe &&= defined $1;
Condition100%3/3
$has_pipe &&= defined $1
!ll&&!rl&&r
3042428
MC/DC100%2/2
$has_pipe &&= defined $1
$has_pipe defined $1
Truth table100%3/3
A &&= B
A= $has_pipeB= defined $1
ABresult
0X0
100
111
926  
927 3092 my @separators = $this->{md} =~ m/\G [ \t]* ( :? -+ :? ) [ \t]* \| /gcx;
928 3092 ▶ return unless $this->{md} =~ m/\G [ \t]* (:? -+ :?)? [ \t]* (:? ${eol_re} | $ ) /gcx;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G [ \t]* (:? -+ :?)? [ \t]* (:? $eol_re | $ ) /cgux 2515 577 3092
929 577 ▶ if (defined $1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1) 60 517 577
930 60 push @separators, $1;
931 60 $has_pipe = 0;
932 }
933 577 ▶ return unless @separators == @headers;
Branch: 1 branch
BranchTrueFalseTotal
unless @separators == @headers 567 10 577
934 my @align =
935 10 ▶ map { s/^(:)?-+(:)?$/ $1 ? ($2 ? 'center' : 'left') : ($2 ? 'right' : '') /er } @separators;
Branch: 3 branches
BranchTrueFalseTotal
$1 ? : 3 16 19
$2 ? : 1 2 3
$2 ? : 2 14 16
936  
937 10 ▶ return if ($m eq 'strict' || ($m eq 'loose' && $i) || @headers == 1) && !$has_pipe;
Branch: 1 branch
BranchTrueFalseTotal
if $m eq "strict" || $m eq "loose" && $i || @headers == 1 and not $has_pipe 0 10 10
Condition50%6/12
$m eq "strict" || $m eq "loose" && $i || @headers == 1 and not $has_pipe
!ll&&!rl&&r
910
$m eq "strict" or $m eq "loose" and $i or @headers == 1
l!l&&r!l&&!r
019
$m eq "strict" or $m eq "loose" and $i
l!l&&r!l&&!r
0010
$m eq "loose" and $i
!ll&&!rl&&r
0100
MC/DC0%0/5
$m eq "strict" || $m eq "loose" && $i || @headers == 1 and not $has_pipe
$m eq "strict" $m eq "loose" $i @headers == 1 not $has_pipe
Truth table20%2/10
A or B and C or D and not(E)
A= $m eq "strict"B= $m eq "loose"C= $iD= @headers == 1E= not $has_pipe
ABCDEresult
00X0X0
0100X0
1XXX00
011X00
00X100
010100
1XXX11
011X11
00X111
010111
938 10 ▶ return if $m ne 'lax' && @headers == 1 && !$has_pipe;
Branch: 1 branch
BranchTrueFalseTotal
if $m ne "lax" and @headers == 1 and not $has_pipe 0 10 10
Condition66%4/6
$m ne "lax" and @headers == 1 and not $has_pipe
!ll&&!rl&&r
910
$m ne "lax" and @headers == 1
!ll&&!rl&&r
091
MC/DC0%0/3
$m ne "lax" and @headers == 1 and not $has_pipe
$m ne "lax" @headers == 1 not $has_pipe
Truth table50%2/4
A and B and not(C)
A= $m ne "lax"B= @headers == 1C= not $has_pipe
ABCresult
0XX0
10X0
1100
1111
939 10 ▶ return if $m ne 'lax' && !$has_pipe && min(map { length } @separators) < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $m ne "lax" and not $has_pipe and &min(map({length $_;} @separators)) < 2 3 7 10
Condition83%5/6
$m ne "lax" and not $has_pipe and &min(map({length $_;} @separators)) < 2
!ll&&!rl&&r
613
$m ne "lax" and not $has_pipe
!ll&&!rl&&r
064
MC/DC66%2/3
$m ne "lax" and not $has_pipe and &min(map({length $_;} @separators)) < 2
$m ne "lax" not $has_pipe &min(map({length $_;} @separators)) < 2
Truth table75%3/4
A and not(B) and C
A= $m ne "lax"B= not $has_pipeC= &min(map({length $_;} @separators)) < 2
ABCresult
0XX0
10X0
1100
1111
940  
941 # And now we try to read as many lines as possible
942 7 my @table;
943 7 while (1) {
944 16 ▶ last if pos($this->{md}) == length($this->{md});
Branch: 1 branch
BranchTrueFalseTotal
if pos $this->{"md"} == length $this->{"md"} 5 11 16
945 11 ▶ last unless $this->{md} =~ m/\G ${cont} \ {0,$n} (\|)? /gcx;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G $cont \ {0,$n} (\|)? /cgux 0 11 11
946 # TODO: use a simulator to decide whether we are entering a new block-level
947 # structure, rather than using this half baked regex.
948 11 ▶ $has_pipe &&= defined $1;
Condition100%3/3
$has_pipe &&= defined $1
!ll&&!rl&&r
227
MC/DC100%2/2
$has_pipe &&= defined $1
$has_pipe defined $1
Truth table100%3/3
A &&= B
A= $has_pipeB= defined $1
ABresult
0X0
100
111
949 11 ▶ last if !defined $1 && $this->{md} =~ m/\G (?: [ ] | > | ${list_item_marker_re} )/x;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $1 and $this->{"md"} =~ /\G (?: [ ] | > | $list_item_marker_re )/ux 1 10 11
Condition100%3/3
not defined $1 and $this->{"md"} =~ /\G (?: [ ] | > | $list_item_marker_re )/ux
!ll&&!rl&&r
731
MC/DC100%2/2
not defined $1 and $this->{"md"} =~ /\G (?: [ ] | > | $list_item_marker_re )/ux
not defined $1 $this->{"md"} =~ /\G (?: [ ] | > | $list_item_marker_re )/ux
Truth table100%3/3
not(A) and B
A= not defined $1B= $this->{"md"} =~ /\G (?: [ ] | > | $list_item_marker_re )/ux
ABresult
0X0
100
111
950 10 my @cells = $this->{md} =~ m/\G [ \t]* (.*? [ \t]* $e) \| /gcx;
951 10 pos($this->{md}) = pos($this->{md});
952 confess 'Unexpected match failure'
953 10 ▶ unless $this->{md} =~ m/\G [ \t]* (.+)? [ \t]* (?: ${eol_re} | $ ) /gcx;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"md"} =~ /\G [ \t]* (.+)? [ \t]* (?: $eol_re | $ ) /cgux 0 10 10
954 10 ▶ if (defined $1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1) 2 8 10
955 2 push @cells, $1;
956 2 $has_pipe = 0;
957 }
958 # There is a small bug when we exit here which is that we have consumed a
959 # blank line. The only case where it would matter would be to decide whether
960 # a list is loose or not, which is a pretty "edge" case with tables.
961 # Otherwise, we will start a new paragraph in all cases.
962 10 ▶ last unless @cells;
Branch: 1 branch
BranchTrueFalseTotal
unless @cells 1 9 10
963 9 ▶ if (@cells != @headers) {
Branch: 1 branch
BranchTrueFalseTotal
if (@cells != @headers) 3 6 9
964 3 $#cells = @headers - 1;
965 # TODO: mention the line number in the file (if possible to track
966 # correctly).
967 3 ▶ carp 'Excess cells in table row are ignored'
Branch: 1 branch
BranchTrueFalseTotal
if @cells > @headers and $this->get_warn_for_unused_input 0 3 3
Condition33%1/3
@cells > @headers and $this->get_warn_for_unused_input
!ll&&!rl&&r
300
MC/DC0%0/2
@cells > @headers and $this->get_warn_for_unused_input
@cells > @headers $this->get_warn_for_unused_input
Truth table33%1/3
A and B
A= @cells > @headersB= $this->get_warn_for_unused_input
ABresult
0X0
100
111
968 if @cells > @headers && $this->get_warn_for_unused_input();
969 }
970 # Pipes need to be escaped inside table, and we need to unescape them here
971 # in case one would appear in a code block for example (where the escaping
972 # would appear literally otherwise). Given that pipes don’t have other
973 # meaning by default, there is not a big risk to do that (and this is
974 # mandated) by the GitHub Spec anyway.
975 9 ▶ push @table, [map { defined ? s/($e)\\\|/${1}|/gr : undef } @cells];
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 14 2 16
976 }
977  
978 7 return {headers => \@headers, align => \@align, table => \@table};
979 }
980  
981 # https://spec.commonmark.org/0.30/#paragraphs
982 sub _do_paragraph {
983 106552 ▶ my ($this) = @_;
Subroutine _do_paragraph: called CC=3 SCAR=11.0
984 # We need to test for blank lines here (not just emptiness) because after we
985 # have removed the markers of container blocks our line can become empty. The
986 # fact that we need to do this, seems to imply that we don’t really need to
987 # check for emptiness when initially building $l.
988 # TODO: check if the blank-line detection in next_line() is needed or not.
989 106552 ▶ if ($l !~ m/^[ \t]*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Markdown::Perl::BlockParser::l =~ /^[ \t]*$/u) 85109 21443 106552
990 85109 push @{$this->{paragraph}}, $l;
991 85109 return 1;
992 }
993  
994 # https://spec.commonmark.org/0.30/#blank-lines
995 # if ($l eq '')
996 21443 $this->_finalize_paragraph();
997 # Needed to detect loose lists. But ignore blank lines when they are inside
998 # block quotes
999 $this->{last_line_is_blank} =
1000 21443 ▶ !@{$this->{blocks_stack}} || $this->{blocks_stack}[-1]{block}{type} ne 'quotes';
Condition100%3/3
!@{$this->{'blocks_stack'};} || $this->{'blocks_stack'}[-1]{'block'}{'type'} ne 'quotes'
l!l&&r!l&&!r
1708930671287
MC/DC100%2/2
!@{$this->{'blocks_stack'};} || $this->{'blocks_stack'}[-1]{'block'}{'type'} ne 'quotes'
!@{$this->{'blocks_stack'};} $this->{'blocks_stack'}[-1]{'block'}{'type'} ne 'quotes'
Truth table100%3/3
not(A) || B
A= !@{$this->{'blocks_stack'};}B= $this->{'blocks_stack'}[-1]{'block'}{'type'} ne 'quotes'
ABresult
1X1
011
000
1001 21443 return 1;
1002 }
1003  
1004 sub _unescape_char {
1005 # TODO: configure the set of escapable character. Note that this regex is
1006 # shared with Inlines.pm process_char_escaping.
1007 259 ▶ $_[0] =~ s/\\(\p{PosixPunct})/$1/g;
Subroutine _unescape_char: called CC=1 SCAR=0.0
1008 259 return;
1009 }
1010  
1011 31 1;
« Markdown/Perl.pm ↑ Summary Markdown/Perl/InlineTree.pm »