Skip to content

Commit 1ca8e21

Browse files
committed
Fixes #525.
Naked groups of LI in HTML5 mode will now have an inferred UL applied to them consistent with HTML4 and earlier modes. Test case added. Note that three regressions were updated in favor of this corrected behavior.
1 parent a46949f commit 1ca8e21

File tree

11 files changed

+109
-25
lines changed

11 files changed

+109
-25
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sort-attributes: none
2+
priority-attributes: id, style, class
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 #525, which claims
3+
that in HTML5 mode, LI tags are not enclosed in UL autiomatically.
4+
-->
5+
<!DOCTYPE html>
6+
<html>
7+
<head>
8+
<title>Issue 525 – Infer UL around LI</title>
9+
</head>
10+
<body>
11+
<br>
12+
<li>Bachelor of Arts</li>
13+
<li>Bachelor of Biomedical Science</li>
14+
<li>Bachelor of Commerce</li>
15+
<li>Bachelor of Commerce Specialist</li>
16+
<li>Bachelor of Computer Science</li>
17+
<li>Bachelor of Education (Honours)</li>
18+
<li>Bachelor of Engineering (Honours)</li>
19+
<li>Bachelor of Global Studies</li>
20+
<li>Bachelor of Information Technology</li>
21+
<li>Bachelor of Laws (Honours)</li>
22+
<li>Bachelor of Music.</li>
23+
<br>
24+
</body>
25+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!--
2+
This test case represents HTML Tidy issue #525, which claims
3+
that in HTML5 mode, LI tags are not enclosed in UL autiomatically.
4+
-->
5+
<!DOCTYPE html>
6+
<html>
7+
<head>
8+
<title>Issue 525 – Infer UL around LI</title>
9+
</head>
10+
<body>
11+
<br>
12+
<ul>
13+
<li>Bachelor of Arts</li>
14+
<li>Bachelor of Biomedical Science</li>
15+
<li>Bachelor of Commerce</li>
16+
<li>Bachelor of Commerce Specialist</li>
17+
<li>Bachelor of Computer Science</li>
18+
<li>Bachelor of Education (Honours)</li>
19+
<li>Bachelor of Engineering (Honours)</li>
20+
<li>Bachelor of Global Studies</li>
21+
<li>Bachelor of Information Technology</li>
22+
<li>Bachelor of Laws (Honours)</li>
23+
<li>Bachelor of Music.</li>
24+
<br></ul>
25+
</body>
26+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
line 12 column 1 - Warning: <li> isn't allowed in <body> elements
2+
line 10 column 1 - Info: <body> previously mentioned
3+
line 12 column 1 - Warning: inserting implicit <ul>
4+
line 24 column 1 - Warning: discarding unexpected </body>
5+
line 25 column 1 - Warning: discarding unexpected </html>
6+
line 12 column 1 - Warning: missing </ul>
7+
Info: Document content looks like HTML5
8+
Tidy found 5 warnings and 0 errors!
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: https://html.spec.whatwg.org/multipage/
14+
Validate your HTML documents: https://validator.w3.org/nu/
15+
Lobby your company to join the W3C: https://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

regression_testing/cases/legacy-expects/case-1410061a.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
restricted spaces. The Compact E.O.S. can be extended at the back
1515
with a table for film processing from a darkroom.<br>
1616
<br>
17-
<li>capacity: up to 240 films per hour (medium format)<br>
1817
<ul class="c1">
18+
<li>capacity: up to 240 films per hour (medium format)<br></li>
1919
<li>cassette cycle time: 15 s<br></li>
2020
<li>film formats: 18 x24cm to 35 x 43cm<br></li>
2121
<li>film storage magazines that can be used: Curix, Scopix<br></li>
@@ -33,6 +33,5 @@
3333
possible service messages<br>
3434
<br></li>
3535
</ul>
36-
</li>
3736
</body>
3837
</html>

regression_testing/cases/legacy-expects/case-1410061a.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
2+
line 6 column 319 - Warning: <li> isn't allowed in <body> elements
3+
line 5 column 1 - Info: <body> previously mentioned
4+
line 6 column 319 - Warning: inserting implicit <ul>
25
line 6 column 319 - Info: missing optional end tag </li>
3-
line 6 column 378 - Warning: inserting implicit <ul>
46
line 6 column 378 - Info: missing optional end tag </li>
57
line 6 column 412 - Info: missing optional end tag </li>
68
line 6 column 456 - Info: missing optional end tag </li>
@@ -10,7 +12,7 @@ line 6 column 665 - Info: missing optional end tag </li>
1012
line 6 column 690 - Info: missing optional end tag </li>
1113
line 6 column 754 - Info: missing optional end tag </li>
1214
line 6 column 842 - Info: missing optional end tag </li>
13-
line 6 column 378 - Warning: missing </ul> before </li>
15+
line 6 column 1041 - Warning: discarding unexpected </li>
1416
line 6 column 1046 - Warning: discarding unexpected </li>
1517
line 6 column 1051 - Warning: discarding unexpected </li>
1618
line 6 column 1056 - Warning: discarding unexpected </li>
@@ -20,8 +22,11 @@ line 6 column 1071 - Warning: discarding unexpected </li>
2022
line 6 column 1076 - Warning: discarding unexpected </li>
2123
line 6 column 1081 - Warning: discarding unexpected </li>
2224
line 6 column 1086 - Warning: discarding unexpected </li>
25+
line 7 column 1 - Warning: discarding unexpected </body>
26+
line 8 column 1 - Warning: discarding unexpected </html>
27+
line 6 column 319 - Warning: missing </ul>
2328
Info: Document content looks like HTML5
24-
Tidy found 12 warnings and 0 errors!
29+
Tidy found 16 warnings and 0 errors!
2530

2631
About HTML Tidy: https://github.com/htacg/tidy-html5
2732
Bug reports and comments: https://github.com/htacg/tidy-html5/issues

regression_testing/cases/legacy-expects/case-1410061b.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
<title>1410061 - issue 1 inferred ul</title>
55

66
<style type="text/css">
7-
span.c1 {font-size: 200%}
7+
span.c2 {font-size: 200%}
8+
ul.c1 {padding-left: 2ex; margin-left: 0ex; margin-top: 0ex; margin-bottom: 0ex}
89
</style>
910
</head>
1011
<body>
11-
<b><span class="c1">In bold</span></b>
12-
<li><span class="c1">Not in bold</span></li>
13-
<li><span class="c1">With font size 6</span></li>
14-
<li><span class="c1">But should NOT be indented</span></li>
12+
<b><span class="c2">In bold</span></b>
13+
<ul class="c1">
14+
<li><span class="c2">Not in bold</span></li>
15+
<li><span class="c2">With font size 6</span></li>
16+
<li><span class="c2">But should NOT be indented</span></li>
17+
</ul>
1518
</body>
1619
</html>

regression_testing/cases/legacy-expects/case-1410061b.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ line 1 column 1 - Warning: missing <!DOCTYPE> declaration
22
line 6 column 4 - Warning: replacing unexpected b with </b>
33
line 6 column 30 - Warning: inserting implicit <font>
44
line 6 column 30 - Warning: missing </font> before <li>
5+
line 7 column 1 - Warning: <li> isn't allowed in <body> elements
6+
line 5 column 1 - Info: <body> previously mentioned
7+
line 7 column 1 - Warning: inserting implicit <ul>
58
line 7 column 5 - Warning: inserting implicit <font>
69
line 8 column 5 - Warning: inserting implicit <font>
710
line 9 column 5 - Warning: inserting implicit <font>
11+
line 10 column 1 - Warning: discarding unexpected </body>
12+
line 11 column 1 - Warning: discarding unexpected </html>
13+
line 7 column 1 - Warning: missing </ul>
814
line 6 column 30 - Warning: trimming empty <font>
915
Info: Document content looks like HTML5
10-
Tidy found 8 warnings and 0 errors!
16+
Tidy found 13 warnings and 0 errors!
1117

1218
You are recommended to use CSS to specify the font and
1319
properties such as its size and color. This will reduce

regression_testing/cases/legacy-expects/case-566542.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
probably throw up its hands and emit an error. -->
77
</head>
88
<body>
9-
<li>
9+
<ul>
1010
<p>Identify the member disks with <strong>ssaraid -H -lssa0 -n
1111
pdisk <em>[n]</em> -u -a use=member</strong></p>
12-
<ul>
13-
<li>
14-
<p><strong>Identify the hot spare with ssaraid -H -lssa0 -n
15-
pdisk <em>[n]</em>-u -a use=spare</strong></p>
16-
</li>
17-
</ul>
18-
</li>
12+
<p><strong>Identify the hot spare with ssaraid -H -lssa0 -n
13+
pdisk <em>[n]</em>-u -a use=spare</strong></p>
14+
</ul>
1915
</body>
2016
</html>

regression_testing/cases/legacy-expects/case-566542.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
22
line 4 column 1 - Warning: inserting implicit <body>
3+
line 4 column 1 - Warning: <li> isn't allowed in <body> elements
4+
line 4 column 1 - Info: <body> previously mentioned
5+
line 4 column 1 - Warning: inserting implicit <ul>
36
line 4 column 39 - Warning: missing </b> before <p>
47
line 6 column 9 - Warning: inserting implicit <b>
58
line 6 column 9 - Warning: missing </b> before <li>
6-
line 4 column 1 - Info: missing optional end tag </li>
7-
line 7 column 1 - Warning: inserting implicit <ul>
89
line 7 column 5 - Warning: inserting implicit <b>
910
line 7 column 5 - Warning: missing </b> before <p>
1011
line 7 column 8 - Warning: inserting implicit <b>
1112
line 7 column 8 - Warning: nested emphasis <b>
1213
line 7 column 8 - Warning: missing </b> before <p>
1314
line 7 column 8 - Warning: missing </b> before <p>
14-
line 7 column 1 - Warning: missing </ul>
15+
line 4 column 1 - Warning: missing </ul>
16+
line 4 column 1 - Warning: trimming empty <li>
1517
line 6 column 9 - Warning: trimming empty <b>
1618
line 6 column 6 - Warning: trimming empty <p>
1719
line 7 column 5 - Warning: trimming empty <b>
20+
line 7 column 1 - Warning: trimming empty <li>
1821
line 8 column 35 - Warning: trimming empty <p>
1922
Info: Document content looks like HTML5
20-
Tidy found 17 warnings and 0 errors!
23+
Tidy found 20 warnings and 0 errors!
2124

2225
One or more empty elements were present in the source document but
2326
dropped on output. If these elements are necessary or you don't want

src/parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,9 @@ Node* TY_(ParseBody)( TidyDocImpl* doc, Node *body, GetTokenMode mode )
18091809
*/
18101810
lexer->excludeBlocks = no;
18111811

1812-
if (( nodeIsINPUT(node) ||
1812+
if ((( nodeIsINPUT(node) ||
18131813
(!TY_(nodeHasCM)(node, CM_BLOCK) && !TY_(nodeHasCM)(node, CM_INLINE))
1814-
) && !TY_(IsHTML5Mode)(doc) )
1814+
) && !TY_(IsHTML5Mode)(doc)) || nodeIsLI(node) )
18151815
{
18161816
/* avoid this error message being issued twice */
18171817
if (!(node->tag->model & CM_HEAD))

0 commit comments

Comments
 (0)