W3C home > Mailing lists > Public > html-tidy@w3.org > April to June 2001

Re: Parse string instead of file

From: Adrian Mugnolo <adrianm@yahoo-inc.com>
Date: Tue, 10 Apr 2001 13:31:53 -0300 (ART)
Message-Id: <200104101631.NAA05673@jazz.ar.yahoo.com>
To: Bjoern Hoehrmann <derhoermi@gmx.net>
CC: html-tidy@w3.org
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:45 GMT