Perl6::Pod::FormattingCode::S - Space-preserving text


Perl6-Pod documentation Contained in the Perl6-Pod distribution.

Index


Code Index:

NAME

Top

Perl6::Pod::FormattingCode::S - Space-preserving text

SYNOPSIS

Top

    The emergency signal is: S<
    dot dot dot   dash dash dash   dot dot dot>.

DESCRIPTION

Top

Any text enclosed in an S<> code is formatted normally, except that every whitespace character in it—including any newline—is preserved. These characters are also treated as being non-breaking (except for the newlines, of course). For example:

    The emergency signal is: S<
    dot dot dot   dash dash dash   dot dot dot>.

would be formatted like so:

    The emergency signal is: 
    dot dot dot   dash dash dash   dot dot dot.

rather than:

    The emergency signal is: dot dot dot dash dash dash dot dot dot.

to_xhtml

    I<test>

Render xhtml:

    <em>test</em>




to_docbook

    S<test>

Render to

    <literallayout>test</literallayout>




http://www.docbook.org/tdg/en/html/literallayout.html

SEE ALSO

Top

http://zag.ru/perl6-pod/S26.html, Perldoc Pod to HTML converter: http://zag.ru/perl6-pod/, Perl6::Pod::Lib

AUTHOR

Top

Zahatski Aliaksandr, <zag@cpan.org>

COPYRIGHT AND LICENSE

Top


Perl6-Pod documentation Contained in the Perl6-Pod distribution.
#===============================================================================
#
#  DESCRIPTION:  Space-preserving text
#
#       AUTHOR:  Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
package Perl6::Pod::FormattingCode::S;

use warnings;
use strict;
use Data::Dumper;
use Perl6::Pod::FormattingCode;
use base 'Perl6::Pod::FormattingCode';

sub to_xhtml {
    my ( $self, $parser, @in ) = @_;
    my @elements = $parser->_make_events(@in);

    #  $VAR1 = {
    #          'data' => \'
    #          dot dots dot   dash dash dash   dot dot dot',
    #                    'type' => 'CHARACTERS
    #    }
    # process only 'type' => 'CHARACTERS
    for (@elements) {
        next unless exists $_->{type};
        next unless $_->{type} eq 'CHARACTERS';

        #replase spaces -> &nbsp;  and new lines -> <br /> )
        ${ $_->{data} } =~ s% %&nbsp;%gs;
        ${ $_->{data} } =~ s%\n%<br />%gs;
    }
    \@elements;
}

sub to_docbook {
    my ( $self, $parser, @in ) = @_;
    $parser->mk_element('literallayout')
      ->add_content( $parser->_make_events(@in) );
}

1;
__END__