| 1 | package String::Fraction; | ||||||||||
| 2 | 1 | ▶ | use base qw(HTML::Fraction); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $VERSION = "0.30"; | |||||||||
| 8 | |||||||||||
| 9 | # Our superclass sometimes uses named | ||||||||||
| 10 | 1 | my %name2char = ( | |||||||||
| 11 | '1/4' => "\x{00BC}", | ||||||||||
| 12 | '1/2' => "\x{00BD}", | ||||||||||
| 13 | '3/4' => "\x{00BE}", | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 29 | ▶ | sub _name2char { | ||||||||
|
Subroutine
_name2char: called CC=2 SCAR=6.9
| |||||||||||
| 17 | 29 | my $self = shift; | |||||||||
| 18 | 29 | my $str = shift; | |||||||||
| 19 | |||||||||||
| 20 | 29 | my $entity = $self->SUPER::_name2char($str); | |||||||||
| 21 | 29 | ▶ | if ($entity =~ /\A &\#(\d+); \z/x) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 19 | return chr($1); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 10 | return $name2char{ $str } | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | =head1 NAME | ||||||||||
| 29 | |||||||||||
| 30 | String::Fraction - convert fractions into unicode chars | ||||||||||
| 31 | |||||||||||
| 32 | =head1 SYNOPSIS | ||||||||||
| 33 | |||||||||||
| 34 | use String::Fraction; | ||||||||||
| 35 | print String::Fraction->tweak( <<ENDOFTEXT ); | ||||||||||
| 36 | When this is run through tweak things like 1/4 and 0.25 and 6.33 | ||||||||||
| 37 | will be converted to unicode chars that represent the fractional parts | ||||||||||
| 38 | ENDOFTEXT | ||||||||||
| 39 | |||||||||||
| 40 | =head1 DESCRIPTION | ||||||||||
| 41 | |||||||||||
| 42 | This module functions identically to its superclass B<HTML::Fraction>, | ||||||||||
| 43 | but rather than converting fractions into HTML entities they are replaced | ||||||||||
| 44 | by the unicode characters for those fractions. | ||||||||||
| 45 | |||||||||||
| 46 | =head1 AUTHOR | ||||||||||
| 47 | |||||||||||
| 48 | Copyright Mark Fowler <mark@twoshortplanks.com> and Fotango 2005. | ||||||||||
| 49 | |||||||||||
| 50 | Copyright Mark Fowler <mark@twoshortplanks.com> 2012. | ||||||||||
| 51 | |||||||||||
| 52 | This module is free software; you can redistribute it and/or modify it | ||||||||||
| 53 | under the same terms as Perl itself. | ||||||||||
| 54 | |||||||||||
| 55 | =head1 BUGS | ||||||||||
| 56 | |||||||||||
| 57 | None Known | ||||||||||
| 58 | |||||||||||
| 59 | =head1 SEE ALSO | ||||||||||
| 60 | |||||||||||
| 61 | L<HTML::Fraction> | ||||||||||
| 62 | |||||||||||
| 63 | =cut | ||||||||||
| 64 | |||||||||||
| 65 | 1 | 1; | |||||||||