Perl6::Pod::FormattingCode::E - include named Unicode or XHTML entities


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

Index


Code Index:

NAME

Top

Perl6::Pod::FormattingCode::E - include named Unicode or XHTML entities

SYNOPSIS

Top

        Perl 6 makes considerable use of E<171> and E<187>.

        C<1E<VERTICAL LINE>2>

        my $label-area-width = 1 + [max] @scoresE<raquo>.keyE<raquo>.chars;




DESCRIPTION

Top

If the contents of the E<> are a number, that number is treated as the decimal Unicode value for the desired codepoint. For example:

    Perl 6 makes considerable use of E<171> and E<187>.

You can also use explicit binary, octal, decimal, or hexadecimal numbers (using the Perl 6 notations for explicitly based numbers):

    Perl 6 makes considerable use of E<0b10101011> and E<0b10111011>.
    Perl 6 makes considerable use of E<0o253> and E<0o273>.
    Perl 6 makes considerable use of E<0d171> and E<0d187>.
    Perl 6 makes considerable use of E<0xAB> and E<0xBB>.

If the contents are not a number, they are interpreted as a Unicode character name (which is always upper-case), or else as an XHTML entity. For example:

    Perl 6 makes considerable use of E<LEFT DOUBLE ANGLE BRACKET>
    and E<RIGHT DOUBLE ANGLE BRACKET>.

or, equivalently:

    Perl 6 makes considerable use of E<laquo> and E<raquo>.

Multiple consecutive entities can be specified in a single E<> code, separated by semicolons:

    Perl 6 makes considerable use of E<laquo;hellip;raquo>.

to_xhtml

    E<lt>

Render to

   &lt;

to_docbook

    E<lt>

Render to

   &lt;

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:  Implement E (Entities)
#
#       AUTHOR:  Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
#$Id$
package Perl6::Pod::FormattingCode::E;
use warnings;
use strict;
use Data::Dumper;
use Perl6::Pod::FormattingCode;
use base 'Perl6::Pod::FormattingCode';

my %line_break = (NEL=>1);

sub to_xhtml {
    my ( $self, $parser, $line ) = @_;
    #split by ;
    [
        map {
            s/^\s+//;
            s/\s+$//;
            if ( exists $line_break{$_} ) {
                $parser->mk_element('br');
            } else {
            $parser->mk_characters( _to_xhtml_entity($_) )
            }
          }
          split( /\s*;\s*/, $line )
    ];
}
sub _to_xhtml_entity {
    my $str = shift;
    if ( $str !~ /^\d/ ) {
        use charnames ':full';
        my $ord = charnames::vianame($str);
        return sprintf( '&#%d;', $ord ) if defined $ord;
        return qq{&$str;};
    }
    # Otherwise, it's the numeric codepoint in some base...
    else {
        # Convert Perl 6 octals and decimals to Perl 5 notation...
        if ($str !~ s{\A 0o}{0}xms) {       # Convert octal
            $str =~ s{\A 0d}{}xms;          # Convert explicit decimal
            $str =~ s{\A 0+ (?=\d)}{}xms;   # Convert implicit decimal
        }

        # Then return the XHTML numeric code...
        return sprintf '&#%d;', eval $str;
    }

    die "Unsupported identity $_ in E<>";
}

sub to_docbook {
    my ( $self, $parser, $line ) = @_;
    #split by ;
    [
        map {
            s/^\s+//;
            s/\s+$//;
            if (exists $line_break{$_} ) {()} else {
            # <br/> not exists in docbook
            $parser->mk_characters( _to_xhtml_entity($_) )}
            }
          split( /\s*;\s*/, $line )
    ];
}

1;
__END__