diff --git a/include/tidyenum.h b/include/tidyenum.h index 3daee5b..76ae07d 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -282,7 +282,8 @@ extern "C" { FN(VENDOR_SPECIFIC_CHARS) \ FN(WHITE_IN_URI) \ FN(XML_DECLARATION_DETECTED) \ - FN(XML_ID_SYNTAX) + FN(XML_ID_SYNTAX) \ + FN(BLANK_TITLE_ELEMENT) /** These are report messages added by Tidy's accessibility module. diff --git a/src/language_en.h b/src/language_en.h index 8d0eb7a..f93324e 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -2055,6 +2055,7 @@ static languageDefinition language_en = { whichPluralForm_en, { { WHITE_IN_URI, 0, "%s discarding whitespace in URI reference" }, { XML_DECLARATION_DETECTED, 0, "An XML declaration was detected. Did you mean to use input-xml?" }, { XML_ID_SYNTAX, 0, "%s ID \"%s\" uses XML ID syntax" }, + { BLANK_TITLE_ELEMENT, 0, "blank 'title' element" }, /*************************************** diff --git a/src/message.c b/src/message.c index ee2e6c6..de0124b 100644 --- a/src/message.c +++ b/src/message.c @@ -372,6 +372,7 @@ static struct _dispatchTable { { WHITE_IN_URI, TidyWarning, formatAttributeReport }, { XML_DECLARATION_DETECTED, TidyWarning, formatStandard }, { XML_ID_SYNTAX, TidyWarning, formatAttributeReport }, + { BLANK_TITLE_ELEMENT, TidyWarning, formatStandard }, { APPLET_MISSING_ALT, TidyAccess, formatAccessReport }, { AREA_MISSING_ALT, TidyAccess, formatAccessReport }, @@ -819,6 +820,7 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin case NESTED_QUOTATION: case SUSPECTED_MISSING_QUOTE: case XML_DECLARATION_DETECTED: + case BLANK_TITLE_ELEMENT: return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level ); case ELEMENT_NOT_EMPTY: diff --git a/src/parser.c b/src/parser.c index 8569ed5..cda3200 100644 --- a/src/parser.c +++ b/src/parser.c @@ -4713,7 +4713,8 @@ void TY_(ParseDocument)(TidyDocImpl* doc) TY_(ParseHTML)(doc, html, IgnoreWhitespace); } - if (!TY_(FindTITLE)(doc)) + node = TY_(FindTITLE)(doc); + if (!node) { Node* head = TY_(FindHEAD)(doc); /* #72, avoid MISSING_TITLE_ELEMENT if show-body-only (but allow InsertNodeAtEnd to avoid new warning) */ @@ -4723,6 +4724,14 @@ void TY_(ParseDocument)(TidyDocImpl* doc) } TY_(InsertNodeAtEnd)(head, TY_(InferredTag)(doc, TidyTag_TITLE)); } + else if (!node->content && !showingBodyOnly(doc)) + { + /* Is #839 - warn node is blank in HTML5 */ + if (TY_(IsHTML5Mode)(doc)) + { + TY_(Report)(doc, node, NULL, BLANK_TITLE_ELEMENT); + } + } AttributeChecks(doc, &doc->root); ReplaceObsoleteElements(doc, &doc->root);