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: https://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... | |
Indicates the number of TidyAccess messages that were generated.
tdoc | An instance of a TidyDoc to query. |
Indicates the number of configuration error messages that were generated.
tdoc | An instance of a TidyDoc to query. |
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.
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.
allocator | The allocator to use for creating the document. |
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.
tdoc | An instance of a TidyDoc to query. |
yes
if the input document was XML. 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.
tdoc | An instance of a TidyDoc to query. |
Indicates whether the output document is or isn't XHTML.
tdoc | An instance of a TidyDoc to query. |
yes
if the document is an XHTML type. Indicates the number of TidyError messages that were generated.
For any value greater than 0
, output is suppressed unless TidyForceOutput is set.
tdoc | An instance of a TidyDoc to query. |
Write more complete information about errors to current error sink.
tdoc | An instance of a TidyDoc to query. |
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.
yes
or no
, indicating whether or not the file exists. tdoc | The TidyDoc on whose behalf you are checking. |
filename | The path to the file whose existence you wish to check. |
Write more general information about markup to current error sink.
tdoc | An instance of a TidyDoc to query. |
Returns the data previously stored with tidySetAppData()
.
tdoc | document where data has been stored. |
Get the version number for the current library.
Load an ASCII Tidy configuration file and set the configuration per its contents.
Reports config option errors, which can be filtered.
tdoc | The TidyDoc to which to apply the configuration. |
configFile | The complete path to the file to load. |
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.
tdoc | The TidyDoc to which to apply the configuration. |
configFile | The complete path to the file to load. |
charenc | The encoding to use. See the _enc2iana struct for valid values. |
Get the platform for which Tidy was built.
Get the release date for the current library.
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.
tdoc | The document in which to store the data. |
appData | The pointer to a block of data to store. |
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.
EINVAL
. tdoc | The TidyDoc for which you are setting the encoding. |
encnam | The encoding name as described above. |
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.
EINVAL
. tdoc | The TidyDoc for which you are setting the encoding. |
encnam | The encoding name as described above. |
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.
EINVAL
. tdoc | The TidyDoc for which you are setting the encoding. |
encnam | The encoding name as described above. |
Get status of current document.
tdoc | An instance of a TidyDoc to query. |
2
indicating that errors were present in the document, 1
indicating warnings, and 0
in the case of everything being okay.