Functions | |
TidyDoc | tidyCreate (void) |
void | tidyRelease (TidyDoc tdoc) |
void | tidySetAppData (TidyDoc tdoc, ulong appData) |
ulong | tidyGetAppData (TidyDoc tdoc) |
ctmbstr | tidyReleaseDate (void) |
int | tidyStatus (TidyDoc tdoc) |
int | tidyDetectedHtmlVersion (TidyDoc tdoc) |
Bool | tidyDetectedXhtml (TidyDoc tdoc) |
Bool | tidyDetectedGenericXml (TidyDoc tdoc) |
uint | tidyErrorCount (TidyDoc tdoc) |
uint | tidyWarningCount (TidyDoc tdoc) |
uint | tidyAccessWarningCount (TidyDoc tdoc) |
uint | tidyConfigErrorCount (TidyDoc tdoc) |
int | tidyLoadConfig (TidyDoc tdoc, ctmbstr configFile) |
int | tidyLoadConfigEnc (TidyDoc tdoc, ctmbstr configFile, ctmbstr charenc) |
Bool | tidyFileExists (ctmbstr filename) |
int | tidySetCharEncoding (TidyDoc tdoc, ctmbstr encnam) |
int | tidySetInCharEncoding (TidyDoc tdoc, ctmbstr encnam) |
int | tidySetOutCharEncoding (TidyDoc tdoc, ctmbstr encnam) |
int | tidyOptSaveFile (TidyDoc tdoc, ctmbstr cfgfil) |
int | tidyOptSaveSink (TidyDoc tdoc, TidyOutputSink *sink) |
void | tidyErrorSummary (TidyDoc tdoc) |
void | tidyGeneralInfo (TidyDoc tdoc) |
Several functions return an integer document status:
0 -> SUCCESS >0 -> 1 == TIDY WARNING, 2 == TIDY ERROR <0 -> SEVERE ERRORThe following is a short example program.
int main(int argc, char **argv ) { const char* input = "<title>Foo</title><p>Foo!"; TidyBuffer output = {0}; TidyBuffer errbuf = {0}; int rc = -1; Bool ok;
TidyDoc tdoc = tidyCreate(); // Initialize "document" 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
|
Let application store a chunk of data w/ each Tidy instance. Useful for callbacks. |
|
Get application data set previously |
|
Get release date (version) for current library |
|
Get status of current document. |
|
Detected HTML version: 0, 2, 3 or 4 |
|
Input is XHTML? |
|
Input is generic XML (not HTML or XHTML)? |
|
Number of Tidy errors encountered. If > 0, output is suppressed unless TidyForceOutput is set. |
|
Number of Tidy warnings encountered. |
|
Number of Tidy accessibility warnings encountered. |
|
Number of Tidy configuration errors encountered. |
|
Load an ASCII Tidy configuration file |
|
Load a Tidy configuration file with the specified character encoding |
|
Set the input/output character encoding for parsing markup. Values include: ascii, latin1, raw, utf8, iso2022, mac, win1252, utf16le, utf16be, utf16, big5 and shiftjis. Case in-sensitive. |
|
Set the input encoding for parsing markup. As for tidySetCharEncoding but only affects the input encoding |
|
Set the output encoding. |
|
Save current settings to named file. Only non-default values are written. |
|
Save current settings to given output sink. Only non-default values are written. |
|
Write more complete information about errors to current error sink. |
|
Write more general information about markup to current error sink. |