+ // Current node doesn't have a close tag, time for a close\r
+ // as this element isn't fit in. (#7497)\r
+ if ( currentNode.isOptionalClose )\r
+ parser.onTagClose( currentName );\r
+ // Fixing malformed nested lists by moving it into a previous list item. (#3828)\r
+ else if ( tagName in listBlocks\r
+ && currentName in listBlocks )\r
+ {\r
+ var children = currentNode.children,\r
+ lastChild = children[ children.length - 1 ];\r
+\r
+ // Establish the list item if it's not existed.\r
+ if ( !( lastChild && lastChild.name == 'li' ) )\r
+ addElement( ( lastChild = new CKEDITOR.htmlParser.element( 'li' ) ), currentNode );\r
+\r
+ !element.returnPoint && ( element.returnPoint = currentNode );\r
+ currentNode = lastChild;\r
+ }\r
+ // Establish new list root for orphan list items.\r
+ else if ( tagName in CKEDITOR.dtd.$listItem && currentName != tagName )\r
+ parser.onTagOpen( tagName == 'li' ? 'ul' : 'dl', {}, 0, 1 );\r
+ // We're inside a structural block like table and list, AND the incoming element\r
+ // is not of the same type (e.g. <td>td1<td>td2</td>), we simply add this new one before it,\r
+ // and most importantly, return back to here once this element is added,\r
+ // e.g. <table><tr><td>td1</td><p>p1</p><td>td2</td></tr></table>\r
+ else if ( currentName in nonBreakingBlocks && currentName != tagName )\r