diff --git a/src/parser.c b/src/parser.c
index 0447fe8..ae773aa 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -328,7 +328,6 @@ static Bool CanPrune( TidyDocImpl* doc, Node *element )
if (nodeIsDD(element))
return no;
-
return yes;
}
@@ -2514,7 +2513,14 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
continue;
}
- if ( !nodeIsLI(node) )
+ if ( nodeIsLI(node) || TY_(IsHTML5Mode)(doc))
+ {
+ /* node is
+ Issue #396 - A can have Zero or more li elements
+ */
+ TY_(InsertNodeAtEnd)(list,node);
+ }
+ else
{
TY_(UngetToken)( doc );
@@ -2567,9 +2573,6 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
TY_(InsertNodeAtEnd)(list,node);
}
}
- else
- /* node is - */
- TY_(InsertNodeAtEnd)(list,node);
ParseTag( doc, node, IgnoreWhitespace);
}
diff --git a/src/tags.c b/src/tags.c
index ed3436c..9e77fcb 100644
--- a/src/tags.c
+++ b/src/tags.c
@@ -780,6 +780,12 @@ void TY_(AdjustTags)( TidyDocImpl *doc )
}
}
+Bool TY_(IsHTML5Mode)( TidyDocImpl *doc )
+{
+ return doc->HTML5Mode;
+}
+
+
/*\
* Issue #285
* Reset the table to default HTML5 mode.
@@ -809,6 +815,7 @@ void TY_(ResetTags)( TidyDocImpl *doc )
#if ELEMENT_HASH_LOOKUP
tagsEmptyHash( doc, tags ); /* not sure this is really required, but to be sure */
#endif
+ doc->HTML5Mode = yes; /* set HTML5 mode */
}
void TY_(FreeTags)( TidyDocImpl* doc )
@@ -823,6 +830,8 @@ void TY_(FreeTags)( TidyDocImpl* doc )
/* get rid of dangling tag references */
TidyClearMemory( tags, sizeof(TidyTagImpl) );
+
+ doc->HTML5Mode = no; /* reset html5 mode == legacy html4 mode */
}
diff --git a/src/tags.h b/src/tags.h
index 2412717..de75809 100644
--- a/src/tags.h
+++ b/src/tags.h
@@ -88,6 +88,7 @@ void TY_(InitTags)( TidyDocImpl* doc );
void TY_(FreeTags)( TidyDocImpl* doc );
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 */
+Bool TY_(IsHTML5Mode)( TidyDocImpl *doc );
/* Parser methods for tags */
diff --git a/src/tidy-int.h b/src/tidy-int.h
index bf1ccd3..e76cb1d 100755
--- a/src/tidy-int.h
+++ b/src/tidy-int.h
@@ -76,6 +76,8 @@ struct _TidyDocImpl
uint badChars; /* for bad char encodings */
uint badForm; /* bit field, for badly placed form tags, or other format errors */
+ Bool HTML5Mode; /* current mode is html5 */
+
/* Memory allocator */
TidyAllocator* allocator;