HTML Tidy  5.8.0
The HTACG Tidy HTML Project
Basic Operations

Detailed Description

For an excellent example of how to invoke LibTidy, please consult console/tidy.c:main() for in-depth implementation details.

A simplified example can be seen on our site: http://www.html-tidy.org/developer/

Instantiation and Destruction

TidyDoc TIDY_CALL tidyCreate (void)
 The primary creation of a document instance. More...
 
TidyDoc TIDY_CALL tidyCreateWithAllocator (TidyAllocator *allocator)
 Create a document supplying your own, custom TidyAllocator instead of using the built-in default. More...
 
void TIDY_CALL tidyRelease (TidyDoc tdoc)
 Free all memory and release the TidyDoc. More...
 

Host Application Data

void TIDY_CALL tidySetAppData (TidyDoc tdoc, void *appData)
 Allows the host application to store a chunk of data with each TidyDoc instance. More...
 
void *TIDY_CALL tidyGetAppData (TidyDoc tdoc)
 Returns the data previously stored with tidySetAppData(). More...
 

LibTidy Version Information

ctmbstr TIDY_CALL tidyReleaseDate (void)
 Get the release date for the current library. More...
 
ctmbstr TIDY_CALL tidyLibraryVersion (void)
 Get the version number for the current library. More...
 
ctmbstr TIDY_CALL tidyPlatform (void)
 Get the platform for which Tidy was built. More...
 

Diagnostics and Repair

int TIDY_CALL tidyStatus (TidyDoc tdoc)
 Get status of current document. More...
 
int TIDY_CALL tidyDetectedHtmlVersion (TidyDoc tdoc)
 Gets the version of HTML that was output, as an integer, times 100. More...
 
Bool TIDY_CALL tidyDetectedXhtml (TidyDoc tdoc)
 Indicates whether the output document is or isn't XHTML. More...
 
Bool TIDY_CALL tidyDetectedGenericXml (TidyDoc tdoc)
 Indicates whether or not the input document was XML. More...
 
uint TIDY_CALL tidyErrorCount (TidyDoc tdoc)
 Indicates the number of TidyError messages that were generated. More...
 
uint TIDY_CALL tidyWarningCount (TidyDoc tdoc)
 Indicates the number of TidyWarning messages that were generated. More...
 
uint TIDY_CALL tidyAccessWarningCount (TidyDoc tdoc)
 Indicates the number of TidyAccess messages that were generated. More...
 
uint TIDY_CALL tidyConfigErrorCount (TidyDoc tdoc)
 Indicates the number of configuration error messages that were generated. More...
 
void TIDY_CALL tidyErrorSummary (TidyDoc tdoc)
 Write more complete information about errors to current error sink. More...
 
void TIDY_CALL tidyGeneralInfo (TidyDoc tdoc)
 Write more general information about markup to current error sink. More...
 

Configuration, File, and Encoding Operations

int TIDY_CALL tidyLoadConfig (TidyDoc tdoc, ctmbstr configFile)
 Load an ASCII Tidy configuration file and set the configuration per its contents. More...
 
int TIDY_CALL tidyLoadConfigEnc (TidyDoc tdoc, ctmbstr configFile, ctmbstr charenc)
 Load a Tidy configuration file with the specified character encoding, and set the configuration per its contents. More...
 
Bool TIDY_CALL tidyFileExists (TidyDoc tdoc, ctmbstr filename)
 Determine whether or not a particular file exists. More...
 
int TIDY_CALL tidySetCharEncoding (TidyDoc tdoc, ctmbstr encnam)
 Set the input/output character encoding for parsing markup. More...
 
int TIDY_CALL tidySetInCharEncoding (TidyDoc tdoc, ctmbstr encnam)
 Set the input encoding for parsing markup. More...
 
int TIDY_CALL tidySetOutCharEncoding (TidyDoc tdoc, ctmbstr encnam)
 Set the input encoding for writing markup. More...
 

Function Documentation

◆ tidyAccessWarningCount()

uint TIDY_CALL tidyAccessWarningCount ( TidyDoc  tdoc)

Indicates the number of TidyAccess messages that were generated.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns the number of TidyAccess messages that were generated.

◆ tidyConfigErrorCount()

uint TIDY_CALL tidyConfigErrorCount ( TidyDoc  tdoc)

Indicates the number of configuration error messages that were generated.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns the number of configuration error messages that were generated.

◆ tidyCreate()

TidyDoc TIDY_CALL tidyCreate ( void  )

The primary creation of a document instance.

Instances of a TidyDoc are used throughout the API as a token to represent a particular document. You must create at least one TidyDoc instance to initialize the library and begin interaction with the API. When done using a TidyDoc instance, be sure to tidyRelease(myTidyDoc); in order to free related memory.

Returns
Returns a TidyDoc instance.

◆ tidyCreateWithAllocator()

TidyDoc TIDY_CALL tidyCreateWithAllocator ( TidyAllocator *  allocator)

Create a document supplying your own, custom TidyAllocator instead of using the built-in default.

See the Memory Allocation module if you want to create and use your own allocator.

Parameters
allocatorThe allocator to use for creating the document.
Returns
Returns a TidyDoc instance.

◆ tidyDetectedGenericXml()

Bool TIDY_CALL tidyDetectedGenericXml ( TidyDoc  tdoc)

Indicates whether or not the input document was XML.

If TidyXml tags is true, or there was an XML declaration in the input document, then this function will return yes.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns yes if the input document was XML.

◆ tidyDetectedHtmlVersion()

int TIDY_CALL tidyDetectedHtmlVersion ( TidyDoc  tdoc)

Gets the version of HTML that was output, as an integer, times 100.

For example, HTML5 will return 500; HTML4.0.1 will return 401.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns the HTML version number (x100).

◆ tidyDetectedXhtml()

Bool TIDY_CALL tidyDetectedXhtml ( TidyDoc  tdoc)

Indicates whether the output document is or isn't XHTML.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns yes if the document is an XHTML type.

◆ tidyErrorCount()

uint TIDY_CALL tidyErrorCount ( TidyDoc  tdoc)

Indicates the number of TidyError messages that were generated.

For any value greater than 0, output is suppressed unless TidyForceOutput is set.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns the number of TidyError messages that were generated.

◆ tidyErrorSummary()

void TIDY_CALL tidyErrorSummary ( TidyDoc  tdoc)

Write more complete information about errors to current error sink.

Parameters
tdocAn instance of a TidyDoc to query.

◆ tidyFileExists()

Bool TIDY_CALL tidyFileExists ( TidyDoc  tdoc,
ctmbstr  filename 
)

Determine whether or not a particular file exists.

On Unix systems, the use of the tilde to represent the user's home directory is supported.

Returns
Returns yes or no, indicating whether or not the file exists.
Parameters
tdocThe TidyDoc on whose behalf you are checking.
filenameThe path to the file whose existence you wish to check.

◆ tidyGeneralInfo()

void TIDY_CALL tidyGeneralInfo ( TidyDoc  tdoc)

Write more general information about markup to current error sink.

Parameters
tdocAn instance of a TidyDoc to query.

◆ tidyGetAppData()

void* TIDY_CALL tidyGetAppData ( TidyDoc  tdoc)

Returns the data previously stored with tidySetAppData().

Parameters
tdocdocument where data has been stored.
Returns
The pointer to the data block previously stored.

◆ tidyLibraryVersion()

ctmbstr TIDY_CALL tidyLibraryVersion ( void  )

Get the version number for the current library.

Returns
The string representing the version number.

◆ tidyLoadConfig()

int TIDY_CALL tidyLoadConfig ( TidyDoc  tdoc,
ctmbstr  configFile 
)

Load an ASCII Tidy configuration file and set the configuration per its contents.

Reports config option errors, which can be filtered.

Returns
Returns 0 upon success, or any other value if there was an option error.
Parameters
tdocThe TidyDoc to which to apply the configuration.
configFileThe complete path to the file to load.

◆ tidyLoadConfigEnc()

int TIDY_CALL tidyLoadConfigEnc ( TidyDoc  tdoc,
ctmbstr  configFile,
ctmbstr  charenc 
)

Load a Tidy configuration file with the specified character encoding, and set the configuration per its contents.

Reports config option errors, which can be filtered.

Returns
Returns 0 upon success, or any other value if there was an option error.
Parameters
tdocThe TidyDoc to which to apply the configuration.
configFileThe complete path to the file to load.
charencThe encoding to use. See the _enc2iana struct for valid values.

◆ tidyPlatform()

ctmbstr TIDY_CALL tidyPlatform ( void  )

Get the platform for which Tidy was built.

Returns
The string representing the version number.

◆ tidyRelease()

void TIDY_CALL tidyRelease ( TidyDoc  tdoc)

Free all memory and release the TidyDoc.

The TidyDoc can not be used after this call.

Parameters
tdocThe TidyDoc to free.

◆ tidyReleaseDate()

ctmbstr TIDY_CALL tidyReleaseDate ( void  )

Get the release date for the current library.

Returns
The string representing the release date.

◆ tidySetAppData()

void TIDY_CALL tidySetAppData ( TidyDoc  tdoc,
void *  appData 
)

Allows the host application to store a chunk of data with each TidyDoc instance.

This can be useful for callbacks, such as saving a reference to self within the document.

Parameters
tdocThe document in which to store the data.
appDataThe pointer to a block of data to store.

◆ tidySetCharEncoding()

int TIDY_CALL tidySetCharEncoding ( TidyDoc  tdoc,
ctmbstr  encnam 
)

Set the input/output character encoding for parsing markup.

Valid values include ascii, latin1, raw, utf8, iso2022, mac, win1252, utf16le, utf16be, utf16, big5, and shiftjis. These values are not case sensitive.

Note
This is the same as using TidySetInCharEncoding() and TidySetOutCharEncoding() to set the same value.
Returns
Returns 0 upon success, or a system standard error number EINVAL.
Parameters
tdocThe TidyDoc for which you are setting the encoding.
encnamThe encoding name as described above.

◆ tidySetInCharEncoding()

int TIDY_CALL tidySetInCharEncoding ( TidyDoc  tdoc,
ctmbstr  encnam 
)

Set the input encoding for parsing markup.

Valid values include ascii, latin1, raw, utf8, iso2022, mac, win1252, utf16le, utf16be, utf16, big5, and shiftjis. These values are not case sensitive.

Returns
Returns 0 upon success, or a system standard error number EINVAL.
Parameters
tdocThe TidyDoc for which you are setting the encoding.
encnamThe encoding name as described above.

◆ tidySetOutCharEncoding()

int TIDY_CALL tidySetOutCharEncoding ( TidyDoc  tdoc,
ctmbstr  encnam 
)

Set the input encoding for writing markup.

Valid values include ascii, latin1, raw, utf8, iso2022, mac, win1252, utf16le, utf16be, utf16, big5, and shiftjis. These values are not case sensitive.

Returns
Returns 0 upon success, or a system standard error number EINVAL.
Parameters
tdocThe TidyDoc for which you are setting the encoding.
encnamThe encoding name as described above.

◆ tidyStatus()

int TIDY_CALL tidyStatus ( TidyDoc  tdoc)

Get status of current document.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns the highest of 2 indicating that errors were present in the document, 1 indicating warnings, and 0 in the case of everything being okay.

◆ tidyWarningCount()

uint TIDY_CALL tidyWarningCount ( TidyDoc  tdoc)

Indicates the number of TidyWarning messages that were generated.

Parameters
tdocAn instance of a TidyDoc to query.
Returns
Returns the number of TidyWarning messages that were generated.