Skip to content

Commit d057bcb

Browse files
authored
Merge pull request #990 from htacg/issue_611
Issue 611
2 parents 86601b1 + 8a45f44 commit d057bcb

File tree

14 files changed

+202
-1
lines changed

14 files changed

+202
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
indent: auto
2+
tidy-mark: no
3+
clean: yes
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template><tr><td>1</td></tr></template>
2+
3+
4+
<template><td>1</td></template>
5+
6+
7+
<template><li>1</li></template>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
indent: auto
2+
tidy-mark: no
3+
clean: yes
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue #611-1</title>
6+
</head>
7+
<body>
8+
<template><tr><td>1</td></tr></template>
9+
</body>
10+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
indent: auto
2+
tidy-mark: no
3+
clean: yes
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue #611-2d</title>
6+
<script>
7+
// Data is hard-coded here, but could come from the server
8+
var data = [
9+
{ name: 'Pillar', color: 'Ticked Tabby', sex: 'Female (neutered)', legs: 3 },
10+
{ name: 'Hedral', color: 'Tuxedo', sex: 'Male (neutered)', legs: 4 },
11+
];
12+
</script>
13+
</head>
14+
<body>
15+
<table>
16+
<thead>
17+
<tr>
18+
<th>Name <th>Color <th>Sex <th>Legs
19+
<tbody>
20+
<template id="row">
21+
<tr><td><td><td><td>
22+
</template>
23+
</table>
24+
<script>
25+
var template = document.querySelector('#row');
26+
for (var i = 0; i < data.length; i += 1) {
27+
var cat = data[i];
28+
var clone = template.content.cloneNode(true);
29+
var cells = clone.querySelectorAll('td');
30+
cells[0].textContent = cat.name;
31+
cells[1].textContent = cat.color;
32+
cells[2].textContent = cat.sex;
33+
cells[3].textContent = cat.legs;
34+
template.parentNode.appendChild(clone);
35+
}
36+
</script>
37+
</body>
38+
</html>
39+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<template>
5+
<tr>
6+
<td>1</td>
7+
</tr>
8+
</template>
9+
<template>
10+
<td>1</td>
11+
</template>
12+
<template>
13+
<li>1</li>
14+
</template>
15+
<title></title>
16+
</head>
17+
<body>
18+
</body>
19+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
2+
line 1 column 1 - Warning: inserting missing 'title' element
3+
Info: Document content looks like HTML5
4+
Tidy found 2 warnings and 0 errors!
5+
6+
About HTML Tidy: https://github.com/htacg/tidy-html5
7+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
8+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
9+
Latest HTML specification: https://html.spec.whatwg.org/multipage/
10+
Validate your HTML documents: https://validator.w3.org/nu/
11+
Lobby your company to join the W3C: https://www.w3.org/Consortium
12+
13+
Do you speak a language other than English, or a different variant of
14+
English? Consider helping us to localize HTML Tidy. For details please see
15+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue #611-1</title>
6+
</head>
7+
<body>
8+
<template>
9+
<tr>
10+
<td>1</td>
11+
</tr>
12+
</template>
13+
</body>
14+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Info: Document content looks like HTML5
2+
No warnings or errors were found.
3+
4+
About HTML Tidy: https://github.com/htacg/tidy-html5
5+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
6+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
7+
Latest HTML specification: https://html.spec.whatwg.org/multipage/
8+
Validate your HTML documents: https://validator.w3.org/nu/
9+
Lobby your company to join the W3C: https://www.w3.org/Consortium
10+
11+
Do you speak a language other than English, or a different variant of
12+
English? Consider helping us to localize HTML Tidy. For details please see
13+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue #611-2d</title>
6+
<script>
7+
// Data is hard-coded here, but could come from the server
8+
var data = [
9+
{ name: 'Pillar', color: 'Ticked Tabby', sex: 'Female (neutered)', legs: 3 },
10+
{ name: 'Hedral', color: 'Tuxedo', sex: 'Male (neutered)', legs: 4 },
11+
];
12+
</script>
13+
</head>
14+
<body>
15+
<script>
16+
var template = document.querySelector('#row');
17+
for (var i = 0; i < data.length; i += 1) {
18+
var cat = data[i];
19+
var clone = template.content.cloneNode(true);
20+
var cells = clone.querySelectorAll('td');
21+
cells[0].textContent = cat.name;
22+
cells[1].textContent = cat.color;
23+
cells[2].textContent = cat.sex;
24+
cells[3].textContent = cat.legs;
25+
template.parentNode.appendChild(clone);
26+
}
27+
</script>
28+
<template id="row">
29+
<tr>
30+
<td></td>
31+
<td></td>
32+
<td></td>
33+
<td></td>
34+
</tr>
35+
</template>
36+
<table>
37+
<thead>
38+
<tr>
39+
<th>Name</th>
40+
<th>Color</th>
41+
<th>Sex</th>
42+
<th>Legs</th>
43+
</tr>
44+
</thead>
45+
</table>
46+
</body>
47+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
line 20 column 3 - Warning: <template> isn't allowed in <tbody> elements
2+
line 19 column 2 - Info: <tbody> previously mentioned
3+
line 22 column 3 - Warning: discarding unexpected </template>
4+
line 23 column 1 - Warning: discarding unexpected </table>
5+
line 24 column 1 - Warning: <script> isn't allowed in <tr> elements
6+
line 21 column 4 - Info: <tr> previously mentioned
7+
line 20 column 3 - Warning: missing </template>
8+
line 15 column 1 - Warning: missing </table>
9+
line 19 column 2 - Warning: trimming empty <tbody>
10+
Info: Document content looks like HTML5
11+
Tidy found 7 warnings and 0 errors!
12+
13+
One or more empty elements were present in the source document but
14+
dropped on output. If these elements are necessary or you don't want
15+
this behavior, then consider setting the option "drop-empty-elements"
16+
to no.
17+
18+
About HTML Tidy: https://github.com/htacg/tidy-html5
19+
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
20+
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
21+
Latest HTML specification: https://html.spec.whatwg.org/multipage/
22+
Validate your HTML documents: https://validator.w3.org/nu/
23+
Lobby your company to join the W3C: https://www.w3.org/Consortium
24+
25+
Do you speak a language other than English, or a different variant of
26+
English? Consider helping us to localize HTML Tidy. For details please see
27+
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md

src/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ Node* TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
14171417
return NULL;
14181418
}
14191419
}
1420-
else /* things like list items */
1420+
else if ( ! nodeIsTEMPLATE( element ) )/* things like list items */
14211421
{
14221422
if (node->tag->model & CM_HEAD)
14231423
{

src/tags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ TY_PRIVATE uint TY_(nodeHeaderLevel)( Node* node );
463463
#define nodeIsDATALIST( node ) TagIsId( node, TidyTag_DATALIST )
464464
#define nodeIsDATA( node ) TagIsId( node, TidyTag_DATA )
465465
#define nodeIsMATHML( node ) TagIsId( node, TidyTag_MATHML ) /* #130 MathML attr and entity fix! */
466+
#define nodeIsTEMPLATE( node ) TagIsId( node, TidyTag_TEMPLATE )
466467

467468
/* NOT in HTML 5 */
468469
#define nodeIsACRONYM( node ) TagIsId( node, TidyTag_ACRONYM )

0 commit comments

Comments
 (0)