Skip to content

Commit 7f2a945

Browse files
authored
Merge pull request #928 from htacg/issue-729
Is #729 - Show 'warnings' in all td cases
2 parents 4153b57 + 4052718 commit 7f2a945

File tree

8 files changed

+122
-2
lines changed

8 files changed

+122
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Sample config for 729a.
2+
strict-tags-attributes: yes
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
This test case represents HTML Tidy issue #729, which describes
3+
how Tidy misbehaves when strict-tags-attributes is set to `no`,
4+
wherein Tidy complains but shouldn't.
5+
6+
Version a of this test shows proper behavior when set to `yes`.
7+
Version b of this test shows proper behavior when set to `no`.
8+
-->
9+
<!DOCTYPE html>
10+
<html>
11+
<head>
12+
<title> Alignment </title>
13+
</head>
14+
<body>
15+
16+
<table>
17+
<tr valign="bottom">
18+
<td width="50" align="center">
19+
text
20+
</td>
21+
</tr>
22+
</table>
23+
24+
</body>
25+
</html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Sample config for 729b.
2+
strict-tags-attributes: no
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
This test case represents HTML Tidy issue #729, which describes
3+
how Tidy misbehaves when strict-tags-attributes is set to `no`,
4+
wherein Tidy complains but shouldn't.
5+
6+
Version a of this test shows proper behavior when set to `yes`.
7+
Version b of this test shows proper behavior when set to `no`.
8+
-->
9+
<!DOCTYPE html>
10+
<html>
11+
<head>
12+
<title> Alignment </title>
13+
</head>
14+
<body>
15+
16+
<table>
17+
<tr valign="bottom">
18+
<td width="50" align="center">
19+
text
20+
</td>
21+
</tr>
22+
</table>
23+
24+
</body>
25+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
line 17 column 13 - Error: <tr> attribute "valign" not allowed for HTML5
2+
line 18 column 17 - Error: <td> attribute "width" not allowed for HTML5
3+
line 18 column 17 - Error: <td> attribute "align" not allowed for HTML5
4+
Info: Document content looks like HTML5
5+
Tidy found 0 warnings and 3 errors!
6+
7+
This document has errors that must be fixed before
8+
using HTML Tidy to generate a tidied up version.
9+
10+
About HTML Tidy: https://github.com/htacg/tidy-html5
11+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
12+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
13+
Latest HTML specification: http://dev.w3.org/html5/spec-author-view/
14+
Validate your HTML documents: http://validator.w3.org/nu/
15+
Lobby your company to join the W3C: http://www.w3.org/Consortium
16+
17+
Do you speak a language other than English, or a different variant of
18+
English? Consider helping us to localize HTML Tidy. For details please see
19+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
This test case represents HTML Tidy issue #729, which describes
3+
how Tidy misbehaves when strict-tags-attributes is set to `no`,
4+
wherein Tidy complains but shouldn't.
5+
6+
Version a of this test shows proper behavior when set to `yes`.
7+
Version b of this test shows proper behavior when set to `no`.
8+
-->
9+
<!DOCTYPE html>
10+
<html>
11+
<head>
12+
<title>Alignment</title>
13+
</head>
14+
<body>
15+
<table>
16+
<tr valign="bottom">
17+
<td width="50" align="center">text</td>
18+
</tr>
19+
</table>
20+
</body>
21+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
line 18 column 17 - Warning: <td> attribute "align" not allowed for HTML5
2+
line 17 column 13 - Warning: <tr> attribute "valign" not allowed for HTML5
3+
line 18 column 17 - Warning: <td> attribute "width" not allowed for HTML5
4+
line 18 column 17 - Warning: <td> attribute "align" not allowed for HTML5
5+
Info: Document content looks like HTML5
6+
Tidy found 4 warnings and 0 errors!
7+
8+
About HTML Tidy: https://github.com/htacg/tidy-html5
9+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
10+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
11+
Latest HTML specification: http://dev.w3.org/html5/spec-author-view/
12+
Validate your HTML documents: http://validator.w3.org/nu/
13+
Lobby your company to join the W3C: http://www.w3.org/Consortium
14+
15+
Do you speak a language other than English, or a different variant of
16+
English? Consider helping us to localize HTML Tidy. For details please see
17+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md

src/tidylib.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,8 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
18801880
next_attr = attval->next;
18811881

18821882
attrIsProprietary = TY_(AttributeIsProprietary)(node, attval);
1883-
attrIsMismatched = check_versions ? TY_(AttributeIsMismatched)(node, attval, doc) : no;
1883+
/* Is. #729 - always check version match if HTML5 */
1884+
attrIsMismatched = (check_versions | htmlIs5) ? TY_(AttributeIsMismatched)(node, attval, doc) : no;
18841885
/* Let the PROPRIETARY_ATTRIBUTE warning have precedence. */
18851886
if ( attrIsProprietary )
18861887
{
@@ -1889,7 +1890,15 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
18891890
}
18901891
else if ( attrIsMismatched )
18911892
{
1892-
TY_(ReportAttrError)(doc, node, attval, attrReportType);
1893+
if (htmlIs5)
1894+
{
1895+
/* Is. #729 - In html5 TidyStrictTagsAttr controls error or warn */
1896+
TY_(ReportAttrError)(doc, node, attval,
1897+
check_versions ? MISMATCHED_ATTRIBUTE_ERROR : MISMATCHED_ATTRIBUTE_WARN);
1898+
}
1899+
else
1900+
TY_(ReportAttrError)(doc, node, attval, attrReportType);
1901+
18931902
}
18941903

18951904
/* @todo: do we need a new option to drop mismatches? Or should we

0 commit comments

Comments
 (0)