Re: bug report to HTML::FormatText

Gisle Aas (aas@oslonett.no)
Tue, 26 Sep 1995 13:54:38 +0100


Andreas Koenig <k@anna.mind.de> writes:
>     Gisle> This will sometimes add space before \n but this is a less
>     Gisle> serious bug I think.  If you set the default left margin to
>     Gisle> 0 (instead of 3) then no additional space will be inserted.
> 
> I don't quite see, how I can do this without changing the source:
> 
> perl -e 'use HTML::Parse;                          
> require HTML::FormatText;        
> $html = parse_htmlfile($ARGV[0]);
> $formatter = new HTML::FormatText;                   
> $formatter->{lm}=0;
> print $formatter->format($html);
> ' 00whois.html
> 
> still gives me 3 spaces left margin.

You can always make a subclass that modifies the behaviour:

perl -e 'use HTML::Parse;                          
require HTML::FormatText;        
$html = parse_htmlfile($ARGV[0]);
{package MyFormatter; @ISA=qw(HTML::FormatText);
 sub begin { my $self = shift; $self->HTML::FormatText::begin(@_); $self->{lm} 
= 0; }
}
$formatter = new MyFormatter;
print $formatter->format($html);
' 00whois.html

The way to go is to make the HTML::FormatText formatter accept parameters to 
the constructor like HTML::FormatPS already does.  I.e. you should eventually 
be able to say:

   $formatter = new HTML::FormatText LeftMargin => 0, RightMargin => 60;

>                                           This would work, if
> HTML::Formatter would be changed as in the patch below, but I don't
> know what it will break:

[patch deleted]

I don't think this is a good idea.


Another problem is that there should have been some way to specify these formatter parameters together with the -o option in the "request" script.  Perhaps something like this:

   request -o ps:papersize=letter;fontfamily=helvetica 00whois.html

Can you think of a better way to do it?

--Gisle