/* Updates document message counts and ** compares counts to options to see if message ** display should go forward. */ static Bool UpdateCount( TidyDocImpl* doc, TidyReportLevel level ) { /* keep quiet after <ShowErrors> errors */ Bool go = ( doc->errors < cfg(doc, TidyShowErrors) ); switch ( level ) { case TidyInfo: doc->infoMessages++; break; case TidyWarning: doc->warnings++; go = go && cfgBool( doc, TidyShowWarnings ); break; case TidyConfig: doc->optionErrors++; break; case TidyAccess: doc->accessErrors++; break; case TidyError: doc->errors++; break; case TidyBadDocument: doc->docErrors++; break; case TidyFatal: /* Ack! */; break; } return go; }
void CheckTABLE( TidyDocImpl* doc, Node *node ) { AttVal* attval; Bool HasSummary = TY_(AttrGetById)(node, TidyAttr_SUMMARY) != NULL; TY_(CheckAttributes)(doc, node); /* a missing summary attribute is bad accessibility, no matter what HTML version is involved; a document without is valid */ if (cfg(doc, TidyAccessibilityCheckLevel) == 0) { if (!HasSummary) { doc->badAccess |= BA_MISSING_SUMMARY; TY_(ReportMissingAttr)( doc, node, "summary"); } } /* convert <table border> to <table border="1"> */ if ( cfgBool(doc, TidyXmlOut) && (attval = TY_(AttrGetById)(node, TidyAttr_BORDER)) ) { if (attval->value == NULL) attval->value = TY_(tmbstrdup)(doc->allocator, "1"); } }
void TY_(ReportMarkupVersion)( TidyDocImpl* doc ) { if (doc->givenDoctype) { /* todo: deal with non-ASCII characters in FPI */ message(doc, TidyInfo, STRING_DOCTYPE_GIVEN, tidyLocalizedString(STRING_DOCTYPE_GIVEN), doc->givenDoctype); } if ( ! cfgBool(doc, TidyXmlTags) ) { Bool isXhtml = doc->lexer->isvoyager; uint apparentVers; ctmbstr vers; apparentVers = TY_(ApparentVersion)( doc ); vers = TY_(HTMLVersionNameFromCode)( apparentVers, isXhtml ); if (!vers) vers = tidyLocalizedString(STRING_HTML_PROPRIETARY); message( doc, TidyInfo, STRING_CONTENT_LOOKS, tidyLocalizedString(STRING_CONTENT_LOOKS), vers ); /* Warn about missing sytem identifier (SI) in emitted doctype */ if ( TY_(WarnMissingSIInEmittedDocType)( doc ) ) message( doc, TidyInfo, STRING_NO_SYSID, "%s", tidyLocalizedString(STRING_NO_SYSID) ); } }
int tidyDocRunDiagnostics( TidyDocImpl* doc ) { Bool quiet = cfgBool( doc, TidyQuiet ); Bool force = cfgBool( doc, TidyForceOutput ); if ( !quiet ) { TY_(ReportMarkupVersion)( doc ); TY_(ReportNumWarnings)( doc ); } if ( doc->errors > 0 && !force ) TY_(NeedsAuthorIntervention)( doc ); return tidyDocStatus( doc ); }
void message( TidyDocImpl* doc, TidyReportLevel level, uint code, ctmbstr msg, ... ) { va_list args; if (level == TidyInfo && !cfgBool(doc, TidyShowInfo)) return; va_start( args, msg ); messagePos( doc, level, code, 0, 0, msg, args ); va_end( args ); }
/* choose what version to use for new doctype */ int HTMLVersion( TidyDocImpl* doc ) { int dtver = doc->lexer->doctype; uint versions = doc->lexer->versions; TidyDoctypeModes dtmode = cfg(doc, TidyDoctypeMode); Bool wantXhtml = !cfgBool(doc, TidyHtmlOut) && ( cfgBool(doc, TidyXmlOut) || doc->lexer->isvoyager ); Bool wantHtml4 = dtmode==TidyDoctypeStrict || dtmode==TidyDoctypeLoose || dtver==VERS_HTML40_STRICT || dtver==VERS_HTML40_LOOSE; /* Prefer HTML 4.x for XHTML */ if ( !wantXhtml && !wantHtml4 ) { if ( versions & VERS_HTML32 ) /* Prefer 3.2 over 2.0 */ return VERS_HTML32; if ( versions & VERS_HTML20 ) return VERS_HTML20; } if ( wantXhtml && (versions & VERS_XHTML11) ) return VERS_XHTML11; if ( versions & VERS_HTML40_STRICT ) return VERS_HTML40_STRICT; if ( versions & VERS_HTML40_LOOSE ) return VERS_HTML40_LOOSE; if ( versions & VERS_FRAMESET ) return VERS_FRAMESET; /* Still here? Try these again. */ if ( versions & VERS_HTML32 ) /* Prefer 3.2 over 2.0 */ return VERS_HTML32; if ( versions & VERS_HTML20 ) return VERS_HTML20; return VERS_UNKNOWN; }
/* Generates the string indicating the source document position for which ** Tidy has generated a message. */ static char* ReportPosition(TidyDocImpl* doc, int line, int col, char* buf, size_t count) { *buf = 0; /* Change formatting to be parsable by GNU Emacs */ if ( cfgBool(doc, TidyEmacs) && cfgStr(doc, TidyEmacsFile) ) TY_(tmbsnprintf)(buf, count, "%s:%d:%d: ", cfgStr(doc, TidyEmacsFile), line, col); else /* traditional format */ TY_(tmbsnprintf)(buf, count, tidyLocalizedString(LINE_COLUMN_STRING), line, col); return buf + TY_(tmbstrlen)( buf ); }
Bool TIDY_CALL tidyOptGetBool( TidyDoc tdoc, TidyOptionId optId ) { TidyDocImpl* impl = tidyDocToImpl( tdoc ); Bool optb = no; if ( impl ) { const TidyOptionImpl* option = TY_(getOption)( optId ); if ( option ) { optb = cfgBool( impl, optId ); } } return optb; }
int tidyDocSaveFile( TidyDocImpl* doc, ctmbstr filnam ) { int status = -ENOENT; FILE* fout = NULL; /* Don't zap input file if no output */ if ( doc->errors > 0 && cfgBool(doc, TidyWriteBack) && !cfgBool(doc, TidyForceOutput) ) status = tidyDocStatus( doc ); else fout = fopen( filnam, "wb" ); if ( fout ) { uint outenc = cfg( doc, TidyOutCharEncoding ); uint nl = cfg( doc, TidyNewline ); StreamOut* out = TY_(FileOutput)( doc, fout, outenc, nl ); status = tidyDocSaveStream( doc, out ); fclose( fout ); TidyDocFree( doc, out ); #if PRESERVE_FILE_TIMES if ( doc->filetimes.actime ) { /* set file last accessed/modified times to original values */ utime( filnam, &doc->filetimes ); TidyClearMemory( &doc->filetimes, sizeof(doc->filetimes) ); } #endif /* PRESERVFILETIMES */ } if ( status < 0 ) /* Error message! */ TY_(FileError)( doc, filnam, TidyError ); return status; }
void TY_(ReportNumWarnings)( TidyDocImpl* doc ) { if ( doc->warnings > 0 || doc->errors > 0 ) { tidy_out( doc, tidyLocalizedString(STRING_ERROR_COUNT), doc->warnings, tidyLocalizedStringN( STRING_ERROR_COUNT_WARNING, doc->warnings ), doc->errors, tidyLocalizedStringN( STRING_ERROR_COUNT_ERROR, doc->errors ) ); if ( doc->errors > cfg(doc, TidyShowErrors) || !cfgBool(doc, TidyShowWarnings) ) tidy_out( doc, " %s\n\n", tidyLocalizedString(STRING_NOT_ALL_SHOWN) ); else tidy_out( doc, "\n\n" ); } else tidy_out( doc, "%s\n\n", tidyLocalizedString(STRING_NO_ERRORS) ); }
/* public interface for finding tag by name */ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node ) { const Dict *np = NULL; if ( cfgBool(doc, TidyXmlTags) ) { node->tag = doc->tags.xml_tags; return yes; } if ( node->element && (np = lookup(doc, &doc->tags, node->element)) ) { node->tag = np; return yes; } return no; }
void CheckTABLE( TidyDocImpl* doc, Node *node ) { Bool HasSummary = no; AttVal *attval; for (attval = node->attributes; attval != null; attval = attval->next) { const Attribute* dict = CheckAttribute( doc, node, attval ); if ( dict && dict->id == TidyAttr_SUMMARY ) HasSummary = yes; } /* suppress warning for missing summary for HTML 2.0 and HTML 3.2 */ if ( cfg(doc, TidyAccessibilityCheckLevel) == 0 ) { Lexer* lexer = doc->lexer; if ( !HasSummary && lexer->doctype != VERS_HTML20 && lexer->doctype != VERS_HTML32 ) { doc->badAccess |= MISSING_SUMMARY; ReportMissingAttr( doc, node, "summary"); } } /* convert <table border> to <table border="1"> */ if ( cfgBool(doc, TidyXmlOut) && (attval = GetAttrByName(node, "border")) ) { if (attval->value == null) attval->value = tmbstrdup("1"); } /* <table height="..."> is proprietary */ if ( attval = GetAttrByName(node, "height") ) { ReportAttrError( doc, node, attval, PROPRIETARY_ATTRIBUTE ); ConstrainVersion( doc, VERS_PROPRIETARY ); } }
int tidyDocParseFile( TidyDocImpl* doc, ctmbstr filnam ) { #ifdef _WIN32 return TY_(DocParseFileWithMappedFile)( doc, filnam ); #else int status = -ENOENT; FILE* fin = fopen( filnam, "rb" ); #if PRESERVE_FILE_TIMES struct stat sbuf = {0}; /* get last modified time */ TidyClearMemory( &doc->filetimes, sizeof(doc->filetimes) ); if ( fin && cfgBool(doc,TidyKeepFileTimes) && fstat(fileno(fin), &sbuf) != -1 ) { doc->filetimes.actime = sbuf.st_atime; doc->filetimes.modtime = sbuf.st_mtime; } #endif if ( fin ) { StreamIn* in = TY_(FileInput)( doc, fin, cfg( doc, TidyInCharEncoding )); if ( !in ) { fclose( fin ); return status; } status = TY_(DocParseStream)( doc, in ); TY_(freeFileSource)(&in->source, yes); TY_(freeStreamIn)(in); } else /* Error message! */ TY_(FileError)( doc, filnam, TidyError ); return status; #endif }
void tidy_out( TidyDocImpl* doc, ctmbstr msg, ... ) { if ( !cfgBool(doc, TidyQuiet) ) { ctmbstr cp; enum { sizeBuf=2048 }; char *buf = (char *)TidyDocAlloc(doc,sizeBuf); va_list args; va_start( args, msg ); TY_(tmbvsnprintf)(buf, sizeBuf, msg, args); va_end( args ); #if !defined(NDEBUG) && defined(_MSC_VER) add_std_out(0); #endif for ( cp=buf; *cp; ++cp ) TY_(WriteChar)( *cp, doc->errout ); #if !defined(NDEBUG) && defined(_MSC_VER) add_std_out(1); #endif TidyDocFree(doc, buf); } }
int tidyDocSaveStream( TidyDocImpl* doc, StreamOut* out ) { Bool showMarkup = cfgBool( doc, TidyShowMarkup ); Bool forceOutput = cfgBool( doc, TidyForceOutput ); #if SUPPORT_UTF16_ENCODINGS Bool outputBOM = ( cfgAutoBool(doc, TidyOutputBOM) == TidyYesState ); Bool smartBOM = ( cfgAutoBool(doc, TidyOutputBOM) == TidyAutoState ); #endif Bool xmlOut = cfgBool( doc, TidyXmlOut ); Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut ); TidyTriState bodyOnly = cfgAutoBool( doc, TidyBodyOnly ); Bool dropComments = cfgBool(doc, TidyHideComments); Bool makeClean = cfgBool(doc, TidyMakeClean); Bool asciiChars = cfgBool(doc, TidyAsciiChars); Bool makeBare = cfgBool(doc, TidyMakeBare); Bool escapeCDATA = cfgBool(doc, TidyEscapeCdata); TidyAttrSortStrategy sortAttrStrat = cfg(doc, TidySortAttributes); if (escapeCDATA) TY_(ConvertCDATANodes)(doc, &doc->root); if (dropComments) TY_(DropComments)(doc, &doc->root); if (makeClean) { /* noop */ TY_(DropFontElements)(doc, &doc->root, NULL); TY_(WbrToSpace)(doc, &doc->root); } if ((makeClean && asciiChars) || makeBare) TY_(DowngradeTypography)(doc, &doc->root); if (makeBare) /* Note: no longer replaces in */ /* attribute values / non-text tokens */ TY_(NormalizeSpaces)(doc->lexer, &doc->root); else TY_(ReplacePreformattedSpaces)(doc, &doc->root); if ( sortAttrStrat != TidySortAttrNone ) TY_(SortAttributes)(&doc->root, sortAttrStrat); if ( showMarkup && (doc->errors == 0 || forceOutput) ) { #if SUPPORT_UTF16_ENCODINGS /* Output a Byte Order Mark if required */ if ( outputBOM || (doc->inputHadBOM && smartBOM) ) TY_(outBOM)( out ); #endif /* No longer necessary. No DOCTYPE == HTML 3.2, ** which gives you only the basic character entities, ** which are safe in any browser. ** if ( !TY_(FindDocType)(doc) ) ** TY_(SetOptionBool)( doc, TidyNumEntities, yes ); */ doc->docOut = out; if ( xmlOut && !xhtmlOut ) TY_(PPrintXMLTree)( doc, NORMAL, 0, &doc->root ); else if ( showBodyOnly( doc, bodyOnly ) ) TY_(PrintBody)( doc ); else TY_(PPrintTree)( doc, NORMAL, 0, &doc->root ); TY_(PFlushLine)( doc, 0 ); doc->docOut = NULL; } TY_(ResetConfigToSnapshot)( doc ); return tidyDocStatus( doc ); }
void TY_(GeneralInfo)( TidyDocImpl* doc ) { if (!cfgBool(doc, TidyShowInfo)) return; tidy_out(doc, "%s", tidyLocalizedString(TEXT_GENERAL_INFO)); tidy_out(doc, "%s", tidyLocalizedString(TEXT_GENERAL_INFO_PLEA)); }
int TY_(DocParseStream)( TidyDocImpl* doc, StreamIn* in ) { Bool xmlIn = cfgBool( doc, TidyXmlTags ); int bomEnc; assert( doc != NULL && in != NULL ); assert( doc->docIn == NULL ); doc->docIn = in; TY_(TakeConfigSnapshot)( doc ); /* Save config state */ TY_(FreeLexer)( doc ); TY_(FreeAnchors)( doc ); TY_(FreeNode)(doc, &doc->root); TidyClearMemory(&doc->root, sizeof(Node)); if (doc->givenDoctype) TidyDocFree(doc, doc->givenDoctype); doc->givenDoctype = NULL; doc->lexer = TY_(NewLexer)( doc ); /* doc->lexer->root = &doc->root; */ doc->root.line = doc->lexer->lines; doc->root.column = doc->lexer->columns; doc->inputHadBOM = no; bomEnc = TY_(ReadBOMEncoding)(in); if (bomEnc != -1) { in->encoding = bomEnc; TY_(SetOptionInt)(doc, TidyInCharEncoding, bomEnc); } #ifdef TIDY_WIN32_MLANG_SUPPORT if (in->encoding > WIN32MLANG) TY_(Win32MLangInitInputTranscoder)(in, in->encoding); #endif /* TIDY_WIN32_MLANG_SUPPORT */ /* Tidy doesn't alter the doctype for generic XML docs */ if ( xmlIn ) { TY_(ParseXMLDocument)( doc ); if ( !TY_(CheckNodeIntegrity)( &doc->root ) ) TidyPanic( doc->allocator, integrity ); } else { doc->warnings = 0; TY_(ParseDocument)( doc ); if ( !TY_(CheckNodeIntegrity)( &doc->root ) ) TidyPanic( doc->allocator, integrity ); } #ifdef TIDY_WIN32_MLANG_SUPPORT TY_(Win32MLangUninitInputTranscoder)(in); #endif /* TIDY_WIN32_MLANG_SUPPORT */ doc->docIn = NULL; return tidyDocStatus( doc ); }
int tidyDocCleanAndRepair( TidyDocImpl* doc ) { Bool word2K = cfgBool( doc, TidyWord2000 ); Bool logical = cfgBool( doc, TidyLogicalEmphasis ); Bool clean = cfgBool( doc, TidyMakeClean ); Bool dropFont = cfgBool( doc, TidyDropFontTags ); Bool htmlOut = cfgBool( doc, TidyHtmlOut ); Bool xmlOut = cfgBool( doc, TidyXmlOut ); Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut ); Bool xmlDecl = cfgBool( doc, TidyXmlDecl ); Bool tidyMark = cfgBool( doc, TidyMark ); Bool tidyXmlTags = cfgBool( doc, TidyXmlTags ); Bool wantNameAttr = cfgBool( doc, TidyAnchorAsName ); Bool mergeEmphasis = cfgBool( doc, TidyMergeEmphasis ); Node* node; if (tidyXmlTags) return tidyDocStatus( doc ); /* simplifies <b><b> ... </b> ...</b> etc. */ if ( mergeEmphasis ) TY_(NestedEmphasis)( doc, &doc->root ); /* cleans up <dir>indented text</dir> etc. */ TY_(List2BQ)( doc, &doc->root ); TY_(BQ2Div)( doc, &doc->root ); /* replaces i by em and b by strong */ if ( logical ) TY_(EmFromI)( doc, &doc->root ); if ( word2K && TY_(IsWord2000)(doc) ) { /* prune Word2000's <![if ...]> ... <![endif]> */ TY_(DropSections)( doc, &doc->root ); /* drop style & class attributes and empty p, span elements */ TY_(CleanWord2000)( doc, &doc->root ); TY_(DropEmptyElements)(doc, &doc->root); } /* replaces presentational markup by style rules */ if ( clean || dropFont ) TY_(CleanDocument)( doc ); /* Move terminating <br /> tags from out of paragraphs */ /*! Do we want to do this for all block-level elements? */ /* This is disabled due to http://tidy.sf.net/bug/681116 */ #if 0 FixBrakes( doc, TY_(FindBody)( doc )); #endif /* Reconcile http-equiv meta element with output encoding */ if (cfg( doc, TidyOutCharEncoding) != RAW #ifndef NO_NATIVE_ISO2022_SUPPORT && cfg( doc, TidyOutCharEncoding) != ISO2022 #endif ) TY_(VerifyHTTPEquiv)( doc, TY_(FindHEAD)( doc )); if ( !TY_(CheckNodeIntegrity)( &doc->root ) ) TidyPanic( doc->allocator, integrity ); /* remember given doctype for reporting */ node = TY_(FindDocType)(doc); if (node) { AttVal* fpi = TY_(GetAttrByName)(node, "PUBLIC"); if (AttrHasValue(fpi)) { if (doc->givenDoctype) TidyDocFree(doc, doc->givenDoctype); doc->givenDoctype = TY_(tmbstrdup)(doc->allocator,fpi->value); } } if ( doc->root.content ) { /* If we had XHTML input but want HTML output */ if ( htmlOut && doc->lexer->isvoyager ) { Node* node = TY_(FindDocType)(doc); /* Remove reference, but do not free */ if (node) TY_(RemoveNode)(node); } if (xhtmlOut && !htmlOut) { TY_(SetXHTMLDocType)(doc); /* TY_(FixAnchors)(doc, &doc->root, wantNameAttr, yes); */ TY_(FixXhtmlNamespace)(doc, yes); TY_(FixLanguageInformation)(doc, &doc->root, yes, yes); } else { TY_(FixDocType)(doc); TY_(FixAnchors)(doc, &doc->root, wantNameAttr, yes); TY_(FixXhtmlNamespace)(doc, no); TY_(FixLanguageInformation)(doc, &doc->root, no, yes); } if (tidyMark ) TY_(AddGenerator)(doc); } /* ensure presence of initial <?xml version="1.0"?> */ if ( xmlOut && xmlDecl ) TY_(FixXmlDecl)( doc ); return tidyDocStatus( doc ); }
void TY_(ReportError)(TidyDocImpl* doc, Node *element, Node *node, uint code) { char nodedesc[ 256 ] = {0}; char elemdesc[ 256 ] = {0}; Node* rpt = ( element ? element : node ); ctmbstr fmt = tidyLocalizedString(code); uint versionEmitted, declared, version; ctmbstr extra_string = NULL; assert( fmt != NULL ); TagToString(node, nodedesc, sizeof(nodedesc)); switch ( code ) { case MISSING_STARTTAG: case UNEXPECTED_ENDTAG: case TOO_MANY_ELEMENTS: case INSERTING_TAG: messageNode(doc, TidyWarning, code, node, fmt, node->element); break; case USING_BR_INPLACE_OF: case CANT_BE_NESTED: case PROPRIETARY_ELEMENT: case UNESCAPED_ELEMENT: case NOFRAMES_CONTENT: messageNode(doc, TidyWarning, code, node, fmt, nodedesc); break; case ELEMENT_VERS_MISMATCH_WARN: versionEmitted = doc->lexer->versionEmitted; declared = doc->lexer->doctype; version = versionEmitted == 0 ? declared : versionEmitted; extra_string = TY_(HTMLVersionNameFromCode)(version, 0); if (!extra_string) extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY); messageNode(doc, TidyWarning, code, node, fmt, nodedesc, extra_string); break; case ELEMENT_VERS_MISMATCH_ERROR: versionEmitted = doc->lexer->versionEmitted; declared = doc->lexer->doctype; version = versionEmitted == 0 ? declared : versionEmitted; extra_string = TY_(HTMLVersionNameFromCode)(version, 0); if (!extra_string) extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY); messageNode(doc, TidyError, code, node, fmt, nodedesc, extra_string); break; case MISSING_TITLE_ELEMENT: case INCONSISTENT_VERSION: case MALFORMED_DOCTYPE: case CONTENT_AFTER_BODY: case MALFORMED_COMMENT: case BAD_COMMENT_CHARS: case BAD_XML_COMMENT: case BAD_CDATA_CONTENT: case INCONSISTENT_NAMESPACE: case DOCTYPE_AFTER_TAGS: case DTYPE_NOT_UPPER_CASE: messageNode(doc, TidyWarning, code, rpt, "%s", fmt); break; case COERCE_TO_ENDTAG: case NON_MATCHING_ENDTAG: messageNode(doc, TidyWarning, code, rpt, fmt, node->element, node->element); break; case UNEXPECTED_ENDTAG_IN: case TOO_MANY_ELEMENTS_IN: messageNode(doc, TidyWarning, code, node, fmt, node->element, element->element); if (cfgBool( doc, TidyShowWarnings )) messageNode(doc, TidyInfo, PREVIOUS_LOCATION, node, tidyLocalizedString(PREVIOUS_LOCATION), element->element); break; case ENCODING_IO_CONFLICT: case MISSING_DOCTYPE: case SPACE_PRECEDING_XMLDECL: messageNode(doc, TidyWarning, code, node, "%s", fmt); break; case TRIM_EMPTY_ELEMENT: case ILLEGAL_NESTING: case UNEXPECTED_END_OF_FILE: case ELEMENT_NOT_EMPTY: TagToString(element, elemdesc, sizeof(elemdesc)); messageNode(doc, TidyWarning, code, element, fmt, elemdesc); break; case MISSING_ENDTAG_FOR: messageNode(doc, TidyWarning, code, rpt, fmt, element->element); break; case MISSING_ENDTAG_BEFORE: messageNode(doc, TidyWarning, code, rpt, fmt, element->element, nodedesc); break; case DISCARDING_UNEXPECTED: /* Force error if in a bad form, or Issue #166 - repeated <main> element */ messageNode(doc, doc->badForm ? TidyError : TidyWarning, code, node, fmt, nodedesc); break; case TAG_NOT_ALLOWED_IN: messageNode(doc, TidyWarning, code, node, fmt, nodedesc, element->element); if (cfgBool( doc, TidyShowWarnings )) messageNode(doc, TidyInfo, PREVIOUS_LOCATION, element, tidyLocalizedString(PREVIOUS_LOCATION), element->element); break; case REPLACING_UNEX_ELEMENT: TagToString(element, elemdesc, sizeof(elemdesc)); messageNode(doc, TidyWarning, code, rpt, fmt, elemdesc, nodedesc); break; case REMOVED_HTML5: messageNode(doc, TidyError, code, rpt, fmt, nodedesc); break; } }
/* ensure that config is self consistent */ void AdjustConfig( TidyDocImpl* doc ) { if ( cfgBool(doc, TidyEncloseBlockText) ) SetOptionBool( doc, TidyEncloseBodyText, yes ); if ( cfgAutoBool(doc, TidyIndentContent) == TidyNoState ) SetOptionInt( doc, TidyIndentSpaces, 0 ); /* disable wrapping */ if ( cfg(doc, TidyWrapLen) == 0 ) SetOptionInt( doc, TidyWrapLen, 0x7FFFFFFF ); /* Word 2000 needs o:p to be declared as inline */ if ( cfgBool(doc, TidyWord2000) ) { doc->config.defined_tags |= tagtype_inline; DefineTag( doc, tagtype_inline, "o:p" ); } /* #480701 disable XHTML output flag if both output-xhtml and xml input are set */ if ( cfgBool(doc, TidyXmlTags) ) SetOptionBool( doc, TidyXhtmlOut, no ); /* XHTML is written in lower case */ if ( cfgBool(doc, TidyXhtmlOut) ) { SetOptionBool( doc, TidyXmlOut, yes ); SetOptionBool( doc, TidyUpperCaseTags, no ); SetOptionBool( doc, TidyUpperCaseAttrs, no ); /* SetOptionBool( doc, TidyXmlPIs, yes ); */ } /* if XML in, then XML out */ if ( cfgBool(doc, TidyXmlTags) ) { SetOptionBool( doc, TidyXmlOut, yes ); SetOptionBool( doc, TidyXmlPIs, yes ); } /* #427837 - fix by Dave Raggett 02 Jun 01 ** generate <?xml version="1.0" encoding="iso-8859-1"?> ** if the output character encoding is Latin-1 etc. */ if ( cfg(doc, TidyOutCharEncoding) != ASCII && cfg(doc, TidyOutCharEncoding) != UTF8 && #if SUPPORT_UTF16_ENCODINGS cfg(doc, TidyOutCharEncoding) != UTF16 && cfg(doc, TidyOutCharEncoding) != UTF16BE && cfg(doc, TidyOutCharEncoding) != UTF16LE && #endif cfg(doc, TidyOutCharEncoding) != RAW && cfgBool(doc, TidyXmlOut) ) { SetOptionBool( doc, TidyXmlDecl, yes ); } /* XML requires end tags */ if ( cfgBool(doc, TidyXmlOut) ) { #if SUPPORT_UTF16_ENCODINGS /* XML requires a BOM on output if using UTF-16 encoding */ ulong enc = cfg( doc, TidyOutCharEncoding ); if ( enc == UTF16LE || enc == UTF16BE || enc == UTF16 ) SetOptionInt( doc, TidyOutputBOM, yes ); #endif SetOptionBool( doc, TidyQuoteAmpersand, yes ); SetOptionBool( doc, TidyHideEndTags, no ); } }