@@ -2435,6 +2435,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
2435
2435
Lexer * lexer = doc -> lexer ;
2436
2436
Node * node , * parent , * lastli ;
2437
2437
Bool wasblock ;
2438
+ Bool nodeisOL = nodeIsOL (list );
2438
2439
2439
2440
#if !defined(NDEBUG ) && defined(_MSC_VER )
2440
2441
in_parse_list ++ ;
@@ -2452,6 +2453,7 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
2452
2453
2453
2454
while ((node = TY_ (GetToken )( doc , IgnoreWhitespace )) != NULL )
2454
2455
{
2456
+ Bool foundLI = no ;
2455
2457
if (node -> tag == list -> tag && node -> type == EndTag )
2456
2458
{
2457
2459
TY_ (FreeNode )( doc , node );
@@ -2473,6 +2475,21 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
2473
2475
TY_ (FreeNode )( doc , node );
2474
2476
continue ;
2475
2477
}
2478
+ if (lexer && (node -> type == TextNode ))
2479
+ {
2480
+ uint ch , ix = node -> start ;
2481
+ /* Issue #572 - Skip whitespace. */
2482
+ while (ix < node -> end && (ch = (lexer -> lexbuf [ix ] & 0xff ))
2483
+ && (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ))
2484
+ ++ ix ;
2485
+ if (ix >= node -> end )
2486
+ {
2487
+ /* Issue #572 - Discard if ALL whitespace. */
2488
+ TY_ (FreeNode )(doc , node );
2489
+ continue ;
2490
+ }
2491
+ }
2492
+
2476
2493
2477
2494
/*
2478
2495
if this is the end tag for an ancestor element
@@ -2521,10 +2538,16 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
2521
2538
continue ;
2522
2539
}
2523
2540
2524
- if ( nodeIsLI (node ) || TY_ (IsHTML5Mode )(doc ))
2541
+ if ( !nodeIsLI (node ) && nodeisOL )
2542
+ {
2543
+ /* Issue #572 - A <ol><li> can have nested <ol> elements */
2544
+ foundLI = FindLastLI (list , & lastli ); /* find last <li> */
2545
+ }
2546
+
2547
+ if ( nodeIsLI (node ) || (TY_ (IsHTML5Mode )(doc ) && !foundLI ) )
2525
2548
{
2526
- /* node is <LI>
2527
- Issue #396 - A <ul> can have Zero or more li elements
2549
+ /* node is <LI> OR
2550
+ Issue #396 - A <ul> can have Zero or more <li> elements
2528
2551
*/
2529
2552
TY_ (InsertNodeAtEnd )(list ,node );
2530
2553
}
0 commit comments