|
Functions |
TidyDoc TIDY_CALL | tidyCreate (void) |
TidyDoc TIDY_CALL | tidyCreateWithAllocator (TidyAllocator *allocator) |
void TIDY_CALL | tidyRelease (TidyDoc tdoc) |
void TIDY_CALL | tidySetAppData (TidyDoc tdoc, void *appData) |
void *TIDY_CALL | tidyGetAppData (TidyDoc tdoc) |
ctmbstr TIDY_CALL | tidyReleaseDate (void) |
int TIDY_CALL | tidyStatus (TidyDoc tdoc) |
int TIDY_CALL | tidyDetectedHtmlVersion (TidyDoc tdoc) |
Bool TIDY_CALL | tidyDetectedXhtml (TidyDoc tdoc) |
Bool TIDY_CALL | tidyDetectedGenericXml (TidyDoc tdoc) |
uint TIDY_CALL | tidyErrorCount (TidyDoc tdoc) |
uint TIDY_CALL | tidyWarningCount (TidyDoc tdoc) |
uint TIDY_CALL | tidyAccessWarningCount (TidyDoc tdoc) |
uint TIDY_CALL | tidyConfigErrorCount (TidyDoc tdoc) |
int TIDY_CALL | tidyLoadConfig (TidyDoc tdoc, ctmbstr configFile) |
int TIDY_CALL | tidyLoadConfigEnc (TidyDoc tdoc, ctmbstr configFile, ctmbstr charenc) |
Bool TIDY_CALL | tidyFileExists (TidyDoc tdoc, ctmbstr filename) |
int TIDY_CALL | tidySetCharEncoding (TidyDoc tdoc, ctmbstr encnam) |
int TIDY_CALL | tidySetInCharEncoding (TidyDoc tdoc, ctmbstr encnam) |
int TIDY_CALL | tidySetOutCharEncoding (TidyDoc tdoc, ctmbstr encnam) |
int TIDY_CALL | tidyOptSaveFile (TidyDoc tdoc, ctmbstr cfgfil) |
int TIDY_CALL | tidyOptSaveSink (TidyDoc tdoc, TidyOutputSink *sink) |
void TIDY_CALL | tidyErrorSummary (TidyDoc tdoc) |
void TIDY_CALL | tidyGeneralInfo (TidyDoc tdoc) |
0 -> SUCCESS
>0 -> 1 == TIDY WARNING, 2 == TIDY ERROR
<0 -> SEVERE ERROR
The following is a short example program.
#include <
tidy.h>
#include <
buffio.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char **argv )
{
const char* input = "<title>Foo</title><p>Foo!";
TidyBuffer output;
TidyBuffer errbuf;
int rc = -1;
Bool ok;
TidyDoc tdoc =
tidyCreate(); // Initialize "document"
tidyBufInit( &output );
tidyBufInit( &errbuf );
printf( "Tidying:\t\%s\\n", input );
ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); // Convert to XHTML
if ( ok )
rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics
if ( rc >= 0 )
rc = tidyParseString( tdoc, input ); // Parse the input
if ( rc >= 0 )
rc = tidyCleanAndRepair( tdoc ); // Tidy it up!
if ( rc >= 0 )
rc = tidyRunDiagnostics( tdoc ); // Kvetch
if ( rc > 1 ) // If error, force output.
rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
if ( rc >= 0 )
rc = tidySaveBuffer( tdoc, &output ); // Pretty Print
if ( rc >= 0 )
{
if ( rc > 0 )
printf( "\\nDiagnostics:\\n\\n\%s", errbuf.bp );
printf( "\\nAnd here is the result:\\n\\n\%s", output.bp );
}
else
printf( "A severe error (\%d) occurred.\\n", rc );
tidyBufFree( &output );
tidyBufFree( &errbuf );
tidyRelease( tdoc );
return rc;
}
Function Documentation