Perl6::Pod::FormattingCode::D - Definition


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

Index


Code Index:

NAME

Top

Perl6::Pod::FormattingCode::D - Definition

SYNOPSIS

Top

    A D<formatting code|formatting codes;formatters> provides a way
    to add inline mark-up to a piece of text.

DESCRIPTION

Top

The D<> formatting code indicates that the contained text is a definition, introducing a term that the adjacent text elucidates. It is the inline equivalent of a =defn block. For example:

    There ensued a terrible moment of D<coyotus interruptus>: a brief
    suspension of the effects of gravity, accompanied by a sudden
    to-the-camera realisation of imminent downwards acceleration.

A definition may be given synonyms, which are specified after a vertical bar and separated by semicolons:

    A D<formatting code|formatting codes;formatters> provides a way
    to add inline mark-up to a piece of text.

A definition would typically be rendered in italics or <dfn>...</dfn> tags and will often be used as a link target for subsequent instances of the term (or any of its specified synonyms) within a hypertext.

to_xhtml

    D<photo|picture>

Render xhtml:

    <dfn>photo</dfn>

to_docbook

    D<photo|picture>

Render xml:

    photo

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:  definition formatting code
#
#       AUTHOR:  Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
#$Id$

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

sub split_text_entry {
    my ( $self, $str ) = @_;
    my ( $dfn, $synonyms ) = split( /\s*\|\s*/, $str );
    for ( $dfn, $synonyms ) {
        next unless defined $_;
        s/^\s+//;
        s/\s+$//;
    }
    wantarray() ? ( $dfn, $synonyms ) : $dfn;
}

sub on_para {
    my ( $self, $parser, $txt ) = @_;
    my $attr = $self->attrs_by_name;
    my ($dfn, $synonyms ) =
      $self->split_text_entry($txt);
    $attr->{synonyms} = $synonyms;
    return $dfn;
}

sub to_xhtml {
 my ( $self, $parser, @in ) = @_;
 my @content = $parser->_make_events(@in);
 return $parser->mk_element('dfn')->add_content(@content);
}

sub to_docbook {
 my ( $self, $parser, @in ) = @_;
 [ $parser->_make_events(@in) ];
}


1;
__END__