diff --git a/include/tidyenum.h b/include/tidyenum.h index 01430f7..5d06a06 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/regression_testing/cases/github-cases/case-839@1.html b/regression_testing/cases/github-cases/case-839@1.html new file mode 100755 index 0000000..0f962c8 --- /dev/null +++ b/regression_testing/cases/github-cases/case-839@1.html @@ -0,0 +1,12 @@ + + diff --git a/regression_testing/cases/github-expects/case-839.html b/regression_testing/cases/github-expects/case-839.html new file mode 100644 index 0000000..d32bc5c --- /dev/null +++ b/regression_testing/cases/github-expects/case-839.html @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/regression_testing/cases/github-expects/case-839.txt b/regression_testing/cases/github-expects/case-839.txt new file mode 100644 index 0000000..7a8a19c --- /dev/null +++ b/regression_testing/cases/github-expects/case-839.txt @@ -0,0 +1,14 @@ +line 12 column 16 - Warning: blank 'title' element +Info: Document content looks like HTML5 +Tidy found 1 warning and 0 errors! + +About HTML Tidy: https://github.com/htacg/tidy-html5 +Bug reports and comments: https://github.com/htacg/tidy-html5/issues +Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/ +Latest HTML specification: http://dev.w3.org/html5/spec-author-view/ +Validate your HTML documents: http://validator.w3.org/nu/ +Lobby your company to join the W3C: http://www.w3.org/Consortium + +Do you speak a language other than English, or a different variant of +English? Consider helping us to localize HTML Tidy. For details please see +https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md diff --git a/regression_testing/cases/legacy-expects/case-1062511.txt b/regression_testing/cases/legacy-expects/case-1062511.txt index f2b2729..fbcacd2 100644 --- a/regression_testing/cases/legacy-expects/case-1062511.txt +++ b/regression_testing/cases/legacy-expects/case-1062511.txt @@ -8,10 +8,11 @@ line 7 column 1 - Warning: isn't allowed in elements line 6 column 1 - Info: previously mentioned line 6 column 1 - Warning: missing before
line 3 column 1 - Warning: content occurs after end of body +line 2 column 1 - Warning: blank 'title' element line 3 column 1 - Warning: trimming empty line 6 column 1 - Warning: trimming empty Info: Document content looks like HTML5 -Tidy found 11 warnings and 0 errors! +Tidy found 12 warnings and 0 errors! One or more empty elements were present in the source document but dropped on output. If these elements are necessary or you don't want diff --git a/regression_testing/cases/legacy-expects/case-1674502.txt b/regression_testing/cases/legacy-expects/case-1674502.txt index e2511f8..0eb188e 100644 --- a/regression_testing/cases/legacy-expects/case-1674502.txt +++ b/regression_testing/cases/legacy-expects/case-1674502.txt @@ -1,7 +1,8 @@ line 1 column 1 - Warning: missing declaration line 7 column 1 - Warning: discarding unexpected XML declaration +line 3 column 1 - Warning: blank 'title' element Info: Document content looks like HTML5 -Tidy found 2 warnings and 0 errors! +Tidy found 3 warnings and 0 errors! About HTML Tidy: https://github.com/htacg/tidy-html5 Bug reports and comments: https://github.com/htacg/tidy-html5/issues diff --git a/regression_testing/cases/legacy-expects/case-1773932.txt b/regression_testing/cases/legacy-expects/case-1773932.txt index 008c5e0..626c84f 100644 --- a/regression_testing/cases/legacy-expects/case-1773932.txt +++ b/regression_testing/cases/legacy-expects/case-1773932.txt @@ -3,9 +3,10 @@ line 7 column 1 - Warning: missing before
    line 8 column 9 - Warning: inserting implicit line 9 column 10 - Warning: inserting implicit line 10 column 10 - Warning: inserting implicit +line 3 column 1 - Warning: blank 'title' element line 7 column 1 - Warning: trimming empty Info: Document content looks like HTML5 -Tidy found 6 warnings and 0 errors! +Tidy found 7 warnings and 0 errors! You are recommended to use CSS to specify the font and properties such as its size and color. This will reduce diff --git a/regression_testing/cases/legacy-expects/case-427675.txt b/regression_testing/cases/legacy-expects/case-427675.txt index bd4751f..98b63c2 100644 --- a/regression_testing/cases/legacy-expects/case-427675.txt +++ b/regression_testing/cases/legacy-expects/case-427675.txt @@ -1,11 +1,12 @@ line 1 column 1 - Warning: missing declaration line 8 column 1 - Warning: discarding unexpected line 10 column 1 - Warning: missing +line 3 column 3 - Warning: blank 'title' element line 5 column 1 - Warning: element removed from HTML5 line 6 column 3 - Warning: element removed from HTML5 line 10 column 1 - Warning: element removed from HTML5 Info: Document content looks like HTML5 -Tidy found 6 warnings and 0 errors! +Tidy found 7 warnings and 0 errors! About HTML Tidy: https://github.com/htacg/tidy-html5 Bug reports and comments: https://github.com/htacg/tidy-html5/issues diff --git a/regression_testing/cases/legacy-expects/case-427676.txt b/regression_testing/cases/legacy-expects/case-427676.txt index d391525..2dd11ad 100644 --- a/regression_testing/cases/legacy-expects/case-427676.txt +++ b/regression_testing/cases/legacy-expects/case-427676.txt @@ -5,9 +5,10 @@ line 6 column 14 - Error: <spanstyle> is not recognized! line 6 column 14 - Warning: discarding unexpected <spanstyle> line 6 column 44 - Warning: discarding unexpected </span> line 6 column 52 - Info: value for attribute "href" missing quote marks +line 3 column 3 - Warning: blank 'title' element line 6 column 52 - Warning: <a> illegal characters found in URI Info: Document content looks like HTML5 -Tidy found 6 warnings and 1 error! +Tidy found 7 warnings and 1 error! This document has errors that must be fixed before using HTML Tidy to generate a tidied up version. diff --git a/src/language_en.h b/src/language_en.h index a77433c..5171bd0 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 9f89f3e..8f6b1fb 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);