allow zero LI in UL when html5. fix for #396
This commit is contained in:
parent
fdf2169ebf
commit
b704a4d0d4
13
src/parser.c
13
src/parser.c
|
@ -328,7 +328,6 @@ static Bool CanPrune( TidyDocImpl* doc, Node *element )
|
||||||
if (nodeIsDD(element))
|
if (nodeIsDD(element))
|
||||||
return no;
|
return no;
|
||||||
|
|
||||||
|
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2514,7 +2513,14 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !nodeIsLI(node) )
|
if ( nodeIsLI(node) || TY_(IsHTML5Mode)(doc))
|
||||||
|
{
|
||||||
|
/* node is <LI>
|
||||||
|
Issue #396 - A <ul> can have Zero or more li elements
|
||||||
|
*/
|
||||||
|
TY_(InsertNodeAtEnd)(list,node);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
TY_(UngetToken)( doc );
|
TY_(UngetToken)( doc );
|
||||||
|
|
||||||
|
@ -2567,9 +2573,6 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
|
||||||
TY_(InsertNodeAtEnd)(list,node);
|
TY_(InsertNodeAtEnd)(list,node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
/* node is <LI> */
|
|
||||||
TY_(InsertNodeAtEnd)(list,node);
|
|
||||||
|
|
||||||
ParseTag( doc, node, IgnoreWhitespace);
|
ParseTag( doc, node, IgnoreWhitespace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,6 +780,12 @@ void TY_(AdjustTags)( TidyDocImpl *doc )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool TY_(IsHTML5Mode)( TidyDocImpl *doc )
|
||||||
|
{
|
||||||
|
return doc->HTML5Mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*\
|
/*\
|
||||||
* Issue #285
|
* Issue #285
|
||||||
* Reset the table to default HTML5 mode.
|
* Reset the table to default HTML5 mode.
|
||||||
|
@ -809,6 +815,7 @@ void TY_(ResetTags)( TidyDocImpl *doc )
|
||||||
#if ELEMENT_HASH_LOOKUP
|
#if ELEMENT_HASH_LOOKUP
|
||||||
tagsEmptyHash( doc, tags ); /* not sure this is really required, but to be sure */
|
tagsEmptyHash( doc, tags ); /* not sure this is really required, but to be sure */
|
||||||
#endif
|
#endif
|
||||||
|
doc->HTML5Mode = yes; /* set HTML5 mode */
|
||||||
}
|
}
|
||||||
|
|
||||||
void TY_(FreeTags)( TidyDocImpl* doc )
|
void TY_(FreeTags)( TidyDocImpl* doc )
|
||||||
|
@ -823,6 +830,8 @@ void TY_(FreeTags)( TidyDocImpl* doc )
|
||||||
|
|
||||||
/* get rid of dangling tag references */
|
/* get rid of dangling tag references */
|
||||||
TidyClearMemory( tags, sizeof(TidyTagImpl) );
|
TidyClearMemory( tags, sizeof(TidyTagImpl) );
|
||||||
|
|
||||||
|
doc->HTML5Mode = no; /* reset html5 mode == legacy html4 mode */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ void TY_(InitTags)( TidyDocImpl* doc );
|
||||||
void TY_(FreeTags)( TidyDocImpl* doc );
|
void TY_(FreeTags)( TidyDocImpl* doc );
|
||||||
void TY_(AdjustTags)( TidyDocImpl *doc ); /* if NOT HTML5 DOCTYPE, fall back to HTML4 legacy mode */
|
void TY_(AdjustTags)( TidyDocImpl *doc ); /* if NOT HTML5 DOCTYPE, fall back to HTML4 legacy mode */
|
||||||
void TY_(ResetTags)( TidyDocImpl *doc ); /* set table to HTML5 mode */
|
void TY_(ResetTags)( TidyDocImpl *doc ); /* set table to HTML5 mode */
|
||||||
|
Bool TY_(IsHTML5Mode)( TidyDocImpl *doc );
|
||||||
|
|
||||||
/* Parser methods for tags */
|
/* Parser methods for tags */
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ struct _TidyDocImpl
|
||||||
uint badChars; /* for bad char encodings */
|
uint badChars; /* for bad char encodings */
|
||||||
uint badForm; /* bit field, for badly placed form tags, or other format errors */
|
uint badForm; /* bit field, for badly placed form tags, or other format errors */
|
||||||
|
|
||||||
|
Bool HTML5Mode; /* current mode is html5 */
|
||||||
|
|
||||||
/* Memory allocator */
|
/* Memory allocator */
|
||||||
TidyAllocator* allocator;
|
TidyAllocator* allocator;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue