8 int main(int argc, char **argv )
10 const char* input = "<title>Hello</title><p>World!";
11 TidyBuffer output = {0};
12 TidyBuffer errbuf = {0};
16 // Initialize "document"
17 TidyDoc tdoc = tidyCreate();
18 printf( "Tidying:\t%s\n", input );
21 ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes );
23 rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics
25 rc = tidyParseString( tdoc, input ); // Parse the input
27 rc = tidyCleanAndRepair( tdoc ); // Tidy it up!
29 rc = tidyRunDiagnostics( tdoc ); // Kvetch
30 if ( rc > 1 ) // If error, force output.
31 rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
33 rc = tidySaveBuffer( tdoc, &output ); // Pretty Print
38 printf( "\nDiagnostics:\n\n%s", errbuf.bp );
39 printf( "\nAnd here is the result:\n\n%s", output.bp );
42 printf( "A severe error (%d) occurred.\n", rc );
44 tidyBufFree( &output );
45 tidyBufFree( &errbuf );