From cbd9eb79038fa33b749e0053319aee16d2c7bb99 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sat, 7 Feb 2015 13:56:13 +0100 Subject: [PATCH] Issue #155 - issue warnings unless --show-body-only yes --- src/parser.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/parser.c b/src/parser.c index 32dfaaa..5ea4a5e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -24,6 +24,13 @@ #include "charsets.h" #endif +/* + Issue #72 - Need to know to avoid error-reporting - no warning only if --show-body-only yes + Issue #132 - likewise avoid warning if showing body only + */ +#define showingBodyOnly(doc) (cfgAutoBool(doc,TidyBodyOnly) == TidyYesState) ? yes : no + + Bool TY_(CheckNodeIntegrity)(Node *node) { #ifndef NO_NODE_INTEGRITY_CHECK @@ -4359,7 +4366,10 @@ void TY_(ParseHTML)(TidyDocImpl* doc, Node *html, GetTokenMode mode) } node = TY_(InferredTag)(doc, TidyTag_BODY); - /* Issue #132 - disable inserting BODY tag warning TY_(ReportError)(doc, html, node, INSERTING_TAG ); */ + /* Issue #132 - disable inserting BODY tag warning + BUT only if NOT --show-body-only yes */ + if (!showingBodyOnly(doc)) + TY_(ReportError)(doc, html, node, INSERTING_TAG ); TY_(ConstrainVersion)(doc, ~VERS_FRAMESET); break; } @@ -4503,29 +4513,6 @@ 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 */