Index: trunk/parsers/wikidom/lib/es/es.Content.js |
— | — | @@ -560,15 +560,16 @@ |
561 | 561 | }; |
562 | 562 | |
563 | 563 | Content.prototype.getLines = function() { |
564 | | - var lines = [], |
565 | | - line = null, |
566 | | - offset = 0, |
567 | | - left = '', |
568 | | - right = '', |
569 | | - leftPlain, |
570 | | - rightPlain, |
571 | | - j,k,i; |
572 | | - |
| 564 | + var lines = []; |
| 565 | + var right = ''; |
| 566 | + var left = ''; |
| 567 | + var rightPlain; |
| 568 | + var leftPlain; |
| 569 | + var i; |
| 570 | + var j; |
| 571 | + var line; |
| 572 | + var offset = 0; |
| 573 | + |
573 | 574 | for ( i = 0; i < this.data.length; i++ ) { |
574 | 575 | |
575 | 576 | if ( line == null ) { |
— | — | @@ -577,23 +578,24 @@ |
578 | 579 | annotations : [] |
579 | 580 | }; |
580 | 581 | } |
581 | | - |
| 582 | + |
582 | 583 | right = this.data[i]; |
583 | 584 | leftPlain = typeof left === 'string'; |
584 | 585 | rightPlain = typeof right === 'string'; |
585 | | - |
| 586 | + |
586 | 587 | if ( rightPlain && right == "\n" ) { |
587 | 588 | lines.push(line); |
588 | 589 | line = null; |
589 | 590 | offset = i + 1; |
| 591 | + left = ''; |
590 | 592 | continue; |
591 | 593 | } |
592 | 594 | |
593 | | - for ( j = 1; j < left.length; j++ ) { |
594 | | - if ( rightPlain || this.indexOfAnnotation( i, left[j], true ) === -1 ) { |
| 595 | + if ( !leftPlain ) { |
| 596 | + for ( j = 1; j < left.length; j++ ) { |
595 | 597 | for ( k = line.annotations.length - 1; k >= 0; k-- ) { |
596 | | - if ( line.annotations[k].type === left[j].type ) { |
597 | | - if ( Content.compareObjects( line.annotations[k].data, left[j].data ) ) { |
| 598 | + if ( left[j].type === line.annotations[k].type ) { |
| 599 | + if ( Content.compareObjects( left[j].data, line.annotations[k].data ) ) { |
598 | 600 | line.annotations[k].range.end = i - offset; |
599 | 601 | break; |
600 | 602 | } |
— | — | @@ -602,26 +604,24 @@ |
603 | 605 | } |
604 | 606 | } |
605 | 607 | |
606 | | - for ( j = 1; j < right.length; j++ ) { |
607 | | - if ( leftPlain || this.indexOfAnnotation( i - 1, right[j], true ) === -1 ) { |
608 | | - var annotation = Content.copyObject( right[j] ); |
609 | | - annotation.range = { |
610 | | - start : i - offset, |
611 | | - end : i + 1 - offset |
612 | | - }; |
613 | | - line.annotations.push( annotation ); |
| 608 | + if ( !rightPlain ) { |
| 609 | + for ( j = 1; j < right.length; j++ ) { |
| 610 | + if ( leftPlain || this.indexOfAnnotation( i - 1, right[j], true ) === -1 ) { |
| 611 | + var annotation = Content.copyObject( right[j] ); |
| 612 | + annotation.range = { |
| 613 | + start : i - offset, |
| 614 | + end : i + 1 - offset |
| 615 | + }; |
| 616 | + line.annotations.push( annotation ); |
| 617 | + } |
614 | 618 | } |
615 | 619 | } |
| 620 | + |
| 621 | + line.text += rightPlain ? right : right[0]; |
616 | 622 | |
617 | | - if ( rightPlain ) { |
618 | | - line.text += right; |
619 | | - } else { |
620 | | - line.text += right[0]; |
621 | | - } |
622 | | - |
623 | 623 | left = right; |
624 | 624 | } |
625 | | - |
| 625 | + |
626 | 626 | if ( line != null ) { |
627 | 627 | lines.push(line); |
628 | 628 | } |