On Wed Apr 10 05:50:18 2013, RJBS wrote:
Show quoted text> I guess I'd be willing to accept a patch that accepted the following:
>
> =begin :list :over<4>
> ...
> =end :list
>
> But note that this uses =begin/=end. =for does not allow for
> parameters to the =begin, by its definition. Blah. :(
A patch set for the above proposal is attached. (This is my first time
submitting patches via RT--be gentle!) :-P
From 5d424afef434c7ed487e84cd7bda7bd465dda350 Mon Sep 17 00:00:00 2001
From: Alex Peters <lxp@cpan.org>
Date: Sun, 21 Apr 2013 19:38:58 +1000
Subject: [PATCH 2/4] refactor: change internal method signature
Pass the entire Region object to the _expand_list_paras method
instead of just its children, since the parent object may hold
a custom indentlevel in its direct content.
See [rt.cpan.org #84488].
---
lib/Pod/Elemental/Transformer/List.pm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/Pod/Elemental/Transformer/List.pm b/lib/Pod/Elemental/Transformer/List.pm
index 8f3eee3..738c903 100644
--- a/lib/Pod/Elemental/Transformer/List.pm
+++ b/lib/Pod/Elemental/Transformer/List.pm
@@ -177,7 +177,7 @@ sub transform_node {
for my $i (reverse(0 .. $#{ $node->children })) {
my $para = $node->children->[ $i ];
next unless $self->__is_xformable($para);
- my @replacements = $self->_expand_list_paras( $para->children );
+ my @replacements = $self->_expand_list_paras( $para );
splice @{ $node->children }, $i, 1, @replacements;
}
}
@@ -201,17 +201,17 @@ my %_TYPE = (
);
sub _expand_list_paras {
- my ($self, $paras) = @_;
+ my ($self, $parent) = @_;
my @replacements;
my $type;
my $i = 1;
- PARA: for my $para (@$paras) {
+ PARA: for my $para (@{ $parent->children }) {
unless ($para->isa('Pod::Elemental::Element::Pod5::Ordinary')) {
push @replacements, $self->__is_xformable($para)
- ? $self->_expand_list_paras($para->children)
+ ? $self->_expand_list_paras($para)
: $para;
next PARA;
--
1.7.10.4
From 85754dc9e7acbc7982187c8fdb3d71b2b27eb6a3 Mon Sep 17 00:00:00 2001
From: Alex Peters <lxp@cpan.org>
Date: Sun, 21 Apr 2013 19:35:05 +1000
Subject: [PATCH 1/4] add tests for custom indentlevel
The desired behaviour is that passing an :over<n> option on the =begin
line will cause an indentlevel of "n" instead of the default of 4.
See [rt.cpan.org #84488].
---
t/equiv-pods.t | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 144 insertions(+)
diff --git a/t/equiv-pods.t b/t/equiv-pods.t
index d004a8d..02a6338 100644
--- a/t/equiv-pods.t
+++ b/t/equiv-pods.t
@@ -200,6 +200,40 @@ Baz is also important, but compared to Foo, Baz isn't even Bar.
=back
END_POD
+TODO: {
+ local $TODO = '[rt.cpan.org #84488]';
+ list_is def_with_custom_indent => <<'END_POD';
+=begin :list :over<6>
+
+= TLA
+Three-letter acronym.
+
+= TBD
+To be defined.
+
+= ETC
+And so on and so forth.
+
+=end :list
+------------------------------------
+=over 6
+
+=item TLA
+
+Three-letter acronym.
+
+=item TBD
+
+To be defined.
+
+=item ETC
+
+And so on and so forth.
+
+=back
+END_POD
+}
+
list_is nested_complex => <<'END_POD';
=begin :list
@@ -306,3 +340,113 @@ Fellow with appeal.
=back
END_POD
+
+TODO: {
+ local $TODO = '[rt.cpan.org #84488]';
+ list_is nested_complex_with_custom_indent => <<'END_POD';
+=begin :list :over<3>
+
+1. foo
+
+Foo is an important aspect of foo.
+
+2. bar
+
+Bar is also important, and takes options:
+
+=begin :list :over<8>
+
+= height
+
+It's supplied in in pixels.
+
+= width
+
+It's supplied in inches.
+
+And those are all of them.
+
+=end :list
+
+3. baz
+
+Reasons why Baz is important:
+
+=for :list
+* it's delicious like L<Net::Delicious>
+* it's nutritious
+* it's seditious
+
+=for :list
+= bananas
+Yellow with a peel.
+= Banderas
+Fellow with appeal.
+
+=end :list
+------------------------------------
+=over 3
+
+=item 1
+
+foo
+
+Foo is an important aspect of foo.
+
+=item 2
+
+bar
+
+Bar is also important, and takes options:
+
+=over 8
+
+=item height
+
+It's supplied in in pixels.
+
+=item width
+
+It's supplied in inches.
+
+And those are all of them.
+
+=back
+
+=item 3
+
+baz
+
+Reasons why Baz is important:
+
+=over 4
+
+=item *
+
+it's delicious like L<Net::Delicious>
+
+=item *
+
+it's nutritious
+
+=item *
+
+it's seditious
+
+=back
+
+=over 4
+
+=item bananas
+
+Yellow with a peel.
+
+=item Banderas
+
+Fellow with appeal.
+
+=back
+
+=back
+END_POD
+}
--
1.7.10.4
From a07a3c632e69e7e7915c2b2e1e7f8ab97b479d1b Mon Sep 17 00:00:00 2001
From: Alex Peters <lxp@cpan.org>
Date: Sun, 21 Apr 2013 19:50:30 +1000
Subject: [PATCH 3/4] allow custom indentlevel (=over) value
Specify "=begin :list :over<6>" for POD with "=over 6" instead of
"=over 4" by default. Resolves [rt.cpan.org #84488].
---
lib/Pod/Elemental/Transformer/List.pm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/Pod/Elemental/Transformer/List.pm b/lib/Pod/Elemental/Transformer/List.pm
index 738c903..4e6d4d7 100644
--- a/lib/Pod/Elemental/Transformer/List.pm
+++ b/lib/Pod/Elemental/Transformer/List.pm
@@ -36,6 +36,11 @@ specification|perlpodspec> but boils down to this: "for" regions will only be
able to contain list markers and paragraphs of text, while "begin and end"
regions can contain arbitrary Pod paragraphs and nested list regions.
+All lists have a default C<indentlevel> value of 4. Adding
+C<< :over<n> >> to a C<=begin :list> definition will result in that list
+having an C<indentlevel> of C<n> instead. (This functionality is not
+available for lists defined with C<=for :list>.)
+
Ordinary paragraphs in list regions are scanned for lines beginning with list
item markers (see below). If they're found, the list is broken into paragraphs
and markers. Here's a demonstrative example:
@@ -256,9 +261,11 @@ sub _expand_list_paras {
}
}
+ my $indentlevel = 4;
+ $indentlevel = $1 if $parent->content =~ /:over<(\d+)>/;
unshift @replacements, Pod::Elemental::Element::Pod5::Command->new({
command => 'over',
- content => 4,
+ content => $indentlevel,
});
push @replacements, Pod::Elemental::Element::Pod5::Command->new({
--
1.7.10.4
From d6d47bc913f8794fb8e9e2a21b7ee825cc8eaeec Mon Sep 17 00:00:00 2001
From: Alex Peters <lxp@cpan.org>
Date: Sun, 21 Apr 2013 20:08:39 +1000
Subject: [PATCH 4/4] unmark tests for completed functionality as TODO
---
t/equiv-pods.t | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/t/equiv-pods.t b/t/equiv-pods.t
index 02a6338..e84e827 100644
--- a/t/equiv-pods.t
+++ b/t/equiv-pods.t
@@ -200,9 +200,7 @@ Baz is also important, but compared to Foo, Baz isn't even Bar.
=back
END_POD
-TODO: {
- local $TODO = '[rt.cpan.org #84488]';
- list_is def_with_custom_indent => <<'END_POD';
+list_is def_with_custom_indent => <<'END_POD';
=begin :list :over<6>
= TLA
@@ -232,7 +230,6 @@ And so on and so forth.
=back
END_POD
-}
list_is nested_complex => <<'END_POD';
=begin :list
@@ -341,9 +338,7 @@ Fellow with appeal.
=back
END_POD
-TODO: {
- local $TODO = '[rt.cpan.org #84488]';
- list_is nested_complex_with_custom_indent => <<'END_POD';
+list_is nested_complex_with_custom_indent => <<'END_POD';
=begin :list :over<3>
1. foo
@@ -449,4 +444,3 @@ Fellow with appeal.
=back
END_POD
-}
--
1.7.10.4