Re: Parse string instead of file

Hi,

> I'd like to use HTML Tidy in some applications, but they mostly deal
> with strings instead of files. Has anyone rewritten the current code
> to deal with (char*) strings or is anyone going to do so?

I've been doing this using a two way pipe.  Because of how tidy works,
reading all input before doing any output, the usual buffering problems
related to open2 don't cause trouble here.

An example in Perl:

        use IPC::Open2;
        open2(*R, *W, 'tidy 2>/dev/null');
        print W '<h1>Hello</h1>';
        close W;
        local $/ = undef;
        $html = <R>;
        close R;
        print $html;

The output looks like:

$ ./open2.pl
<html>
<head>
<title></title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>

HTH

Received on Tuesday, 10 April 2001 12:32:14 UTC