Hello community, here is the log from the commit of package perl-Text-Autoformat for openSUSE:Factory checked in at 2015-04-23 08:03:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Text-Autoformat (Old) and /work/SRC/openSUSE:Factory/.perl-Text-Autoformat.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Text-Autoformat" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Text-Autoformat/perl-Text-Autoformat.changes 2012-01-04 07:29:34.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Text-Autoformat.new/perl-Text-Autoformat.changes 2015-04-23 08:03:45.000000000 +0200 @@ -1,0 +2,6 @@ +Tue Apr 14 18:32:15 UTC 2015 - co...@suse.com + +- updated to 1.69 + see /usr/share/doc/packages/perl-Text-Autoformat/Changes + +------------------------------------------------------------------- Old: ---- Text-Autoformat-1.669002.tar.gz New: ---- Text-Autoformat-1.69.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Text-Autoformat.spec ++++++ --- /var/tmp/diff_new_pack.Kn2VsU/_old 2015-04-23 08:03:46.000000000 +0200 +++ /var/tmp/diff_new_pack.Kn2VsU/_new 2015-04-23 08:03:46.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Text-Autoformat # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,63 +17,45 @@ Name: perl-Text-Autoformat +Version: 1.69 +Release: 0 %define cpan_name Text-Autoformat Summary: Automatic text wrapping and reformatting -License: Artistic-1.0 or GPL-1.0+ +License: GPL-1.0+ or Artistic-1.0 Group: Development/Libraries/Perl -Version: 1.669002 -Release: 0 Url: http://search.cpan.org/dist/Text-Autoformat/ -Source: http://www.cpan.org/modules/by-module/Text/Text-Autoformat-%{version}.tar.gz +Source: http://www.cpan.org/authors/id/N/NE/NEILB/%{cpan_name}-%{version}.tar.gz BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build -%{perl_requires} BuildRequires: perl +BuildRequires: perl-macros BuildRequires: perl(Module::Build) -BuildRequires: perl(Test::More) BuildRequires: perl(Text::Reform) >= 1.11 BuildRequires: perl(version) -BuildRequires: perl-macros Requires: perl(Text::Reform) >= 1.11 Requires: perl(version) +%{perl_requires} %description -Text::Autoformat provides intelligent formatting of -plaintext without the need for any kind of embedded mark-up. The -module recognizes Internet quoting conventions, a wide range of -bulleting and number schemes, centred text, and block quotations, -and reformats each appropriately. Other options allow the user to -adjust inter-word and inter-paragraph spacing, justify text, and -impose various capitalization schemes. - -The module also supplies a re-entrant, highly configurable -replacement for the built-in Perl format() mechanism. - -Author: -------- - Damian Conway <dam...@conway.org> +Automatic text wrapping and reformatting %prep %setup -q -n %{cpan_name}-%{version} -#rpmlint: spurious-executable-perm -%{__chmod} a-x config.{vim,emacs} +find . -type f -print0 | xargs -0 chmod 644 %build %{__perl} Build.PL installdirs=vendor -./Build +./Build build flags=%{?_smp_mflags} %check ./Build test %install -./Build install destdir=$RPM_BUILD_ROOT create_packlist=0 +./Build install destdir=%{buildroot} create_packlist=0 %perl_gen_filelist -%clean -%{__rm} -rf $RPM_BUILD_ROOT - %files -f %{name}.files -%defattr(-,root,root,-) +%defattr(-,root,root,755) %doc Changes config.emacs config.vim README %changelog ++++++ Text-Autoformat-1.669002.tar.gz -> Text-Autoformat-1.69.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/Build.PL new/Text-Autoformat-1.69/Build.PL --- old/Text-Autoformat-1.669002/Build.PL 2007-09-29 20:38:31.000000000 +0200 +++ new/Text-Autoformat-1.69/Build.PL 2015-01-08 22:36:51.000000000 +0100 @@ -13,6 +13,11 @@ 'version' => 0, }, add_to_cleanup => [ 'Text-Autoformat-*' ], + meta_merge => { + resources => { + repository => 'https://github.com/neilbowers/Text-Autoformat' + } + }, ); $builder->create_build_script(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/Changes new/Text-Autoformat-1.69/Changes --- old/Text-Autoformat-1.669002/Changes 2010-06-22 21:39:35.000000000 +0200 +++ new/Text-Autoformat-1.69/Changes 2015-02-15 10:54:21.000000000 +0100 @@ -1,184 +1,145 @@ -Revision history for Text-Autoformat +Revision history for Perl module Text::Autoformat -0.01 Mon Nov 3 14:05:02 1997 - - original version; created by h2xs 1.18 - -1.03 Thu Oct 26 10:14:20 2000 - - - Tweaked test.pl and POD - - - required 5.005 - (module uses funky stuff that's broken in earlier perls - sorry Dave) +1.69 2015-02-15 NEILB + - Changed the internal packages Hang and NullHang to + Text::Autoformat::Hang and Text::Autoformat::NullHang respectively. + +1.68 2015-02-15 NEILB + - Was failing on input of an empty string RT#101994. Fix from DCONWAY. + Apologies for the confusion caused by Damian and I both releasing, + this release should straighten things up. + - Fixed syntax errors in Quoting section of doc. DCONWAY++ + +1.67 2015-01-08 NEILB + - Got co-maint from Damian so I could put the dist on github. + Thanks Damian! + - Reformatted this file as per CPAN::Changes::Spec + - Added github repo to metadata and doc + +1.669006 2014-10-03 DCONWAY + - Improved 'quoter' option to allow augmenting quoter regex, + rather than just replacing it (thanks Peter) + +1.669005 2014-10-03 DCONWAY + - Added Lisp-style leading ; as a quoter (thanks Roland) + - Added 'quoter' option to allow user to specify a regex + to be used to recognize quoters (thanks Peter) - - added break_TeX subroutine to take advantage of TeX::Hyphen - if it's installed. - - - documented "sticky" config mode - - - Changed semantics of footer generation slightly (see doc) - - - fixed niggle in widow handling under full justification - - - Added pagenum option to control page numbering - - - Added three-part hash specification option for headers and footers - (thanks Chaim) - - - Added separator handling to autoformat -- also fixes - underlining of heading (thanks very much Simon) - - -1.04 Tue Dec 5 10:31:22 2000 - - - Limited numerical bullets to 3 digits. - This stops autoformat from misclassifying orphaned years such as - 2001. +1.669004 2013-07-31 DCONWAY + - Tweaked widow handling to avoid a nasty edge case (thanks Michael!) - - Added new abbreviations - - - Doc patch on numerical formatting (thanks Andy) - - - Major bug fixes to renumbering mechanism - - - Turned off renumbering in quoted text. - - - Added correct autostringification of autostringifying objects - passed to &form. (Thanks Leon) - - - Cleaned up "evil" exporting code left over from testing - (Thanks Rick) - - -1.07 Wed Apr 2 04:45:05 2003 - - - Tweaked pod to remove invalid markup - - - Fixed left justification of last line of fully justified text - (thanks Elias) - - - Devolved &from and &tag to Text::Reform - - - Fixed incorrect handling of stringifiable objects (thanks dLux) - - - Fixed bugs on null input (now short-circuits) - - - Fixed unwarranted trimming of trailing newlines (thanks Mark) - - - Added C<renumber> option to control renumbering - - - Preserved capitalization of abbreviations under case changes - (thanks Alex) - - - Added "autocentre" flag to switch off auto-centring of paras - - - Added "ignore" flag to control which paragraphs are reformatted - (thanks Tony) - - -1.08 Wed Apr 2 22:30:05 2003 - - - Simplified test.pl - - -1.10 Wed Apr 9 08:49:51 2003 - - - Fixed test.pl again!!! - - -1.11 Wed May 7 09:44:26 2003 - - - Enhanced "highlight" casing mode (thanks Tom) - - - Made hyphenation smarter (thanks Raj) - - -1.12 Tue May 27 23:34:33 2003 - - - Now honours -- mail sig introducer - (stops formatting that that point) - - - Now ignores mail headers - - - Added exportable &ignore_headers for - when using in user-defined "ignore" subs - - - Now handles of embedded HTML entities - (thanks David) - - - Added call to C<use utf8> for 5.6 compatibility - (thanks Paolo) - - - 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) +1.669003 2013-05-13 DCONWAY + - Unknown changes - - 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) +1.669002 2010-06-22 DCONWAY + - Patched missing case in 'ignore' option handling (thanks Alan) +1.669001 2010-05-30 DCONWAY + - Added major improvements to the 'ignore' option (thanks Dan!) +1.668001 2010-04-03 DCONWAY + - Removed spurious debugging statement in bad Pod. (Thanks Chris) -1.14.0 Sun Sep 30 04:29:29 2007 +1.666.0 2009-04-16 DCONWAY + - No changes logged +1.14.0 2007-09-29 DCONWAY - Fixed bug in handling empty mail messages - - Fixed bug in handling sig delimiters - - Fixed bug in paragraph ignoring code (thanks Rob) - - Fixed bug in handling whitespace-only input (thanks Ed) - - Fixed bug in Roman numerals (thanks Suresh) - - Fixed overeager autocentering (thanks Suresh) - - Enhanced 'lists' option to allow only specific types of lists to be recognized (thanks Rob) - - Fixed bug in numbered hangs (thanks Rob) - - Fixed bug in Roman numeraled hangs (thanks Rob) - - Fixed misidentification of 8:20-style times as leading numbers (thanks Rob) - - Fixed sentence mode (thanks Eric) - - Changed licence to "same terms as Perl itself" to improve Fedora compatibility +1.13 2005-05-04 DCONWAY + - 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) +1.12 2003-05-27 DCONWAY + - Now honours -- mail sig introducer + (stops formatting that that point) + - Now ignores mail headers + - Added exportable &ignore_headers for + when using in user-defined "ignore" subs + - Now handles of embedded HTML entities + (thanks David) + - Added call to C<use utf8> for 5.6 compatibility + (thanks Paolo) + - 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) + - Fixed subtle bug with words starting with "ps-" + being treated as post scripts (thanks Rashid!) -1.666.0 Fri Apr 17 08:00:36 2009 - No changes logged - +1.11 2003-05-07 DCONWAY + - Enhanced "highlight" casing mode (thanks Tom) + - Made hyphenation smarter (thanks Raj) -1.668001 Sat Apr 3 15:38:55 2010 +1.10 2003-04-09 DCONWAY + - Fixed test.pl again!!! - - Removed spurious debugging statement in bad Pod. (Thanks Chris) +1.08 2003-04-02 DCONWAY + - Simplified test.pl +1.07 2003-04-02 DCONWAY + - Tweaked pod to remove invalid markup + - Fixed left justification of last line of fully justified text + (thanks Elias) + - Devolved &from and &tag to Text::Reform + - Fixed incorrect handling of stringifiable objects (thanks dLux) + - Fixed bugs on null input (now short-circuits) + - Fixed unwarranted trimming of trailing newlines (thanks Mark) + - Added C<renumber> option to control renumbering + - Preserved capitalization of abbreviations under case changes + (thanks Alex) + - Added "autocentre" flag to switch off auto-centring of paras + - Added "ignore" flag to control which paragraphs are reformatted + (thanks Tony) -1.669001 Fri May 28 07:38:36 2010 +1.04 2000-12-04 DCONWAY + - Limited numerical bullets to 3 digits. + This stops autoformat from misclassifying orphaned years such as 2001. + - Added new abbreviations + - Doc patch on numerical formatting (thanks Andy) + - Major bug fixes to renumbering mechanism + - Turned off renumbering in quoted text. + - Added correct autostringification of autostringifying objects + passed to &form. (Thanks Leon) + - Cleaned up "evil" exporting code left over from testing + (Thanks Rick) - - Added major improvements to the 'ignore' option (thanks Dan!) +1.03 2000-10-25 DCONWAY + - Tweaked test.pl and POD + - required 5.005 + (module uses funky stuff that's broken in earlier perls - sorry Dave) + - added break_TeX subroutine to take advantage of TeX::Hyphen + if it's installed. + - documented "sticky" config mode + - Changed semantics of footer generation slightly (see doc) + - fixed niggle in widow handling under full justification + - Added pagenum option to control page numbering + - Added three-part hash specification option for headers and footers + (thanks Chaim) + - Added separator handling to autoformat -- also fixes + underlining of heading (thanks very much Simon) +1.02 2000-08-05 DCONWAY -1.669002 Tue Jun 22 15:39:35 2010 +0.01 1997-11-03 + - original version; created by h2xs 1.18 - - Patched missing case in 'ignore' option handling (thanks Alan) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/MANIFEST new/Text-Autoformat-1.69/MANIFEST --- old/Text-Autoformat-1.669002/MANIFEST 2010-05-27 23:41:53.000000000 +0200 +++ new/Text-Autoformat-1.69/MANIFEST 2015-02-15 10:55:14.000000000 +0100 @@ -9,3 +9,4 @@ t/01.ignore.t config.emacs config.vim +META.json Module JSON meta-data (added by MakeMaker) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/META.json new/Text-Autoformat-1.69/META.json --- old/Text-Autoformat-1.669002/META.json 1970-01-01 01:00:00.000000000 +0100 +++ new/Text-Autoformat-1.69/META.json 2015-02-15 10:55:14.000000000 +0100 @@ -0,0 +1,50 @@ +{ + "abstract" : "Automatic text wrapping and reformatting", + "author" : [ + "Damian Conway <dcon...@cpan.org>" + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 7.02, CPAN::Meta::Converter version 2.143240", + "license" : [ + "unknown" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Text-Autoformat", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : { + "Test::More" : "0", + "Text::Reform" : "1.11", + "version" : "0" + } + } + }, + "release_status" : "stable", + "resources" : { + "repository" : { + "type" : "git", + "url" : "git://github.com/neilbowers/Text-Autoformat.git", + "web" : "https://github.com/neilbowers/Text-Autoformat" + } + }, + "version" : "1.69" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/META.yml new/Text-Autoformat-1.69/META.yml --- old/Text-Autoformat-1.669002/META.yml 2010-06-22 21:39:36.000000000 +0200 +++ new/Text-Autoformat-1.69/META.yml 2015-02-15 10:55:14.000000000 +0100 @@ -1,16 +1,26 @@ ---- #YAML:1.0 -name: Text-Autoformat -version: 1.669002 -abstract: Automatic text wrapping and reformatting -license: ~ -author: - - Damian Conway <dcon...@cpan.org> -generated_by: ExtUtils::MakeMaker version 6.42 -distribution_type: module -requires: - Test::More: 0 - Text::Reform: 1.11 - version: 0 +--- +abstract: 'Automatic text wrapping and reformatting' +author: + - 'Damian Conway <dcon...@cpan.org>' +build_requires: + ExtUtils::MakeMaker: '0' +configure_requires: + ExtUtils::MakeMaker: '0' +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 7.02, CPAN::Meta::Converter version 2.143240' +license: unknown meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.3.html - version: 1.3 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Text-Autoformat +no_index: + directory: + - t + - inc +requires: + Test::More: '0' + Text::Reform: '1.11' + version: '0' +resources: + repository: git://github.com/neilbowers/Text-Autoformat.git +version: '1.69' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/Makefile.PL new/Text-Autoformat-1.69/Makefile.PL --- old/Text-Autoformat-1.669002/Makefile.PL 2007-09-29 20:38:16.000000000 +0200 +++ new/Text-Autoformat-1.69/Makefile.PL 2015-01-08 22:35:23.000000000 +0100 @@ -2,6 +2,12 @@ use warnings; use ExtUtils::MakeMaker; +my $mm_ver = $ExtUtils::MakeMaker::VERSION; +if ($mm_ver =~ /_/) { # dev version + $mm_ver = eval $mm_ver; + die $@ if $@; +} + WriteMakefile( NAME => 'Text::Autoformat', AUTHOR => 'Damian Conway <dcon...@cpan.org>', @@ -15,4 +21,19 @@ }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Text-Autoformat-*' }, + + ($mm_ver <= 6.45 + ? () + : (META_MERGE => { + 'meta-spec' => { version => 2 }, + resources => { + repository => { + type => 'git', + web => 'https://github.com/neilbowers/Text-Autoformat', + url => 'git://github.com/neilbowers/Text-Autoformat.git', + }, + }, + }) + ), + ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/README new/Text-Autoformat-1.69/README --- old/Text-Autoformat-1.669002/README 2010-06-22 21:39:35.000000000 +0200 +++ new/Text-Autoformat-1.69/README 2014-10-03 23:32:33.000000000 +0200 @@ -1,4 +1,4 @@ -Text::Autoformat version 1.669002 +Text::Autoformat version 1.669006 NAME Text::Autoformat - Automatic and manual text wrapping and reformating diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Text-Autoformat-1.669002/lib/Text/Autoformat.pm new/Text-Autoformat-1.69/lib/Text/Autoformat.pm --- old/Text-Autoformat-1.669002/lib/Text/Autoformat.pm 2010-06-22 21:39:35.000000000 +0200 +++ new/Text-Autoformat-1.69/lib/Text/Autoformat.pm 2015-02-15 10:53:31.000000000 +0100 @@ -1,8 +1,10 @@ package Text::Autoformat; -use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Carp; +use strict; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); +use Carp; use 5.005; -our $VERSION = '1.669002'; +our $VERSION = '1.69'; require Exporter; @@ -14,7 +16,7 @@ qw( form tag break_at break_with break_wrap break_TeX ignore_headers ); -my %ignore = map {$_=>1} qw { +my %std_highlight_ignore = map {$_=>1} qw { a an at as and are but by ere @@ -28,6 +30,11 @@ with while whilst within without }; +my $STD_HIGHLIGHT_IGNORES = sub { + my ($word) = @_; + return $std_highlight_ignore{lc $word} ? recase($word,'lower') : recase($word,'title'); +}; + my @entities = qw { Á á Â â Æ æ À à Α α Ã ã @@ -89,9 +96,9 @@ # BITS OF A TEXT LINE -my $quotechar = qq{[!#%=|:]}; +my $quotechar = qq{[!#%=|:;]}; my $quotechunk = qq{(?:$quotechar(?![a-z])|(?:[a-z]\\w*)?>+)}; -my $quoter = qq{(?:(?i)(?:$quotechunk(?:[ \\t]*$quotechunk)*))}; +my $QUOTER = qq{(?:(?i)(?:$quotechunk(?:[ \\t]*$quotechunk)*))}; my $separator = q/(?:[-_]{2,}|[=#*]{3,}|[+~]{4,})/; @@ -116,7 +123,6 @@ $toSTDOUT = !defined wantarray(); } - return unless length $text; return $text unless $text =~ /\S/; $args{right} = $default_margin unless exists $args{right}; @@ -155,6 +161,10 @@ use Text::Tabs; $tabstop = $args{tabspace}; @rawlines = expand(@rawlines); + # HANDLE QUOTING CHANGE + my $quoter = exists $args{quoter} ? $args{quoter} : $QUOTER; + $quoter =~ s/<QUOTER>/$QUOTER/g; + # PARSE EACH LINE my $pre = 0; @@ -168,7 +178,7 @@ $lines[-1]{presig} .= $lines[-1]{quoter} = defn $2; $lines[-1]{presig} .= $lines[-1]{quotespace} = defn $3; - $lines[-1]{hang} = Hang->new($_, $args{lists}); + $lines[-1]{hang} = Text::Autoformat::Hang->new($_, $args{lists}); s/([ \t]*)(.*?)(\s*)$// or die "Internal Error ($@) on '$_'"; @@ -203,7 +213,6 @@ CHUNK: foreach my $chunk ( @chunks ) { - $DB::single=1; next CHUNK if !$args{autocentre} || @$chunk < 2 || $chunk->[0]{hang}; my @length; my $ave = 0; @@ -286,19 +295,22 @@ if ($args{case}) { foreach my $para ( @paras ) { next if $para->{ignore}; - if ($args{case} =~ /upper/i) { + if (ref $args{case} eq 'CODE') { + $para->{text} = entitle($para->{text}, $args{case}); + } + elsif ($args{case} =~ /upper/i) { $para->{text} = recase($para->{text}, 'upper'); } - if ($args{case} =~ /lower/i) { + elsif ($args{case} =~ /lower/i) { $para->{text} = recase($para->{text}, 'lower'); } - if ($args{case} =~ /title/i) { - entitle($para->{text},0); + elsif ($args{case} =~ /title/i) { + $para->{text} = entitle($para->{text}, 0); } - if ($args{case} =~ /highlight/i) { - entitle($para->{text},1); + elsif ($args{case} =~ /highlight/i) { + $para->{text} = entitle($para->{text}, $STD_HIGHLIGHT_IGNORES); } - if ($args{case} =~ /sentence(\s*)/i) { + elsif ($args{case} =~ /sentence(\s*)/i) { my $trailer = $1; $args{squeeze}=0 if $trailer && $trailer ne " "; ensentence(); @@ -452,8 +464,9 @@ $tryformat, @hang, $para->{text}); $firsttext ||= $newtext; - $newtext =~ /\s*([^\n]*)$/; - $widow_okay = $para->{empty} || length($1) >= $args{widow}; + (my $widow) = $newtext =~ /([^\n]*)$/; + $widow =~ s/^\s+//; + $widow_okay = $para->{empty} || length($widow) >= $args{widow}; } until $widow_okay || ++$rightindent > $rightslack; $text .= $widow_okay ? $newtext : $firsttext; @@ -530,22 +543,26 @@ my $alword = qr{(?:\pL|&[a-z]+;)(?:[\pL']|&[a-z]+;)*}i; sub entitle { - my $ignore = pop; - local *_ = \shift; + my ($text, $retitler_ref) = @_; # put into lowercase if on stop list, else titlecase - s{($alword)} - { $ignore && $ignore{lc $1} ? recase($1,'lower') : recase($1,'title') }gex; + $text =~ s{($alword)} + { $retitler_ref ? $retitler_ref->($1) : recase($1,'title') }gex; - s/^($alword) /recase($1,'title')/ex; # last word always to cap - s/ ($alword)$/recase($1,'title')/ex; # first word always to cap + if ($retitler_ref == $STD_HIGHLIGHT_IGNORES) { + # First and final words always capitalized... + $text =~ s/^($alword) /recase($1,'title')/ex; + $text =~ s/ ($alword)$/recase($1,'title')/ex; + + # treat parethesized portion as a complete title + $text =~ s/\( ($alword) /'('.recase($1,'title')/ex; + $text =~ s/($alword) \) /recase($1,'title').')'/ex; - # treat parethesized portion as a complete title - s/\( ($alword) /'('.recase($1,'title')/ex; - s/($alword) \) /recase($1,'title').')'/ex; + # capitalize first word following colon or semi-colon + $text =~ s/ ( [:;] \s+ ) ($alword) /$1 . recase($2,'title')/ex; + } - # capitalize first word following colon or semi-colon - s/ ( [:;] \s+ ) ($alword) /$1 . recase($2,'title')/ex; + return $text; } sub inv($@) { my ($k, %inv)=shift; for(0..$#_) {$inv{$_[$_]}=$_*$k} %inv } @@ -636,7 +653,7 @@ return 1; } -package Hang; +package Text::Autoformat::Hang; use strict; # ROMAN NUMERALS @@ -675,7 +692,7 @@ sub new { my ($class, $orig, $lists_mode) = @_; - return NullHang->new() if !$lists_mode; + return Text::Autoformat::NullHang->new() if !$lists_mode; my $origlen = length $orig; my @vals; @@ -728,7 +745,7 @@ } } - return NullHang->new if !@vals; + return Text::Autoformat::NullHang->new if !@vals; bless \@vals, $class; } @@ -838,7 +855,7 @@ sub empty { 0 } -package NullHang; +package Text::Autoformat::NullHang; use strict; sub new { bless {}, $_[0] } @@ -860,7 +877,7 @@ =head1 VERSION -This document describes version 1.669002 of Text::Autoformat +This document describes version 1.69 of Text::Autoformat =head1 SYNOPSIS @@ -907,6 +924,7 @@ $formatted = autoformat $rawtext, { case => 'sentence' }; $formatted = autoformat $rawtext, { case => 'title' }; $formatted = autoformat $rawtext, { case => 'highlight' }; + $formatted = autoformat $rawtext, { case => \&my_case_func }; # Selective reformatting @@ -1209,6 +1227,27 @@ example and treats it as three paragraphs to be independently reformatted. +You may also override the default set of recognized quoters by specifying +a C<'quoter'> argument when calling C<autoformat()>. For example, to +format lines such as: + + // This is a comment + // in the standard C(++) + // comment-to-EOL + // format + +specify: + + autoformat($text, { quoter =E<gt> qr{//} }) + +Instead of completely replacing the existing set of quoters, you can +I<extend> them by specifying a pattern that includes the metasequence +C<< <QUOTER> >>, which is then replaced by the module's standard pattern +for quoters. So, for example, to add C<//> to the set of existing quoters: + + autoformat($text, { quoter =E<gt> qr{//|<QUOTER>} }) + + Block quotations present a different challenge. A typical formatter would render the following quotation: @@ -1333,7 +1372,7 @@ The C<autoformat> subroutine can also optionally perform case conversions on the text it processes. The C<{case =E<gt> I<type>}> -argument allows the user to specify five different conversions: +argument allows the user to specify six different conversions: =over 4 @@ -1385,6 +1424,35 @@ 'What I Did on my Summer Vacation in Monterey' +=item C<sub{...}> + +If the argument for C<'case'> is a subroutine reference, that subroutine +is applied to each word and the result replaces the word in the text. + +For example, to convert a string to hostage-case: + + my $ransom_note = sub { + return join "", # ^ Reconcatenate + map {/[aeiou]/i ? lc : uc} # | uPPeR aND LoWeR each + split //, # | Break into chars + shift; # | Take argument + }; + + $text = autoformat($text, {case => $ransom_note }); + # "FoR eXaMPLe, To CoNVeRT a STRiNG To HoSTaGe-CaSe:" + +Or to highlight particular words: + + my @SPECIAL = qw( perl camel wall ); + sub highlight_specials { + my ($word) = @_; + return $word ~~ @SPECIAL ? uc($word) : $word; + } + + $text = autoformat($text, {case => \&highlight_specials}); + # "It is easier for a CAMEL to pass through a WALL of PERL..." + + =back =head2 Selective reformatting @@ -1422,6 +1490,10 @@ The Text::Reform module +=head1 REPOSITORY + +L<https://github.com/neilbowers/Text-Autoformat> + =head1 AUTHOR Damian Conway (dam...@conway.org) Files old/Text-Autoformat-1.669002/t/._01.ignore.t and new/Text-Autoformat-1.69/t/._01.ignore.t differ