Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js |
— | — | @@ -356,7 +356,44 @@ |
357 | 357 | }; |
358 | 358 | |
359 | 359 | es.ListBlock.prototype.getWikiDom = function() { |
| 360 | + var items = this.list.items; |
| 361 | + var stack = []; |
360 | 362 | |
| 363 | + for ( var i = 0; i < items.length; i++ ) { |
| 364 | + var item = items[i]; |
| 365 | + var itemLevel = item.getLevel(); |
| 366 | + |
| 367 | + if ( itemLevel + 1 > stack.length ) { |
| 368 | + for( var j = stack.length; j < itemLevel + 1; j++ ) { |
| 369 | + stack.push( { |
| 370 | + 'style' : item.getStyle(j), |
| 371 | + 'items' : [] |
| 372 | + } ); |
| 373 | + } |
| 374 | + } |
| 375 | + |
| 376 | + if ( itemLevel + 1 < stack.length ) { |
| 377 | + for( var j = stack.length; j > itemLevel + 1; j-- ) { |
| 378 | + if ( stack[stack.length - 2].items.length === 0 ) { |
| 379 | + stack[stack.length - 2].items.push( { |
| 380 | + 'lists' : [] |
| 381 | + } ); |
| 382 | + } else if( !stack[stack.length - 2].items[stack[stack.length - 2].items.length - 1].lists ) { |
| 383 | + stack[stack.length - 2].items[stack[stack.length - 2].items.length - 1].lists = []; |
| 384 | + } |
| 385 | + stack[stack.length - 2].items[stack[stack.length - 2].items.length - 1].lists.push( stack.pop() ); |
| 386 | + } |
| 387 | + } |
| 388 | + |
| 389 | + if ( itemLevel + 1 === stack.length ) { |
| 390 | + stack[stack.length - 1].items.push( { |
| 391 | + 'line' : item.content.getWikiDomLines()[0] } |
| 392 | + ); |
| 393 | + } |
| 394 | + } |
| 395 | + |
| 396 | + stack[0].type = 'list'; |
| 397 | + return stack[0]; |
361 | 398 | }; |
362 | 399 | |
363 | 400 | /* Registration */ |