HTML::FormatText and newlines...

Alex Tang (altitude@iname.com)
Mon, 11 May 1998 05:36:56 -0400 (EDT)


Hi folks.

Forgive me if this is a newbie question, I haven't found any relavent
questions in the archives...

I'm using HTML::FormatText to parse some html text in a CGI program.  The
code looks like this:


    use HTML::Parse;
    use HTML::FormatText;
    sub FormatHTML {
	my ( $text ) = @_;
	#$text =~ s/\n//gm;
	print ( "NOT FORMATTED:\n$text\n" );
	$h = parse_html ( $text );
	$formatter = HTML::FormatText->new ( leftmargin=>2, rightmargin=>64 );
	$foo = $formatter->format ( $h );
	print ( "FORMATTED:\n$foo\n" );
	return $foo;
    }



If I run the following:


    $html = <<EOF;
    <HTML>
    This is <B>BOLD, </B>NOT bold
    <BR>&nbsp;
    <UL>
    <LI>
    List item 1</LI>

    <LI>
    List Item 2</LI>

    <LI>
    List Item 3.</LI>
    </UL>
    </HTML>
    EOF

    $strRet = &FormatHtml ( $html );
    print "$strRet";

from the command line, I get normal output.  However in my CGI program, I
get:


    FORMATHTML:
    <HTML>
    This is <B>BOLD, </B>NOT bold
    <BR>&nbsp;
    <UL>
    <LI>
    List item 1</LI>

    <LI>
    List Item 2</LI>

    <LI>
    List Item 3.</LI>
    </UL>
    </HTML>



    FORMATTED:
      This is List item 1 List Item 2 List Item 3.

      BOLD, NOT bold


	*

	*

	*


Which is incorrect.  The Formatted text is wrong.

If I remove the newlines from the text right before I call parse_html(),
the resulting HTML is ok again.  Does anyone know what's going on?

Thanks!

...alex...

-- 
           |    altitude@iname.com
 Alex Tang |
           |    "Come on Kringle, I'll buy you an Orange smootie."