Changeset 288
- Timestamp:
- 02/14/08 22:00:14 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/ingy/WikiText/lib/WikiText/WikiByte/Emitter.pm
r286 r288 5 5 sub new { 6 6 my $class = shift; 7 return bless { @_ }, ref($class) || $class; 7 return bless { 8 @_, 9 last_event => '', 10 }, ref($class) || $class; 8 11 } 9 12 … … 21 24 my $self = shift; 22 25 my $ast = shift; 23 $self->{output} .= $ast->{output} || ''; 26 if ($self->{last_event} eq 'text') { 27 chomp $self->{output}; 28 my $subtext = $ast->{output} || ''; 29 $subtext =~ s/^ //; 30 $self->{output} .= $subtext; 31 } 32 else { 33 $self->{output} .= $ast->{output} || ''; 34 } 24 35 } 25 36 … … 31 42 my $attributes = _get_attributes($node); 32 43 $self->{output} .= "+$tag$attributes\n"; 44 $self->{last_event} = 'begin'; 33 45 } 34 46 … … 38 50 my $tag = $node->{type}; 39 51 40 return if $self->{output} =~ s/^\+$tag\n\z/=$tag\n/m; 52 $self->{last_event} = 'end'; 53 54 return if $self->{output} =~ s/^\+$tag\b(.*\n)\z/=$tag$1/m; 41 55 42 56 $tag =~ s/-.*//; … … 48 62 my $text = shift; 49 63 $text =~ s/\n/\n /g; 50 $self->{output} .= " $text\n"; 64 if ($self->{last_event} eq 'text') { 65 chomp $self->{output}; 66 $self->{output} .= "$text\n"; 67 } 68 else { 69 $self->{output} .= " $text\n"; 70 } 71 $self->{last_event} = 'text'; 51 72 } 52 73
