version 1.6, 2008/04/14 09:33:39
|
version 1.8, 2008/04/21 11:02:43
|
Line 61 use strict;
|
Line 61 use strict;
|
|
|
# Note numerical entities are essentially unicode character codes. |
# Note numerical entities are essentially unicode character codes. |
# |
# |
my %entities = { |
package Apache::entities; |
|
|
|
my %entities = ( |
|
|
# ---- ASCII code page: ---------------- |
# ---- ASCII code page: ---------------- |
|
|
Line 181 my %entities = {
|
Line 183 my %entities = {
|
130 => ',', |
130 => ',', |
131 => '\\textflorin ', |
131 => '\\textflorin ', |
132 => ',,', # Low double left quotes. |
132 => ',,', # Low double left quotes. |
133 => '\\ensuremat\{\\ldots\}', |
133 => '\\ensuremath\{\\ldots\}', |
134 => '\\ensuremath\{\\dagger\}', |
134 => '\\ensuremath\{\\dagger\}', |
135 => '\\ensuremath\{\\ddagger\}', |
135 => '\\ensuremath\{\\ddagger\}', |
136 => '\\ensuremath\{\\wedge\}', |
136 => '\\ensuremath\{\\wedge\}', |
Line 406 my %entities = {
|
Line 408 my %entities = {
|
# ISO also documents a 'planck' entity. |
# ISO also documents a 'planck' entity. |
|
|
295 => '\\ensuremath\{\hbar\}', |
295 => '\\ensuremath\{\hbar\}', |
'plank' => '\\ensuremath\{\hbar\}', |
'planck' => '\\ensuremath\{\hbar\}', |
|
|
# Latin extended-A HTML 4.01 entities: |
# Latin extended-A HTML 4.01 entities: |
|
|
Line 656 my %entities = {
|
Line 658 my %entities = {
|
8659 => '\\ensuremath\{\\Downarrow\}', |
8659 => '\\ensuremath\{\\Downarrow\}', |
'dArr' => '\\ensuremath\{\\Downarrow\}', |
'dArr' => '\\ensuremath\{\\Downarrow\}', |
8660 => '\\ensuremath\{\\Leftrightarrow\}', |
8660 => '\\ensuremath\{\\Leftrightarrow\}', |
'vArr' => '\\ensuremath\{\\Updownarrow\}', |
'hArr' => '\\ensuremath\{\\Leftrightarrow\}', |
8661 => '\\ensuremath\{\\Updownarrow\}', |
8661 => '\\ensuremath\{\\Updownarrow\}', |
'lAarr' => '\\ensuremath\{\\Lleftarrow\}', |
'vArr' => '\\ensuremath\{\\Updownarrow\}', |
8666 => '\\ensuremath\{\\Lleftarrow\}', |
8666 => '\\ensuremath\{\\Lleftarrow\}', |
'rAarr' => '\\ensuremath\{\\Rrightarrow\}', |
'lAarr' => '\\ensuremath\{\\Lleftarrow\}', |
8667 => '\\ensuremath\{\\Rrightarrow\}', |
8667 => '\\ensuremath\{\\Rrightarrow\}', |
'rarrw' => '\\ensuremath\{\\rightsquigarrow\}', |
'rAarr' => '\\ensuremath\{\\Rrightarrow\}', |
8669 => '\\ensuremath\{\\rightsquigarrow\}', |
8669 => '\\ensuremath\{\\rightsquigarrow\}', |
|
'rarrw' => '\\ensuremath\{\\rightsquigarrow\}', |
|
|
|
|
# Mathematical operators. |
# Mathematical operators. |
Line 922 my %entities = {
|
Line 925 my %entities = {
|
'diams' => '\\ensuremath\{\\blacklozenge\}', |
'diams' => '\\ensuremath\{\\blacklozenge\}', |
9830 => '\\ensuremath\{\\blacklozenge\}' |
9830 => '\\ensuremath\{\\blacklozenge\}' |
|
|
}; |
); |
|
|
# |
# |
# Convert a numerical entity (that does not exist in our hash) |
# Convert a numerical entity (that does not exist in our hash) |
Line 966 sub entity_to_latex {
|
Line 969 sub entity_to_latex {
|
|
|
# Try to look up the entity (text or numeric) in the hash: |
# Try to look up the entity (text or numeric) in the hash: |
|
|
my $latex = $entities{$entity}; |
|
if ($latex) { |
my $latex = $entities{"$entity"}; |
|
if (defined $latex) { |
return $latex; |
return $latex; |
} |
} |
# If the text is purely numeric we can do the UTF-8 conversion: |
# If the text is purely numeric we can do the UTF-8 conversion: |
Line 975 sub entity_to_latex {
|
Line 979 sub entity_to_latex {
|
if ($entity =~ /^\d$/) { |
if ($entity =~ /^\d$/) { |
return &entity_to_utf8($entity); |
return &entity_to_utf8($entity); |
} |
} |
# Can't do the conversion ... |
# Can't do the conversion`< ... |
|
|
return " "; |
return " "; |
} |
} |
Line 1013 sub replace_entities {
|
Line 1017 sub replace_entities {
|
} |
} |
# Now the &text; entites; |
# Now the &text; entites; |
|
|
while ($input =~/($\w;)/) { |
while ($input =~/(&\w+;)/) { |
($start) = @-; |
($start) = @-; |
($end) = @+; |
($end) = @+; |
$entity = substr($input, $start+1, $end-$start-2); |
$entity = substr($input, $start+1, $end-$start-2); |
$latex = &entity_to_latex($entity); |
$latex = &entity_to_latex($entity); |
substr($input, $start, $end-$start) = $latex; |
substr($input, $start, $end-$start) = $latex; |
|
|
} |
} |
|
return $input; |
} |
} |
|
|
|
1; |
|
|
|
__END__ |