r2081 - in
packages/libtext-autoformat-perl/branches/upstream/current: .
lib/Text
Niko Tyni
ntyni-guest at costa.debian.org
Thu Feb 2 20:29:31 UTC 2006
Author: ntyni-guest
Date: 2006-02-02 20:29:30 +0000 (Thu, 02 Feb 2006)
New Revision: 2081
Added:
packages/libtext-autoformat-perl/branches/upstream/current/config.emacs
packages/libtext-autoformat-perl/branches/upstream/current/config.vim
Modified:
packages/libtext-autoformat-perl/branches/upstream/current/Changes
packages/libtext-autoformat-perl/branches/upstream/current/MANIFEST
packages/libtext-autoformat-perl/branches/upstream/current/Makefile.PL
packages/libtext-autoformat-perl/branches/upstream/current/README
packages/libtext-autoformat-perl/branches/upstream/current/lib/Text/Autoformat.pm
packages/libtext-autoformat-perl/branches/upstream/current/test.pl
Log:
Load /tmp/tmp.g3GcF7/libtext-autoformat-perl-1.13 into
packages/libtext-autoformat-perl/branches/upstream/current.
Modified: packages/libtext-autoformat-perl/branches/upstream/current/Changes
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/Changes 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/Changes 2006-02-02 20:29:30 UTC (rev 2081)
@@ -114,3 +114,20 @@
- Fixed subtle bug with words starting with "ps-"
being treated as post scripts (thanks Rashid!)
+
+
+1.13 Wed May 4 22:44:20 2005
+
+ - Added sample config files for emacs and vim
+
+ - Extended allows "Name>" quoters to "Name_1>" (thanks Simon)
+
+ - Fixed weird behaviour of "(e.g. at start of line" (thanks Tim)
+
+ - Fixed handling of mail headers by adding "mail" option
+ (thanks Struan)
+
+ - Fixed bug in quoters (thanks Steve)
+
+ - Added a C<lists> option to turn off special treatment of apparent
+ lists (thanks Ingvar)
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/Changes
___________________________________________________________________
Name: svn:executable
-
+ *
Modified: packages/libtext-autoformat-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/MANIFEST 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/MANIFEST 2006-02-02 20:29:30 UTC (rev 2081)
@@ -3,3 +3,5 @@
MANIFEST
Makefile.PL
test.pl
+config.emacs
+config.vim
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/MANIFEST
___________________________________________________________________
Name: svn:executable
-
+ *
Modified: packages/libtext-autoformat-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/Makefile.PL 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/Makefile.PL 2006-02-02 20:29:30 UTC (rev 2081)
@@ -2,7 +2,7 @@
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => q[Text::Autoformat],
- VERSION => q[1.12],
- PREREQ_PM => { 'Text::Reform' => 0 },
+ VERSION => q[1.13],
+ PREREQ_PM => { 'Text::Reform' => 1.11 },
);
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/Makefile.PL
___________________________________________________________________
Name: svn:executable
-
+ *
Modified: packages/libtext-autoformat-perl/branches/upstream/current/README
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/README 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/README 2006-02-02 20:29:30 UTC (rev 2081)
@@ -1,5 +1,5 @@
==============================================================================
- Release of version 1.12 of Text::Autoformat
+ Release of version 1.13 of Text::Autoformat
==============================================================================
@@ -32,31 +32,24 @@
==============================================================================
-CHANGES IN VERSION 1.12
+CHANGES IN VERSION 1.13
- - Now honours -- mail sig introducer
- (stops formatting that that point)
+ - Added sample config files for emacs and vim
- - Now ignores mail headers
+ - Extended allows "Name>" quoters to "Name_1>" (thanks Simon)
- - Added exportable &ignore_headers for
- when using in user-defined "ignore" subs
+ - Fixed weird behaviour of "(e.g. at start of line" (thanks Tim)
- - Now handles of embedded HTML entities
- (thanks David)
+ - Fixed handling of mail headers by adding "mail" option
+ (thanks Struan)
- - Added call to C<use utf8> for 5.6 compatibility
- (thanks Paolo)
+ - Fixed bug in quoters (thanks Steve)
- - Restricted normal numbering to the range 0-999
- to prevent false numbering caused by a year (like
- 1999) at the start of a line (like this)
+ - Added a C<lists> option to turn off special treatment of apparent
+ lists (thanks Ingvar)
- - Fixed subtle bug with words starting with "ps-"
- being treated as post scripts (thanks Rashid!)
-
==============================================================================
AVAILABILITY
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/README
___________________________________________________________________
Name: svn:executable
-
+ *
Added: packages/libtext-autoformat-perl/branches/upstream/current/config.emacs
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/config.emacs 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/config.emacs 2006-02-02 20:29:30 UTC (rev 2081)
@@ -0,0 +1,9 @@
+;; Add these lines to your .emacs and you will be happy with
+;; p5-Text-Autoformat.
+;; Use ctrl-c k to reformat a region.
+
+;; Set a global key for autoformat region
+(global-set-key (kbd "C-c k") (lambda () (interactive)
+ (shell-command-on-region (region-beginning) (region-end)
+ "perl -MText::Autoformat -e \"{autoformat{all=>1};}\""
+ (current-buffer) t)))
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/config.emacs
___________________________________________________________________
Name: svn:executable
+ *
Added: packages/libtext-autoformat-perl/branches/upstream/current/config.vim
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/config.vim 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/config.vim 2006-02-02 20:29:30 UTC (rev 2081)
@@ -0,0 +1,11 @@
+" Add these lines to your .vimrc and you will be happy with
+" p5-Text-Autoformat. Use ctrl-k to reformat a paragraph and ctrl-n to
+" reformat all text from the cursor.
+
+imap <C-K> <esc> !G perl -MText::Autoformat -e "{autoformat;}"<cr>
+nmap <C-K> !G perl -MText::Autoformat -e "{autoformat;}"<cr>
+vmap <C-K> !G perl -MText::Autoformat -e "{autoformat;}"<cr>
+
+imap <C-N> <esc> !G perl -MText::Autoformat -e "{autoformat{all=>1};}"<cr>
+nmap <C-N> !G perl -MText::Autoformat -e "{autoformat{all=>1};}"<cr>
+vmap <C-N> !G perl -MText::Autoformat -e "{autoformat{all=>1};}"<cr>
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/config.vim
___________________________________________________________________
Name: svn:executable
+ *
Modified: packages/libtext-autoformat-perl/branches/upstream/current/lib/Text/Autoformat.pm
===================================================================
--- packages/libtext-autoformat-perl/branches/upstream/current/lib/Text/Autoformat.pm 2006-02-02 19:52:34 UTC (rev 2080)
+++ packages/libtext-autoformat-perl/branches/upstream/current/lib/Text/Autoformat.pm 2006-02-02 20:29:30 UTC (rev 2081)
@@ -2,7 +2,7 @@
use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Carp;
use 5.005;
-$VERSION = '1.12';
+$VERSION = '1.13';
require Exporter;
@@ -74,15 +74,23 @@
return "";
}
-my $ignore_headers = qr/\A(From\b.*$)?([^:]+:.*$([ \t].*$)*)+\s*\Z/m;
+my $ignore_headers = qr/
+ \A
+ (?: From \b .* $)?
+ (?: [^:\n]+ : .* \n
+ (?: [ \t] .* \n)*
+ )+
+ \s*
+ \Z
+ /mx;
my $ignore_indent = qr/^[^\S\n].*(\n[^\S\n].*)*$/;
-sub ignore_headers { $_[0]==1 && /$ignore_headers/ }
+sub ignore_headers { $_[0] && /$ignore_headers/ }
# BITS OF A TEXT LINE
my $quotechar = qq{[!#%=|:]};
-my $quotechunk = qq{(?:$quotechar(?![a-z])|[a-z]*>+)};
+my $quotechunk = qq{(?:$quotechar(?![a-z])|(?:[a-z]\\w*)?>+)};
my $quoter = qq{(?:(?i)(?:$quotechunk(?:[ \\t]*$quotechunk)*))};
my $separator = q/(?:[-_]{2,}|[=#*]{3,}|[+~]{4,})/;
@@ -115,14 +123,17 @@
$args{widow} = 0 if $args{justify}||"" =~ /full/;
$args{widow} = $default_widow unless exists $args{widow};
$args{case} = '' unless exists $args{case};
+ $args{lists} = 1 unless exists $args{lists};
$args{squeeze} = 1 unless exists $args{squeeze};
$args{gap} = 0 unless exists $args{gap};
$args{break} = break_at('-') unless exists $args{break};
$args{impfill} = ! exists $args{fill};
$args{expfill} = $args{fill};
+ $args{tabspace} = 8 unless exists $args{tabspace};
$args{renumber} = 1 unless exists $args{renumber};
$args{autocentre} = 1 unless exists $args{autocentre};
$args{_centred} = 1 if $args{justify} =~ /cent(er(ed)?|red?)/;
+ $args{all} ||= $args{mail};
# SPECIAL IGNORANCE...
if ($args{ignore}) {
@@ -138,13 +149,16 @@
croak "Expected suboutine reference as value for -ignore option"
if ref $args{ignore} ne 'CODE';
}
- else {
+ elsif ($args{mail}) {
$args{ignore} = \&ignore_headers;
}
+ else {
+ $args{ignore} = sub{0};
+ }
# DETABIFY
my @rawlines = split /\n/, $text;
- use Text::Tabs;
+ use Text::Tabs; $tabstop = $args{tabspace};
@rawlines = expand(@rawlines);
# PARSE EACH LINE
@@ -160,7 +174,7 @@
$lines[-1]{presig} .= $lines[-1]{quoter} = defn $2;
$lines[-1]{presig} .= $lines[-1]{quotespace} = defn $3;
- $lines[-1]{hang} = Hang->new($_);
+ $lines[-1]{hang} = $args{lists} ? Hang->new($_) : NullHang->new();
s/([ \t]*)(.*?)(\s*)$//
or die "Internal Error ($@) on '$_'";
@@ -255,11 +269,13 @@
# SELECT PARAS TO HANDLE
my $remainder = "";
- if ($args{all}) { # STOP AT MAIL TERMINATOR
+ if ($args{all}) { # STOP AT MAIL TERMINATOR IF $args{mail}
+ my $lastignored = 1;
for my $index (0..$#paras) {
- local $_ = $paras[$index]{raw};
- $paras[$index]{ignore} = $args{ignore}($index+1);
- next unless /^--$/;
+ local $_ = $paras[$index]{raw} . "\n";
+ $lastignored &&=
+ $paras[$index]{ignore} = $args{ignore}($lastignored);
+ next unless $args{mail} && /^--$/;
$remainder = join "\n", map { $_->{raw} } splice @paras, $index;
$remainder .= "\n" unless $remainder =~ /\n\z/;
last;
@@ -513,7 +529,9 @@
}
my $abbrev = join '|', qw{
- etc[.] pp[.] ph[.]?d[.] U[.]S[.]
+ etc[.] pp[.] ph[.]?d[.]
+ (?:[A-Z][A-Za-z]+[.])+
+ (?:[A-Z][.])(?:[A-Z][.])+
};
my $gen_abbrev = join '|', $abbrev, qw{
@@ -604,6 +622,7 @@
}
package Hang;
+use strict;
# ROMAN NUMERALS
@@ -658,6 +677,9 @@
elsif ($_[1] =~ s#\A($hang)##) {
@vals = { type => 'bul', val => $1 }
}
+ elsif ($_[1] =~ m#\([^\s)]+\s#) {
+ @vals = ();
+ }
else {
local $^W;
my $cut;
@@ -801,6 +823,7 @@
sub empty { 0 }
package NullHang;
+use strict;
sub new { bless {}, $_[0] }
sub stringify { "" }
@@ -821,8 +844,8 @@
=head1 VERSION
-This document describes version 1.12 of Text::Autoformat,
-released May 27, 2003.
+This document describes version 1.13 of Text::Autoformat,
+released May 4, 2005.
=head1 SYNOPSIS
@@ -1021,6 +1044,14 @@
C<autoformat> will ignore any paragraph in which I<every> line begins with a
whitespace.
+One other special case of ignorance is ignoring mail headers and signature.
+This option is specified using the C<mail> argument:
+
+ $tidied_mesg = autoformat($messy_mesg, {mail=>1});
+
+Note that the C<mail> option automatically implies C<all>.
+
+
=head2 Bulleting and (re-)numbering
Often plaintext will include lists that are either:
@@ -1080,7 +1111,7 @@
more characters long.
If automatic renumbering isn't wanted, just specify the C<'renumber'>
-option with a false value.
+option with a false value.
Note that numbers above 1000 at the start of a line are no longer
considered to be paragraph numbering. Numbered paragraphs running that
@@ -1113,6 +1144,11 @@
is a new phenomenon (it didn't happen in 1001) because the idea
that the future might be different is a new phenomenon.
+If you want numbers less than 1000 (or other characters strings currently
+treated as bullets) to be ignored in this way, you can turn of list formatting
+entirely by setting the C<'lists'> option to a false value.
+
+
=head2 Quoting
Another case in which contiguous lines may be interpreted as belonging
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/lib/Text/Autoformat.pm
___________________________________________________________________
Name: svn:executable
-
+ *
Property changes on: packages/libtext-autoformat-perl/branches/upstream/current/test.pl
___________________________________________________________________
Name: svn:executable
-
+ *
More information about the Pkg-perl-cvs-commits
mailing list