| blib/lib/Perl6/Pod/FormattingCode/S.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 15 | 27 | 55.5 |
| branch | 0 | 4 | 0.0 |
| condition | n/a | ||
| subroutine | 5 | 7 | 71.4 |
| pod | 2 | 2 | 100.0 |
| total | 22 | 40 | 55.0 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | #=============================================================================== | ||||||
| 2 | # | ||||||
| 3 | # DESCRIPTION: Space-preserving text | ||||||
| 4 | # | ||||||
| 5 | # AUTHOR: Aliaksandr P. Zahatski, |
||||||
| 6 | #=============================================================================== | ||||||
| 7 | package Perl6::Pod::FormattingCode::S; | ||||||
| 8 | |||||||
| 9 | =pod | ||||||
| 10 | |||||||
| 11 | =head1 NAME | ||||||
| 12 | |||||||
| 13 | Perl6::Pod::FormattingCode::S - Space-preserving text | ||||||
| 14 | |||||||
| 15 | =head1 SYNOPSIS | ||||||
| 16 | |||||||
| 17 | The emergency signal is: S< | ||||||
| 18 | dot dot dot dash dash dash dot dot dot>. | ||||||
| 19 | |||||||
| 20 | =head1 DESCRIPTION | ||||||
| 21 | |||||||
| 22 | Any text enclosed in an C |
||||||
| 23 | every whitespace character in itE |
||||||
| 24 | preserved. These characters are also treated as being non-breaking | ||||||
| 25 | (except for the newlines, of course). For example: | ||||||
| 26 | |||||||
| 27 | The emergency signal is: S< | ||||||
| 28 | dot dot dot dash dash dash dot dot dot>. | ||||||
| 29 | |||||||
| 30 | would be formatted like so: | ||||||
| 31 | |||||||
| 32 | The emergency signal is: | ||||||
| 33 | dot dot dot dash dash dash dot dot dot. | ||||||
| 34 | |||||||
| 35 | rather than: | ||||||
| 36 | |||||||
| 37 | The emergency signal is: dot dot dot dash dash dash dot dot dot. | ||||||
| 38 | |||||||
| 39 | =cut | ||||||
| 40 | |||||||
| 41 | 3 | 3 | 15 | use warnings; | |||
| 3 | 4 | ||||||
| 3 | 82 | ||||||
| 42 | 3 | 3 | 14 | use strict; | |||
| 3 | 5 | ||||||
| 3 | 58 | ||||||
| 43 | 3 | 3 | 14 | use Data::Dumper; | |||
| 3 | 5 | ||||||
| 3 | 121 | ||||||
| 44 | 3 | 3 | 14 | use Perl6::Pod::FormattingCode; | |||
| 3 | 5 | ||||||
| 3 | 90 | ||||||
| 45 | 3 | 3 | 26 | use base 'Perl6::Pod::FormattingCode'; | |||
| 3 | 5 | ||||||
| 3 | 845 | ||||||
| 46 | our $VERSION = '0.01'; | ||||||
| 47 | |||||||
| 48 | =head2 to_xhtml | ||||||
| 49 | |||||||
| 50 | I |
||||||
| 51 | |||||||
| 52 | Render xhtml: | ||||||
| 53 | |||||||
| 54 | test | ||||||
| 55 | |||||||
| 56 | |||||||
| 57 | =cut | ||||||
| 58 | |||||||
| 59 | sub to_xhtml { | ||||||
| 60 | 0 | 0 | 1 | my ( $self, $parser, @in ) = @_; | |||
| 61 | 0 | my @elements = $parser->_make_events(@in); | |||||
| 62 | |||||||
| 63 | # $VAR1 = { | ||||||
| 64 | # 'data' => \' | ||||||
| 65 | # dot dots dot dash dash dash dot dot dot', | ||||||
| 66 | # 'type' => 'CHARACTERS | ||||||
| 67 | # } | ||||||
| 68 | # process only 'type' => 'CHARACTERS | ||||||
| 69 | 0 | for (@elements) { | |||||
| 70 | 0 | 0 | next unless exists $_->{type}; | ||||
| 71 | 0 | 0 | next unless $_->{type} eq 'CHARACTERS'; | ||||
| 72 | |||||||
| 73 | #replase spaces -> and new lines -> ) |
||||||
| 74 | 0 | ${ $_->{data} } =~ s% % %gs; | |||||
| 0 | |||||||
| 75 | 0 | ${ $_->{data} } =~ s%\n% %gs; |
|||||
| 0 | |||||||
| 76 | } | ||||||
| 77 | 0 | \@elements; | |||||
| 78 | } | ||||||
| 79 | |||||||
| 80 | =head2 to_docbook | ||||||
| 81 | |||||||
| 82 | S |
||||||
| 83 | |||||||
| 84 | Render to | ||||||
| 85 | |||||||
| 86 | |
||||||
| 87 | |||||||
| 88 | |||||||
| 89 | L |
||||||
| 90 | |||||||
| 91 | =cut | ||||||
| 92 | |||||||
| 93 | sub to_docbook { | ||||||
| 94 | 0 | 0 | 1 | my ( $self, $parser, @in ) = @_; | |||
| 95 | 0 | $parser->mk_element('literallayout') | |||||
| 96 | ->add_content( $parser->_make_events(@in) ); | ||||||
| 97 | } | ||||||
| 98 | |||||||
| 99 | 1; | ||||||
| 100 | __END__ |