| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #! perl | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 863 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 24 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 20 |  | 
| 5 | 1 |  |  | 1 |  | 4 | use utf8; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 6 | 1 |  |  | 1 |  | 16 | use Carp; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 50 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | package Text::Layout::Markdown; | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 1 |  |  | 1 |  | 382 | use parent 'Text::Layout'; | 
|  | 1 |  |  |  |  | 250 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | #### API | 
| 13 |  |  |  |  |  |  | sub new { | 
| 14 | 0 |  |  | 0 | 1 |  | my ( $pkg, @data ) = @_; | 
| 15 | 0 |  |  |  |  |  | my $self = $pkg->SUPER::new; | 
| 16 | 0 |  |  |  |  |  | $self->{_currentfont} = { family => 'default', | 
| 17 |  |  |  |  |  |  | style => 'normal', | 
| 18 |  |  |  |  |  |  | weight => 'normal' }; | 
| 19 | 0 |  |  |  |  |  | $self->{_currentcolor} = 'black'; | 
| 20 | 0 |  |  |  |  |  | $self->{_currentsize} = 12; | 
| 21 | 0 |  |  |  |  |  | $self; | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | #### API | 
| 25 |  |  |  |  |  |  | sub render { | 
| 26 | 0 |  |  | 0 | 0 |  | my ( $self ) = @_; | 
| 27 | 0 |  |  |  |  |  | my $res = ""; | 
| 28 | 0 |  |  |  |  |  | foreach my $fragment ( @{ $self->{_content} } ) { | 
|  | 0 |  |  |  |  |  |  | 
| 29 | 0 | 0 |  |  |  |  | next unless length($fragment->{text}); | 
| 30 | 0 |  | 0 |  |  |  | my $f = $fragment->{font} || $self->{_currentfont}; | 
| 31 | 0 |  |  |  |  |  | my $open = ""; | 
| 32 | 0 |  |  |  |  |  | my $close = ""; | 
| 33 | 0 | 0 |  |  |  |  | if ( $f->{style} eq "italic" ) { | 
| 34 | 0 |  |  |  |  |  | $open = $close = "_" | 
| 35 |  |  |  |  |  |  | } | 
| 36 | 0 | 0 |  |  |  |  | if ( $f->{weight} eq "bold" ) { | 
| 37 | 0 |  |  |  |  |  | $open = "**$open"; | 
| 38 | 0 |  |  |  |  |  | $close = "$close**"; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 0 | 0 |  |  |  |  | if ( $res =~ /(.*)\Q$close\E$/ ) { | 
| 42 | 0 |  |  |  |  |  | $res = $1; | 
| 43 | 0 |  |  |  |  |  | $open = ""; | 
| 44 |  |  |  |  |  |  | } | 
| 45 | 0 |  |  |  |  |  | $res .= $open . $fragment->{text} . $close; | 
| 46 |  |  |  |  |  |  | } | 
| 47 | 0 |  |  |  |  |  | $res; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | #### API | 
| 51 |  |  |  |  |  |  | sub bbox { | 
| 52 | 0 |  |  | 0 | 0 |  | my ( $self ) = @_; | 
| 53 | 0 |  |  |  |  |  | [ 0, -5, 10, 15 ];		# dummy | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | #### API | 
| 57 |  |  |  |  |  |  | sub load_font { | 
| 58 | 0 |  |  | 0 | 0 |  | my ( $self, $description ) = @_; | 
| 59 | 0 |  |  |  |  |  | return $description; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | 1; |