+ // We're moving out of the current list, cleaning up.\r
+ if ( listItemIndent != lastIndent )\r
+ previousListType = previousListStyleType = null;\r
+\r
+ // List type and item style are already resolved.\r
+ if ( !bullet )\r
+ {\r
+ listType = listItemAttrs[ 'cke:listtype' ] || 'ol';\r
+ listStyleType = listItemAttrs[ 'cke:list-style-type' ];\r
+ }\r
+ else\r
+ {\r
+ // Probably share the same list style type with previous list item,\r
+ // give it priority to avoid ambiguous between C(Alpha) and C.(Roman).\r
+ if ( previousListType && listMarkerPatterns[ previousListType ] [ previousListStyleType ].test( bullet[ 1 ] ) )\r
+ {\r
+ listType = previousListType;\r
+ listStyleType = previousListStyleType;\r
+ }\r
+ else\r
+ {\r
+ for ( var type in listMarkerPatterns )\r
+ {\r
+ for ( var style in listMarkerPatterns[ type ] )\r
+ {\r
+ if ( listMarkerPatterns[ type ][ style ].test( bullet[ 1 ] ) )\r
+ {\r
+ // Small numbering has higher priority, when dealing with ambiguous\r
+ // between C(Alpha) and C.(Roman).\r
+ if ( type == 'ol' && ( /alpha|roman/ ).test( style ) )\r
+ {\r
+ var num = /roman/.test( style ) ? fromRoman( bullet[ 1 ] ) : fromAlphabet( bullet[ 1 ] );\r
+ if ( !itemNumeric || num < itemNumeric )\r
+ {\r
+ itemNumeric = num;\r
+ listType = type;\r
+ listStyleType = style;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ listType = type;\r
+ listStyleType = style;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ // Simply use decimal/disc for the rest forms of unrepresentable\r
+ // numerals, e.g. Chinese..., but as long as there a second part\r
+ // included, it has a bigger chance of being a order list ;)\r
+ !listType && ( listType = bullet[ 2 ] ? 'ol' : 'ul' );\r
+ }\r
+\r
+ previousListType = listType;\r
+ previousListStyleType = listStyleType || ( listType == 'ol' ? 'decimal' : 'disc' );\r
+ if ( listStyleType && listStyleType != ( listType == 'ol' ? 'decimal' : 'disc' ) )\r
+ listItem.addStyle( 'list-style-type', listStyleType );\r
+\r
+ // Figure out start numbering.\r
+ if ( listType == 'ol' && bullet )\r
+ {\r
+ switch ( listStyleType )\r
+ {\r
+ case 'decimal' :\r
+ itemNumeric = Number( bullet[ 1 ] );\r
+ break;\r
+ case 'lower-roman':\r
+ case 'upper-roman':\r
+ itemNumeric = fromRoman( bullet[ 1 ] );\r
+ break;\r
+ case 'lower-alpha':\r
+ case 'upper-alpha':\r
+ itemNumeric = fromAlphabet( bullet[ 1 ] );\r
+ break;\r
+ }\r
+\r
+ // Always create the numbering, swipe out unnecessary ones later.\r
+ listItem.attributes.value = itemNumeric;\r
+ }\r
+\r
+ // Start the list construction.\r