Perl6::Pod::FormattingCode::C - Contained text is code


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

Index


Code Index:

NAME

Top

Perl6::Pod::FormattingCode::C - Contained text is code

SYNOPSIS

Top

        =para
        Use C<=config> for this or C<< $i > 4 >>;

DESCRIPTION

Top

The C<> formatting code specifies that the contained text is code; that is, something that might appear in a program or specification. Such content would typically be rendered in a fixed-width font (preferably a different font from that used for the T<> or K<> formatting codes) or with <samp>...</samp> tags. The contents of a C<> code are space-preserved and verbatim. The C<> code is the inline equivalent of the =code block.

To include other formatting codes in a C<> code, you can lexically reconfigure it:

    =begin para
    =config C<> :allow<E I>
    Perl 6 makes extensive use of the C<E<laquo>> and C<E<raquo>>
    characters, for example, in a hash look-up:
    C<%hashI<E<laquo>>keyI<E<raquo>>>
    =end para

To enable entities in every C<...> put a =config C<>> :allowC<E> at the top of the document

Exported :

* docbook
    <code></code>

http://www.w3.org/TR/html401/struct/text.html#edef-CODE

* html
  <code></code>

http://www.w3.org/TR/html401/struct/text.html#edef-CODE

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.
package Perl6::Pod::FormattingCode::C;

#$Id$

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

sub to_xhtml {
    my $self   = shift;
    my $parser = shift;
    my $el =
#      $parser->mk_element('code')->add_content( $parser->_make_elements(@_) );
      $parser->mk_element('code')->add_content( $self->_make_elements($parser,@_) );
    return $el;
}

sub to_docbook {
    my $self   = shift;
    return $self->to_xhtml(@_)
}

#add escaping
sub _make_elements {
    my $self = shift;
    my $parser = shift;
    my @res  = ();
    for (@_) {
        push @res, ref($_)
          ? ref($_) eq 'ARRAY'
              ? $parser->_make_elements(@$_)
              : $_
          : $parser->mk_characters(_html_escape($_));
    }
    return @res;
}


sub _html_escape {
    my ( $txt ) =@_;
    $txt   =~ s/&/&amp;/g;
    $txt   =~ s/</&lt;/g;
    $txt   =~ s/>/&gt;/g;
#    $txt   =~ s/"/&quot;/g;
#    $txt   =~ s/'/&apos;/g;
    $txt
}

1;
__END__