#72, avoid showing some warnings when show-body-only.

This commit is contained in:
Jim Derry 2015-02-01 21:16:17 +08:00
parent e6930feb02
commit 3c721d8bf8

View file

@ -4319,6 +4319,29 @@ static void AttributeChecks(TidyDocImpl* doc, Node* node)
}
}
/*
Need to know to avoid error-reporting
*/
Bool showingBodyOnly( TidyDocImpl* doc)
{
Node* node;
TidyTriState bodyOnly = doc->config.value[TidyBodyOnly].v;
switch( bodyOnly )
{
case TidyNoState:
return no;
case TidyYesState:
return yes;
default:
node = TY_(FindBody)( doc );
if (node && node->implicit )
return yes;
}
return yes;
}
/*
HTML is the top level element
*/
@ -4414,7 +4437,8 @@ void TY_(ParseDocument)(TidyDocImpl* doc)
else
html = node;
if (!TY_(FindDocType)(doc))
/* #72, avoid MISSING_DOCTYPE if show-body-only. */
if (!TY_(FindDocType)(doc) && !showingBodyOnly(doc))
TY_(ReportError)(doc, NULL, NULL, MISSING_DOCTYPE);
TY_(InsertNodeAtEnd)( &doc->root, html);
@ -4439,7 +4463,11 @@ void TY_(ParseDocument)(TidyDocImpl* doc)
if (!TY_(FindTITLE)(doc))
{
Node* head = TY_(FindHEAD)(doc);
TY_(ReportError)(doc, head, NULL, MISSING_TITLE_ELEMENT);
/* #72, avoid MISSING_TITLE_ELEMENT if show-body-only (but allow InsertNodeAtEnd to avoid new warning) */
if (!showingBodyOnly(doc))
{
TY_(ReportError)(doc, head, NULL, MISSING_TITLE_ELEMENT);
}
TY_(InsertNodeAtEnd)(head, TY_(InferredTag)(doc, TidyTag_TITLE));
}
@ -4625,6 +4653,7 @@ void TY_(ParseXMLDocument)(TidyDocImpl* doc)
TY_(FixXmlDecl)( doc );
}
/*
* local variables:
* mode: c