Skip to content

Commit be1aac2

Browse files
committed
Add warnings to the return data of the parsePGMLBlock method.
1 parent 2db6e22 commit be1aac2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/WeBWorK/PG/Critic/Utils.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ blocks found.
3131
If the PGML content or a block within fails to parse, then the return hash will
3232
contain the key C<errors> with a reference to an array of errors that occurred.
3333
34+
Also if there are any warnings that occur in the parsing, those will be in the
35+
C<warnings> key of the return hash.
36+
3437
=head2 parseTextBlock
3538
3639
my $textElements = parseTextBlock(@lines);
@@ -110,9 +113,10 @@ sub parsePGMLBlock (@lines) {
110113

111114
PGML::ClearWarnings();
112115
my $parser = eval { PGML::Parse->new($source =~ s/\\\\/\\/gr) };
113-
return { errors => [$@] } if $@;
116+
return { errors => [$@], warnings => \@PGML::warnings } if $@;
114117

115-
return $processedBlocks{$sourceHash} = WeBWorK::PG::Critic::Utils::walkPGMLTree($parser->{root});
118+
return $processedBlocks{$sourceHash} =
119+
WeBWorK::PG::Critic::Utils::walkPGMLTree($parser->{root}, { warnings => \@PGML::warnings });
116120
}
117121

118122
# For now, only contents of \{ .. \} blocks are returned. Add other text elements as needed.

0 commit comments

Comments
 (0)