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