Merge pull request #930 from htacg/issue-839-2

Is. #839 -  new message for 'blank' title
This commit is contained in:
Jim Derry 2021-06-30 11:21:19 -04:00 committed by GitHub
commit 39c1e69be3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 70 additions and 7 deletions

View file

@ -282,7 +282,8 @@ extern "C" {
FN(VENDOR_SPECIFIC_CHARS) \ FN(VENDOR_SPECIFIC_CHARS) \
FN(WHITE_IN_URI) \ FN(WHITE_IN_URI) \
FN(XML_DECLARATION_DETECTED) \ 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. /** These are report messages added by Tidy's accessibility module.

View file

@ -0,0 +1,12 @@
<!--
This test case represents HTML Tidy issue #839, which describes
a descrepancy between tidy's behavior and the W3C Nu HTML
checker behavior. Tidy has historically allowed empty <title>
elements, but this is not allowed by HTML5, and is flagged by
the Nu checker. Because a <title> is required by HTML5, it
would be even worse for HTML Tidy to remove this element, and
so Tidy will now provide a warning if the title element is
empty. It is assumed the HTML author will add a title as well
as addressing other warnings.
-->
<!DOCTYPE html><title></title>

View file

@ -0,0 +1,19 @@
<!--
This test case represents HTML Tidy issue #839, which describes
a descrepancy between tidy's behavior and the W3C Nu HTML
checker behavior. Tidy has historically allowed empty <title>
elements, but this is not allowed by HTML5, and is flagged by
the Nu checker. Because a <title> is required by HTML5, it
would be even worse for HTML Tidy to remove this element, and
so Tidy will now provide a warning if the title element is
empty. It is assumed the HTML author will add a title as well
as addressing other warnings.
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>

View file

@ -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

View file

@ -8,10 +8,11 @@ line 7 column 1 - Warning: <base> isn't allowed in <b> elements
line 6 column 1 - Info: <b> previously mentioned line 6 column 1 - Info: <b> previously mentioned
line 6 column 1 - Warning: missing </b> before <hr> line 6 column 1 - Warning: missing </b> before <hr>
line 3 column 1 - Warning: content occurs after end of body 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 <marquee> line 3 column 1 - Warning: trimming empty <marquee>
line 6 column 1 - Warning: trimming empty <b> line 6 column 1 - Warning: trimming empty <b>
Info: Document content looks like HTML5 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 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 dropped on output. If these elements are necessary or you don't want

View file

@ -1,7 +1,8 @@
line 1 column 1 - Warning: missing <!DOCTYPE> declaration line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 7 column 1 - Warning: discarding unexpected XML declaration line 7 column 1 - Warning: discarding unexpected XML declaration
line 3 column 1 - Warning: blank 'title' element
Info: Document content looks like HTML5 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 About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues Bug reports and comments: https://github.com/htacg/tidy-html5/issues

View file

@ -3,9 +3,10 @@ line 7 column 1 - Warning: missing </font> before <ol>
line 8 column 9 - Warning: inserting implicit <font> line 8 column 9 - Warning: inserting implicit <font>
line 9 column 10 - Warning: inserting implicit <font> line 9 column 10 - Warning: inserting implicit <font>
line 10 column 10 - Warning: inserting implicit <font> line 10 column 10 - Warning: inserting implicit <font>
line 3 column 1 - Warning: blank 'title' element
line 7 column 1 - Warning: trimming empty <font> line 7 column 1 - Warning: trimming empty <font>
Info: Document content looks like HTML5 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 You are recommended to use CSS to specify the font and
properties such as its size and color. This will reduce properties such as its size and color. This will reduce

View file

@ -1,11 +1,12 @@
line 1 column 1 - Warning: missing <!DOCTYPE> declaration line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 8 column 1 - Warning: discarding unexpected <frame> line 8 column 1 - Warning: discarding unexpected <frame>
line 10 column 1 - Warning: missing </noframes> line 10 column 1 - Warning: missing </noframes>
line 3 column 3 - Warning: blank 'title' element
line 5 column 1 - Warning: <frameset> element removed from HTML5 line 5 column 1 - Warning: <frameset> element removed from HTML5
line 6 column 3 - Warning: <frame> element removed from HTML5 line 6 column 3 - Warning: <frame> element removed from HTML5
line 10 column 1 - Warning: <noframes> element removed from HTML5 line 10 column 1 - Warning: <noframes> element removed from HTML5
Info: Document content looks like 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 About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues Bug reports and comments: https://github.com/htacg/tidy-html5/issues

View file

@ -5,9 +5,10 @@ line 6 column 14 - Error: <spanstyle> is not recognized!
line 6 column 14 - Warning: discarding unexpected <spanstyle> line 6 column 14 - Warning: discarding unexpected <spanstyle>
line 6 column 44 - Warning: discarding unexpected </span> line 6 column 44 - Warning: discarding unexpected </span>
line 6 column 52 - Info: value for attribute "href" missing quote marks 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 line 6 column 52 - Warning: <a> illegal characters found in URI
Info: Document content looks like HTML5 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 This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version. using HTML Tidy to generate a tidied up version.

View file

@ -2055,6 +2055,7 @@ static languageDefinition language_en = { whichPluralForm_en, {
{ WHITE_IN_URI, 0, "%s discarding whitespace in URI reference" }, { 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_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" }, { XML_ID_SYNTAX, 0, "%s ID \"%s\" uses XML ID syntax" },
{ BLANK_TITLE_ELEMENT, 0, "blank 'title' element" },
/*************************************** /***************************************

View file

@ -372,6 +372,7 @@ static struct _dispatchTable {
{ WHITE_IN_URI, TidyWarning, formatAttributeReport }, { WHITE_IN_URI, TidyWarning, formatAttributeReport },
{ XML_DECLARATION_DETECTED, TidyWarning, formatStandard }, { XML_DECLARATION_DETECTED, TidyWarning, formatStandard },
{ XML_ID_SYNTAX, TidyWarning, formatAttributeReport }, { XML_ID_SYNTAX, TidyWarning, formatAttributeReport },
{ BLANK_TITLE_ELEMENT, TidyWarning, formatStandard },
{ APPLET_MISSING_ALT, TidyAccess, formatAccessReport }, { APPLET_MISSING_ALT, TidyAccess, formatAccessReport },
{ AREA_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 NESTED_QUOTATION:
case SUSPECTED_MISSING_QUOTE: case SUSPECTED_MISSING_QUOTE:
case XML_DECLARATION_DETECTED: case XML_DECLARATION_DETECTED:
case BLANK_TITLE_ELEMENT:
return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level ); return TY_(tidyMessageCreateWithNode)(doc, rpt, code, level );
case ELEMENT_NOT_EMPTY: case ELEMENT_NOT_EMPTY:

View file

@ -4713,7 +4713,8 @@ void TY_(ParseDocument)(TidyDocImpl* doc)
TY_(ParseHTML)(doc, html, IgnoreWhitespace); TY_(ParseHTML)(doc, html, IgnoreWhitespace);
} }
if (!TY_(FindTITLE)(doc)) node = TY_(FindTITLE)(doc);
if (!node)
{ {
Node* head = TY_(FindHEAD)(doc); Node* head = TY_(FindHEAD)(doc);
/* #72, avoid MISSING_TITLE_ELEMENT if show-body-only (but allow InsertNodeAtEnd to avoid new warning) */ /* #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)); 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); AttributeChecks(doc, &doc->root);
ReplaceObsoleteElements(doc, &doc->root); ReplaceObsoleteElements(doc, &doc->root);