Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH #1968: input/output block lines are squeezed
Original issue: Pod input and output blocks don't preserve newlines The input and output blocks should be treated essentially the same as code blocks, and newlines should be preserved. But before this fix newlines WERE removed. This commit corrects that. Major changes: 1. File changed to equate code/input/output pod blocks: + src/Perl6/Grammar.nqp 2. Test file added: + t/07-pod-to-text/02-input-output.t The tests include tests missing for the existing code block tests. 3. Test file modified to add equivalent tests for 'input' and 'code' blocks: + t/07-pod-to-text/01-whitespace.t Other changes: + Formatted some long lines in src/Perl6/Grammar.nqp to ease editing with CLI editors.
- Loading branch information
Showing
3 changed files
with
276 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
use v6.c; | ||
use Test; | ||
|
||
use Pod::To::Text; | ||
|
||
plan 18; | ||
|
||
my $r; | ||
my $rp; | ||
my $p = -1; | ||
|
||
# explicit code blocks | ||
{ | ||
=begin code | ||
say 1; | ||
say 2; | ||
=end code | ||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
|
||
=code | ||
say 1; | ||
say 2; | ||
|
||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
|
||
=for code | ||
say 1; | ||
say 2; | ||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
} | ||
|
||
# implicit code blocks: input | ||
{ | ||
=begin input | ||
say 1; | ||
say 2; | ||
=end input | ||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
|
||
=input | ||
say 1; | ||
say 2; | ||
|
||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
|
||
=for input | ||
say 1; | ||
say 2; | ||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
} | ||
|
||
# implicit code blocks: output | ||
{ | ||
=begin output | ||
say 1; | ||
say 2; | ||
=end output | ||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
|
||
=output | ||
say 1; | ||
say 2; | ||
|
||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
|
||
=for output | ||
say 1; | ||
say 2; | ||
$r = $=pod[++$p]; | ||
isa-ok $r, Pod::Block::Code; | ||
# code blocks should get indented 4 spaces by Pod::To::Text | ||
$rp = Pod::To::Text.render($r), | ||
is $rp, | ||
q:to/END/; | ||
say 1; | ||
say 2; | ||
END | ||
} | ||
|
||
# vim: expandtab shiftwidth=4 ft=perl6 |