void CheckHTML( TidyDocImpl* doc, Node *node ) { AttVal *attval; AttVal *xmlns; xmlns = GetAttrByName(node, "xmlns"); if ( xmlns != null && tmbstrcmp(xmlns->value, XHTML_NAMESPACE) == 0 ) { Bool htmlOut = cfgBool( doc, TidyHtmlOut ); doc->lexer->isvoyager = yes; /* Unless plain HTML */ SetOptionBool( doc, TidyXhtmlOut, !htmlOut ); /* is specified, output*/ SetOptionBool( doc, TidyXmlOut, !htmlOut ); /* will be XHTML. */ /* adjust other config options, just as in config.c */ if ( !htmlOut ) { SetOptionBool( doc, TidyUpperCaseTags, no ); SetOptionBool( doc, TidyUpperCaseAttrs, no ); } } for (attval = node->attributes; attval != null; attval = attval->next) { CheckAttribute( doc, node, attval ); } }
Bool ParseBool( TidyDocImpl* doc, const TidyOptionImpl* entry ) { ulong flag = 0; Bool status = ParseTriState( TidyNoState, doc, entry, &flag ); if ( status ) SetOptionBool( doc, entry->id, flag != 0 ); return status; }
/* 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 ); } }