![]()
|
tidy.hGo to the documentation of this file.00001 #ifndef __TIDY_H__ 00002 #define __TIDY_H__ 00003 00004 /** @file tidy.h - Defines HTML Tidy API implemented by tidy library. 00005 00006 Public interface is const-correct and doesn't explicitly depend 00007 on any globals. Thus, thread-safety may be introduced w/out 00008 changing the interface. 00009 00010 Looking ahead to a C++ wrapper, C functions always pass 00011 this-equivalent as 1st arg. 00012 00013 00014 Copyright (c) 1998-2002 World Wide Web Consortium 00015 (Massachusetts Institute of Technology, Institut National de 00016 Recherche en Informatique et en Automatique, Keio University). 00017 All Rights Reserved. 00018 00019 CVS Info : 00020 00021 $Author: creitzel $ 00022 $Date: 2002/12/13 23:29:42 $ 00023 $Revision: 1.1.2.1 $ 00024 00025 Contributing Author(s): 00026 00027 Dave Raggett <dsr@w3.org> 00028 00029 The contributing author(s) would like to thank all those who 00030 helped with testing, bug fixes and suggestions for improvements. 00031 This wouldn't have been possible without your help. 00032 00033 COPYRIGHT NOTICE: 00034 00035 This software and documentation is provided "as is," and 00036 the copyright holders and contributing author(s) make no 00037 representations or warranties, express or implied, including 00038 but not limited to, warranties of merchantability or fitness 00039 for any particular purpose or that the use of the software or 00040 documentation will not infringe any third party patents, 00041 copyrights, trademarks or other rights. 00042 00043 The copyright holders and contributing author(s) will not be held 00044 liable for any direct, indirect, special or consequential damages 00045 arising out of any use of the software or documentation, even if 00046 advised of the possibility of such damage. 00047 00048 Permission is hereby granted to use, copy, modify, and distribute 00049 this source code, or portions hereof, documentation and executables, 00050 for any purpose, without fee, subject to the following restrictions: 00051 00052 1. The origin of this source code must not be misrepresented. 00053 2. Altered versions must be plainly marked as such and must 00054 not be misrepresented as being the original source. 00055 3. This Copyright notice may not be removed or altered from any 00056 source or altered source distribution. 00057 00058 The copyright holders and contributing author(s) specifically 00059 permit, without fee, and encourage the use of this source code 00060 as a component for supporting the Hypertext Markup Language in 00061 commercial products. If you use this source code in a product, 00062 acknowledgment is not required but would be appreciated. 00063 00064 00065 Created 2001-05-20 by Charles Reitzel 00066 Updated 2002-07-01 by Charles Reitzel - 1st Implementation 00067 00068 */ 00069 00070 #include "platform.h" 00071 #include "tidyenum.h" 00072 00073 #ifdef __cplusplus 00074 extern "C" { 00075 #endif 00076 00077 /** @defgroup Opaque Opaque Types 00078 ** 00079 ** Cast to implementation types within lib. 00080 ** Reduces inter-dependencies/conflicts w/ application code. 00081 ** @{ 00082 */ 00083 00084 /** @struct TidyDoc 00085 ** Opaque document datatype 00086 */ 00087 opaque( TidyDoc ); 00088 00089 /** @struct TidyOption 00090 ** Opaque option datatype 00091 */ 00092 opaque( TidyOption ); 00093 00094 /** @struct TidyNode 00095 ** Opaque node datatype 00096 */ 00097 opaque( TidyNode ); 00098 00099 /** @struct TidyAttr 00100 ** Opaque attribute datatype 00101 */ 00102 opaque( TidyAttr ); 00103 00104 /** @} */ 00105 00106 TIDY_STRUCT struct _TidyBuffer; 00107 typedef struct _TidyBuffer TidyBuffer; 00108 00109 00110 /** @defgroup Basic Basic Operations 00111 ** 00112 ** Tidy public interface 00113 ** 00114 ** Several functions return an integer document status: 00115 ** 00116 ** <pre> 00117 ** 0 -> SUCCESS 00118 ** >0 -> 1 == TIDY WARNING, 2 == TIDY ERROR 00119 ** <0 -> SEVERE ERROR 00120 ** </pre> 00121 ** 00122 The following is a short example program. 00123 00124 <pre> 00125 #include <tidy.h> 00126 #include <buffio.h> 00127 #include <stdio.h> 00128 #include <errno.h> 00129 00130 00131 int main(int argc, char **argv ) 00132 { 00133 const char* input = "<title>Foo</title><p>Foo!"; 00134 TidyBuffer output = {0}; 00135 TidyBuffer errbuf = {0}; 00136 int rc = -1; 00137 Bool ok; 00138 00139 TidyDoc tdoc = tidyCreate(); // Initialize "document" 00140 printf( "Tidying:\t\%s\\n", input ); 00141 00142 ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); // Convert to XHTML 00143 if ( ok ) 00144 rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics 00145 if ( rc >= 0 ) 00146 rc = tidyParseString( tdoc, input ); // Parse the input 00147 if ( rc >= 0 ) 00148 rc = tidyCleanAndRepair( tdoc ); // Tidy it up! 00149 if ( rc >= 0 ) 00150 rc = tidyRunDiagnostics( tdoc ); // Kvetch 00151 if ( rc > 1 ) // If error, force output. 00152 rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 ); 00153 if ( rc >= 0 ) 00154 rc = tidySaveBuffer( tdoc, &output ); // Pretty Print 00155 00156 if ( rc >= 0 ) 00157 { 00158 if ( rc > 0 ) 00159 printf( "\\nDiagnostics:\\n\\n\%s", errbuf.bp ); 00160 printf( "\\nAnd here is the result:\\n\\n\%s", output.bp ); 00161 } 00162 else 00163 printf( "A severe error (\%d) occurred.\\n", rc ); 00164 00165 tidyBufFree( &output ); 00166 tidyBufFree( &errbuf ); 00167 tidyRelease( tdoc ); 00168 return rc; 00169 } 00170 </pre> 00171 ** @{ 00172 */ 00173 00174 TIDY_EXPORT TidyDoc tidyCreate(); 00175 TIDY_EXPORT void tidyRelease( TidyDoc tdoc ); 00176 00177 /** Let application store a chunk of data w/ each Tidy instance. 00178 ** Useful for callbacks. 00179 */ 00180 TIDY_EXPORT void tidySetAppData( TidyDoc tdoc, uint appData ); 00181 00182 /** Get application data set previously */ 00183 TIDY_EXPORT uint tidyGetAppData( TidyDoc tdoc ); 00184 00185 /** Get release date (version) for current library */ 00186 TIDY_EXPORT ctmbstr tidyReleaseDate(); 00187 00188 /* Diagnostics and Repair 00189 */ 00190 00191 /** Get status of current document. */ 00192 TIDY_EXPORT int tidyStatus( TidyDoc tdoc ); 00193 00194 /** Detected HTML version: 0, 2, 3 or 4 */ 00195 TIDY_EXPORT int tidyDetectedHtmlVersion( TidyDoc tdoc ); 00196 00197 /** Input is XHTML? */ 00198 TIDY_EXPORT Bool tidyDetectedXhtml( TidyDoc tdoc ); 00199 00200 /** Input is generic XML (not HTML or XHTML)? */ 00201 TIDY_EXPORT Bool tidyDetectedGenericXml( TidyDoc tdoc ); 00202 00203 /** Number of Tidy errors encountered. If > 0, output is suppressed 00204 ** unless TidyForceOutput is set. 00205 */ 00206 TIDY_EXPORT uint tidyErrorCount( TidyDoc tdoc ); 00207 00208 /** Number of Tidy warnings encountered. */ 00209 TIDY_EXPORT uint tidyWarningCount( TidyDoc tdoc ); 00210 00211 /** Number of Tidy accessibility warnings encountered. */ 00212 TIDY_EXPORT uint tidyAccessWarningCount( TidyDoc tdoc ); 00213 00214 /** Number of Tidy configuration errors encountered. */ 00215 TIDY_EXPORT uint tidyConfigErrorCount( TidyDoc tdoc ); 00216 00217 /* Get/Set configuration options 00218 */ 00219 /** Load an ASCII Tidy configuration file */ 00220 TIDY_EXPORT int tidyLoadConfig( TidyDoc tdoc, ctmbstr configFile ); 00221 00222 /** Load a Tidy configuration file with the specified character encoding */ 00223 TIDY_EXPORT int tidyLoadConfigEnc( TidyDoc tdoc, ctmbstr configFile, 00224 ctmbstr charenc ); 00225 00226 /** Set the input/output character encoding for parsing markup. 00227 ** Values include: ascii, latin1, raw, utf8, iso2022, mac, 00228 ** win1252, utf16le, utf16be, utf16, big5 and shiftjis. Case in-sensitive. 00229 */ 00230 TIDY_EXPORT int tidySetCharEncoding( TidyDoc tdoc, ctmbstr encnam ); 00231 00232 /** @} end Basic group */ 00233 00234 00235 /** @defgroup Configuration Configuration Options 00236 ** 00237 ** Functions for getting and setting Tidy configuration options. 00238 ** @{ 00239 */ 00240 00241 /** Get option ID by name */ 00242 TIDY_EXPORT TidyOptionId tidyOptGetIdForName( ctmbstr optnam ); 00243 00244 /** Get iterator for list of option */ 00245 /** 00246 Example: 00247 <pre> 00248 TidyIterator itOpt = tidyGetOptionList( tdoc ); 00249 while ( itOpt ) 00250 { 00251 TidyOption opt = tidyGetNextOption( tdoc, &itOpt ); 00252 .. get/set option values .. 00253 } 00254 </pre> 00255 */ 00256 00257 TIDY_EXPORT TidyIterator tidyGetOptionList( TidyDoc tdoc ); 00258 /** Get next Option */ 00259 TIDY_EXPORT TidyOption tidyGetNextOption( TidyDoc tdoc, TidyIterator* pos ); 00260 00261 /** Lookup option by ID */ 00262 TIDY_EXPORT TidyOption tidyGetOption( TidyDoc tdoc, TidyOptionId optId ); 00263 /** Lookup option by name */ 00264 TIDY_EXPORT TidyOption tidyGetOptionByName( TidyDoc tdoc, ctmbstr optnam ); 00265 00266 /** Get ID of given Option */ 00267 TIDY_EXPORT TidyOptionId tidyOptGetId( TidyOption opt ); 00268 00269 /** Get name of given Option */ 00270 TIDY_EXPORT ctmbstr tidyOptGetName( TidyOption opt ); 00271 00272 /** Get datatype of given Option */ 00273 TIDY_EXPORT TidyOptionType tidyOptGetType( TidyOption opt ); 00274 00275 /** Is Option read-only? */ 00276 TIDY_EXPORT Bool tidyOptIsReadOnly( TidyOption opt ); 00277 00278 /** Get category of given Option */ 00279 TIDY_EXPORT TidyConfigCategory tidyOptGetCategory( TidyOption opt ); 00280 00281 /** Get default value of given Option as a string */ 00282 TIDY_EXPORT ctmbstr tidyOptGetDefault( TidyOption opt ); 00283 00284 /** Get default value of given Option as an unsigned integer */ 00285 TIDY_EXPORT uint tidyOptGetDefaultInt( TidyOption opt ); 00286 00287 /** Get default value of given Option as a Boolean value */ 00288 TIDY_EXPORT Bool tidyOptGetDefaultBool( TidyOption opt ); 00289 00290 /** Iterate over Option "pick list" */ 00291 TIDY_EXPORT TidyIterator tidyOptGetPickList( TidyOption opt ); 00292 /** Get next string value of Option "pick list" */ 00293 TIDY_EXPORT ctmbstr tidyOptGetNextPick( TidyOption opt, TidyIterator* pos ); 00294 00295 /** Get current Option value as a string */ 00296 TIDY_EXPORT ctmbstr tidyOptGetValue( TidyDoc tdoc, TidyOptionId optId ); 00297 /** Set Option value as a string */ 00298 TIDY_EXPORT Bool tidyOptSetValue( TidyDoc tdoc, TidyOptionId optId, ctmbstr val ); 00299 /** Set named Option value as a string. Good if not sure of type. */ 00300 TIDY_EXPORT Bool tidyOptParseValue( TidyDoc tdoc, ctmbstr optnam, ctmbstr val ); 00301 00302 /** Get current Option value as an integer */ 00303 TIDY_EXPORT uint tidyOptGetInt( TidyDoc tdoc, TidyOptionId optId ); 00304 /** Set Option value as an integer */ 00305 TIDY_EXPORT Bool tidyOptSetInt( TidyDoc tdoc, TidyOptionId optId, uint val ); 00306 00307 /** Get current Option value as a Boolean flag */ 00308 TIDY_EXPORT Bool tidyOptGetBool( TidyDoc tdoc, TidyOptionId optId ); 00309 /** Set Option value as a Boolean flag */ 00310 TIDY_EXPORT Bool tidyOptSetBool( TidyDoc tdoc, TidyOptionId optId, Bool val ); 00311 00312 /** Reset option to default value by ID */ 00313 TIDY_EXPORT Bool tidyOptResetToDefault( TidyDoc tdoc, TidyOptionId opt ); 00314 /** Reset all options to their default values */ 00315 TIDY_EXPORT Bool tidyOptResetAllToDefault( TidyDoc tdoc ); 00316 00317 /** Take a snapshot of current config settings */ 00318 TIDY_EXPORT Bool tidyOptSnapshot( TidyDoc tdoc ); 00319 /** Reset config settings to snapshot (after document processing) */ 00320 TIDY_EXPORT Bool tidyOptResetToSnapshot( TidyDoc tdoc ); 00321 00322 /** Any settings different than default? */ 00323 TIDY_EXPORT Bool tidyOptDiffThanDefault( TidyDoc tdoc ); 00324 /** Any settings different than snapshot? */ 00325 TIDY_EXPORT Bool tidyOptDiffThanSnapshot( TidyDoc tdoc ); 00326 00327 /** Copy current configuration settings from one document to another */ 00328 TIDY_EXPORT Bool tidyOptCopyConfig( TidyDoc tdocTo, TidyDoc tdocFrom ); 00329 00330 /** Get character encoding name. Used with TidyCharEncoding, 00331 ** TidyOutCharEncoding, TidyInCharEncoding */ 00332 TIDY_EXPORT ctmbstr tidyOptGetEncName( TidyDoc tdoc, TidyOptionId optId ); 00333 00334 /** Get current pick list value for option by ID. Useful for enum types. */ 00335 TIDY_EXPORT ctmbstr tidyOptGetCurrPick( TidyDoc tdoc, TidyOptionId optId); 00336 00337 /** Iterate over user declared tags */ 00338 TIDY_EXPORT TidyIterator tidyOptGetDeclTagList( TidyDoc tdoc ); 00339 /** Get next declared tag of specified type: TidyInlineTags, TidyBlockTags, 00340 ** TidyEmptyTags, TidyPreTags */ 00341 TIDY_EXPORT ctmbstr tidyOptGetNextDeclTag( TidyDoc tdoc, 00342 TidyOptionId optId, 00343 TidyIterator* iter ); 00344 /** @} end Configuration group */ 00345 00346 /** @defgroup IO I/O and Messages 00347 ** 00348 ** By default, Tidy will define, create and use 00349 ** instances of input and output handlers for 00350 ** standard C buffered I/O (i.e. FILE* stdin, 00351 ** FILE* stdout and FILE* stderr for content 00352 ** input, content output and diagnostic output, 00353 ** respectively. A FILE* cfgFile input handler 00354 ** will be used for config files. Command line 00355 ** options will just be set directly. 00356 ** 00357 ** @{ 00358 */ 00359 00360 /***************** 00361 Input Source 00362 *****************/ 00363 /** Input Callback: get next byte of input */ 00364 typedef int (*TidyGetByteFunc)( uint sourceData ); 00365 00366 /** Input Callback: unget a byte of input */ 00367 typedef void (*TidyUngetByteFunc)( uint sourceData, byte bt ); 00368 00369 /** Input Callback: is end of input? */ 00370 typedef Bool (*TidyEOFFunc)( uint sourceData ); 00371 00372 /** End of input "character" */ 00373 #define EndOfStream (~0u) 00374 00375 /** TidyInputSource - Delivers raw bytes of input 00376 */ 00377 TIDY_STRUCT 00378 typedef struct _TidyInputSource 00379 { 00380 /* Instance data */ 00381 uint sourceData; /**< Input context. Passed to callbacks */ 00382 00383 /* Methods */ 00384 TidyGetByteFunc getByte; /**< Pointer to "get byte" callback */ 00385 TidyUngetByteFunc ungetByte; /**< Pointer to "unget" callback */ 00386 TidyEOFFunc eof; /**< Pointer to "eof" callback */ 00387 } TidyInputSource; 00388 00389 /** Facilitates user defined source by providing 00390 ** an entry point to marshal pointers-to-functions. 00391 ** Needed by .NET and possibly other language bindings. 00392 */ 00393 TIDY_EXPORT Bool tidyInitSource( TidyInputSource* source, 00394 void* srcData, 00395 TidyGetByteFunc gbFunc, 00396 TidyUngetByteFunc ugbFunc, 00397 TidyEOFFunc endFunc ); 00398 00399 /** Helper: get next byte from input source */ 00400 TIDY_EXPORT uint tidyGetByte( TidyInputSource* source ); 00401 00402 /** Helper: unget byte back to input source */ 00403 TIDY_EXPORT void tidyUngetByte( TidyInputSource* source, uint byteValue ); 00404 00405 /** Helper: check if input source at end */ 00406 TIDY_EXPORT Bool tidyIsEOF( TidyInputSource* source ); 00407 00408 00409 /**************** 00410 Output Sink 00411 ****************/ 00412 /** Output callback: send a byte to output */ 00413 typedef void (*TidyPutByteFunc)( uint sinkData, byte bt ); 00414 00415 00416 /** TidyOutputSink - accepts raw bytes of output 00417 */ 00418 TIDY_STRUCT 00419 typedef struct _TidyOutputSink 00420 { 00421 /* Instance data */ 00422 uint sinkData; /**< Output context. Passed to callbacks */ 00423 00424 /* Methods */ 00425 TidyPutByteFunc putByte; /**< Pointer to "put byte" callback */ 00426 } TidyOutputSink; 00427 00428 /** Facilitates user defined sinks by providing 00429 ** an entry point to marshal pointers-to-functions. 00430 ** Needed by .NET and possibly other language bindings. 00431 */ 00432 TIDY_EXPORT Bool tidyInitSink( TidyOutputSink* sink, 00433 void* snkData, 00434 TidyPutByteFunc pbFunc ); 00435 00436 /** Helper: send a byte to output */ 00437 TIDY_EXPORT void tidyPutByte( TidyOutputSink* sink, uint byteValue ); 00438 00439 00440 /** Callback to filter messages by diagnostic level: 00441 ** info, warning, etc. Just set diagnostic output 00442 ** handler to redirect all diagnostics output. Return true 00443 ** to proceed with output, false to cancel. 00444 */ 00445 typedef Bool (*TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl, 00446 uint line, uint col, ctmbstr mssg ); 00447 00448 /** Give Tidy a filter callback to use */ 00449 TIDY_EXPORT Bool tidySetReportFilter( TidyDoc tdoc, 00450 TidyReportFilter filtCallback ); 00451 00452 /** Set error sink to named file */ 00453 TIDY_EXPORT FILE* tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam ); 00454 /** Set error sink to given buffer */ 00455 TIDY_EXPORT int tidySetErrorBuffer( TidyDoc tdoc, TidyBuffer* errbuf ); 00456 /** Set error sink to given generic sink */ 00457 TIDY_EXPORT int tidySetErrorSink( TidyDoc tdoc, TidyOutputSink* sink ); 00458 00459 /** @} end IO group */ 00460 00461 00462 /** @defgroup Memory Memory Allocation 00463 ** 00464 ** By default, Tidy will use its own wrappers 00465 ** around standard C malloc/free calls. 00466 ** These wrappers will abort upon any failures. 00467 ** If any are set, all must be set. 00468 ** Pass NULL to clear previous setting. 00469 ** 00470 ** May be used to set environment-specific allocators 00471 ** such as used by web server plugins, etc. 00472 ** 00473 ** @{ 00474 */ 00475 00476 /** Callback for "malloc" replacement */ 00477 typedef void* (*TidyMalloc)( size_t len ); 00478 /** Callback for "realloc" replacement */ 00479 typedef void* (*TidyRealloc)( void* buf, size_t len ); 00480 /** Callback for "free" replacement */ 00481 typedef void (*TidyFree)( void* buf ); 00482 /** Callback for "out of memory" panic state */ 00483 typedef void (*TidyPanic)( ctmbstr mssg ); 00484 00485 /** Give Tidy a malloc() replacement */ 00486 TIDY_EXPORT Bool tidySetMallocCall( TidyMalloc fmalloc ); 00487 /** Give Tidy a realloc() replacement */ 00488 TIDY_EXPORT Bool tidySetReallocCall( TidyRealloc frealloc ); 00489 /** Give Tidy a free() replacement */ 00490 TIDY_EXPORT Bool tidySetFreeCall( TidyFree ffree ); 00491 /** Give Tidy an "out of memory" handler */ 00492 TIDY_EXPORT Bool tidySetPanicCall( TidyPanic fpanic ); 00493 00494 /** @} end Memory group */ 00495 00496 /* TODO: Catalog all messages for easy translation 00497 TIDY_EXPORT ctmbstr tidyLookupMessage( int errorNo ); 00498 */ 00499 00500 00501 00502 /** @defgroup Parse Document Parse 00503 ** 00504 ** Parse markup from a given input source. String and filename 00505 ** functions added for convenience. HTML/XHTML version determined 00506 ** from input. 00507 ** @{ 00508 */ 00509 00510 /** Parse markup in named file */ 00511 TIDY_EXPORT int tidyParseFile( TidyDoc tdoc, ctmbstr filename ); 00512 00513 /** Parse markup from the standard input */ 00514 TIDY_EXPORT int tidyParseStdin( TidyDoc tdoc ); 00515 00516 /** Parse markup in given string */ 00517 TIDY_EXPORT int tidyParseString( TidyDoc tdoc, ctmbstr content ); 00518 00519 /** Parse markup in given buffer */ 00520 TIDY_EXPORT int tidyParseBuffer( TidyDoc tdoc, TidyBuffer* buf ); 00521 00522 /** Parse markup in given generic input source */ 00523 TIDY_EXPORT int tidyParseSource( TidyDoc tdoc, TidyInputSource* source); 00524 00525 /** @} End Parse group */ 00526 00527 00528 /** @defgroup Clean Diagnostics and Repair 00529 ** 00530 ** @{ 00531 */ 00532 /** Execute configured cleanup and repair operations on parsed markup */ 00533 TIDY_EXPORT int tidyCleanAndRepair( TidyDoc tdoc ); 00534 00535 /** Run configured diagnostics on parsed and repaired markup. 00536 ** Must call tidyCleanAndRepair() first. 00537 */ 00538 TIDY_EXPORT int tidyRunDiagnostics( TidyDoc tdoc ); 00539 00540 /** @} end Clean group */ 00541 00542 00543 /** @defgroup Save Document Save Functions 00544 ** 00545 ** Save currently parsed document to the given output sink. File name 00546 ** and string/buffer functions provided for convenience. 00547 ** @{ 00548 */ 00549 00550 /** Save to named file */ 00551 TIDY_EXPORT int tidySaveFile( TidyDoc tdoc, ctmbstr filename ); 00552 00553 /** Save to standard output (FILE*) */ 00554 TIDY_EXPORT int tidySaveStdout( TidyDoc tdoc ); 00555 00556 /** Save to given TidyBuffer object */ 00557 TIDY_EXPORT int tidySaveBuffer( TidyDoc tdoc, TidyBuffer* buf ); 00558 00559 /** Save document to application buffer. If buffer is not big enough, 00560 ** ENOMEM will be returned and the necessary buffer size will be placed 00561 ** in *buflen. 00562 */ 00563 TIDY_EXPORT int tidySaveString( TidyDoc tdoc, 00564 tmbstr buffer, uint* buflen ); 00565 00566 /** Save to given generic output sink */ 00567 TIDY_EXPORT int tidySaveSink( TidyDoc tdoc, TidyOutputSink* sink ); 00568 00569 /** @} end Save group */ 00570 00571 00572 /** @addtogroup Basic 00573 ** @{ 00574 */ 00575 /** Save current settings to named file. 00576 Only non-default values are written. */ 00577 TIDY_EXPORT int tidyOptSaveFile( TidyDoc tdoc, ctmbstr cfgfil ); 00578 00579 /** Save current settings to given output sink. 00580 Only non-default values are written. */ 00581 TIDY_EXPORT int tidyOptSaveSink( TidyDoc tdoc, TidyOutputSink* sink ); 00582 00583 00584 /* Error reporting functions 00585 */ 00586 00587 /** Write more complete information about errors to current error sink. */ 00588 TIDY_EXPORT void tidyErrorSummary( TidyDoc tdoc ); 00589 00590 /** Write more general information about markup to current error sink. */ 00591 TIDY_EXPORT void tidyGeneralInfo( TidyDoc tdoc ); 00592 00593 /** @} end Basic group (again) */ 00594 00595 00596 /** @defgroup Tree Document Tree 00597 ** 00598 ** A parsed and, optionally, repaired document is 00599 ** represented by Tidy as a Tree, much like a W3C DOM. 00600 ** This tree may be traversed using these functions. 00601 ** The following snippet gives a basic idea how these 00602 ** functions can be used. 00603 ** 00604 <pre> 00605 void dumpNode( TidyNode tnod, int indent ) 00606 { 00607 TidyNode child; 00608 00609 for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) 00610 { 00611 ctmbstr name = tidyNodeGetName( child ); 00612 if ( !name ) 00613 { 00614 switch ( tidyNodeGetType(child) ) 00615 { 00616 case TidyNode_Root: name = "Root"; break; 00617 case TidyNode_DocType: name = "DOCTYPE"; break; 00618 case TidyNode_Comment: name = "Comment"; break; 00619 case TidyNode_ProcIns: name = "Processing Instruction"; break; 00620 case TidyNode_Text: name = "Text"; break; 00621 case TidyNode_CDATA: name = "CDATA"; break; 00622 case TidyNode_Section: name = "XML Section"; break; 00623 case TidyNode_Asp: name = "ASP"; break; 00624 case TidyNode_Jste: name = "JSTE"; break; 00625 case TidyNode_Php: name = "PHP"; break; 00626 case TidyNode_XmlDecl: name = "XML Declaration"; break; 00627 00628 case TidyNode_Start: 00629 case TidyNode_End: 00630 case TidyNode_StartEnd: 00631 default: 00632 assert( name != NULL ); // Shouldn't get here 00633 break; 00634 } 00635 } 00636 assert( name != NULL ); 00637 printf( "\%*.*sNode: \%s\\n", indent, indent, tidy ); 00638 dumpNode( child, indent + 4 ); 00639 } 00640 } 00641 00642 void dumpDoc( TidyDoc tdoc ) 00643 { 00644 dumpNode( tidyGetRoot(tdoc), 0 ); 00645 } 00646 00647 void dumpBody( TidyDoc tdoc ) 00648 { 00649 dumpNode( tidyGetBody(tdoc), 0 ); 00650 } 00651 </pre> 00652 00653 @{ 00654 00655 */ 00656 00657 TIDY_EXPORT TidyNode tidyGetRoot( TidyDoc tdoc ); 00658 TIDY_EXPORT TidyNode tidyGetHtml( TidyDoc tdoc ); 00659 TIDY_EXPORT TidyNode tidyGetHead( TidyDoc tdoc ); 00660 TIDY_EXPORT TidyNode tidyGetBody( TidyDoc tdoc ); 00661 00662 /* parent / child */ 00663 TIDY_EXPORT TidyNode tidyGetParent( TidyNode tnod ); 00664 TIDY_EXPORT TidyNode tidyGetChild( TidyNode tnod ); 00665 00666 /* siblings */ 00667 TIDY_EXPORT TidyNode tidyGetNext( TidyNode tnod ); 00668 TIDY_EXPORT TidyNode tidyGetPrev( TidyNode tnod ); 00669 00670 /* Null for non-element nodes and all pure HTML 00671 TIDY_EXPORT ctmbstr tidyNodeNsLocal( TidyNode tnod ); 00672 TIDY_EXPORT ctmbstr tidyNodeNsPrefix( TidyNode tnod ); 00673 TIDY_EXPORT ctmbstr tidyNodeNsUri( TidyNode tnod ); 00674 */ 00675 00676 /* Iterate over attribute values */ 00677 TIDY_EXPORT TidyAttr tidyAttrFirst( TidyNode tnod ); 00678 TIDY_EXPORT TidyAttr tidyAttrNext( TidyAttr tattr ); 00679 00680 TIDY_EXPORT ctmbstr tidyAttrName( TidyAttr tattr ); 00681 TIDY_EXPORT ctmbstr tidyAttrValue( TidyAttr tattr ); 00682 00683 /* Null for pure HTML 00684 TIDY_EXPORT ctmbstr tidyAttrNsLocal( TidyAttr tattr ); 00685 TIDY_EXPORT ctmbstr tidyAttrNsPrefix( TidyAttr tattr ); 00686 TIDY_EXPORT ctmbstr tidyAttrNsUri( TidyAttr tattr ); 00687 */ 00688 00689 /** @} end Tree group */ 00690 00691 00692 /** @defgroup NodeAsk Node Interrogation 00693 ** 00694 ** Get information about any givent node. 00695 ** @{ 00696 */ 00697 00698 /* Node info */ 00699 TIDY_EXPORT TidyNodeType tidyNodeGetType( TidyNode tnod ); 00700 TIDY_EXPORT ctmbstr tidyNodeGetName( TidyNode tnod ); 00701 00702 TIDY_EXPORT Bool tidyNodeIsText( TidyNode tnod ); 00703 TIDY_EXPORT Bool tidyNodeIsProp( TidyDoc tdoc, TidyNode tnod ); 00704 TIDY_EXPORT Bool tidyNodeIsHeader( TidyNode tnod ); /* h1, h2, ... */ 00705 00706 TIDY_EXPORT Bool tidyNodeHasText( TidyDoc tdoc, TidyNode tnod ); 00707 TIDY_EXPORT Bool tidyNodeGetText( TidyDoc tdoc, TidyNode tnod, TidyBuffer* buf ); 00708 00709 TIDY_EXPORT TidyTagId tidyNodeGetId( TidyNode tnod ); 00710 00711 TIDY_EXPORT Bool tidyNodeIsHTML( TidyNode tnod ); 00712 TIDY_EXPORT Bool tidyNodeIsHEAD( TidyNode tnod ); 00713 TIDY_EXPORT Bool tidyNodeIsTITLE( TidyNode tnod ); 00714 TIDY_EXPORT Bool tidyNodeIsBASE( TidyNode tnod ); 00715 TIDY_EXPORT Bool tidyNodeIsMETA( TidyNode tnod ); 00716 TIDY_EXPORT Bool tidyNodeIsBODY( TidyNode tnod ); 00717 TIDY_EXPORT Bool tidyNodeIsFRAMESET( TidyNode tnod ); 00718 TIDY_EXPORT Bool tidyNodeIsFRAME( TidyNode tnod ); 00719 TIDY_EXPORT Bool tidyNodeIsIFRAME( TidyNode tnod ); 00720 TIDY_EXPORT Bool tidyNodeIsNOFRAMES( TidyNode tnod ); 00721 TIDY_EXPORT Bool tidyNodeIsHR( TidyNode tnod ); 00722 TIDY_EXPORT Bool tidyNodeIsH1( TidyNode tnod ); 00723 TIDY_EXPORT Bool tidyNodeIsH2( TidyNode tnod ); 00724 TIDY_EXPORT Bool tidyNodeIsPRE( TidyNode tnod ); 00725 TIDY_EXPORT Bool tidyNodeIsLISTING( TidyNode tnod ); 00726 TIDY_EXPORT Bool tidyNodeIsP( TidyNode tnod ); 00727 TIDY_EXPORT Bool tidyNodeIsUL( TidyNode tnod ); 00728 TIDY_EXPORT Bool tidyNodeIsOL( TidyNode tnod ); 00729 TIDY_EXPORT Bool tidyNodeIsDL( TidyNode tnod ); 00730 TIDY_EXPORT Bool tidyNodeIsDIR( TidyNode tnod ); 00731 TIDY_EXPORT Bool tidyNodeIsLI( TidyNode tnod ); 00732 TIDY_EXPORT Bool tidyNodeIsDT( TidyNode tnod ); 00733 TIDY_EXPORT Bool tidyNodeIsDD( TidyNode tnod ); 00734 TIDY_EXPORT Bool tidyNodeIsTABLE( TidyNode tnod ); 00735 TIDY_EXPORT Bool tidyNodeIsCAPTION( TidyNode tnod ); 00736 TIDY_EXPORT Bool tidyNodeIsTD( TidyNode tnod ); 00737 TIDY_EXPORT Bool tidyNodeIsTH( TidyNode tnod ); 00738 TIDY_EXPORT Bool tidyNodeIsTR( TidyNode tnod ); 00739 TIDY_EXPORT Bool tidyNodeIsCOL( TidyNode tnod ); 00740 TIDY_EXPORT Bool tidyNodeIsCOLGROUP( TidyNode tnod ); 00741 TIDY_EXPORT Bool tidyNodeIsBR( TidyNode tnod ); 00742 TIDY_EXPORT Bool tidyNodeIsA( TidyNode tnod ); 00743 TIDY_EXPORT Bool tidyNodeIsLINK( TidyNode tnod ); 00744 TIDY_EXPORT Bool tidyNodeIsB( TidyNode tnod ); 00745 TIDY_EXPORT Bool tidyNodeIsI( TidyNode tnod ); 00746 TIDY_EXPORT Bool tidyNodeIsSTRONG( TidyNode tnod ); 00747 TIDY_EXPORT Bool tidyNodeIsEM( TidyNode tnod ); 00748 TIDY_EXPORT Bool tidyNodeIsBIG( TidyNode tnod ); 00749 TIDY_EXPORT Bool tidyNodeIsSMALL( TidyNode tnod ); 00750 TIDY_EXPORT Bool tidyNodeIsPARAM( TidyNode tnod ); 00751 TIDY_EXPORT Bool tidyNodeIsOPTION( TidyNode tnod ); 00752 TIDY_EXPORT Bool tidyNodeIsOPTGROUP( TidyNode tnod ); 00753 TIDY_EXPORT Bool tidyNodeIsIMG( TidyNode tnod ); 00754 TIDY_EXPORT Bool tidyNodeIsMAP( TidyNode tnod ); 00755 TIDY_EXPORT Bool tidyNodeIsAREA( TidyNode tnod ); 00756 TIDY_EXPORT Bool tidyNodeIsNOBR( TidyNode tnod ); 00757 TIDY_EXPORT Bool tidyNodeIsWBR( TidyNode tnod ); 00758 TIDY_EXPORT Bool tidyNodeIsFONT( TidyNode tnod ); 00759 TIDY_EXPORT Bool tidyNodeIsLAYER( TidyNode tnod ); 00760 TIDY_EXPORT Bool tidyNodeIsSPACER( TidyNode tnod ); 00761 TIDY_EXPORT Bool tidyNodeIsCENTER( TidyNode tnod ); 00762 TIDY_EXPORT Bool tidyNodeIsSTYLE( TidyNode tnod ); 00763 TIDY_EXPORT Bool tidyNodeIsSCRIPT( TidyNode tnod ); 00764 TIDY_EXPORT Bool tidyNodeIsNOSCRIPT( TidyNode tnod ); 00765 TIDY_EXPORT Bool tidyNodeIsFORM( TidyNode tnod ); 00766 TIDY_EXPORT Bool tidyNodeIsTEXTAREA( TidyNode tnod ); 00767 TIDY_EXPORT Bool tidyNodeIsBLOCKQUOTE( TidyNode tnod ); 00768 TIDY_EXPORT Bool tidyNodeIsAPPLET( TidyNode tnod ); 00769 TIDY_EXPORT Bool tidyNodeIsOBJECT( TidyNode tnod ); 00770 TIDY_EXPORT Bool tidyNodeIsDIV( TidyNode tnod ); 00771 TIDY_EXPORT Bool tidyNodeIsSPAN( TidyNode tnod ); 00772 TIDY_EXPORT Bool tidyNodeIsINPUT( TidyNode tnod ); 00773 TIDY_EXPORT Bool tidyNodeIsQ( TidyNode tnod ); 00774 TIDY_EXPORT Bool tidyNodeIsLABEL( TidyNode tnod ); 00775 TIDY_EXPORT Bool tidyNodeIsH3( TidyNode tnod ); 00776 TIDY_EXPORT Bool tidyNodeIsH4( TidyNode tnod ); 00777 TIDY_EXPORT Bool tidyNodeIsH5( TidyNode tnod ); 00778 TIDY_EXPORT Bool tidyNodeIsH6( TidyNode tnod ); 00779 TIDY_EXPORT Bool tidyNodeIsADDRESS( TidyNode tnod ); 00780 TIDY_EXPORT Bool tidyNodeIsXMP( TidyNode tnod ); 00781 TIDY_EXPORT Bool tidyNodeIsSELECT( TidyNode tnod ); 00782 TIDY_EXPORT Bool tidyNodeIsBLINK( TidyNode tnod ); 00783 TIDY_EXPORT Bool tidyNodeIsMARQUEE( TidyNode tnod ); 00784 TIDY_EXPORT Bool tidyNodeIsEMBED( TidyNode tnod ); 00785 TIDY_EXPORT Bool tidyNodeIsBASEFONT( TidyNode tnod ); 00786 TIDY_EXPORT Bool tidyNodeIsISINDEX( TidyNode tnod ); 00787 TIDY_EXPORT Bool tidyNodeIsS( TidyNode tnod ); 00788 TIDY_EXPORT Bool tidyNodeIsSTRIKE( TidyNode tnod ); 00789 TIDY_EXPORT Bool tidyNodeIsU( TidyNode tnod ); 00790 TIDY_EXPORT Bool tidyNodeIsMENU( TidyNode tnod ); 00791 00792 /** @} End NodeAsk group */ 00793 00794 00795 /** @defgroup Attribute Attribute Interrogation 00796 ** 00797 ** Get information about any given attribute. 00798 ** @{ 00799 */ 00800 00801 TIDY_EXPORT TidyAttrId tidyAttrGetId( TidyAttr tattr ); 00802 TIDY_EXPORT Bool tidyAttrIsEvent( TidyAttr tattr ); 00803 TIDY_EXPORT Bool tidyAttrIsProp( TidyAttr tattr ); 00804 00805 TIDY_EXPORT Bool tidyAttrIsHREF( TidyAttr tattr ); 00806 TIDY_EXPORT Bool tidyAttrIsSRC( TidyAttr tattr ); 00807 TIDY_EXPORT Bool tidyAttrIsID( TidyAttr tattr ); 00808 TIDY_EXPORT Bool tidyAttrIsNAME( TidyAttr tattr ); 00809 TIDY_EXPORT Bool tidyAttrIsSUMMARY( TidyAttr tattr ); 00810 TIDY_EXPORT Bool tidyAttrIsALT( TidyAttr tattr ); 00811 TIDY_EXPORT Bool tidyAttrIsLONGDESC( TidyAttr tattr ); 00812 TIDY_EXPORT Bool tidyAttrIsUSEMAP( TidyAttr tattr ); 00813 TIDY_EXPORT Bool tidyAttrIsISMAP( TidyAttr tattr ); 00814 TIDY_EXPORT Bool tidyAttrIsLANGUAGE( TidyAttr tattr ); 00815 TIDY_EXPORT Bool tidyAttrIsTYPE( TidyAttr tattr ); 00816 TIDY_EXPORT Bool tidyAttrIsVALUE( TidyAttr tattr ); 00817 TIDY_EXPORT Bool tidyAttrIsCONTENT( TidyAttr tattr ); 00818 TIDY_EXPORT Bool tidyAttrIsTITLE( TidyAttr tattr ); 00819 TIDY_EXPORT Bool tidyAttrIsXMLNS( TidyAttr tattr ); 00820 TIDY_EXPORT Bool tidyAttrIsDATAFLD( TidyAttr tattr ); 00821 TIDY_EXPORT Bool tidyAttrIsWIDTH( TidyAttr tattr ); 00822 TIDY_EXPORT Bool tidyAttrIsHEIGHT( TidyAttr tattr ); 00823 TIDY_EXPORT Bool tidyAttrIsFOR( TidyAttr tattr ); 00824 TIDY_EXPORT Bool tidyAttrIsSELECTED( TidyAttr tattr ); 00825 TIDY_EXPORT Bool tidyAttrIsCHECKED( TidyAttr tattr ); 00826 TIDY_EXPORT Bool tidyAttrIsLANG( TidyAttr tattr ); 00827 TIDY_EXPORT Bool tidyAttrIsTARGET( TidyAttr tattr ); 00828 TIDY_EXPORT Bool tidyAttrIsHTTP_EQUIV( TidyAttr tattr ); 00829 TIDY_EXPORT Bool tidyAttrIsREL( TidyAttr tattr ); 00830 TIDY_EXPORT Bool tidyAttrIsOnMOUSEMOVE( TidyAttr tattr ); 00831 TIDY_EXPORT Bool tidyAttrIsOnMOUSEDOWN( TidyAttr tattr ); 00832 TIDY_EXPORT Bool tidyAttrIsOnMOUSEUP( TidyAttr tattr ); 00833 TIDY_EXPORT Bool tidyAttrIsOnCLICK( TidyAttr tattr ); 00834 TIDY_EXPORT Bool tidyAttrIsOnMOUSEOVER( TidyAttr tattr ); 00835 TIDY_EXPORT Bool tidyAttrIsOnMOUSEOUT( TidyAttr tattr ); 00836 TIDY_EXPORT Bool tidyAttrIsOnKEYDOWN( TidyAttr tattr ); 00837 TIDY_EXPORT Bool tidyAttrIsOnKEYUP( TidyAttr tattr ); 00838 TIDY_EXPORT Bool tidyAttrIsOnKEYPRESS( TidyAttr tattr ); 00839 TIDY_EXPORT Bool tidyAttrIsOnFOCUS( TidyAttr tattr ); 00840 TIDY_EXPORT Bool tidyAttrIsOnBLUR( TidyAttr tattr ); 00841 TIDY_EXPORT Bool tidyAttrIsBGCOLOR( TidyAttr tattr ); 00842 TIDY_EXPORT Bool tidyAttrIsLINK( TidyAttr tattr ); 00843 TIDY_EXPORT Bool tidyAttrIsALINK( TidyAttr tattr ); 00844 TIDY_EXPORT Bool tidyAttrIsVLINK( TidyAttr tattr ); 00845 TIDY_EXPORT Bool tidyAttrIsTEXT( TidyAttr tattr ); 00846 TIDY_EXPORT Bool tidyAttrIsSTYLE( TidyAttr tattr ); 00847 TIDY_EXPORT Bool tidyAttrIsABBR( TidyAttr tattr ); 00848 TIDY_EXPORT Bool tidyAttrIsCOLSPAN( TidyAttr tattr ); 00849 TIDY_EXPORT Bool tidyAttrIsROWSPAN( TidyAttr tattr ); 00850 00851 /** @} end AttrAsk group */ 00852 00853 00854 /** @defgroup AttrGet Attribute Retrieval 00855 ** 00856 ** Lookup an attribute from a given node 00857 ** @{ 00858 */ 00859 00860 00861 TIDY_EXPORT TidyAttr tidyAttrGetHREF( TidyNode tnod ); 00862 TIDY_EXPORT TidyAttr tidyAttrGetSRC( TidyNode tnod ); 00863 TIDY_EXPORT TidyAttr tidyAttrGetID( TidyNode tnod ); 00864 TIDY_EXPORT TidyAttr tidyAttrGetNAME( TidyNode tnod ); 00865 TIDY_EXPORT TidyAttr tidyAttrGetSUMMARY( TidyNode tnod ); 00866 TIDY_EXPORT TidyAttr tidyAttrGetALT( TidyNode tnod ); 00867 TIDY_EXPORT TidyAttr tidyAttrGetLONGDESC( TidyNode tnod ); 00868 TIDY_EXPORT TidyAttr tidyAttrGetUSEMAP( TidyNode tnod ); 00869 TIDY_EXPORT TidyAttr tidyAttrGetISMAP( TidyNode tnod ); 00870 TIDY_EXPORT TidyAttr tidyAttrGetLANGUAGE( TidyNode tnod ); 00871 TIDY_EXPORT TidyAttr tidyAttrGetTYPE( TidyNode tnod ); 00872 TIDY_EXPORT TidyAttr tidyAttrGetVALUE( TidyNode tnod ); 00873 TIDY_EXPORT TidyAttr tidyAttrGetCONTENT( TidyNode tnod ); 00874 TIDY_EXPORT TidyAttr tidyAttrGetTITLE( TidyNode tnod ); 00875 TIDY_EXPORT TidyAttr tidyAttrGetXMLNS( TidyNode tnod ); 00876 TIDY_EXPORT TidyAttr tidyAttrGetDATAFLD( TidyNode tnod ); 00877 TIDY_EXPORT TidyAttr tidyAttrGetWIDTH( TidyNode tnod ); 00878 TIDY_EXPORT TidyAttr tidyAttrGetHEIGHT( TidyNode tnod ); 00879 TIDY_EXPORT TidyAttr tidyAttrGetFOR( TidyNode tnod ); 00880 TIDY_EXPORT TidyAttr tidyAttrGetSELECTED( TidyNode tnod ); 00881 TIDY_EXPORT TidyAttr tidyAttrGetCHECKED( TidyNode tnod ); 00882 TIDY_EXPORT TidyAttr tidyAttrGetLANG( TidyNode tnod ); 00883 TIDY_EXPORT TidyAttr tidyAttrGetTARGET( TidyNode tnod ); 00884 TIDY_EXPORT TidyAttr tidyAttrGetHTTP_EQUIV( TidyNode tnod ); 00885 TIDY_EXPORT TidyAttr tidyAttrGetREL( TidyNode tnod ); 00886 TIDY_EXPORT TidyAttr tidyAttrGetOnMOUSEMOVE( TidyNode tnod ); 00887 TIDY_EXPORT TidyAttr tidyAttrGetOnMOUSEDOWN( TidyNode tnod ); 00888 TIDY_EXPORT TidyAttr tidyAttrGetOnMOUSEUP( TidyNode tnod ); 00889 TIDY_EXPORT TidyAttr tidyAttrGetOnCLICK( TidyNode tnod ); 00890 TIDY_EXPORT TidyAttr tidyAttrGetOnMOUSEOVER( TidyNode tnod ); 00891 TIDY_EXPORT TidyAttr tidyAttrGetOnMOUSEOUT( TidyNode tnod ); 00892 TIDY_EXPORT TidyAttr tidyAttrGetOnKEYDOWN( TidyNode tnod ); 00893 TIDY_EXPORT TidyAttr tidyAttrGetOnKEYUP( TidyNode tnod ); 00894 TIDY_EXPORT TidyAttr tidyAttrGetOnKEYPRESS( TidyNode tnod ); 00895 TIDY_EXPORT TidyAttr tidyAttrGetOnFOCUS( TidyNode tnod ); 00896 TIDY_EXPORT TidyAttr tidyAttrGetOnBLUR( TidyNode tnod ); 00897 TIDY_EXPORT TidyAttr tidyAttrGetBGCOLOR( TidyNode tnod ); 00898 TIDY_EXPORT TidyAttr tidyAttrGetLINK( TidyNode tnod ); 00899 TIDY_EXPORT TidyAttr tidyAttrGetALINK( TidyNode tnod ); 00900 TIDY_EXPORT TidyAttr tidyAttrGetVLINK( TidyNode tnod ); 00901 TIDY_EXPORT TidyAttr tidyAttrGetTEXT( TidyNode tnod ); 00902 TIDY_EXPORT TidyAttr tidyAttrGetSTYLE( TidyNode tnod ); 00903 TIDY_EXPORT TidyAttr tidyAttrGetABBR( TidyNode tnod ); 00904 TIDY_EXPORT TidyAttr tidyAttrGetCOLSPAN( TidyNode tnod ); 00905 TIDY_EXPORT TidyAttr tidyAttrGetROWSPAN( TidyNode tnod ); 00906 00907 00908 /** @} end AttrGet group */ 00909 00910 #ifdef __cplusplus 00911 } /* extern "C" */ 00912 #endif 00913 #endif /* __TIDY_H__ */ Generated on Fri Dec 13 18:27:08 2002 for HTML Tidy by ![]() |