Permalink
Browse files

Sanitize margin handling, add some new tests for code blocks

  • Loading branch information...
tadzik committed Jun 13, 2011
1 parent 6ee135c commit dc14982e827d4a6868f5781026197a0b9241ec31
Showing with 24 additions and 5 deletions.
  1. +4 −4 lib/Pod6/Grammar.pm
  2. +20 −1 t/05-code-comment.t
View
@@ -1,6 +1,6 @@
grammar Pod6::Grammar {
token TOP {
- :my $*VMARGIN := -1;
+ :my $*VMARGIN := 0;
<pod_newline>*
<pod_content>
<pod_newline>*
@@ -33,15 +33,15 @@ grammar Pod6::Grammar {
# text not being code
token pod_textcontent:sym<regular> {
$<spaces>=[ \h* ]
- <?{ $*VMARGIN >= 0 ?? ~$<spaces> eq $*VMARGIN !! 1 }>
+ <?{ ($<spaces>.to - $<spaces>.from) <= $*VMARGIN }>
$<text> = [
\h* <!before '=' \w> \N+ <pod_newline>
] +
}
token pod_textcontent:sym<code> {
$<spaces>=[ \h* ]
- <?{ $*VMARGIN >= 0 ?? ~$<spaces> ne $*VMARGIN !! 1 }>
+ <?{ ($<spaces>.to - $<spaces>.from) > $*VMARGIN }>
$<text> = [
[<!before '=' \w> \N+] ** [<pod_newline> $<spaces>]
]
@@ -53,7 +53,7 @@ grammar Pod6::Grammar {
^^
$<spaces> = [ \h* ]
{}
- :my $*VMARGIN := ~$<spaces>;
+ :my $*VMARGIN := $<spaces>.to - $<spaces>.from;
'=begin' \h+ <!before 'END'> <identifier> <pod_newline>+
[
<pod_content> *
View
@@ -1,6 +1,6 @@
use Test;
use Pod6;
-plan 44;
+plan 49;
my $x = q[
=begin comment
@@ -173,3 +173,22 @@ is $r.content[1],
isa_ok $r.content[2], Pod6::Block::Code;
is $r.content[2].content,
q[$this = pod('also'); # Specifically, a code block];
+
+$x = q[
+ =begin pod
+ not a code
+ still not a code
+
+ a code
+
+ and not a code
+ =end pod
+];
+
+$r = Pod6::parse($x);
+say $r.perl;
+is $r.content.elems, 3;
+is $r.content[0], 'not a code still not a code';
+isa_ok $r.content[1], Pod6::Block::Code;
+is $r.content[1].content, 'a code';
+is $r.content[2], 'and not a code';

0 comments on commit dc14982

Please sign in to comment.