Issue #572 - More conditions for #396

This commit is contained in:
Geoff McLane 2017-07-02 21:10:20 +02:00
parent e48b06b8c0
commit f26a068809

View file

@ -2435,6 +2435,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
Lexer* lexer = doc->lexer; Lexer* lexer = doc->lexer;
Node *node, *parent, *lastli; Node *node, *parent, *lastli;
Bool wasblock; Bool wasblock;
Bool nodeisOL = nodeIsOL(list);
#if !defined(NDEBUG) && defined(_MSC_VER) #if !defined(NDEBUG) && defined(_MSC_VER)
in_parse_list++; in_parse_list++;
@ -2452,6 +2453,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
while ((node = TY_(GetToken)( doc, IgnoreWhitespace)) != NULL) while ((node = TY_(GetToken)( doc, IgnoreWhitespace)) != NULL)
{ {
Bool foundLI = no;
if (node->tag == list->tag && node->type == EndTag) if (node->tag == list->tag && node->type == EndTag)
{ {
TY_(FreeNode)( doc, node); TY_(FreeNode)( doc, node);
@ -2521,10 +2523,16 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
continue; continue;
} }
if ( nodeIsLI(node) || TY_(IsHTML5Mode)(doc)) if ( !nodeIsLI(node) && nodeisOL )
{ {
/* node is <LI> /* Issue #572 - A <ol><li> can have nested <ol> elements */
Issue #396 - A <ul> can have Zero or more li elements foundLI = FindLastLI(list, &lastli); /* find last <li> */
}
if ( nodeIsLI(node) || (TY_(IsHTML5Mode)(doc) && !foundLI) )
{
/* node is <LI> OR
Issue #396 - A <ul> can have Zero or more <li> elements
*/ */
TY_(InsertNodeAtEnd)(list,node); TY_(InsertNodeAtEnd)(list,node);
} }