Introduction
Public interface is const-correct and doesn't explicitly depend
on any globals. Thus, thread-safety may be introduced w/out
changing the interface.
Looking ahead to a C++ wrapper, C functions always pass
this-equivalent as 1st arg.
Copyright (c) 1998-2004 World Wide Web Consortium
(Massachusetts Institute of Technology, European Research
Consortium for Informatics and Mathematics, Keio University).
All Rights Reserved.
CVS Info :
$Author: rbraun $
$Date: 2004/05/04 20:05:14 $
$Revision: 1.1.1.1 $
Contributing Author(s):
Dave Raggett
The contributing author(s) would like to thank all those who
helped with testing, bug fixes and suggestions for improvements.
This wouldn't have been possible without your help.
COPYRIGHT NOTICE:
This software and documentation is provided "as is," and
the copyright holders and contributing author(s) make no
representations or warranties, express or implied, including
but not limited to, warranties of merchantability or fitness
for any particular purpose or that the use of the software or
documentation will not infringe any third party patents,
copyrights, trademarks or other rights.
The copyright holders and contributing author(s) will not be held
liable for any direct, indirect, special or consequential damages
arising out of any use of the software or documentation, even if
advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute
this source code, or portions hereof, documentation and executables,
for any purpose, without fee, subject to the following restrictions:
- The origin of this source code must not be misrepresented.
- Altered versions must be plainly marked as such and must
not be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The copyright holders and contributing author(s) specifically
permit, without fee, and encourage the use of this source code
as a component for supporting the Hypertext Markup Language in
commercial products. If you use this source code in a product,
acknowledgment is not required but would be appreciated.
Created 2001-05-20 by Charles Reitzel
Updated 2002-07-01 by Charles Reitzel - 1st Implementation
Functions
- opaque_type( TidyAttr)
- opaque_type( TidyDoc)
- opaque_type( TidyNode)
- opaque_type( TidyOption)
- tidyAccessWarningCount
- tidyAttrGetHREF
- tidyAttrGetId
- tidyCleanAndRepair
- tidyConfigErrorCount
- tidyCreate
- tidyDetectedGenericXml
- tidyDetectedHtmlVersion
- tidyDetectedXhtml
- tidyErrorCount
- tidyErrorSummary
- tidyGeneralInfo
- tidyGetAppData
- tidyGetByte
- tidyGetNextOption
- tidyGetOption
- tidyGetOptionByName
- tidyGetOptionList
- tidyGetRoot
- tidyInitSink
- tidyInitSource
- tidyIsEOF
- tidyLoadConfig
- tidyLoadConfigEnc
- tidyNodeGetType
- tidyOptCopyConfig
- tidyOptDiffThanDefault
- tidyOptDiffThanSnapshot
- tidyOptGetBool
- tidyOptGetCategory
- tidyOptGetCurrPick
- tidyOptGetDeclTagList
- tidyOptGetDefault
- tidyOptGetDefaultBool
- tidyOptGetDefaultInt
- tidyOptGetEncName
- tidyOptGetId
- tidyOptGetIdForName
- tidyOptGetInt
- tidyOptGetName
- tidyOptGetNextDeclTag
- tidyOptGetNextPick
- tidyOptGetPickList
- tidyOptGetType
- tidyOptGetValue
- tidyOptIsReadOnly
- tidyOptParseValue
- tidyOptResetAllToDefault
- tidyOptResetToDefault
- tidyOptResetToSnapshot
- tidyOptSaveFile
- tidyOptSaveSink
- tidyOptSetBool
- tidyOptSetInt
- tidyOptSetValue
- tidyOptSnapshot
- tidyParseBuffer
- tidyParseFile
- tidyParseSource
- tidyParseStdin
- tidyParseString
- tidyPutByte
- tidyReleaseDate
- tidyRunDiagnostics
- tidySaveBuffer
- tidySaveFile
- tidySaveSink
- tidySaveStdout
- tidySaveString
- tidySetAppData
- tidySetCharEncoding
- tidySetErrorBuffer
- tidySetErrorFile
- tidySetErrorSink
- tidySetFreeCall
- tidySetInCharEncoding
- tidySetMallocCall
- tidySetOutCharEncoding
- tidySetPanicCall
- tidySetReallocCall
- tidySetReportFilter
- tidyStatus
- tidyUngetByte
- tidyWarningCount
See Also:
- opaque_type
- opaque_type
opaque_type(
TidyAttr );
Discussion
** Opaque option datatype
opaque_type(
TidyDoc );
Discussion
@defgroup Opaque Opaque Types
**
** Cast to implementation types within lib.
** Reduces inter-dependencies/conflicts w/ application code.
** @{
See Also:
- opaque_type
- opaque_type
opaque_type(
TidyNode );
Discussion
** Opaque option datatype
See Also:
- opaque_type
- opaque_type
opaque_type(
TidyOption );
Discussion
** Opaque option datatype
TIDY_EXPORT uint tidyAccessWarningCount(
TidyDoc tdoc );
Discussion
Number of Tidy accessibility warnings encountered.
TIDY_EXPORT TidyAttr tidyAttrGetHREF(
TidyNode tnod );
Discussion
@} end AttrAsk group
TIDY_EXPORT TidyAttrId tidyAttrGetId(
TidyAttr tattr );
Discussion
@} End NodeAsk group
TIDY_EXPORT int tidyCleanAndRepair(
TidyDoc tdoc );
Discussion
@} End Parse group
TIDY_EXPORT uint tidyConfigErrorCount(
TidyDoc tdoc );
Discussion
Number of Tidy configuration errors encountered.
TIDY_EXPORT TidyDoc tidyCreate(
void);
Discussion
@defgroup Basic Basic Operations
**
** Tidy public interface
**
** Several functions return an integer document status:
**
**
** 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 = {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;
}
** @{
TIDY_EXPORT Bool tidyDetectedGenericXml(
TidyDoc tdoc );
Discussion
Input is generic XML (not HTML or XHTML)?
TIDY_EXPORT int tidyDetectedHtmlVersion(
TidyDoc tdoc );
Discussion
Detected HTML version: 0, 2, 3 or 4
TIDY_EXPORT Bool tidyDetectedXhtml(
TidyDoc tdoc );
Discussion
Input is XHTML?
TIDY_EXPORT uint tidyErrorCount(
TidyDoc tdoc );
Discussion
Number of Tidy errors encountered. If > 0, output is suppressed
** unless TidyForceOutput is set.
TIDY_EXPORT void tidyErrorSummary(
TidyDoc tdoc );
Discussion
Write more complete information about errors to current error sink.
TIDY_EXPORT void tidyGeneralInfo(
TidyDoc tdoc );
Discussion
Write more general information about markup to current error sink.
TIDY_EXPORT ulong tidyGetAppData(
TidyDoc tdoc );
Discussion
Get application data set previously
TIDY_EXPORT uint tidyGetByte(
TidyInputSource*source );
Discussion
Helper: get next byte from input source
TIDY_EXPORT TidyOption tidyGetNextOption(
TidyDoc tdoc,
TidyIterator*pos );
Discussion
Get next Option
TIDY_EXPORT TidyOption tidyGetOption(
TidyDoc tdoc,
TidyOptionId optId );
Discussion
Lookup option by ID
TIDY_EXPORT TidyOption tidyGetOptionByName(
TidyDoc tdoc,
ctmbstr optnam );
Discussion
Lookup option by name
TIDY_EXPORT TidyIterator tidyGetOptionList(
TidyDoc tdoc );
Discussion
Get iterator for list of option
TIDY_EXPORT TidyNode tidyGetRoot(
TidyDoc tdoc );
Discussion
@} end Basic group (again)
TIDY_EXPORT Bool tidyInitSink(
TidyOutputSink*sink,
void*snkData,
TidyPutByteFunc pbFunc );
Discussion
Facilitates user defined sinks by providing
** an entry point to marshal pointers-to-functions.
** Needed by .NET and possibly other language bindings.
TIDY_EXPORT Bool tidyInitSource(
TidyInputSource*source,
void*srcData,
TidyGetByteFunc gbFunc,
TidyUngetByteFunc ugbFunc,
TidyEOFFunc endFunc );
Discussion
Facilitates user defined source by providing
** an entry point to marshal pointers-to-functions.
** Needed by .NET and possibly other language bindings.
TIDY_EXPORT Bool tidyIsEOF(
TidyInputSource*source );
Discussion
Helper: check if input source at end
TIDY_EXPORT int tidyLoadConfig(
TidyDoc tdoc,
ctmbstr configFile );
Discussion
Load an ASCII Tidy configuration file
TIDY_EXPORT int tidyLoadConfigEnc(
TidyDoc tdoc,
ctmbstr configFile,
ctmbstr charenc );
Discussion
Load a Tidy configuration file with the specified character encoding
TIDY_EXPORT TidyNodeType tidyNodeGetType(
TidyNode tnod );
Discussion
@} end Tree group
TIDY_EXPORT Bool tidyOptCopyConfig(
TidyDoc tdocTo,
TidyDoc tdocFrom );
Discussion
Copy current configuration settings from one document to another
TIDY_EXPORT Bool tidyOptDiffThanDefault(
TidyDoc tdoc );
Discussion
Any settings different than default?
TIDY_EXPORT Bool tidyOptDiffThanSnapshot(
TidyDoc tdoc );
Discussion
Any settings different than snapshot?
TIDY_EXPORT Bool tidyOptGetBool(
TidyDoc tdoc,
TidyOptionId optId );
Discussion
Get current Option value as a Boolean flag
TIDY_EXPORT TidyConfigCategory tidyOptGetCategory(
TidyOption opt );
Discussion
Get category of given Option
TIDY_EXPORT ctmbstr tidyOptGetCurrPick(
TidyDoc tdoc,
TidyOptionId optId);
Discussion
Get current pick list value for option by ID. Useful for enum types.
TIDY_EXPORT TidyIterator tidyOptGetDeclTagList(
TidyDoc tdoc );
Discussion
Iterate over user declared tags
TIDY_EXPORT ctmbstr tidyOptGetDefault(
TidyOption opt );
Discussion
Get default value of given Option as a string
TIDY_EXPORT Bool tidyOptGetDefaultBool(
TidyOption opt );
Discussion
Get default value of given Option as a Boolean value
TIDY_EXPORT ulong tidyOptGetDefaultInt(
TidyOption opt );
Discussion
Get default value of given Option as an unsigned integer
TIDY_EXPORT ctmbstr tidyOptGetEncName(
TidyDoc tdoc,
TidyOptionId optId );
Discussion
Get character encoding name. Used with TidyCharEncoding,
** TidyOutCharEncoding, TidyInCharEncoding
TIDY_EXPORT TidyOptionId tidyOptGetId(
TidyOption opt );
Discussion
Get ID of given Option
TIDY_EXPORT TidyOptionId tidyOptGetIdForName(
ctmbstr optnam );
Discussion
Get option ID by name
TIDY_EXPORT ulong tidyOptGetInt(
TidyDoc tdoc,
TidyOptionId optId );
Discussion
Get current Option value as an integer
TIDY_EXPORT ctmbstr tidyOptGetName(
TidyOption opt );
Discussion
Get name of given Option
TIDY_EXPORT ctmbstr tidyOptGetNextDeclTag(
TidyDoc tdoc,
TidyOptionId optId,
TidyIterator*iter );
Discussion
Get next declared tag of specified type: TidyInlineTags, TidyBlockTags,
** TidyEmptyTags, TidyPreTags
TIDY_EXPORT ctmbstr tidyOptGetNextPick(
TidyOption opt,
TidyIterator*pos );
Discussion
Get next string value of Option "pick list"
TIDY_EXPORT TidyIterator tidyOptGetPickList(
TidyOption opt );
Discussion
Iterate over Option "pick list"
TIDY_EXPORT TidyOptionType tidyOptGetType(
TidyOption opt );
Discussion
Get datatype of given Option
TIDY_EXPORT ctmbstr tidyOptGetValue(
TidyDoc tdoc,
TidyOptionId optId );
Discussion
Get current Option value as a string
TIDY_EXPORT Bool tidyOptIsReadOnly(
TidyOption opt );
Discussion
Is Option read-only?
TIDY_EXPORT Bool tidyOptParseValue(
TidyDoc tdoc,
ctmbstr optnam,
ctmbstr val );
Discussion
Set named Option value as a string. Good if not sure of type.
TIDY_EXPORT Bool tidyOptResetAllToDefault(
TidyDoc tdoc );
Discussion
Reset all options to their default values
TIDY_EXPORT Bool tidyOptResetToDefault(
TidyDoc tdoc,
TidyOptionId opt );
Discussion
Reset option to default value by ID
TIDY_EXPORT Bool tidyOptResetToSnapshot(
TidyDoc tdoc );
Discussion
Reset config settings to snapshot (after document processing)
TIDY_EXPORT int tidyOptSaveFile(
TidyDoc tdoc,
ctmbstr cfgfil );
Discussion
@} end Save group
TIDY_EXPORT int tidyOptSaveSink(
TidyDoc tdoc,
TidyOutputSink*sink );
Discussion
Save current settings to given output sink.
Only non-default values are written.
TIDY_EXPORT Bool tidyOptSetBool(
TidyDoc tdoc,
TidyOptionId optId,
Bool val );
Discussion
Set Option value as a Boolean flag
TIDY_EXPORT Bool tidyOptSetInt(
TidyDoc tdoc,
TidyOptionId optId,
ulong val );
Discussion
Set Option value as an integer
TIDY_EXPORT Bool tidyOptSetValue(
TidyDoc tdoc,
TidyOptionId optId,
ctmbstr val );
Discussion
Set Option value as a string
TIDY_EXPORT Bool tidyOptSnapshot(
TidyDoc tdoc );
Discussion
Take a snapshot of current config settings
TIDY_EXPORT int tidyParseBuffer(
TidyDoc tdoc,
TidyBuffer*buf );
Discussion
Parse markup in given buffer
TIDY_EXPORT int tidyParseFile(
TidyDoc tdoc,
ctmbstr filename );
Discussion
@} end Memory group
TIDY_EXPORT int tidyParseSource(
TidyDoc tdoc,
TidyInputSource*source);
Discussion
Parse markup in given generic input source
TIDY_EXPORT int tidyParseStdin(
TidyDoc tdoc );
Discussion
Parse markup from the standard input
TIDY_EXPORT int tidyParseString(
TidyDoc tdoc,
ctmbstr content );
Discussion
Parse markup in given string
TIDY_EXPORT void tidyPutByte(
TidyOutputSink*sink,
uint byteValue );
Discussion
Helper: send a byte to output
TIDY_EXPORT ctmbstr tidyReleaseDate(
void);
Discussion
Get release date (version) for current library
TIDY_EXPORT int tidyRunDiagnostics(
TidyDoc tdoc );
Discussion
Run configured diagnostics on parsed and repaired markup.
** Must call tidyCleanAndRepair() first.
TIDY_EXPORT int tidySaveBuffer(
TidyDoc tdoc,
TidyBuffer*buf );
Discussion
Save to given TidyBuffer object
TIDY_EXPORT int tidySaveFile(
TidyDoc tdoc,
ctmbstr filename );
Discussion
@} end Clean group
TIDY_EXPORT int tidySaveSink(
TidyDoc tdoc,
TidyOutputSink*sink );
Discussion
Save to given generic output sink
TIDY_EXPORT int tidySaveStdout(
TidyDoc tdoc );
Discussion
Save to standard output (FILE*)
TIDY_EXPORT int tidySaveString(
TidyDoc tdoc,
tmbstr buffer,
uint*buflen );
Discussion
Save document to application buffer. If buffer is not big enough,
** ENOMEM will be returned and the necessary buffer size will be placed
** in *buflen.
TIDY_EXPORT void tidySetAppData(
TidyDoc tdoc,
ulong appData );
Discussion
Let application store a chunk of data w/ each Tidy instance.
** Useful for callbacks.
TIDY_EXPORT int tidySetCharEncoding(
TidyDoc tdoc,
ctmbstr encnam );
Discussion
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.
TIDY_EXPORT int tidySetErrorBuffer(
TidyDoc tdoc,
TidyBuffer*errbuf );
Discussion
Set error sink to given buffer
TIDY_EXPORT FILE* tidySetErrorFile(
TidyDoc tdoc,
ctmbstr errfilnam );
Discussion
Set error sink to named file
TIDY_EXPORT int tidySetErrorSink(
TidyDoc tdoc,
TidyOutputSink*sink );
Discussion
Set error sink to given generic sink
TIDY_EXPORT Bool tidySetFreeCall(
TidyFree ffree );
Discussion
Give Tidy a free() replacement
TIDY_EXPORT int tidySetInCharEncoding(
TidyDoc tdoc,
ctmbstr encnam );
Discussion
Set the input encoding for parsing markup.
** As for tidySetCharEncoding but only affects the input encoding
*
TIDY_EXPORT Bool tidySetMallocCall(
TidyMalloc fmalloc );
Discussion
Give Tidy a malloc() replacement
TIDY_EXPORT int tidySetOutCharEncoding(
TidyDoc tdoc,
ctmbstr encnam );
Discussion
Set the output encoding.
*
TIDY_EXPORT Bool tidySetPanicCall(
TidyPanic fpanic );
Discussion
Give Tidy an "out of memory" handler
TIDY_EXPORT Bool tidySetReallocCall(
TidyRealloc frealloc );
Discussion
Give Tidy a realloc() replacement
TIDY_EXPORT Bool tidySetReportFilter(
TidyDoc tdoc,
TidyReportFilter filtCallback );
Discussion
Give Tidy a filter callback to use
TIDY_EXPORT int tidyStatus(
TidyDoc tdoc );
Discussion
Get status of current document.
TIDY_EXPORT void tidyUngetByte(
TidyInputSource*source,
uint byteValue );
Discussion
Helper: unget byte back to input source
TIDY_EXPORT uint tidyWarningCount(
TidyDoc tdoc );
Discussion
Number of Tidy warnings encountered.
Typedefs
typedef Bool (*TidyEOFFunc)(
ulong sourceData );
Discussion
Input Callback: is end of input?
typedef void (*TidyFree)(
void*buf );
Discussion
Callback for "free" replacement
typedef int (*TidyGetByteFunc)(
ulong sourceData );
Discussion
@} end Configuration group
typedef void* (*TidyMalloc)(
size_t len );
Discussion
@} end IO group
typedef Bool (*TidyOptCallback)(
ctmbstr option,
ctmbstr value );
Discussion
@} end Basic group
typedef void (*TidyPanic)(
ctmbstr mssg );
Discussion
Callback for "out of memory" panic state
typedef void (*TidyPutByteFunc)(
ulong sinkData,
byte bt );
Discussion
Output callback: send a byte to output
typedef void* (*TidyRealloc)(
void*buf,
size_t len );
Discussion
Callback for "realloc" replacement
typedef Bool (*TidyReportFilter)(
TidyDoc tdoc,
TidyReportLevel lvl,
uint line,
uint col,
ctmbstr mssg );
Discussion
Callback to filter messages by diagnostic level:
** info, warning, etc. Just set diagnostic output
** handler to redirect all diagnostics output. Return true
** to proceed with output, false to cancel.
typedef void (*TidyUngetByteFunc)(
ulong sourceData,
byte bt );
Discussion
Input Callback: unget a byte of input
#defines
Value: 0xffffffff (-1)
#define EndOfStream
Discussion
End of input "character"
|
Did this document help you? |
Yes: Tell us what works for you.
|
|
Last Updated: 2006-06-20