Merge pull request #989 from htacg/issue_464

Fixes #464. Test cases added.
This commit is contained in:
Jim Derry 2021-08-17 11:52:07 -04:00 committed by GitHub
commit 172d5a888c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 217 additions and 4 deletions

View File

@ -0,0 +1,3 @@
tidy-mark: no
wrap: 0
indent: yes

View File

@ -0,0 +1,29 @@
<!--
This test case represents HTML Tidy issue #464, which describes
a descrepancy between tidy's behavior and the W3C Nu HTML
checker behavior. In this case, <dl> is now allowed to contain
a div as a descendent in HTML5.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Issue #464</title>
</head>
<body>
<dl>
<dt>term</dt>
<dd>def</dd>
<dt>another term<dt>
<dd>another def</dd>
</dl>
<dl>
<div>
<dt>term</dt>
<dd>def</dd>
<dt>another term<dt>
<dd>another def</dd>
</div>
</dl>
</body>
</html>

View File

@ -0,0 +1,3 @@
tidy-mark: no
wrap: 0
indent: yes

View File

@ -0,0 +1,29 @@
<!--
This test case represents HTML Tidy issue #464, which describes
a descrepancy between tidy's behavior and the W3C Nu HTML
checker behavior. In this case, <dl> is now allowed to contain
a div as a descendent in HTML5.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta charset="utf-8">
<title>Issue #464</title>
</head>
<body>
<dl>
<dt>term</dt>
<dd>def</dd>
<dt>another term<dt>
<dd>another def</dd>
</dl>
<dl>
<div>
<dt>term</dt>
<dd>def</dd>
<dt>another term<dt>
<dd>another def</dd>
</div>
</dl>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!--
This test case represents HTML Tidy issue #464, which describes
a descrepancy between tidy's behavior and the W3C Nu HTML
checker behavior. In this case, <dl> is now allowed to contain
a div as a descendent in HTML5.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
Issue #464
</title>
</head>
<body>
<dl>
<dt>
term
</dt>
<dd>
def
</dd>
<dt>
another term
</dt>
<dd>
another def
</dd>
</dl>
<dl>
<div>
<dt>
term
</dt>
<dd>
def
</dd>
<dt>
another term
</dt>
<dd>
another def
</dd>
</div>
</dl>
</body>
</html>

View File

@ -0,0 +1,20 @@
line 17 column 21 - Warning: trimming empty <dt>
line 24 column 21 - Warning: trimming empty <dt>
Info: Document content looks like HTML5
Tidy found 2 warnings and 0 errors!
One or more empty elements were present in the source document but
dropped on output. If these elements are necessary or you don't want
this behavior, then consider setting the option "drop-empty-elements"
to no.
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: https://html.spec.whatwg.org/multipage/
Validate your HTML documents: https://validator.w3.org/nu/
Lobby your company to join the W3C: https://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,52 @@
<!--
This test case represents HTML Tidy issue #464, which describes
a descrepancy between tidy's behavior and the W3C Nu HTML
checker behavior. In this case, <dl> is now allowed to contain
a div as a descendent in HTML5.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta charset="utf-8">
<title>
Issue #464
</title>
</head>
<body>
<dl>
<dt>
term
</dt>
<dd>
def
</dd>
<dt>
another term
</dt>
<dd>
another def
</dd>
</dl>
<dl>
<dd>
<div>
<dl>
<dt>
term
</dt>
<dd>
def
</dd>
<dt>
another term
</dt>
<dd>
another def
</dd>
</dl>
</div>
</dd>
</dl>
</body>
</html>

View File

@ -0,0 +1,25 @@
line 21 column 4 - Warning: missing <dd>
line 21 column 4 - Warning: missing </div> before <dt>
line 22 column 5 - Warning: inserting implicit <dl>
line 22 column 5 - Warning: missing </dl> before </div>
line 17 column 21 - Warning: trimming empty <dt>
line 24 column 21 - Warning: trimming empty <dt>
Info: Doctype given is "-//W3C//DTD HTML 4.01//EN"
Info: Document content looks like HTML Proprietary
Tidy found 6 warnings and 0 errors!
One or more empty elements were present in the source document but
dropped on output. If these elements are necessary or you don't want
this behavior, then consider setting the option "drop-empty-elements"
to no.
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: https://html.spec.whatwg.org/multipage/
Validate your HTML documents: https://validator.w3.org/nu/
Lobby your company to join the W3C: https://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

@ -1115,6 +1115,11 @@ Node* TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
return NULL;
}
if ( nodeIsDIV(element) && nodeIsDL(element->parent) && TY_(IsHTML5Mode)(doc) )
{
return TY_(ParseDefList)(doc, element, mode);
}
if ( nodeIsFORM(element) &&
DescendantOf(element, TidyTag_FORM) )
TY_(Report)(doc, element, NULL, ILLEGAL_NESTING );
@ -1332,7 +1337,7 @@ Node* TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode )
TY_(FreeNode)( doc, node );
continue;
}
/* #427671 - Fix by Randy Waki - 10 Aug 00 */
/*
If an LI contains an illegal FRAME, FRAMESET, OPTGROUP, or OPTION
@ -2311,7 +2316,7 @@ Node* TY_(ParseDefList)( TidyDocImpl* doc, Node *list, GetTokenMode mode )
}
}
if ( !(nodeIsDT(node) || nodeIsDD(node)) )
if ( !( nodeIsDT(node) || nodeIsDD(node) || ( nodeIsDIV(node) && TY_(IsHTML5Mode)(doc) ) ) )
{
TY_(UngetToken)( doc );
@ -2340,7 +2345,7 @@ Node* TY_(ParseDefList)( TidyDocImpl* doc, Node *list, GetTokenMode mode )
continue;
}
/* node should be <DT> or <DD>*/
/* node should be <DT> or <DD> or <DIV>*/
TY_(InsertNodeAtEnd)(list, node);
{
TidyParserMemory memory = {0};

View File

@ -56,7 +56,7 @@ typedef struct _TidyParserMemory
int reentry_state; /**< State to set during re-entry. Defined locally in each parser. */
GetTokenMode mode; /**< The caller will peek at this value to get the correct mode. */
int register_1; /**< Local variable storage. */
int register_2; /**< Local variable storage. */
int register_2; /**< Local variable storage. */
} TidyParserMemory;