Skip to content

Commit 172d5a8

Browse files
authored
Merge pull request #989 from htacg/issue_464
Fixes #464. Test cases added.
2 parents 2e6ffff + 6001011 commit 172d5a8

File tree

10 files changed

+217
-4
lines changed

10 files changed

+217
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tidy-mark: no
2+
wrap: 0
3+
indent: yes
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
This test case represents HTML Tidy issue #464, which describes
3+
a descrepancy between tidy's behavior and the W3C Nu HTML
4+
checker behavior. In this case, <dl> is now allowed to contain
5+
a div as a descendent in HTML5.
6+
-->
7+
<!DOCTYPE html>
8+
<html>
9+
<head>
10+
<meta charset="utf-8">
11+
<title>Issue #464</title>
12+
</head>
13+
<body>
14+
<dl>
15+
<dt>term</dt>
16+
<dd>def</dd>
17+
<dt>another term<dt>
18+
<dd>another def</dd>
19+
</dl>
20+
<dl>
21+
<div>
22+
<dt>term</dt>
23+
<dd>def</dd>
24+
<dt>another term<dt>
25+
<dd>another def</dd>
26+
</div>
27+
</dl>
28+
</body>
29+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tidy-mark: no
2+
wrap: 0
3+
indent: yes
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
This test case represents HTML Tidy issue #464, which describes
3+
a descrepancy between tidy's behavior and the W3C Nu HTML
4+
checker behavior. In this case, <dl> is now allowed to contain
5+
a div as a descendent in HTML5.
6+
-->
7+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
8+
<html>
9+
<head>
10+
<meta charset="utf-8">
11+
<title>Issue #464</title>
12+
</head>
13+
<body>
14+
<dl>
15+
<dt>term</dt>
16+
<dd>def</dd>
17+
<dt>another term<dt>
18+
<dd>another def</dd>
19+
</dl>
20+
<dl>
21+
<div>
22+
<dt>term</dt>
23+
<dd>def</dd>
24+
<dt>another term<dt>
25+
<dd>another def</dd>
26+
</div>
27+
</dl>
28+
</body>
29+
</html>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!--
2+
This test case represents HTML Tidy issue #464, which describes
3+
a descrepancy between tidy's behavior and the W3C Nu HTML
4+
checker behavior. In this case, <dl> is now allowed to contain
5+
a div as a descendent in HTML5.
6+
-->
7+
<!DOCTYPE html>
8+
<html>
9+
<head>
10+
<meta charset="utf-8">
11+
<title>
12+
Issue #464
13+
</title>
14+
</head>
15+
<body>
16+
<dl>
17+
<dt>
18+
term
19+
</dt>
20+
<dd>
21+
def
22+
</dd>
23+
<dt>
24+
another term
25+
</dt>
26+
<dd>
27+
another def
28+
</dd>
29+
</dl>
30+
<dl>
31+
<div>
32+
<dt>
33+
term
34+
</dt>
35+
<dd>
36+
def
37+
</dd>
38+
<dt>
39+
another term
40+
</dt>
41+
<dd>
42+
another def
43+
</dd>
44+
</div>
45+
</dl>
46+
</body>
47+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
line 17 column 21 - Warning: trimming empty <dt>
2+
line 24 column 21 - Warning: trimming empty <dt>
3+
Info: Document content looks like HTML5
4+
Tidy found 2 warnings and 0 errors!
5+
6+
One or more empty elements were present in the source document but
7+
dropped on output. If these elements are necessary or you don't want
8+
this behavior, then consider setting the option "drop-empty-elements"
9+
to no.
10+
11+
About HTML Tidy: https://github.com/htacg/tidy-html5
12+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
13+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
14+
Latest HTML specification: https://html.spec.whatwg.org/multipage/
15+
Validate your HTML documents: https://validator.w3.org/nu/
16+
Lobby your company to join the W3C: https://www.w3.org/Consortium
17+
18+
Do you speak a language other than English, or a different variant of
19+
English? Consider helping us to localize HTML Tidy. For details please see
20+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!--
2+
This test case represents HTML Tidy issue #464, which describes
3+
a descrepancy between tidy's behavior and the W3C Nu HTML
4+
checker behavior. In this case, <dl> is now allowed to contain
5+
a div as a descendent in HTML5.
6+
-->
7+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
8+
"http://www.w3.org/TR/html4/strict.dtd">
9+
<html>
10+
<head>
11+
<meta charset="utf-8">
12+
<title>
13+
Issue #464
14+
</title>
15+
</head>
16+
<body>
17+
<dl>
18+
<dt>
19+
term
20+
</dt>
21+
<dd>
22+
def
23+
</dd>
24+
<dt>
25+
another term
26+
</dt>
27+
<dd>
28+
another def
29+
</dd>
30+
</dl>
31+
<dl>
32+
<dd>
33+
<div>
34+
<dl>
35+
<dt>
36+
term
37+
</dt>
38+
<dd>
39+
def
40+
</dd>
41+
<dt>
42+
another term
43+
</dt>
44+
<dd>
45+
another def
46+
</dd>
47+
</dl>
48+
</div>
49+
</dd>
50+
</dl>
51+
</body>
52+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
line 21 column 4 - Warning: missing <dd>
2+
line 21 column 4 - Warning: missing </div> before <dt>
3+
line 22 column 5 - Warning: inserting implicit <dl>
4+
line 22 column 5 - Warning: missing </dl> before </div>
5+
line 17 column 21 - Warning: trimming empty <dt>
6+
line 24 column 21 - Warning: trimming empty <dt>
7+
Info: Doctype given is "-//W3C//DTD HTML 4.01//EN"
8+
Info: Document content looks like HTML Proprietary
9+
Tidy found 6 warnings and 0 errors!
10+
11+
One or more empty elements were present in the source document but
12+
dropped on output. If these elements are necessary or you don't want
13+
this behavior, then consider setting the option "drop-empty-elements"
14+
to no.
15+
16+
About HTML Tidy: https://github.com/htacg/tidy-html5
17+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
18+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
19+
Latest HTML specification: https://html.spec.whatwg.org/multipage/
20+
Validate your HTML documents: https://validator.w3.org/nu/
21+
Lobby your company to join the W3C: https://www.w3.org/Consortium
22+
23+
Do you speak a language other than English, or a different variant of
24+
English? Consider helping us to localize HTML Tidy. For details please see
25+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md

src/parser.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,11 @@ Node* TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
11151115
return NULL;
11161116
}
11171117

1118+
if ( nodeIsDIV(element) && nodeIsDL(element->parent) && TY_(IsHTML5Mode)(doc) )
1119+
{
1120+
return TY_(ParseDefList)(doc, element, mode);
1121+
}
1122+
11181123
if ( nodeIsFORM(element) &&
11191124
DescendantOf(element, TidyTag_FORM) )
11201125
TY_(Report)(doc, element, NULL, ILLEGAL_NESTING );
@@ -1332,7 +1337,7 @@ Node* TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
13321337
TY_(FreeNode)( doc, node );
13331338
continue;
13341339
}
1335-
1340+
13361341
/* #427671 - Fix by Randy Waki - 10 Aug 00 */
13371342
/*
13381343
If an LI contains an illegal FRAME, FRAMESET, OPTGROUP, or OPTION
@@ -2311,7 +2316,7 @@ Node* TY_(ParseDefList)( TidyDocImpl* doc, Node *list, GetTokenMode mode )
23112316
}
23122317
}
23132318

2314-
if ( !(nodeIsDT(node) || nodeIsDD(node)) )
2319+
if ( !( nodeIsDT(node) || nodeIsDD(node) || ( nodeIsDIV(node) && TY_(IsHTML5Mode)(doc) ) ) )
23152320
{
23162321
TY_(UngetToken)( doc );
23172322

@@ -2340,7 +2345,7 @@ Node* TY_(ParseDefList)( TidyDocImpl* doc, Node *list, GetTokenMode mode )
23402345
continue;
23412346
}
23422347

2343-
/* node should be <DT> or <DD>*/
2348+
/* node should be <DT> or <DD> or <DIV>*/
23442349
TY_(InsertNodeAtEnd)(list, node);
23452350
{
23462351
TidyParserMemory memory = {0};

src/parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ typedef struct _TidyParserMemory
5656
int reentry_state; /**< State to set during re-entry. Defined locally in each parser. */
5757
GetTokenMode mode; /**< The caller will peek at this value to get the correct mode. */
5858
int register_1; /**< Local variable storage. */
59-
int register_2; /**< Local variable storage. */
59+
int register_2; /**< Local variable storage. */
6060
} TidyParserMemory;
6161

6262

0 commit comments

Comments
 (0)