Subject: | =END block shouldn't terminate |
=END blocks are treated like normal named blocks ending at the next
blank line. They should instead never terminate.
The following code produces an ambient block after the END block. It
should instead produce a para block inside the END block.
#------
use Perl6::Perldoc::Parser;
$result = Perl6::Perldoc::Parser->parse( \<<END );
ambient
=END
pod
more pod
END
$, = "\n";
print map ref $_, $result->{tree}->content;
#------
Patches are attached for two approaches for fixing this. Fix1 stops
=END blocks from being removed from the stack (this will address =for
END if it is also buggy), fix2 changes the termination of =END blocks.
Subject: | perl6-perldoc-fix2.diff |
diff -ru Perl6-Perldoc-v0.0.5-orig\lib\Perl6\Perldoc\Parser.pm Perl6-Perldoc-v0.0.5\lib\Perl6\Perldoc\Parser.pm
--- Perl6-Perldoc-v0.0.5-orig\lib\Perl6\Perldoc\Parser.pm Sat Jun 13 13:03:36 2009
+++ Perl6-Perldoc-v0.0.5\lib\Perl6\Perldoc\Parser.pm Sat Jun 20 08:34:59 2009
@@ -1072,6 +1072,13 @@
# Copy allowed fcodes...
my $allow_ref = _update_allow($top, $config, {});
+ # =END blocks don't end
+ my $terminator = $type eq 'END' ? qr'(?!)' :
+ qr{ ^ \s* $
+ | $DIR_NC
+ | (?= $top->{terminator} )
+ }xms;
+
# Add it to the stack (not yet in the representation)...
push @stack, {
typename => $type,
@@ -1079,12 +1086,9 @@
config => $config,
@config_stack_entry,
range => { %range },
- terminator => qr{ ^ \s* $
- | $DIR_NC
- | (?= $top->{terminator} )
- }xms,
+ terminator => $terminator,
is_verbatim => $verbatim || $top->{is_verbatim},
- is_blank_terminated => 1,
+ is_blank_terminated => ($type ne 'END'),
allow => $allow_ref,
disjoint => $disjoint_item1,
permits_implicit_blocks => $permits_implicit_blocks,
Subject: | perl6-perldoc-fix1.diff |
diff -ru Perl6-Perldoc-v0.0.5-orig/lib/Perl6/Perldoc/Parser.pm Perl6-Perldoc-v0.0.5/lib/Perl6/Perldoc/Parser.pm
--- Perl6-Perldoc-v0.0.5-orig/lib/Perl6/Perldoc/Parser.pm Sat Jun 13 13:03:37 2009
+++ Perl6-Perldoc-v0.0.5/lib/Perl6/Perldoc/Parser.pm Sat Jun 20 08:26:19 2009
@@ -696,6 +696,12 @@
else {
my $block = pop @stack;
+ # Ignore trying to terminate an END block.
+ if( $block->{typename} eq 'END' ) {
+ push @stack, $block;
+ next TOKEN;
+ }
+
# Execute any use statement...
if ($block->{typename} eq '(use)') {
my $source = $block->{source};