Merge pull request #928 from htacg/issue-729

Is #729 - Show 'warnings' in all td cases
This commit is contained in:
Jim Derry 2021-06-30 10:21:59 -04:00 committed by GitHub
commit 7f2a945337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 122 additions and 2 deletions

View file

@ -0,0 +1,2 @@
# Sample config for 729a.
strict-tags-attributes: yes

View file

@ -0,0 +1,25 @@
<!--
This test case represents HTML Tidy issue #729, which describes
how Tidy misbehaves when strict-tags-attributes is set to `no`,
wherein Tidy complains but shouldn't.
Version a of this test shows proper behavior when set to `yes`.
Version b of this test shows proper behavior when set to `no`.
-->
<!DOCTYPE html>
<html>
<head>
<title> Alignment </title>
</head>
<body>
<table>
<tr valign="bottom">
<td width="50" align="center">
text
</td>
</tr>
</table>
</body>
</html>

View file

@ -0,0 +1,2 @@
# Sample config for 729b.
strict-tags-attributes: no

View file

@ -0,0 +1,25 @@
<!--
This test case represents HTML Tidy issue #729, which describes
how Tidy misbehaves when strict-tags-attributes is set to `no`,
wherein Tidy complains but shouldn't.
Version a of this test shows proper behavior when set to `yes`.
Version b of this test shows proper behavior when set to `no`.
-->
<!DOCTYPE html>
<html>
<head>
<title> Alignment </title>
</head>
<body>
<table>
<tr valign="bottom">
<td width="50" align="center">
text
</td>
</tr>
</table>
</body>
</html>

View file

@ -0,0 +1,19 @@
line 17 column 13 - Error: <tr> attribute "valign" not allowed for HTML5
line 18 column 17 - Error: <td> attribute "width" not allowed for HTML5
line 18 column 17 - Error: <td> attribute "align" not allowed for HTML5
Info: Document content looks like HTML5
Tidy found 0 warnings and 3 errors!
This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version.
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

@ -0,0 +1,21 @@
<!--
This test case represents HTML Tidy issue #729, which describes
how Tidy misbehaves when strict-tags-attributes is set to `no`,
wherein Tidy complains but shouldn't.
Version a of this test shows proper behavior when set to `yes`.
Version b of this test shows proper behavior when set to `no`.
-->
<!DOCTYPE html>
<html>
<head>
<title>Alignment</title>
</head>
<body>
<table>
<tr valign="bottom">
<td width="50" align="center">text</td>
</tr>
</table>
</body>
</html>

View file

@ -0,0 +1,17 @@
line 18 column 17 - Warning: <td> attribute "align" not allowed for HTML5
line 17 column 13 - Warning: <tr> attribute "valign" not allowed for HTML5
line 18 column 17 - Warning: <td> attribute "width" not allowed for HTML5
line 18 column 17 - Warning: <td> attribute "align" not allowed for HTML5
Info: Document content looks like HTML5
Tidy found 4 warnings 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

@ -1880,7 +1880,8 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
next_attr = attval->next;
attrIsProprietary = TY_(AttributeIsProprietary)(node, attval);
attrIsMismatched = check_versions ? TY_(AttributeIsMismatched)(node, attval, doc) : no;
/* Is. #729 - always check version match if HTML5 */
attrIsMismatched = (check_versions | htmlIs5) ? TY_(AttributeIsMismatched)(node, attval, doc) : no;
/* Let the PROPRIETARY_ATTRIBUTE warning have precedence. */
if ( attrIsProprietary )
{
@ -1889,7 +1890,15 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
}
else if ( attrIsMismatched )
{
if (htmlIs5)
{
/* Is. #729 - In html5 TidyStrictTagsAttr controls error or warn */
TY_(ReportAttrError)(doc, node, attval,
check_versions ? MISMATCHED_ATTRIBUTE_ERROR : MISMATCHED_ATTRIBUTE_WARN);
}
else
TY_(ReportAttrError)(doc, node, attval, attrReportType);
}
/* @todo: do we need a new option to drop mismatches? Or should we