Skip Menu |

This queue is for tickets about the Text-Quoted CPAN distribution.

Report information
The Basics
Id: 103444
Status: resolved
Priority: 0/
Queue: Text-Quoted

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.10



Subject: make it possible to disable "separator" paragraphs
Separators break paragraph formation, which is fine when you want them to, but annoying when they have no meaning for you. Because there's no object doing the parsing, I've just added a no_separators argument to extract. If nobody else is using this module, I'm happy to take care of the next few release, etc. -- rjbs
Subject: 0001-add-no_separators-option.patch
From c11cbd18d4ab11b3fcbacf0052213fe4f4b5bf4e Mon Sep 17 00:00:00 2001 From: Ricardo Signes <rjbs@cpan.org> Date: Fri, 10 Apr 2015 13:28:27 -0400 Subject: [PATCH] add no_separators option --- lib/Text/Quoted.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/Text/Quoted.pm b/lib/Text/Quoted.pm index 317929b..4e4f814 100644 --- a/lib/Text/Quoted.pm +++ b/lib/Text/Quoted.pm @@ -69,9 +69,16 @@ C<quoter> is the quotation string. =head2 extract + my $struct = extract($text, \%arg); + Takes a single string argument which is the text to extract quote structure from. Returns a nested datastructure as described above. +Second argument is optional: a hashref of options. The only valid +argument at present is: + + no_separators - never mark paragraphs as "separators" + Exported by default. =cut @@ -187,10 +194,13 @@ sub combine_hunks { } sub _classify { - my $text = shift; + my ($text, $arg) = @_; + $arg ||= {}; + + # If the user passes in a null string, we really want to end up with + # _something_ return { raw => undef, text => undef, quoter => undef } unless defined $text && length $text; - # If the user passes in a null string, we really want to end up with _something_ # DETABIFY my @lines = Text::Tabs::expand( split /\n/, $text ); @@ -201,7 +211,8 @@ sub _classify { @line{'quoter', 'text'} = (/\A *($quoter?) *(.*?)\s*\Z/); $line{hang} = $hang_package->new( $line{'text'} ); $line{empty} = 1 if $line{hang}->empty() && $line{'text'} !~ /\S/; - $line{separator} = 1 if $line{text} =~ /\A *$separator *\Z/o; + $line{separator} = 1 if $line{text} =~ /\A *$separator *\Z/o + and ! $arg->{no_separators}; push @lines, \%line; } -- 2.3.5
Subject: Re: [rt.cpan.org #103444] make it possible to disable "separator" paragraphs
Date: Fri, 10 Apr 2015 13:36:44 -0400
To: Ricardo Signes via RT <bug-Text-Quoted [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] bestpractical.com>
Since there are separator tests, could I sucker you into adding a failing test? (RT does use Text::Quoted) On Fri, Apr 10, 2015 at 01:32:05PM -0400, Ricardo Signes via RT wrote: Show quoted text
> Fri Apr 10 13:32:04 2015: Request 103444 was acted upon. > Transaction: Ticket created by RJBS > Queue: Text-Quoted > Subject: make it possible to disable "separator" paragraphs > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: rjbs@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=103444 > > > > Separators break paragraph formation, which is fine when you want them to, but annoying when they have no meaning for you. Because there's no object doing the parsing, I've just added a no_separators argument to extract. > > If nobody else is using this module, I'm happy to take care of the next few release, etc. > > -- > rjbs
Show quoted text
> From c11cbd18d4ab11b3fcbacf0052213fe4f4b5bf4e Mon Sep 17 00:00:00 2001 > From: Ricardo Signes <rjbs@cpan.org> > Date: Fri, 10 Apr 2015 13:28:27 -0400 > Subject: [PATCH] add no_separators option > > --- > lib/Text/Quoted.pm | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/lib/Text/Quoted.pm b/lib/Text/Quoted.pm > index 317929b..4e4f814 100644 > --- a/lib/Text/Quoted.pm > +++ b/lib/Text/Quoted.pm > @@ -69,9 +69,16 @@ C<quoter> is the quotation string. > > =head2 extract > > + my $struct = extract($text, \%arg); > + > Takes a single string argument which is the text to extract quote > structure from. Returns a nested datastructure as described above. > > +Second argument is optional: a hashref of options. The only valid > +argument at present is: > + > + no_separators - never mark paragraphs as "separators" > + > Exported by default. > > =cut > @@ -187,10 +194,13 @@ sub combine_hunks { > } > > sub _classify { > - my $text = shift; > + my ($text, $arg) = @_; > + $arg ||= {}; > + > + # If the user passes in a null string, we really want to end up with > + # _something_ > return { raw => undef, text => undef, quoter => undef } > unless defined $text && length $text; > - # If the user passes in a null string, we really want to end up with _something_ > > # DETABIFY > my @lines = Text::Tabs::expand( split /\n/, $text ); > @@ -201,7 +211,8 @@ sub _classify { > @line{'quoter', 'text'} = (/\A *($quoter?) *(.*?)\s*\Z/); > $line{hang} = $hang_package->new( $line{'text'} ); > $line{empty} = 1 if $line{hang}->empty() && $line{'text'} !~ /\S/; > - $line{separator} = 1 if $line{text} =~ /\A *$separator *\Z/o; > + $line{separator} = 1 if $line{text} =~ /\A *$separator *\Z/o > + and ! $arg->{no_separators}; > push @lines, \%line; > } > > -- > 2.3.5 >
--
On 2015-04-10 13:36:46, jesse@bestpractical.com wrote: Show quoted text
> Since there are separator tests, could I sucker you into adding a > failing test?
Gladly!
Subject: 0001-add-no_separator-tests.patch
From 83887f9d70e78d062811c395b6406e0dc48d130a Mon Sep 17 00:00:00 2001 From: Ricardo Signes <rjbs@cpan.org> Date: Fri, 10 Apr 2015 14:00:43 -0400 Subject: [PATCH] add no_separator tests --- t/separator.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/separator.t b/t/separator.t index 1e347e8..0125746 100644 --- a/t/separator.t +++ b/t/separator.t @@ -1,5 +1,5 @@ -use Test::More tests => 3; +use Test::More tests => 5; BEGIN { use_ok('Text::Quoted') }; use Data::Dumper; @@ -22,6 +22,12 @@ is_deeply(extract($text), [ "Sample text is organized properly" ) or diag Dumper(extract($text)); +is_deeply(extract($text, { no_separators => 1 }), [ + {text => "foo\n============\nbar\n============\nbaz", quoter => '', raw => "foo\n============\nbar\n============\nbaz"}, + ], + "Sample text is organized properly (no separators)" +) or diag Dumper(extract($text, { no_separators => 1 })); + $text = <<EOF; foo > bar @@ -42,3 +48,12 @@ is_deeply(extract($text), [ "Sample text is organized properly" ) or diag Dumper(extract($text)); +is_deeply(extract($text, { no_separators => 1 }), [ + {text => 'foo', quoter => '', raw => 'foo'}, + [ + {text => "bar\n============\nbaz\n============", quoter => '>', raw => "> bar\n> ============\n> baz\n> ============"}, + ], + ], + "Sample text is organized properly (no separators)" +) or diag Dumper(extract($text, { no_separators => 1 })); + -- 2.3.5
Subject: Re: [rt.cpan.org #103444] make it possible to disable "separator" paragraphs
Date: Fri, 10 Apr 2015 15:01:36 -0400
To: Ricardo Signes via RT <bug-Text-Quoted [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] bestpractical.com>
Patches applied :) On Fri, Apr 10, 2015 at 02:01:11PM -0400, Ricardo Signes via RT wrote: Show quoted text
> Queue: Text-Quoted > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=103444 > > > On 2015-04-10 13:36:46, jesse@bestpractical.com wrote:
> > Since there are separator tests, could I sucker you into adding a > > failing test?
> > Gladly!
Show quoted text
> From 83887f9d70e78d062811c395b6406e0dc48d130a Mon Sep 17 00:00:00 2001 > From: Ricardo Signes <rjbs@cpan.org> > Date: Fri, 10 Apr 2015 14:00:43 -0400 > Subject: [PATCH] add no_separator tests > > --- > t/separator.t | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/t/separator.t b/t/separator.t > index 1e347e8..0125746 100644 > --- a/t/separator.t > +++ b/t/separator.t > @@ -1,5 +1,5 @@ > > -use Test::More tests => 3; > +use Test::More tests => 5; > BEGIN { use_ok('Text::Quoted') }; > > use Data::Dumper; > @@ -22,6 +22,12 @@ is_deeply(extract($text), [ > "Sample text is organized properly" > ) or diag Dumper(extract($text)); > > +is_deeply(extract($text, { no_separators => 1 }), [ > + {text => "foo\n============\nbar\n============\nbaz", quoter => '', raw => "foo\n============\nbar\n============\nbaz"}, > + ], > + "Sample text is organized properly (no separators)" > +) or diag Dumper(extract($text, { no_separators => 1 })); > + > $text = <<EOF; > foo
> > bar
> @@ -42,3 +48,12 @@ is_deeply(extract($text), [ > "Sample text is organized properly" > ) or diag Dumper(extract($text)); > > +is_deeply(extract($text, { no_separators => 1 }), [ > + {text => 'foo', quoter => '', raw => 'foo'}, > + [ > + {text => "bar\n============\nbaz\n============", quoter => '>', raw => "> bar\n> ============\n> baz\n> ============"}, > + ], > + ], > + "Sample text is organized properly (no separators)" > +) or diag Dumper(extract($text, { no_separators => 1 })); > + > -- > 2.3.5 >
--
Merged in 2.10, thanks! -sunnavy