| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
4
|
|
|
4
|
|
95603
|
use strict; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
139
|
|
|
2
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
106
|
|
|
3
|
4
|
|
|
4
|
|
964
|
use utf8; |
|
|
4
|
|
|
|
|
17
|
|
|
|
4
|
|
|
|
|
22
|
|
|
4
|
|
|
|
|
|
|
package Unicode::Subscript; |
|
5
|
|
|
|
|
|
|
#ABSTRACT: Generate subscripted and superscripted UTF-8 text without markup |
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
152
|
use Carp; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
420
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
|
10
|
4
|
|
|
4
|
|
26
|
use Exporter; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
377
|
|
|
11
|
4
|
|
|
4
|
|
57
|
our @ISA = qw(Exporter); |
|
12
|
4
|
|
|
|
|
11
|
our @EXPORT_OK = qw(subscript superscript TM SM); |
|
13
|
4
|
|
|
|
|
486
|
our %EXPORT_TAGS = (all => \@EXPORT_OK); |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $TM = '™'; |
|
17
|
|
|
|
|
|
|
my $SM = '℠'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub subscript { |
|
21
|
13
|
|
|
13
|
1
|
5799
|
my $text = shift; |
|
22
|
13
|
100
|
|
|
|
57
|
croak "text is undefined" if !defined $text; |
|
23
|
12
|
100
|
|
|
|
39
|
croak "too many arguments" if @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
22
|
$text =~ tr/0-9+\-=()/₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎/; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
47
|
|
|
|
11
|
|
|
|
|
51
|
|
|
26
|
11
|
|
|
|
|
39
|
$text =~ tr/aehiklmnoprstuvx/ₐₑₕᵢₖₗₘₙₒₚᵣₛₜᵤᵥₓ/; |
|
27
|
11
|
|
|
|
|
50
|
return $text; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub superscript { |
|
32
|
13
|
|
|
13
|
1
|
2933
|
my $text = shift; |
|
33
|
13
|
100
|
|
|
|
47
|
croak "text is undefined" if !defined $text; |
|
34
|
12
|
100
|
|
|
|
37
|
croak "too many arguments" if @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
11
|
|
|
|
|
45
|
$text =~ tr/0-9+\-=()/⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾/; |
|
37
|
11
|
|
|
|
|
47
|
$text =~ tr/a-pr-z/ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻ/; |
|
38
|
11
|
|
|
|
|
51
|
$text =~ tr/ABDEGHIJKLMNOPRTUVW/ᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁⱽᵂ/; |
|
39
|
11
|
|
|
|
|
51
|
return $text; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub TM { |
|
44
|
1
|
|
|
1
|
1
|
5
|
return $TM; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub SM { |
|
49
|
1
|
|
|
1
|
1
|
218
|
return $SM; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding utf-8 |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Unicode::Subscript - Generate subscripted and superscripted UTF-8 text without markup |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Unicode::Subscript qw(subscript superscript); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
say 'H' . subscript(2) . 'O'; # H₂O |
|
69
|
|
|
|
|
|
|
say 'This algorithm is O(n' . superscript(3) . ')'; # O(n³) |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
say superscript('this text is really high!'); # ᵗʰⁱˢ ᵗᵉˣᵗ ⁱˢ ʳᵉᵃˡˡʸ ʰⁱᵍʰ! |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
use Unicode::Subscript qw(SM TM); |
|
74
|
|
|
|
|
|
|
say 'Eat at Subway' . TM(); # Eat at Subway™ |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use Unicode::Subscript ':all'; # import everything |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This module provides methods to convert characters to the equivalent UTF-8 |
|
81
|
|
|
|
|
|
|
characters for their subscripted or superscripted forms. This may come in |
|
82
|
|
|
|
|
|
|
handy when generating fractions, chemical formulas, footnotes, etc. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 subscript ($text) |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Return the subscripted version of C<$text>, in UTF-8 encoding. The following |
|
89
|
|
|
|
|
|
|
characters has subscripted forms in Unicode: |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Digits 0-9, +, -, = and () |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
A small number of lowercase letters: a e h i k l m n o p r s t u v x |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Any other input characters will be left un-suscripted. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 superscript ($text) |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Return the superscripted version of C<$text>, in UTF-8 encoding. The following |
|
108
|
|
|
|
|
|
|
characters have superscripted forms in Unicode: |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over 4 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Digits 0-9, +, -, = and () |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
All of the lowercase letters except q |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
A small number of uppercase letters: A B D E G H I J K L M N O P R T U V W |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Any other input characters will be left un-superscripted. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 TM |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the Unicode (TM) superscript character. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 SM |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns the Unicode (SM) superscript character. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Richard Harris |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Richard Harris. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
149
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |