#!/usr/bin/perl -w # Copyright (C) 2000-2003 Simon Huggins # reformats longer lengths after the substitutions have taken place # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; use vars qw($nomod); BEGIN { unless (eval "use Text::Balanced qw(gen_extract_tagged);1;") { print STDERR "Text::Balanced not available, reformat plugin will not work\n"; $nomod=1; } } return if $nomod; sub remove_space($) { my $text=shift; # Remove whitespace at the end of lines but not newlines themselves. # And don't remove the space if it comes directly after a -- which is # anchored at the beginning of a line. $text =~ s/(?', undef, '(?s).*(?=<(?:CENTER|RIGHT|LEFT)\d+>)', {reject => ['<(?:CENTER|RIGHT|LEFT)\d+>']} ); while (1) { ($stuff, $end, $beg, $otag, $ext, $ctag) = &$process($text); if (not defined $stuff) { if ($text =~ /<(?:CENTER|RIGHT|LEFT)\d+>/) { nicedie($@->{'error'}); } } last if !$stuff; my $size = $otag; $size =~ s/<(?:CENTER|RIGHT|LEFT)//; $size =~ s/>//; my $align = $otag; $align =~ s/^.(.).*$/$1/; my $c = chunksizealign($ext, $size, $align); $stuff=quotemeta($stuff); $text =~ s/$stuff/$c/; } return $text; } my ($tag,$sig,$newsig); open(SIG, "<$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; while() { $sig .= $_; } close(SIG); if (defined $sig) { $sig = reformat($sig); $sig = remove_space($sig); if (defined $sig) { open(SIG, ">$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; print SIG $sig; close(SIG); return; } else { return(10); } }